mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
197468: apply fix
This commit is contained in:
parent
01323153a0
commit
424485c971
15 changed files with 265 additions and 149 deletions
|
@ -26,6 +26,7 @@ import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
|
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||||
|
@ -629,6 +630,44 @@ public class ManagedBuildTestHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cloned from core CProjectHelper
|
||||||
|
*/
|
||||||
|
public static void delete(ICProject cproject) {
|
||||||
|
try {
|
||||||
|
cproject.getProject().delete(true, true, null);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e1) {
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
System.gc();
|
||||||
|
System.runFinalization();
|
||||||
|
cproject.getProject().delete(true, true, null);
|
||||||
|
} catch (CoreException e2) {
|
||||||
|
Assert.fail(getMessage(e2.getStatus()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cloned from core CProjectHelper
|
||||||
|
*/
|
||||||
|
private static String getMessage(IStatus status) {
|
||||||
|
StringBuffer message = new StringBuffer("[");
|
||||||
|
message.append(status.getMessage());
|
||||||
|
if (status.isMultiStatus()) {
|
||||||
|
IStatus children[] = status.getChildren();
|
||||||
|
for( int i = 0; i < children.length; i++) {
|
||||||
|
message.append(getMessage(children[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message.append("]");
|
||||||
|
return message.toString();
|
||||||
|
}
|
||||||
|
|
||||||
static private void deleteDirectory(File dir) {
|
static private void deleteDirectory(File dir) {
|
||||||
boolean b;
|
boolean b;
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
||||||
<simple name="name" value="$(projectName)" />
|
<simple name="name" value="$(projectName)" />
|
||||||
<simple name="targetType" value="exe" />
|
<simple name="location" value="$(location)" />
|
||||||
|
<simple name="artifactExtension" value="exe" />
|
||||||
|
<simple name="isCProject" value="false" />
|
||||||
</process>
|
</process>
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.SetMBSStringListOptionValues">
|
<process type="org.eclipse.cdt.managedbuilder.core.SetMBSStringListOptionValues">
|
||||||
|
@ -39,6 +41,38 @@
|
||||||
</element>
|
</element>
|
||||||
</complex-array>
|
</complex-array>
|
||||||
</process>
|
</process>
|
||||||
|
|
||||||
|
<process type="org.eclipse.cdt.managedbuilder.core.SetMBSStringListOptionValues">
|
||||||
|
<simple name="projectName" value="$(projectName)" />
|
||||||
|
<complex-array name="resourcePaths">
|
||||||
|
<element>
|
||||||
|
<simple name="id" value=".*gnu.c.link.option.paths.*" />
|
||||||
|
<simple-array name="values">
|
||||||
|
<element value="$(StringListValue0)" />
|
||||||
|
<element value="$(StringListValue1)" />
|
||||||
|
<element value="$(StringListValue2)" />
|
||||||
|
<element value="$(StringListValue3)" />
|
||||||
|
</simple-array>
|
||||||
|
<simple name="path" value="" />
|
||||||
|
</element>
|
||||||
|
</complex-array>
|
||||||
|
</process>
|
||||||
|
|
||||||
|
<process type="org.eclipse.cdt.managedbuilder.core.AppendToMBSStringListOptionValues">
|
||||||
|
<simple name="projectName" value= "$(projectName)"/>
|
||||||
|
<complex-array name="resourcePaths">
|
||||||
|
<element>
|
||||||
|
<simple name="id" value=".*gnu.c.link.option.paths.*" />
|
||||||
|
<simple-array name="values">
|
||||||
|
<element value="$(AppendStringListValue0)" />
|
||||||
|
<element value="$(AppendStringListValue1)" />
|
||||||
|
<element value="$(AppendStringListValue2)" />
|
||||||
|
<element value="$(AppendStringListValue3)" />
|
||||||
|
</simple-array>
|
||||||
|
<simple name="path" value="" />
|
||||||
|
</element>
|
||||||
|
</complex-array>
|
||||||
|
</process>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
||||||
<simple name="name" value="$(projectName)" />
|
<simple name="name" value="$(projectName)" />
|
||||||
<simple name="targetType" value="exe" />
|
<simple name="location" value="$(location)" />
|
||||||
|
<simple name="artifactExtension" value="exe" />
|
||||||
|
<simple name="isCProject" value="false" />
|
||||||
</process>
|
</process>
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.SetMBSStringOptionValue">
|
<process type="org.eclipse.cdt.managedbuilder.core.SetMBSStringOptionValue">
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
||||||
<simple name="name" value="$(projectName)" />
|
<simple name="name" value="$(projectName)" />
|
||||||
<simple name="targetType" value="exe" />
|
<simple name="location" value="$(location)" />
|
||||||
|
<simple name="artifactExtension" value="exe" />
|
||||||
|
<simple name="isCProject" value="$(isCProject)" />
|
||||||
</process>
|
</process>
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.CreateIncludeFolder">
|
<process type="org.eclipse.cdt.managedbuilder.core.CreateIncludeFolder">
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
||||||
<simple name="name" value="$(projectName)" />
|
<simple name="name" value="$(projectName)" />
|
||||||
<simple name="targetType" value="exe" />
|
<simple name="location" value="$(location)" />
|
||||||
|
<simple name="artifactExtension" value="exe" />
|
||||||
|
<simple name="isCProject" value="false" />
|
||||||
</process>
|
</process>
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.core.AddFiles">
|
<process type="org.eclipse.cdt.core.AddFiles">
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
||||||
<simple name="name" value="$(projectName)" />
|
<simple name="name" value="$(projectName)" />
|
||||||
<simple name="targetType" value="exe" />
|
<simple name="location" value="$(location)" />
|
||||||
<simple name="isCProject" value="true" />
|
<simple name="artifactExtension" value="exe" />
|
||||||
|
<simple name="isCProject" value="true" />
|
||||||
</process>
|
</process>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
||||||
<simple name="name" value="$(projectName)" />
|
<simple name="name" value="$(projectName)" />
|
||||||
<simple name="targetType" value="exe" />
|
<simple name="location" value="$(location)" />
|
||||||
|
<simple name="artifactExtension" value="exe" />
|
||||||
|
<simple name="isCProject" value="false" />
|
||||||
</process>
|
</process>
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.SetMBSBooleanOptionValue">
|
<process type="org.eclipse.cdt.managedbuilder.core.SetMBSBooleanOptionValue">
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
||||||
<simple name="name" value="$(projectName)" />
|
<simple name="name" value="$(projectName)" />
|
||||||
<simple name="targetType" value="exe" />
|
<simple name="location" value="$(location)" />
|
||||||
|
<simple name="artifactExtension" value="exe" />
|
||||||
|
<simple name="isCProject" value="false" />
|
||||||
</process>
|
</process>
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.SetMBSStringListOptionValues">
|
<process type="org.eclipse.cdt.managedbuilder.core.SetMBSStringListOptionValues">
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
|
||||||
<simple name="name" value="$(projectName)" />
|
<simple name="name" value="$(projectName)" />
|
||||||
<simple name="targetType" value="exe" />
|
<simple name="location" value="$(location)" />
|
||||||
|
<simple name="artifactExtension" value="exe" />
|
||||||
|
<simple name="isCProject" value="false" />
|
||||||
</process>
|
</process>
|
||||||
|
|
||||||
<process type="org.eclipse.cdt.managedbuilder.core.SetMBSStringOptionValue">
|
<process type="org.eclipse.cdt.managedbuilder.core.SetMBSStringOptionValue">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Symbian Software Limited and others.
|
* Copyright (c) 2007 2008 Symbian Software Limited and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -15,33 +15,32 @@ import junit.framework.TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a TestSuite, the TestCases created to test Template engine are
|
* This is a TestSuite, the TestCases created to test Template engine are
|
||||||
* added to testsuite.
|
* added to test-suite. The test suite will execute all the test cases added
|
||||||
* The test suite will execute all the Testcases added to the Suite.
|
* to the Suite.
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AllTemplateEngineTests extends TestSuite{
|
public class AllTemplateEngineTests extends TestSuite{
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
junit.swingui.TestRunner.run(AllTemplateEngineTests.class);
|
junit.swingui.TestRunner.run(AllTemplateEngineTests.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Since the TemplateEngine consists of UI(Wizard).
|
* Since the TemplateEngine consists of UI(Wizard).
|
||||||
* A TestWizard is created to which the dynamically generated
|
* A TestWizard is created to which the dynamically generated
|
||||||
* UIPages are added. The Wizard is launched from here.
|
* UIPages are added. The Wizard is launched from here.
|
||||||
* The TestCases created to test the TemplateEngine is initialized here.
|
* The TestCases created to test the TemplateEngine is initialized here.
|
||||||
* @return
|
* @return
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite("Template engine tests"); //$NON-NLS-1$
|
TestSuite suite = new TestSuite("Template engine tests"); //$NON-NLS-1$
|
||||||
//$JUnit-BEGIN$
|
//$JUnit-BEGIN$
|
||||||
|
|
||||||
// suite.addTestSuite(TestProcesses.class);
|
suite.addTestSuite(TestProcesses.class);
|
||||||
|
|
||||||
//$JUnit-END$
|
//$JUnit-END$
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,65 +16,86 @@ import java.util.Map;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateEngine;
|
import org.eclipse.cdt.core.templateengine.TemplateEngine;
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateEngineHelper;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
|
||||||
public class TestProcesses extends TestCase {
|
public class TestProcesses extends TestCase {
|
||||||
|
|
||||||
private static final String workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getRawLocation().toOSString();
|
private static final String workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getRawLocation().toOSString();
|
||||||
private static final String PROJECT_NAME = "TemplateEngineTestsProject"; //$NON-NLS-1$
|
|
||||||
private static final String SOURCE_FOLDER = "Source"; //$NON-NLS-1$
|
|
||||||
private static final String INCLUDE_FOLDER = "Include"; //$NON-NLS-1$
|
private static final String INCLUDE_FOLDER = "Include"; //$NON-NLS-1$
|
||||||
private static final String FILE_NAME = "File"; //$NON-NLS-1$
|
|
||||||
private static final String LINK = "Link"; //$NON-NLS-1$
|
|
||||||
private static final String APPEND = "Append"; //$NON-NLS-1$
|
private static final String APPEND = "Append"; //$NON-NLS-1$
|
||||||
private static final String CPP_EXT = ".cpp"; //$NON-NLS-1$
|
|
||||||
private static final String H_EXT = ".h"; //$NON-NLS-1$
|
|
||||||
private static final String MBS_GNU_CPP_LINK_OPTION_ID = ".*gnu.cpp.link.option.*"; //$NON-NLS-1$
|
private static final String MBS_GNU_CPP_LINK_OPTION_ID = ".*gnu.cpp.link.option.*"; //$NON-NLS-1$
|
||||||
private static final String MBS_STRING_OPTION_VALUE = "MBSStringOption"; //$NON-NLS-1$
|
private static final String MBS_STRING_OPTION_VALUE = "MBSStringOption"; //$NON-NLS-1$
|
||||||
private static final String[] MBS_STRING_LIST_OPTION_VALUES = {"MBS", "String", "List", "Option"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
private static final String[] MBS_STRING_LIST_OPTION_VALUES = {"MBS", "String", "List", "Option"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
private static final String RELEASE_CONFIG_ID = ".*release.*"; //$NON-NLS-1$
|
private static final String RELEASE_CONFIG_ID = ".*release.*"; //$NON-NLS-1$
|
||||||
private static final String PROJECT_TYPE = "org.eclipse.cdt.managedbuilder.core.tests.projectType"; //$NON-NLS-1$
|
private static final String PROJECT_TYPE = "org.eclipse.cdt.managedbuilder.core.tests.projectType"; //$NON-NLS-1$
|
||||||
|
|
||||||
private List configList;
|
String projectName;
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
TemplateEngineTestsHelper.turnOffAutoBuild();
|
TemplateEngineTestsHelper.turnOffAutoBuild();
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
|
projectName= "TemplateEngineTestsProject"+System.currentTimeMillis();
|
||||||
if (project.exists()) {
|
|
||||||
project.delete(true, true, null);
|
|
||||||
}
|
|
||||||
configList = new ArrayList();
|
|
||||||
//TODO: Add valid configurations for project creation
|
|
||||||
configList.add(new IConfiguration[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||||
|
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
|
||||||
|
if (project.exists()) {
|
||||||
|
try {
|
||||||
|
ManagedBuildTestHelper.delete(CoreModel.getDefault().create(project));
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
fail(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a sensible number of arbitrary IConfiguration objects
|
||||||
|
*/
|
||||||
|
private List/*<IConfiguration>*/ getConfigurations() {
|
||||||
|
List/*<IConfiguration>*/ result= new ArrayList/*<IConfiguration>*/();
|
||||||
|
IConfiguration[] configs= ManagedBuildManager.getExtensionConfigurations();
|
||||||
|
for(int i=0; i<configs.length; i++) {
|
||||||
|
if(configs[i].getToolChain()!=null && configs[i].getBuilder()!=null) {
|
||||||
|
result.add(configs[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(result.size()>5) {
|
||||||
|
result= result.subList(0, 4);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public void testCreateIncludeFolder() {
|
public void testCreateIncludeFolder() {
|
||||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*CreateIncludeFolder"); //$NON-NLS-1$
|
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*CreateIncludeFolder"); //$NON-NLS-1$
|
||||||
|
template.getTemplateInfo().setConfigurations(getConfigurations());
|
||||||
|
|
||||||
Map valueStore = template.getValueStore();
|
Map valueStore = template.getValueStore();
|
||||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
valueStore.put("projectName", projectName); //$NON-NLS-1$
|
||||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
valueStore.put("includeDir1", INCLUDE_FOLDER + 1); //$NON-NLS-1$
|
valueStore.put("includeDir1", INCLUDE_FOLDER + 1); //$NON-NLS-1$
|
||||||
valueStore.put("includeDir2", INCLUDE_FOLDER + 2); //$NON-NLS-1$
|
valueStore.put("includeDir2", INCLUDE_FOLDER + 2); //$NON-NLS-1$
|
||||||
valueStore.put(TemplateEngineHelper.CONFIGURATIONS, configList); //$NON-NLS-1$
|
|
||||||
|
|
||||||
if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) {
|
if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||||
assertTrue(project.exists());
|
assertTrue(project.exists());
|
||||||
IFolder folder = project.getFolder(INCLUDE_FOLDER + 1);
|
IFolder folder = project.getFolder(INCLUDE_FOLDER + 1);
|
||||||
assertTrue(folder.exists());
|
assertTrue(folder.exists());
|
||||||
|
@ -84,24 +105,27 @@ public class TestProcesses extends TestCase {
|
||||||
|
|
||||||
public void testNewManagedProject() {
|
public void testNewManagedProject() {
|
||||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*NewManagedProject"); //$NON-NLS-1$
|
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*NewManagedProject"); //$NON-NLS-1$
|
||||||
|
template.getTemplateInfo().setConfigurations(getConfigurations());
|
||||||
|
|
||||||
Map valueStore = template.getValueStore();
|
Map valueStore = template.getValueStore();
|
||||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
valueStore.put("projectName", projectName); //$NON-NLS-1$
|
||||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
valueStore.put(TemplateEngineHelper.CONFIGURATIONS, configList); //$NON-NLS-1$
|
|
||||||
|
|
||||||
if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) {
|
if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||||
assertTrue(project.exists());
|
assertTrue(project.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetMBSBooleanOptionValue() {
|
public void testSetMBSBooleanOptionValue() {
|
||||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*SetMBSBooleanOptionValue"); //$NON-NLS-1$
|
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*SetMBSBooleanOptionValue"); //$NON-NLS-1$
|
||||||
|
template.getTemplateInfo().setConfigurations(getConfigurations());
|
||||||
|
|
||||||
Map valueStore = template.getValueStore();
|
Map valueStore = template.getValueStore();
|
||||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
valueStore.put("projectName", projectName); //$NON-NLS-1$
|
||||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -111,7 +135,7 @@ public class TestProcesses extends TestCase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||||
assertTrue(project.exists());
|
assertTrue(project.exists());
|
||||||
try {
|
try {
|
||||||
assertSetMBSOptionValues(project, MBS_GNU_CPP_LINK_OPTION_ID, IOption.BOOLEAN, false);
|
assertSetMBSOptionValues(project, MBS_GNU_CPP_LINK_OPTION_ID, IOption.BOOLEAN, false);
|
||||||
|
@ -120,11 +144,13 @@ public class TestProcesses extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetMBSStringOptionValue() {
|
public void testSetMBSStringOptionValue() {
|
||||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*SetMBSStringOptionValue"); //$NON-NLS-1$
|
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*SetMBSStringOptionValue"); //$NON-NLS-1$
|
||||||
|
template.getTemplateInfo().setConfigurations(getConfigurations());
|
||||||
|
|
||||||
Map valueStore = template.getValueStore();
|
Map valueStore = template.getValueStore();
|
||||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
valueStore.put("projectName", projectName); //$NON-NLS-1$
|
||||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -135,7 +161,7 @@ public class TestProcesses extends TestCase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||||
assertTrue(project.exists());
|
assertTrue(project.exists());
|
||||||
try {
|
try {
|
||||||
assertSetMBSOptionValues(project, MBS_GNU_CPP_LINK_OPTION_ID, IOption.STRING, false);
|
assertSetMBSOptionValues(project, MBS_GNU_CPP_LINK_OPTION_ID, IOption.STRING, false);
|
||||||
|
@ -143,16 +169,18 @@ public class TestProcesses extends TestCase {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetMBSStringListOptionValues() {
|
public void testSetMBSStringListOptionValues() {
|
||||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*SetMBSStringListOptionValues"); //$NON-NLS-1$
|
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*SetMBSStringListOptionValues"); //$NON-NLS-1$
|
||||||
|
template.getTemplateInfo().setConfigurations(getConfigurations());
|
||||||
|
|
||||||
Map valueStore = template.getValueStore();
|
Map valueStore = template.getValueStore();
|
||||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
valueStore.put("projectName", projectName); //$NON-NLS-1$
|
||||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
valueStore.put("id", MBS_GNU_CPP_LINK_OPTION_ID); //$NON-NLS-1$
|
valueStore.put("id", MBS_GNU_CPP_LINK_OPTION_ID); //$NON-NLS-1$
|
||||||
|
|
||||||
for (int i=0; i < MBS_STRING_LIST_OPTION_VALUES.length; i++) {
|
for (int i=0; i < MBS_STRING_LIST_OPTION_VALUES.length; i++) {
|
||||||
valueStore.put("StringListValue" + i, MBS_STRING_LIST_OPTION_VALUES[i]); //$NON-NLS-1$
|
valueStore.put("StringListValue" + i, MBS_STRING_LIST_OPTION_VALUES[i]); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -161,7 +189,7 @@ public class TestProcesses extends TestCase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||||
assertTrue(project.exists());
|
assertTrue(project.exists());
|
||||||
try {
|
try {
|
||||||
assertSetMBSOptionValues(project, MBS_GNU_CPP_LINK_OPTION_ID, IOption.STRING_LIST, false);
|
assertSetMBSOptionValues(project, MBS_GNU_CPP_LINK_OPTION_ID, IOption.STRING_LIST, false);
|
||||||
|
@ -169,11 +197,13 @@ public class TestProcesses extends TestCase {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAppendToMBSStringOptionValue() {
|
public void testAppendToMBSStringOptionValue() {
|
||||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AppendToMBSStringOptionValue"); //$NON-NLS-1$
|
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AppendToMBSStringOptionValue"); //$NON-NLS-1$
|
||||||
|
template.getTemplateInfo().setConfigurations(getConfigurations());
|
||||||
|
|
||||||
Map valueStore = template.getValueStore();
|
Map valueStore = template.getValueStore();
|
||||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
valueStore.put("projectName", projectName); //$NON-NLS-1$
|
||||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -185,7 +215,7 @@ public class TestProcesses extends TestCase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||||
assertTrue(project.exists());
|
assertTrue(project.exists());
|
||||||
try {
|
try {
|
||||||
assertSetMBSOptionValues(project, MBS_GNU_CPP_LINK_OPTION_ID, IOption.STRING, true);
|
assertSetMBSOptionValues(project, MBS_GNU_CPP_LINK_OPTION_ID, IOption.STRING, true);
|
||||||
|
@ -193,11 +223,13 @@ public class TestProcesses extends TestCase {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAppendToMBSStringListOptionValues() {
|
public void testAppendToMBSStringListOptionValues() {
|
||||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AppendToMBSStringListOptionValues"); //$NON-NLS-1$
|
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AppendToMBSStringListOptionValues"); //$NON-NLS-1$
|
||||||
|
template.getTemplateInfo().setConfigurations(getConfigurations());
|
||||||
|
|
||||||
Map valueStore = template.getValueStore();
|
Map valueStore = template.getValueStore();
|
||||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
valueStore.put("projectName", projectName); //$NON-NLS-1$
|
||||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -215,51 +247,54 @@ public class TestProcesses extends TestCase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||||
assertTrue(project.exists());
|
assertTrue(project.exists());
|
||||||
try {
|
try {
|
||||||
assertSetMBSOptionValues(project, MBS_GNU_CPP_LINK_OPTION_ID, IOption.STRING_LIST, true);
|
assertSetMBSOptionValues(project, MBS_GNU_CPP_LINK_OPTION_ID, IOption.STRING_LIST, true);
|
||||||
|
assertSetMBSOptionValues(project, ".*gnu.c.link.option.paths.*", IOption.LIBRARY_PATHS, true);
|
||||||
} catch (BuildException e) {
|
} catch (BuildException e) {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExcludeResources() {
|
public void testExcludeResources() {
|
||||||
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*ExcludeResources"); //$NON-NLS-1$
|
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*ExcludeResources"); //$NON-NLS-1$
|
||||||
|
template.getTemplateInfo().setConfigurations(getConfigurations());
|
||||||
|
|
||||||
Map valueStore = template.getValueStore();
|
Map valueStore = template.getValueStore();
|
||||||
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
|
valueStore.put("projectName", projectName); //$NON-NLS-1$
|
||||||
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
|
||||||
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
for (int i=0; i < 3; i++) {
|
for (int i=0; i < 3; i++) {
|
||||||
valueStore.put("baseName" + i, "BaseName" + i); //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("baseName" + i, "BaseName" + i); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
valueStore.put("configIdPattern", RELEASE_CONFIG_ID); //$NON-NLS-1$
|
valueStore.put("configIdPattern", RELEASE_CONFIG_ID); //$NON-NLS-1$
|
||||||
valueStore.put("filePatterns0", ".*BaseName0.*"); //Exlude BaseName0.* from Release config //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("filePatterns0", ".*BaseName0.*"); //Exlude BaseName0.* from Release config //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
valueStore.put("filePatterns1", ".*BaseName1.*"); //Exlude BaseName1.* from all other configs except from Release config //$NON-NLS-1$ //$NON-NLS-2$
|
valueStore.put("filePatterns1", ".*BaseName1.*"); //Exlude BaseName1.* from all other configs except from Release config //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) {
|
if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||||
assertTrue(project.exists());
|
assertTrue(project.exists());
|
||||||
|
|
||||||
IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(project).getManagedProject().getConfigurations();
|
IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(project).getManagedProject().getConfigurations();
|
||||||
for(int i=0; i<projectConfigs.length; i++) {
|
for(int i=0; i<projectConfigs.length; i++) {
|
||||||
IConfiguration config = projectConfigs[i];
|
IConfiguration config = projectConfigs[i];
|
||||||
IResourceConfiguration[] resourceConfigs = config.getResourceConfigurations();
|
IResourceConfiguration[] resourceConfigs = config.getResourceConfigurations();
|
||||||
for (int j=0; j<resourceConfigs.length; j++) {
|
for (int j=0; j<resourceConfigs.length; j++) {
|
||||||
if (resourceConfigs[j].isExcluded()) {
|
if (resourceConfigs[j].isExcluded()) {
|
||||||
String resourcePath = resourceConfigs[i].getResourcePath();
|
String resourcePath = resourceConfigs[j].getResourcePath();
|
||||||
if (resourcePath.matches(".*BaseName0.*")) { //$NON-NLS-1$
|
if (resourcePath.matches(".*BaseName0.*")) { //$NON-NLS-1$
|
||||||
//Exlude BaseName0.* only from Release config
|
//Exclude BaseName0.* only from Release config
|
||||||
assertTrue(config.getId().matches(RELEASE_CONFIG_ID));
|
assertTrue(config.getId().matches(RELEASE_CONFIG_ID));
|
||||||
} else if (resourcePath.matches(".*BaseName1.*")) { //$NON-NLS-1$
|
} else if (resourcePath.matches(".*BaseName1.*")) { //$NON-NLS-1$
|
||||||
//Exlude BaseName1.* from all other configs other than from Release config
|
//Exclude BaseName1.* from all other configs other than from Release config
|
||||||
assertFalse(config.getId().matches(RELEASE_CONFIG_ID));
|
assertFalse(config.getId().matches(RELEASE_CONFIG_ID));
|
||||||
} else {
|
} else {
|
||||||
fail(resourcePath + " shouldn't be excluded from project"); //$NON-NLS-1$
|
fail(resourcePath + " shouldn't be excluded from project"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -267,7 +302,7 @@ public class TestProcesses extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertSetMBSOptionValues(IProject project, String id, int optionType, boolean append) throws BuildException {
|
private void assertSetMBSOptionValues(IProject project, String id, int optionType, boolean append) throws BuildException {
|
||||||
IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(project).getManagedProject().getConfigurations();
|
IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(project).getManagedProject().getConfigurations();
|
||||||
|
|
||||||
|
@ -275,14 +310,14 @@ public class TestProcesses extends TestCase {
|
||||||
IConfiguration config = projectConfigs[i];
|
IConfiguration config = projectConfigs[i];
|
||||||
IOption[] globalOptions = config.getToolChain().getOptions();
|
IOption[] globalOptions = config.getToolChain().getOptions();
|
||||||
assertMBSOptionValues(id.toLowerCase(), globalOptions, optionType, append);
|
assertMBSOptionValues(id.toLowerCase(), globalOptions, optionType, append);
|
||||||
|
|
||||||
ITool[] tools = config.getTools();
|
ITool[] tools = config.getTools();
|
||||||
for(int j=0; j<tools.length; j++) {
|
for(int j=0; j<tools.length; j++) {
|
||||||
assertMBSOptionValues(id.toLowerCase(), tools[j].getOptions(), optionType, append);
|
assertMBSOptionValues(id.toLowerCase(), tools[j].getOptions(), optionType, append);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertMBSOptionValues(String id, IOption[] options, int optionType, boolean append) throws BuildException {
|
public void assertMBSOptionValues(String id, IOption[] options, int optionType, boolean append) throws BuildException {
|
||||||
for (int i = 0; i < options.length; i++) {
|
for (int i = 0; i < options.length; i++) {
|
||||||
IOption option = options[i];
|
IOption option = options[i];
|
||||||
|
@ -299,34 +334,32 @@ public class TestProcesses extends TestCase {
|
||||||
assertTrue(option.getStringValue().equals(MBS_STRING_OPTION_VALUE));
|
assertTrue(option.getStringValue().equals(MBS_STRING_OPTION_VALUE));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IOption.STRING_LIST:
|
default:
|
||||||
case IOption.INCLUDE_PATH:
|
if(option.getValue() instanceof List) {
|
||||||
case IOption.PREPROCESSOR_SYMBOLS:
|
List list= (List) option.getValue();
|
||||||
case IOption.LIBRARIES:
|
String[] optionValues= (String[]) list.toArray(new String[list.size()]);
|
||||||
case IOption.OBJECTS:
|
if (append) {
|
||||||
String[] optionValues = option.getStringListValue();
|
assertTrue(optionValues.length == 2 * MBS_STRING_LIST_OPTION_VALUES.length);
|
||||||
if (append) {
|
int j=0;
|
||||||
assertTrue(optionValues.length == 2 * MBS_STRING_LIST_OPTION_VALUES.length);
|
for (; j < MBS_STRING_LIST_OPTION_VALUES.length; j++) {
|
||||||
int j=0;
|
assertTrue(optionValues[j].equals(MBS_STRING_LIST_OPTION_VALUES[j]));
|
||||||
for (; j < MBS_STRING_LIST_OPTION_VALUES.length; j++) {
|
}
|
||||||
assertTrue(optionValues[j].equals(MBS_STRING_LIST_OPTION_VALUES[j]));
|
for (; j < optionValues.length; j++) {
|
||||||
}
|
assertTrue(optionValues[j].equals(APPEND + MBS_STRING_LIST_OPTION_VALUES[j-MBS_STRING_LIST_OPTION_VALUES.length]));
|
||||||
for (; j < optionValues.length; j++) {
|
}
|
||||||
assertTrue(optionValues[j].equals(APPEND + MBS_STRING_LIST_OPTION_VALUES[j-MBS_STRING_LIST_OPTION_VALUES.length]));
|
} else {
|
||||||
}
|
assertTrue(optionValues.length == MBS_STRING_LIST_OPTION_VALUES.length);
|
||||||
} else {
|
for (int j=0; j < optionValues.length; j++) {
|
||||||
assertTrue(optionValues.length == MBS_STRING_LIST_OPTION_VALUES.length);
|
assertTrue(optionValues[j].equals(MBS_STRING_LIST_OPTION_VALUES[j]));
|
||||||
for (int j=0; j < optionValues.length; j++) {
|
}
|
||||||
assertTrue(optionValues[j].equals(MBS_STRING_LIST_OPTION_VALUES[j]));
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
continue;
|
||||||
default:
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,13 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.templateengine.processes;
|
package org.eclipse.cdt.managedbuilder.templateengine.processes;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.templateengine.process.processes.Messages;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
||||||
import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
|
import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
|
||||||
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
|
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
|
||||||
import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
|
import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
|
||||||
|
import org.eclipse.cdt.core.templateengine.process.processes.Messages;
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
||||||
|
@ -36,7 +38,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
* This class Appends contents to Managed Build System StringList Option Values.
|
* This class Appends contents to Managed Build System StringList Option Values.
|
||||||
*/
|
*/
|
||||||
public class AppendToMBSStringListOptionValues extends ProcessRunner {
|
public class AppendToMBSStringListOptionValues extends ProcessRunner {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method Appends contents to Managed Build System StringList Option Values.
|
* This method Appends contents to Managed Build System StringList Option Values.
|
||||||
*/
|
*/
|
||||||
|
@ -51,7 +53,7 @@ public class AppendToMBSStringListOptionValues extends ProcessRunner {
|
||||||
workspace.setDescription(workspaceDesc);
|
workspace.setDescription(workspaceDesc);
|
||||||
} catch (CoreException e) {//ignore
|
} catch (CoreException e) {//ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessArgument[][] resourcePathObjects = args[1].getComplexArrayValue();
|
ProcessArgument[][] resourcePathObjects = args[1].getComplexArrayValue();
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
for(int i=0; i<resourcePathObjects.length; i++) {
|
for(int i=0; i<resourcePathObjects.length; i++) {
|
||||||
|
@ -75,13 +77,13 @@ public class AppendToMBSStringListOptionValues extends ProcessRunner {
|
||||||
} catch (CoreException e) {//ignore
|
} catch (CoreException e) {//ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setOptionValue(IProject projectHandle, String id, String[] value, String path) throws BuildException, ProcessFailureException {
|
private boolean setOptionValue(IProject projectHandle, String id, String[] value, String path) throws BuildException, ProcessFailureException {
|
||||||
IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(projectHandle).getManagedProject().getConfigurations();
|
IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(projectHandle).getManagedProject().getConfigurations();
|
||||||
|
|
||||||
boolean resource = !(path == null || path.equals("") || path.equals("/")); //$NON-NLS-1$ //$NON-NLS-2$
|
boolean resource = !(path == null || path.equals("") || path.equals("/")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
|
|
||||||
for(int i=0; i<projectConfigs.length; i++) {
|
for(int i=0; i<projectConfigs.length; i++) {
|
||||||
IConfiguration config = projectConfigs[i];
|
IConfiguration config = projectConfigs[i];
|
||||||
IResourceConfiguration resourceConfig = null;
|
IResourceConfiguration resourceConfig = null;
|
||||||
|
@ -101,14 +103,14 @@ public class AppendToMBSStringListOptionValues extends ProcessRunner {
|
||||||
} else {
|
} else {
|
||||||
IToolChain toolChain = config.getToolChain();
|
IToolChain toolChain = config.getToolChain();
|
||||||
modified |= setOptionForConfig(id, value, config, toolChain.getOptions(), toolChain);
|
modified |= setOptionForConfig(id, value, config, toolChain.getOptions(), toolChain);
|
||||||
|
|
||||||
ITool[] tools = config.getTools();
|
ITool[] tools = config.getTools();
|
||||||
for(int j=0; j<tools.length; j++) {
|
for(int j=0; j<tools.length; j++) {
|
||||||
modified |= setOptionForConfig(id, value, config, tools[j].getOptions(), tools[j]);
|
modified |= setOptionForConfig(id, value, config, tools[j].getOptions(), tools[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,34 +120,23 @@ public class AppendToMBSStringListOptionValues extends ProcessRunner {
|
||||||
for (int i = 0; i < options.length; i++) {
|
for (int i = 0; i < options.length; i++) {
|
||||||
IOption option = options[i];
|
IOption option = options[i];
|
||||||
if (option.getId().toLowerCase().matches(lowerId)) {
|
if (option.getId().toLowerCase().matches(lowerId)) {
|
||||||
String[] oldValue;
|
switch(options[i].getValueType()) {
|
||||||
switch (option.getValueType()) {
|
|
||||||
case IOption.STRING_LIST:
|
case IOption.STRING_LIST:
|
||||||
oldValue = option.getStringListValue();
|
|
||||||
break;
|
|
||||||
case IOption.INCLUDE_PATH:
|
case IOption.INCLUDE_PATH:
|
||||||
oldValue = option.getIncludePaths();
|
|
||||||
break;
|
|
||||||
case IOption.PREPROCESSOR_SYMBOLS:
|
case IOption.PREPROCESSOR_SYMBOLS:
|
||||||
oldValue = option.getDefinedSymbols();
|
|
||||||
break;
|
|
||||||
case IOption.LIBRARIES:
|
case IOption.LIBRARIES:
|
||||||
oldValue = option.getLibraries();
|
|
||||||
break;
|
|
||||||
case IOption.OBJECTS:
|
case IOption.OBJECTS:
|
||||||
oldValue = option.getUserObjects();
|
case IOption.INCLUDE_FILES:
|
||||||
break;
|
case IOption.LIBRARY_PATHS:
|
||||||
|
case IOption.LIBRARY_FILES:
|
||||||
|
case IOption.MACRO_FILES:
|
||||||
|
List list= (List) option.getValue();
|
||||||
|
String[] newValue= concat((String[]) list.toArray(new String[list.size()]), value);
|
||||||
|
ManagedBuildManager.setOption(resourceConfig, optionHolder, option, newValue);
|
||||||
|
modified = true;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String[] newValue = new String[oldValue.length + value.length];
|
|
||||||
System.arraycopy(oldValue, 0, newValue, 0, oldValue.length);
|
|
||||||
System.arraycopy(value, 0, newValue, oldValue.length, value.length);
|
|
||||||
IOption setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, option, newValue);
|
|
||||||
if (setOption == null) {
|
|
||||||
setOption = option;
|
|
||||||
}
|
|
||||||
modified = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return modified;
|
return modified;
|
||||||
|
@ -157,36 +148,37 @@ public class AppendToMBSStringListOptionValues extends ProcessRunner {
|
||||||
for (int i = 0; i < options.length; i++) {
|
for (int i = 0; i < options.length; i++) {
|
||||||
IOption option = options[i];
|
IOption option = options[i];
|
||||||
if (option.getId().toLowerCase().matches(lowerId)) {
|
if (option.getId().toLowerCase().matches(lowerId)) {
|
||||||
String[] oldValue;
|
switch(options[i].getValueType()) {
|
||||||
switch (option.getValueType()) {
|
|
||||||
case IOption.STRING_LIST:
|
case IOption.STRING_LIST:
|
||||||
oldValue = option.getStringListValue();
|
|
||||||
break;
|
|
||||||
case IOption.INCLUDE_PATH:
|
case IOption.INCLUDE_PATH:
|
||||||
oldValue = option.getIncludePaths();
|
|
||||||
break;
|
|
||||||
case IOption.PREPROCESSOR_SYMBOLS:
|
case IOption.PREPROCESSOR_SYMBOLS:
|
||||||
oldValue = option.getDefinedSymbols();
|
|
||||||
break;
|
|
||||||
case IOption.LIBRARIES:
|
case IOption.LIBRARIES:
|
||||||
oldValue = option.getLibraries();
|
|
||||||
break;
|
|
||||||
case IOption.OBJECTS:
|
case IOption.OBJECTS:
|
||||||
oldValue = option.getUserObjects();
|
case IOption.INCLUDE_FILES:
|
||||||
break;
|
case IOption.LIBRARY_PATHS:
|
||||||
|
case IOption.LIBRARY_FILES:
|
||||||
|
case IOption.MACRO_FILES:
|
||||||
|
List list= (List) option.getValue();
|
||||||
|
String[] newValue= concat((String[]) list.toArray(new String[list.size()]), value);
|
||||||
|
ManagedBuildManager.setOption(config, optionHolder, option, newValue);
|
||||||
|
modified = true;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String[] newValue = new String[oldValue.length + value.length];
|
|
||||||
System.arraycopy(oldValue, 0, newValue, 0, oldValue.length);
|
|
||||||
System.arraycopy(value, 0, newValue, oldValue.length, value.length);
|
|
||||||
IOption setOption = ManagedBuildManager.setOption(config, optionHolder, option, newValue);
|
|
||||||
if (setOption == null) {
|
|
||||||
setOption = option;
|
|
||||||
}
|
|
||||||
modified = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param a non-null array to form start of resulting array
|
||||||
|
* @param b non-null array to from end of resulting array
|
||||||
|
* @return return an array with the contents of a followed by the contents of b
|
||||||
|
*/
|
||||||
|
private static String[] concat(String[] a, String[] b) {
|
||||||
|
String[] result = new String[a.length + b.length];
|
||||||
|
System.arraycopy(a, 0, result, 0, a.length);
|
||||||
|
System.arraycopy(b, 0, result, a.length, b.length);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,10 @@ public class SetMBSStringListOptionValues extends ProcessRunner {
|
||||||
case IOption.PREPROCESSOR_SYMBOLS:
|
case IOption.PREPROCESSOR_SYMBOLS:
|
||||||
case IOption.LIBRARIES:
|
case IOption.LIBRARIES:
|
||||||
case IOption.OBJECTS:
|
case IOption.OBJECTS:
|
||||||
|
case IOption.INCLUDE_FILES:
|
||||||
|
case IOption.LIBRARY_PATHS:
|
||||||
|
case IOption.LIBRARY_FILES:
|
||||||
|
case IOption.MACRO_FILES:
|
||||||
setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, option, value);
|
setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, option, value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -149,6 +153,10 @@ public class SetMBSStringListOptionValues extends ProcessRunner {
|
||||||
case IOption.PREPROCESSOR_SYMBOLS:
|
case IOption.PREPROCESSOR_SYMBOLS:
|
||||||
case IOption.LIBRARIES:
|
case IOption.LIBRARIES:
|
||||||
case IOption.OBJECTS:
|
case IOption.OBJECTS:
|
||||||
|
case IOption.INCLUDE_FILES:
|
||||||
|
case IOption.LIBRARY_PATHS:
|
||||||
|
case IOption.LIBRARY_FILES:
|
||||||
|
case IOption.MACRO_FILES:
|
||||||
setOption = ManagedBuildManager.setOption(config, optionHolder, option, value);
|
setOption = ManagedBuildManager.setOption(config, optionHolder, option, value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.eclipse.core.runtime.Status;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class TemplateCore {
|
public class TemplateCore {
|
||||||
|
|
||||||
private static final String DESCRIPTION = "description"; //$NON-NLS-1$
|
private static final String DESCRIPTION = "description"; //$NON-NLS-1$
|
||||||
private static final String LABEL = "label"; //$NON-NLS-1$
|
private static final String LABEL = "label"; //$NON-NLS-1$
|
||||||
private static final String ID = "id"; //$NON-NLS-1$
|
private static final String ID = "id"; //$NON-NLS-1$
|
||||||
|
|
|
@ -56,7 +56,6 @@ public class TemplateEngineHelper {
|
||||||
public static final String TOOL_CHAIN = "toolChain"; //$NON-NLS-1$
|
public static final String TOOL_CHAIN = "toolChain"; //$NON-NLS-1$
|
||||||
public static final String EXTRA_PAGES_PROVIDER = "pagesAfterTemplateSelectionProvider"; //$NON-NLS-1$
|
public static final String EXTRA_PAGES_PROVIDER = "pagesAfterTemplateSelectionProvider"; //$NON-NLS-1$
|
||||||
public static final String IS_CATEGORY = "isCategory"; //$NON-NLS-1$
|
public static final String IS_CATEGORY = "isCategory"; //$NON-NLS-1$
|
||||||
public static final String CONFIGURATIONS = "Configurations"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the backup shareddefaults XML file. Presence of the file indicates
|
* Gets the backup shareddefaults XML file. Presence of the file indicates
|
||||||
|
|
Loading…
Add table
Reference in a new issue