diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml index 251a90103f3..b87a1d6dfc0 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml @@ -3829,7 +3829,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0) + ManagedBuildManager.setDefaultConfiguration(proj, cfgs[0]); + else + ManagedBuildManager.setDefaultConfiguration(proj, null); + } + // open project w/o progress monitor; no action performed if it's opened + try { + proj.open(null); + } catch (CoreException e) {} + } + + /* + * isArrayContains() + */ + private boolean isArrayContains(String[] actualConfigNames, String name) { + if (actualConfigNames != null) { + for (int i = 0; i < actualConfigNames.length; i++) { + if ( ( actualConfigNames[i] != null) && (actualConfigNames[i].equals(name)) ) { + return true; + } + } + } + return false; + } + + /** + * doInit() - call it at the beginning of every test + * + */ + private void doInit(String projectName, String projectTypeId) { + createManagedProject(projectName, projectTypeId); + assertNotNull(proj); + assertNotNull(mproj); + worksp = proj.getWorkspace(); + assertNotNull(worksp); + cfgs = mproj.getConfigurations(); + assertNotNull(cfgs); + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ProjectConverter.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ProjectConverter.java new file mode 100644 index 00000000000..e216876626b --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ProjectConverter.java @@ -0,0 +1,35 @@ +package org.eclipse.cdt.managedbuilder.core.tests; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import org.eclipse.cdt.managedbuilder.core.IBuildObject; +import org.eclipse.cdt.managedbuilder.core.IConvertManagedBuildObject; + +public class ProjectConverter implements IConvertManagedBuildObject { + + public IBuildObject convert(IBuildObject buildObj, String fromId, + String toId, boolean isConfirmed) { + + String tmpDir = System.getProperty("java.io.tmpdir"); + + File outputFile = new File(tmpDir + "/converterOutput.txt"); + try { + FileWriter out = new FileWriter(outputFile); + out.write("---------- Start-------"); + out.write("Converter for the build object : '" + buildObj.getName() + "' is invoked."); + out.write("From Id : " + fromId ); + out.write("To Id : " + toId); + out.write("---------- End-------"); + } catch (IOException e) { + // TODO Auto-generated catch block + // e.printStackTrace(); + System.out.println("Exception raised."); + } + + + return buildObj; + } + +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/TestConfigurationNameProvider.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/TestConfigurationNameProvider.java new file mode 100644 index 00000000000..3fbd1e67228 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/TestConfigurationNameProvider.java @@ -0,0 +1,66 @@ +package org.eclipse.cdt.managedbuilder.core.tests; + + +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IConfigurationNameProvider; +import org.eclipse.core.runtime.Platform; + + +public class TestConfigurationNameProvider implements + IConfigurationNameProvider { + + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.managedbuilder.core.IConfigurationNameProvider#getNewConfigurationName(org.eclipse.cdt.managedbuilder.core.IConfiguration, + * java.lang.String[]) This function will generate a unique + * configuration name based on used names, current OS and current + * Architecture. + * + */ + private static int configNumber = 0; + + public String getNewConfigurationName(IConfiguration configuration, + String[] usedConfigurationNames) { + + String configName = configuration.getName(); + + // Get the current OS & architecture + String os = Platform.getOS(); + String arch = Platform.getOSArch(); + + if (isArrayContains(usedConfigurationNames, configName) == false) + return configName; + else { + String[] supportedArchList = configuration.getToolChain() + .getArchList(); + if (supportedArchList.length == 1) { + String newConfigName = configName + "_" + supportedArchList[0]; + if (isArrayContains(usedConfigurationNames, newConfigName) == false) { + return newConfigName; + } + } + + String[] supportedOsList = configuration.getToolChain().getOSList(); + if (supportedOsList.length == 1) { + String newConfigName = configName + "_" + supportedOsList[0]; + if (isArrayContains(usedConfigurationNames, newConfigName) == false) { + return newConfigName; + } + } + configNumber += 1; + return configName + "_" + configNumber; + } + } + + private boolean isArrayContains(String[] usedNames, String name) { + if (usedNames != null) { + for (int i = 0; i < usedNames.length; i++) { + if ( ( usedNames[i] != null) && (usedNames[i].equals(name)) ) { + return true; + } + } + } + return false; + } +}