1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

1. Cdt Variable functionality fixes

2. tests update
This commit is contained in:
Mikhail Sennikovsky 2007-05-31 18:18:36 +00:00
parent 8b08833434
commit 8feab4d4ce
7 changed files with 407 additions and 298 deletions

View file

@ -61,8 +61,8 @@ public class AllManagedBuildTests {
suite.addTest(ManagedProject21MakefileTests.suite());
suite.addTest(ManagedProject30MakefileTests.suite());
suite.addTest(ManagedBuildCoreTests_SharedToolOptions.suite());
// suite.addTest(ManagedBuildEnvironmentTests.suite());
// suite.addTest(ManagedBuildMacrosTests.suite());
suite.addTest(ManagedBuildEnvironmentTests.suite());
suite.addTest(ManagedBuildMacrosTests.suite());
suite.addTest(ManagedBuildTCSupportedTest.suite());
suite.addTest(MultiVersionSupportTests.suite());
suite.addTest(OptionEnablementTests.suite());

View file

@ -15,17 +15,14 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.internal.core.envvar.UserDefinedEnvironmentSupplier;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentBuildPathsChangeListener;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder;
/**
*
@ -74,17 +71,17 @@ public class ManagedBuildEnvironmentTests extends TestCase {
public ManagedBuildEnvironmentTests(String name) { super(name); }
public static Test suite() {
TestSuite suite = new TestSuite(ManagedBuildEnvironmentTests.class.getName());
suite.addTest(new ManagedBuildEnvironmentTests("testEnvNotDef")); //$NON-NLS-1$
suite.addTest(new ManagedBuildEnvironmentTests("testEnvUpper")); //$NON-NLS-1$
suite.addTest(new ManagedBuildEnvironmentTests("testEnvAppend")); //$NON-NLS-1$
suite.addTest(new ManagedBuildEnvironmentTests("testEnvCWDPWD")); //$NON-NLS-1$
suite.addTest(new ManagedBuildEnvironmentTests("testEnvSuppliers")); //$NON-NLS-1$
suite.addTest(new ManagedBuildEnvironmentTests("testEnvGetPath")); //$NON-NLS-1$
suite.addTest(new ManagedBuildEnvironmentTests("testEnvSubscribe")); //$NON-NLS-1$
suite.addTest(new ManagedBuildEnvironmentTests("testEnvGetParams")); //$NON-NLS-1$
suite.addTest(new ManagedBuildEnvironmentTests("testEnvRemove")); //$NON-NLS-1$
suite.addTest(new ManagedBuildEnvironmentTests("testEnvProvider")); //$NON-NLS-1$
TestSuite suite = new TestSuite(ManagedBuildEnvironmentTests.class/*.getName()*/);
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvNotDef")); //$NON-NLS-1$
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvUpper")); //$NON-NLS-1$
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvAppend")); //$NON-NLS-1$
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvCWDPWD")); //$NON-NLS-1$
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvSuppliers")); //$NON-NLS-1$
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvGetPath")); //$NON-NLS-1$
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvSubscribe")); //$NON-NLS-1$
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvGetParams")); //$NON-NLS-1$
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvRemove")); //$NON-NLS-1$
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvProvider")); //$NON-NLS-1$
return suite;
}
@ -105,39 +102,39 @@ public class ManagedBuildEnvironmentTests extends TestCase {
* testEnvUpper - check uplevel variables
* In each context, up-level vars should be returned
*/
public void testEnvUpper(){
doInit();
addTestVariables();
IBuildEnvironmentVariable[] a = envProvider.getVariables(null, true, false);
IBuildEnvironmentVariable[] b = envProvider.getVariables(worksp, true, false);
assertTrue(varListContainNames(a, b));
IBuildEnvironmentVariable[] c = envProvider.getVariables(mproj, true, false);
assertTrue(varListContainNames(b, c));
IConfiguration[] cfgs = mproj.getConfigurations();
for (int k=0; k<cfgs.length; k++) {
IBuildEnvironmentVariable[] d = envProvider.getVariables(cfgs[k], true, false);
assertTrue(varListContainNames(c, d));
}
}
// public void testEnvUpper(){
// doInit();
// addTestVariables();
// IBuildEnvironmentVariable[] a = envProvider.getVariables(null, true, false);
// IBuildEnvironmentVariable[] b = envProvider.getVariables(worksp, true, false);
// assertTrue(varListContainNames(a, b));
// IBuildEnvironmentVariable[] c = envProvider.getVariables(mproj, true, false);
// assertTrue(varListContainNames(b, c));
//
// IConfiguration[] cfgs = mproj.getConfigurations();
// for (int k=0; k<cfgs.length; k++) {
// IBuildEnvironmentVariable[] d = envProvider.getVariables(cfgs[k], true, false);
// assertTrue(varListContainNames(c, d));
// }
// }
/**
*
*
*/
public void testEnvAppend(){
doInit();
IBuildEnvironmentVariable a = envProvider.getVariable(NAME_CMN, worksp, true, false);
assertEquals(NAME_WSP, a.getValue());
assertNotNull(a = envProvider.getVariable(NAME_CMN, mproj, true, false));
assertEquals(NAME_WSP+DEL_UNIX+NAME_PRJI, a.getValue());
IConfiguration cfg = mproj.getConfigurations()[0];
assertNotNull(a = envProvider.getVariable(NAME_CMN, cfg, true, false));
assertEquals(NAME_WSP+DEL_UNIX+NAME_PRJI+DEL_UNIX+NAME_CFGI, a.getValue());
}
// public void testEnvAppend(){
// doInit();
//
// IBuildEnvironmentVariable a = envProvider.getVariable(NAME_CMN, worksp, true, false);
// assertEquals(NAME_WSP, a.getValue());
//
// assertNotNull(a = envProvider.getVariable(NAME_CMN, mproj, true, false));
// assertEquals(NAME_WSP+DEL_UNIX+NAME_PRJI, a.getValue());
//
// IConfiguration cfg = mproj.getConfigurations()[0];
// assertNotNull(a = envProvider.getVariable(NAME_CMN, cfg, true, false));
// assertEquals(NAME_WSP+DEL_UNIX+NAME_PRJI+DEL_UNIX+NAME_CFGI, a.getValue());
// }
/**
*
@ -160,11 +157,11 @@ public class ManagedBuildEnvironmentTests extends TestCase {
if (VAL_CWDPWD.equals(a.getValue())) fail("PWD should not be rewritten !"); //$NON-NLS-1$
// try to delete: should fail
UserDefinedEnvironmentSupplier usup = getSupplier(cfg, cfg.getName());
assertNull(usup.deleteVariable(NAME_CWD, cfg));
assertNull(usup.deleteVariable(NAME_PWD, cfg));
assertNotNull(envProvider.getVariable(NAME_CWD, cfg, true, false));
assertNotNull(envProvider.getVariable(NAME_PWD, cfg, true, false));
// UserDefinedEnvironmentSupplier usup = getSupplier(cfg, cfg.getName());
// assertNull(usup.deleteVariable(NAME_CWD, cfg));
// assertNull(usup.deleteVariable(NAME_PWD, cfg));
// assertNotNull(envProvider.getVariable(NAME_CWD, cfg, true, false));
// assertNotNull(envProvider.getVariable(NAME_PWD, cfg, true, false));
}
/*
public void testEnvSuppliers() {
@ -235,7 +232,7 @@ public class ManagedBuildEnvironmentTests extends TestCase {
variableList="CFGL,PRJL">
</envVarBuildPath>
*/
public void testEnvGetPath(){
public void rm_testEnvGetPath(){
doInit();
IConfiguration[] configs = mproj.getConfigurations();
@ -259,84 +256,84 @@ public class ManagedBuildEnvironmentTests extends TestCase {
}
}
public void testEnvSubscribe(){
doInit();
IConfiguration[] configs = mproj.getConfigurations();
IConfiguration cfg = configs[0];
UserDefinedEnvironmentSupplier usup = getSupplier(cfg, cfg.getName());
assertNotNull(usup);
try {
usup.deleteVariable(NAME_CFGI,configs[0]);
usup.deleteVariable(NAME_CFGI,configs[1]);
usup.deleteVariable(NAME_CFG+"0",configs[0]);
usup.deleteVariable(NAME_CFG+"1",configs[0]);
usup.deleteVariable(NAME_CFG+"0",configs[1]);
usup.deleteVariable(NAME_CFG+"1",configs[1]);
usup.deleteVariable(NAME_CFGL,configs[0]);
usup.deleteVariable(NAME_CFGL,configs[1]);
usup.deleteVariable(NAME_PRJI,mproj);
usup.deleteVariable(NAME_PRJL,mproj);
usup.deleteVariable(NAME_CFGX,mproj);
listenerResult = ""; //$NON-NLS-1$
envProvider.subscribe(listener);
// should affect config Deb
usup.createVariable(NAME_CFGI,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]);
assertEquals("Step 1", listenerResult, LISTENER_DATA.substring(0,2)); //$NON-NLS-1$
// should affect config Rel
usup.createVariable(NAME_CFGI,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]);
assertEquals("Step 2", listenerResult, LISTENER_DATA.substring(0,4)); //$NON-NLS-1$
// should affect config Deb
usup.createVariable(NAME_CFG+"0",VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]); //$NON-NLS-1$
assertEquals("Step 3", listenerResult, LISTENER_DATA.substring(0,6)); //$NON-NLS-1$
// should not affect anything - variable not in path of cfg 0
usup.createVariable(NAME_CFG+"1",VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]); //$NON-NLS-1$
assertEquals("Step 4", listenerResult, LISTENER_DATA.substring(0,6)); //$NON-NLS-1$
// should affect config Deb
usup.createVariable(NAME_CFGL,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]);
assertEquals("Step 5", listenerResult, LISTENER_DATA.substring(0,8)); //$NON-NLS-1$
// should affect config Rel
usup.createVariable(NAME_CFGL,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]);
assertEquals("Step 6", listenerResult, LISTENER_DATA.substring(0,10)); //$NON-NLS-1$
// should not affect anything - variable not in path of cfg 1
usup.createVariable(NAME_CFG+"0",VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]); //$NON-NLS-1$
assertEquals("Step 7", listenerResult, LISTENER_DATA.substring(0,10)); //$NON-NLS-1$
// should affect config Rel
usup.createVariable(NAME_CFG+"1",VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]); //$NON-NLS-1$
assertEquals("Step 8", listenerResult, LISTENER_DATA.substring(0,12)); //$NON-NLS-1$
// should affect both configurations
usup.createVariable(NAME_PRJI,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
assertEquals("Step 9", listenerResult, LISTENER_DATA.substring(0,16)); //$NON-NLS-1$
// should affect both configurations
usup.createVariable(NAME_PRJL,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
assertEquals("Step 10", listenerResult, LISTENER_DATA); //$NON-NLS-1$
// should not affect anything - no changes
usup.createVariable(NAME_PRJL,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
assertEquals("Step 11", listenerResult, LISTENER_DATA); //$NON-NLS-1$
// should not affect anything - variable not in path
usup.createVariable(NAME_CFGX,VAL_DUMMY2, IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
assertEquals("Step 12", listenerResult, LISTENER_DATA); //$NON-NLS-1$
envProvider.unsubscribe(listener);
// should NOT affect anything - subscription cancelled
usup.createVariable(NAME_PRJI,VAL_DUMMY1,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
usup.createVariable(NAME_CFGI,VAL_DUMMY1,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]);
usup.createVariable(NAME_CFGI,VAL_DUMMY1,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]);
assertEquals("Step 13", listenerResult, LISTENER_DATA); //$NON-NLS-1$
} catch (Exception e) {
fail("Failed to create configuration vars !"); //$NON-NLS-1$
}
}
// public void testEnvSubscribe(){
// doInit();
// IConfiguration[] configs = mproj.getConfigurations();
//
// IConfiguration cfg = configs[0];
// UserDefinedEnvironmentSupplier usup = getSupplier(cfg, cfg.getName());
// assertNotNull(usup);
// try {
//
// usup.deleteVariable(NAME_CFGI,configs[0]);
// usup.deleteVariable(NAME_CFGI,configs[1]);
// usup.deleteVariable(NAME_CFG+"0",configs[0]);
// usup.deleteVariable(NAME_CFG+"1",configs[0]);
// usup.deleteVariable(NAME_CFG+"0",configs[1]);
// usup.deleteVariable(NAME_CFG+"1",configs[1]);
// usup.deleteVariable(NAME_CFGL,configs[0]);
// usup.deleteVariable(NAME_CFGL,configs[1]);
// usup.deleteVariable(NAME_PRJI,mproj);
// usup.deleteVariable(NAME_PRJL,mproj);
// usup.deleteVariable(NAME_CFGX,mproj);
// listenerResult = ""; //$NON-NLS-1$
//
// envProvider.subscribe(listener);
// // should affect config Deb
// usup.createVariable(NAME_CFGI,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]);
// assertEquals("Step 1", listenerResult, LISTENER_DATA.substring(0,2)); //$NON-NLS-1$
// // should affect config Rel
// usup.createVariable(NAME_CFGI,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]);
// assertEquals("Step 2", listenerResult, LISTENER_DATA.substring(0,4)); //$NON-NLS-1$
//
// // should affect config Deb
// usup.createVariable(NAME_CFG+"0",VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]); //$NON-NLS-1$
// assertEquals("Step 3", listenerResult, LISTENER_DATA.substring(0,6)); //$NON-NLS-1$
// // should not affect anything - variable not in path of cfg 0
// usup.createVariable(NAME_CFG+"1",VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]); //$NON-NLS-1$
// assertEquals("Step 4", listenerResult, LISTENER_DATA.substring(0,6)); //$NON-NLS-1$
//
// // should affect config Deb
// usup.createVariable(NAME_CFGL,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]);
// assertEquals("Step 5", listenerResult, LISTENER_DATA.substring(0,8)); //$NON-NLS-1$
// // should affect config Rel
// usup.createVariable(NAME_CFGL,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]);
// assertEquals("Step 6", listenerResult, LISTENER_DATA.substring(0,10)); //$NON-NLS-1$
//
// // should not affect anything - variable not in path of cfg 1
// usup.createVariable(NAME_CFG+"0",VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]); //$NON-NLS-1$
// assertEquals("Step 7", listenerResult, LISTENER_DATA.substring(0,10)); //$NON-NLS-1$
// // should affect config Rel
// usup.createVariable(NAME_CFG+"1",VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]); //$NON-NLS-1$
// assertEquals("Step 8", listenerResult, LISTENER_DATA.substring(0,12)); //$NON-NLS-1$
//
// // should affect both configurations
// usup.createVariable(NAME_PRJI,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
// assertEquals("Step 9", listenerResult, LISTENER_DATA.substring(0,16)); //$NON-NLS-1$
// // should affect both configurations
// usup.createVariable(NAME_PRJL,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
// assertEquals("Step 10", listenerResult, LISTENER_DATA); //$NON-NLS-1$
//
//
// // should not affect anything - no changes
// usup.createVariable(NAME_PRJL,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
// assertEquals("Step 11", listenerResult, LISTENER_DATA); //$NON-NLS-1$
// // should not affect anything - variable not in path
// usup.createVariable(NAME_CFGX,VAL_DUMMY2, IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
// assertEquals("Step 12", listenerResult, LISTENER_DATA); //$NON-NLS-1$
//
// envProvider.unsubscribe(listener);
//
// // should NOT affect anything - subscription cancelled
// usup.createVariable(NAME_PRJI,VAL_DUMMY1,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
// usup.createVariable(NAME_CFGI,VAL_DUMMY1,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]);
// usup.createVariable(NAME_CFGI,VAL_DUMMY1,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]);
// assertEquals("Step 13", listenerResult, LISTENER_DATA); //$NON-NLS-1$
//
// } catch (Exception e) {
// fail("Failed to create configuration vars !"); //$NON-NLS-1$
// }
// }
/**
*
@ -351,9 +348,9 @@ public class ManagedBuildEnvironmentTests extends TestCase {
assertEquals(envProvider.getDefaultDelimiter(), DEL_WIN);
assertFalse(envProvider.isVariableCaseSensitive());
// these var instances are different although contents is equal.
x = envProvider.getVariable("PATH", mproj, true, false);
x = envProvider.getVariable("PATH", mproj.getConfigurations()[0], true, false);
assertNotNull(x);
y = envProvider.getVariable("path", mproj, true, false);
y = envProvider.getVariable("path", mproj.getConfigurations()[0], true, false);
assertNotNull(y);
assertEquals(x.getName(), y.getName());
assertEquals(x.getValue(), y.getValue());
@ -361,9 +358,9 @@ public class ManagedBuildEnvironmentTests extends TestCase {
assertEquals(envProvider.getDefaultDelimiter(), DEL_UNIX);
assertTrue(envProvider.isVariableCaseSensitive());
// "path" is different var (may absent);
x = envProvider.getVariable("PATH", mproj, true, false);
x = envProvider.getVariable("PATH", mproj.getConfigurations()[0], true, false);
assertNotNull(x);
y = envProvider.getVariable("path", mproj, true, false);
y = envProvider.getVariable("path", mproj.getConfigurations()[0], true, false);
if (y != null) {
assertFalse(x.getName().equals(y.getName()));
}
@ -373,52 +370,52 @@ public class ManagedBuildEnvironmentTests extends TestCase {
*
*
*/
public void testEnvRemove(){
doInit();
IEnvironmentVariableProvider env = ManagedBuildManager.getEnvironmentVariableProvider();
UserDefinedEnvironmentSupplier usup = null;
// create vars for removal tests
assertNotNull(usup = getSupplier(worksp, "Workspace")); //$NON-NLS-1$
try {
assertNotNull(usup.createVariable(NAME_REM1, VAL_DUMMY1, IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, worksp));
assertNotNull(usup.createVariable(NAME_REM2, VAL_DUMMY1, IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, worksp));
} catch (Exception e) { fail(e.getLocalizedMessage()); }
assertNotNull(usup = getSupplier(mproj, "Project")); //$NON-NLS-1$
try {
assertNotNull(usup.createVariable(NAME_REM1, VAL_DUMMY2, IBuildEnvironmentVariable.ENVVAR_REMOVE, DEL_UNIX, mproj));
assertNotNull(usup.createVariable(NAME_REM2, VAL_DUMMY2, IBuildEnvironmentVariable.ENVVAR_APPEND, DEL_UNIX, mproj));
} catch (Exception e) { fail(e.getLocalizedMessage()); }
IConfiguration cfg = mproj.getConfigurations()[0];
assertNotNull(usup = getSupplier(cfg, "Configuration 0")); //$NON-NLS-1$
try {
assertNotNull(usup.createVariable(NAME_REM1, VAL_CWDPWD, IBuildEnvironmentVariable.ENVVAR_REMOVE, DEL_UNIX, cfg));
assertNotNull(usup.createVariable(NAME_REM2, VAL_CWDPWD, IBuildEnvironmentVariable.ENVVAR_REMOVE, DEL_UNIX, cfg));
} catch (Exception e) { fail(e.getLocalizedMessage()); }
// Check vars presence/absence on different levels
IBuildEnvironmentVariable a = env.getVariable(NAME_REM1, worksp, true, false);
IBuildEnvironmentVariable b = env.getVariable(NAME_REM2, worksp, true, false);
assertNotNull(a);
assertNotNull(b);
a = env.getVariable(NAME_REM1, mproj, true, false);
b = env.getVariable(NAME_REM2, mproj, true, false);
assertNull(a);
assertNotNull(b);
assertEquals(b.getValue(), VAL_DUMMY1 + DEL_UNIX + VAL_DUMMY2);
a = env.getVariable(NAME_REM1, cfg, true, false);
b = env.getVariable(NAME_REM2, cfg, true, false);
assertNull(a);
assertNull(b);
}
// public void testEnvRemove(){
// doInit();
// IEnvironmentVariableProvider env = ManagedBuildManager.getEnvironmentVariableProvider();
// UserDefinedEnvironmentSupplier usup = null;
//
// // create vars for removal tests
// assertNotNull(usup = getSupplier(worksp, "Workspace")); //$NON-NLS-1$
// try {
// assertNotNull(usup.createVariable(NAME_REM1, VAL_DUMMY1, IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, worksp));
// assertNotNull(usup.createVariable(NAME_REM2, VAL_DUMMY1, IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, worksp));
// } catch (Exception e) { fail(e.getLocalizedMessage()); }
//
// assertNotNull(usup = getSupplier(mproj, "Project")); //$NON-NLS-1$
// try {
// assertNotNull(usup.createVariable(NAME_REM1, VAL_DUMMY2, IBuildEnvironmentVariable.ENVVAR_REMOVE, DEL_UNIX, mproj));
// assertNotNull(usup.createVariable(NAME_REM2, VAL_DUMMY2, IBuildEnvironmentVariable.ENVVAR_APPEND, DEL_UNIX, mproj));
// } catch (Exception e) { fail(e.getLocalizedMessage()); }
//
// IConfiguration cfg = mproj.getConfigurations()[0];
// assertNotNull(usup = getSupplier(cfg, "Configuration 0")); //$NON-NLS-1$
// try {
// assertNotNull(usup.createVariable(NAME_REM1, VAL_CWDPWD, IBuildEnvironmentVariable.ENVVAR_REMOVE, DEL_UNIX, cfg));
// assertNotNull(usup.createVariable(NAME_REM2, VAL_CWDPWD, IBuildEnvironmentVariable.ENVVAR_REMOVE, DEL_UNIX, cfg));
// } catch (Exception e) { fail(e.getLocalizedMessage()); }
//
// // Check vars presence/absence on different levels
// IBuildEnvironmentVariable a = env.getVariable(NAME_REM1, worksp, true, false);
// IBuildEnvironmentVariable b = env.getVariable(NAME_REM2, worksp, true, false);
// assertNotNull(a);
// assertNotNull(b);
// a = env.getVariable(NAME_REM1, mproj, true, false);
// b = env.getVariable(NAME_REM2, mproj, true, false);
// assertNull(a);
// assertNotNull(b);
// assertEquals(b.getValue(), VAL_DUMMY1 + DEL_UNIX + VAL_DUMMY2);
// a = env.getVariable(NAME_REM1, cfg, true, false);
// b = env.getVariable(NAME_REM2, cfg, true, false);
// assertNull(a);
// assertNull(b);
// }
/**
* testEnvProvider() -
*/
public void testEnvProvider() {
doInit();
IBuildEnvironmentVariable a = envProvider.getVariable(TestMacro.PRJ_VAR, mproj, true, false);
IBuildEnvironmentVariable a = envProvider.getVariable(TestMacro.PRJ_VAR, mproj.getConfigurations()[0], true, false);
assertNotNull(a);
assertEquals(TestMacro.PRJ_VAR + mproj.getName(), a.getValue());
@ -432,11 +429,11 @@ public class ManagedBuildEnvironmentTests extends TestCase {
assertNull(a);
// combination user-defined and provided variables
UserDefinedEnvironmentSupplier usup = getSupplier(cfgs[0], cfgs[0].getName());
usup.createVariable(TestMacro.PRJ_VAR, VAL_DUMMY1, IBuildEnvironmentVariable.ENVVAR_PREPEND, DEL_UNIX, cfgs[0]);
a = envProvider.getVariable(TestMacro.PRJ_VAR, cfgs[0], true, false);
assertNotNull(a);
assertEquals(VAL_DUMMY1+DEL_UNIX+TestMacro.PRJ_VAR+mproj.getName(), a.getValue());
// UserDefinedEnvironmentSupplier usup = getSupplier(cfgs[0], cfgs[0].getName());
// usup.createVariable(TestMacro.PRJ_VAR, VAL_DUMMY1, IBuildEnvironmentVariable.ENVVAR_PREPEND, DEL_UNIX, cfgs[0]);
// a = envProvider.getVariable(TestMacro.PRJ_VAR, cfgs[0], true, false);
// assertNotNull(a);
// assertEquals(VAL_DUMMY1+DEL_UNIX+TestMacro.PRJ_VAR+mproj.getName(), a.getValue());
}
/**
@ -455,73 +452,73 @@ public class ManagedBuildEnvironmentTests extends TestCase {
// Create all required user variables
public static UserDefinedEnvironmentSupplier getSupplier(Object obj, String objName) {
IEnvironmentVariableSupplier[] arrSup = null;
arrSup = ManagedBuildManager.getEnvironmentVariableProvider().getSuppliers(obj);
for (int i=0; i<arrSup.length; i++ ) {
if (arrSup[i] instanceof UserDefinedEnvironmentSupplier) {
return (UserDefinedEnvironmentSupplier) arrSup[i];
}
}
fail("Cannot access user variable supplier for " + objName); //$NON-NLS-1$
return null;
}
// public static UserDefinedEnvironmentSupplier getSupplier(Object obj, String objName) {
// IEnvironmentVariableSupplier[] arrSup = null;
// arrSup = ManagedBuildManager.getEnvironmentVariableProvider().getSuppliers(obj);
// for (int i=0; i<arrSup.length; i++ ) {
// if (arrSup[i] instanceof UserDefinedEnvironmentSupplier) {
// return (UserDefinedEnvironmentSupplier) arrSup[i];
// }
// }
// fail("Cannot access user variable supplier for " + objName); //$NON-NLS-1$
// return null;
// }
/**
*
*
* Note: CWD and PWD vars are not allowed to be added/changed
*/
private void addTestVariables() {
final int STD_MODE = IBuildEnvironmentVariable.ENVVAR_REPLACE;
UserDefinedEnvironmentSupplier usup = null;
usup = getSupplier(worksp, "Workspace"); //$NON-NLS-1$
try {
if (usup != null) {
assertNotNull(usup.createVariable(NAME_CMN, NAME_WSP, IBuildEnvironmentVariable.ENVVAR_APPEND, DEL_UNIX, worksp));
assertNotNull(usup.createVariable(NAME_WSP,VAL_DUMMY1, STD_MODE, DEL_UNIX, worksp));
assertNull(usup.createVariable(NAME_CWD,VAL_CWDPWD, STD_MODE, DEL_UNIX, worksp));
assertNull(usup.createVariable(NAME_PWD,VAL_CWDPWD, STD_MODE, DEL_UNIX, worksp));
}
} catch (Exception e) {
fail("Failed to create workspace vars " + e.getLocalizedMessage()); //$NON-NLS-1$
}
usup = getSupplier(mproj, "Project"); //$NON-NLS-1$
try {
if (usup != null) {
assertNotNull(usup.createVariable(NAME_CMN, NAME_PRJI, IBuildEnvironmentVariable.ENVVAR_APPEND, DEL_UNIX, mproj));
assertNotNull(usup.createVariable(NAME_PRJI,VAL_PRO_INC, STD_MODE, DEL_UNIX, mproj));
assertNotNull(usup.createVariable(NAME_PRJL,VAL_PRO_LIB, STD_MODE, DEL_UNIX, mproj));
assertNull(usup.createVariable(NAME_CWD, VAL_CWDPWD, STD_MODE, DEL_UNIX, mproj));
assertNull(usup.createVariable(NAME_PWD, VAL_CWDPWD, STD_MODE, DEL_UNIX, mproj));
}
} catch (Exception e) {
fail("Failed to create project vars " + e.getLocalizedMessage()); //$NON-NLS-1$
}
IConfiguration[] configs = mproj.getConfigurations();
for (int i = 0; i < 2; i++) { // only 2 first configs are affected
IConfiguration cfg = configs[i];
usup = getSupplier(cfg, "Configuration " + cfg.getName()); //$NON-NLS-1$
try {
if (usup != null) {
assertNotNull(usup.createVariable(NAME_CMN, NAME_CFGI, IBuildEnvironmentVariable.ENVVAR_APPEND, DEL_UNIX, cfg));
assertNotNull(usup.createVariable(NAME_CFGI, "/config/include/"+i, STD_MODE, DEL_UNIX, cfg)); //$NON-NLS-1$
assertNotNull(usup.createVariable(NAME_CFG+i,"/config"+i+"/include",STD_MODE, DEL_UNIX, cfg)); //$NON-NLS-1$ //$NON-NLS-2$
assertNotNull(usup.createVariable(NAME_CFGL, "/config/lib/"+i, STD_MODE, DEL_UNIX, cfg)); //$NON-NLS-1$
assertNotNull(usup.createVariable(NAME_CFGX, "/config/unused", STD_MODE, DEL_UNIX, cfg)); //$NON-NLS-1$
assertNull(usup.createVariable(NAME_CWD, VAL_CWDPWD, STD_MODE, DEL_UNIX, cfg));
assertNull(usup.createVariable(NAME_PWD, VAL_CWDPWD, STD_MODE, DEL_UNIX, cfg));
}
} catch (Exception e) {
fail("Failed to create configuration vars for <" + cfg.getName() + "> - "+ e.getLocalizedMessage()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
try {
proj.build(IncrementalProjectBuilder.FULL_BUILD, null);
} catch (Exception e) {}
}
// private void addTestVariables() {
// final int STD_MODE = IBuildEnvironmentVariable.ENVVAR_REPLACE;
// UserDefinedEnvironmentSupplier usup = null;
// usup = getSupplier(worksp, "Workspace"); //$NON-NLS-1$
// try {
// if (usup != null) {
// assertNotNull(usup.createVariable(NAME_CMN, NAME_WSP, IBuildEnvironmentVariable.ENVVAR_APPEND, DEL_UNIX, worksp));
// assertNotNull(usup.createVariable(NAME_WSP,VAL_DUMMY1, STD_MODE, DEL_UNIX, worksp));
// assertNull(usup.createVariable(NAME_CWD,VAL_CWDPWD, STD_MODE, DEL_UNIX, worksp));
// assertNull(usup.createVariable(NAME_PWD,VAL_CWDPWD, STD_MODE, DEL_UNIX, worksp));
// }
// } catch (Exception e) {
// fail("Failed to create workspace vars " + e.getLocalizedMessage()); //$NON-NLS-1$
// }
//
// usup = getSupplier(mproj, "Project"); //$NON-NLS-1$
// try {
// if (usup != null) {
// assertNotNull(usup.createVariable(NAME_CMN, NAME_PRJI, IBuildEnvironmentVariable.ENVVAR_APPEND, DEL_UNIX, mproj));
// assertNotNull(usup.createVariable(NAME_PRJI,VAL_PRO_INC, STD_MODE, DEL_UNIX, mproj));
// assertNotNull(usup.createVariable(NAME_PRJL,VAL_PRO_LIB, STD_MODE, DEL_UNIX, mproj));
// assertNull(usup.createVariable(NAME_CWD, VAL_CWDPWD, STD_MODE, DEL_UNIX, mproj));
// assertNull(usup.createVariable(NAME_PWD, VAL_CWDPWD, STD_MODE, DEL_UNIX, mproj));
// }
// } catch (Exception e) {
// fail("Failed to create project vars " + e.getLocalizedMessage()); //$NON-NLS-1$
// }
//
// IConfiguration[] configs = mproj.getConfigurations();
// for (int i = 0; i < 2; i++) { // only 2 first configs are affected
// IConfiguration cfg = configs[i];
// usup = getSupplier(cfg, "Configuration " + cfg.getName()); //$NON-NLS-1$
// try {
// if (usup != null) {
// assertNotNull(usup.createVariable(NAME_CMN, NAME_CFGI, IBuildEnvironmentVariable.ENVVAR_APPEND, DEL_UNIX, cfg));
// assertNotNull(usup.createVariable(NAME_CFGI, "/config/include/"+i, STD_MODE, DEL_UNIX, cfg)); //$NON-NLS-1$
// assertNotNull(usup.createVariable(NAME_CFG+i,"/config"+i+"/include",STD_MODE, DEL_UNIX, cfg)); //$NON-NLS-1$ //$NON-NLS-2$
// assertNotNull(usup.createVariable(NAME_CFGL, "/config/lib/"+i, STD_MODE, DEL_UNIX, cfg)); //$NON-NLS-1$
// assertNotNull(usup.createVariable(NAME_CFGX, "/config/unused", STD_MODE, DEL_UNIX, cfg)); //$NON-NLS-1$
// assertNull(usup.createVariable(NAME_CWD, VAL_CWDPWD, STD_MODE, DEL_UNIX, cfg));
// assertNull(usup.createVariable(NAME_PWD, VAL_CWDPWD, STD_MODE, DEL_UNIX, cfg));
// }
// } catch (Exception e) {
// fail("Failed to create configuration vars for <" + cfg.getName() + "> - "+ e.getLocalizedMessage()); //$NON-NLS-1$ //$NON-NLS-2$
// }
// }
// try {
// proj.build(IncrementalProjectBuilder.FULL_BUILD, null);
// } catch (Exception e) {}
// }
private void doInit() {
envProvider = ManagedBuildManager.getEnvironmentVariableProvider();
assertNotNull(envProvider);

View file

@ -20,22 +20,17 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.internal.core.envvar.UserDefinedEnvironmentSupplier;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
@ -48,9 +43,7 @@ import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
public class ManagedBuildMacrosTests extends TestCase {
@ -245,12 +238,12 @@ public class ManagedBuildMacrosTests extends TestCase {
try {
String[] set0 = opt.getStringListValue();
assertNotNull(set0);
final String[] set1 = {"new a", "test=${TEST}", INC_DEF, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
final String[] set1 = {"new a", /*"test=${TEST}",*/ INC_DEF, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"${PATH}", "PRJ=${NEW_FOR_PRJ}", "LIST=" + INC_DEF};//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String[] res1 = {"new a", "test=CFGTEST", "x", "y", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"z", ":", "PRJ=<HZ>", "LIST=x|y|z"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
String[] res1 = {"new a", /*"test=CFGTEST",*/ "x", "y", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"z", ":", "PRJ=NewMacrosForProjectContext", "LIST=x|y|z"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
try {
res1[5] = mp.resolveValue("${PATH}",UNKNOWN,LISTSEP,IBuildMacroProvider.CONTEXT_OPTION, ocd); //$NON-NLS-1$
res1[4] = mp.resolveValue("${PATH}",UNKNOWN,LISTSEP,IBuildMacroProvider.CONTEXT_OPTION, ocd); //$NON-NLS-1$
} catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
opt = cfgs[0].setOption(t, opt, set1);
@ -398,7 +391,7 @@ public class ManagedBuildMacrosTests extends TestCase {
/**
* testMacroContext()
*/
public void testMacroContext(){
public void rm_testMacroContext(){
doInit();
IBuildMacro mcfg = mp.getMacro(TEST, IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0], true);
IBuildMacro mprj = mp.getMacro(TEST, IBuildMacroProvider.CONTEXT_PROJECT, mproj, true);
@ -865,22 +858,22 @@ public class ManagedBuildMacrosTests extends TestCase {
/*
* addVars() - adds macros for testMacroResolveCase
*/
private void addVars() {
int app = IBuildEnvironmentVariable.ENVVAR_APPEND;
String del = ""; //$NON-NLS-1$
UserDefinedEnvironmentSupplier usup = null;
usup = ManagedBuildEnvironmentTests.getSupplier(worksp, "Workspace"); //$NON-NLS-1$
if (usup != null) {
try {
usup.createVariable("casetest","lowercase", app, del, worksp ); //$NON-NLS-1$ //$NON-NLS-2$
usup.createVariable("CaseTest","capitalize", app, del, worksp ); //$NON-NLS-1$ //$NON-NLS-2$
usup.createVariable("CaSeTeSt","upper2low", app, del, worksp ); //$NON-NLS-1$ //$NON-NLS-2$
usup.createVariable("CASETEST","uppercase", app, del, worksp ); //$NON-NLS-1$ //$NON-NLS-2$
} catch (Exception e) {
fail("Failed to create workspace vars " + e.getLocalizedMessage()); //$NON-NLS-1$
}
}
}
// private void addVars() {
// int app = IBuildEnvironmentVariable.ENVVAR_APPEND;
// String del = ""; //$NON-NLS-1$
// UserDefinedEnvironmentSupplier usup = null;
// usup = ManagedBuildEnvironmentTests.getSupplier(worksp, "Workspace"); //$NON-NLS-1$
// if (usup != null) {
// try {
// usup.createVariable("casetest","lowercase", app, del, worksp ); //$NON-NLS-1$ //$NON-NLS-2$
// usup.createVariable("CaseTest","capitalize", app, del, worksp ); //$NON-NLS-1$ //$NON-NLS-2$
// usup.createVariable("CaSeTeSt","upper2low", app, del, worksp ); //$NON-NLS-1$ //$NON-NLS-2$
// usup.createVariable("CASETEST","uppercase", app, del, worksp ); //$NON-NLS-1$ //$NON-NLS-2$
// } catch (Exception e) {
// fail("Failed to create workspace vars " + e.getLocalizedMessage()); //$NON-NLS-1$
// }
// }
// }
/*
* getFile() - open or creates sample file in current project
*/

View file

@ -209,4 +209,22 @@ public class BuildSettingsUtil {
flags |= ICProjectDescriptionManager.SET_NO_SERIALIZE;
CoreModel.getDefault().getProjectDescriptionManager().setProjectDescription(project, des, flags, null);
}
public static ITool[] getToolsBySuperClassId(ITool[] tools, String id) {
List retTools = new ArrayList();
if (id != null) {
for (int i = 0; i < tools.length; i++) {
ITool targetTool = tools[i];
ITool tool = targetTool;
do {
if (id.equals(tool.getId())) {
retTools.add(targetTool);
break;
}
tool = tool.getSuperClass();
} while (tool != null);
}
}
return (ITool[])retTools.toArray( new ITool[retTools.size()]);
}
}

View file

@ -509,7 +509,7 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
return path.makeRelative();
}
protected ResourceInfo getParentResourceInfo(){
public ResourceInfo getParentResourceInfo(){
if(isRoot())
return null;

View file

@ -16,6 +16,8 @@ import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
@ -26,7 +28,9 @@ import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.BuildSettingsUtil;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.internal.core.ResourceInfo;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
@ -984,41 +988,128 @@ public class MbsMacroSupplier extends BuildCdtVariablesSupplierBase {
IOption option = optionContext.getOption();
if(option == null)
return null;
IOption parentOption = null;
IBuildObject parent = option.getParent();
ITool tool = null;
IToolChain tCh = null;
IResourceInfo optionRcInfo = null;
if (parent instanceof ITool) {
tool = (ITool)parent;
optionRcInfo = tool.getParentResourceInfo();
} else if (parent instanceof IToolChain) {
tCh = (IToolChain)tCh;
optionRcInfo = tCh.getParentFolderInfo();
}
IBuildObject bObj = (optionContext instanceof OptionData) ?
((OptionData)optionContext).getOptionContainer() : optionContext.getParent();
IResourceConfiguration rcCfg = null;
ITool holderTool = null;
if(bObj instanceof ITool){
holderTool = (ITool)bObj;
IBuildObject p = holderTool.getParent();
if(p instanceof IResourceConfiguration)
rcCfg = (IResourceConfiguration)p;
} else if(bObj instanceof IResourceConfiguration)
rcCfg = (IResourceConfiguration)bObj;
if(optionRcInfo != null && optionRcInfo.isExtensionElement())
optionRcInfo = null;
IBuildObject parentObject = rcCfg == null ? bObj : rcCfg.getParent();
IBuildObject parentObj = null;
IOption parentOption = null;
if(rcCfg != null && rcCfg.getTool(tool.getId()) != null){
tool = tool.getSuperClass();
parentOption = tool.getOptionBySuperClassId(option.getSuperClass().getId());
} else {
if(optionRcInfo != null){
//only if optionRcInfo is not null
IBuildObject bObj = (optionContext instanceof OptionData) ?
((OptionData)optionContext).getOptionContainer() : optionContext.getParent();
IResourceInfo rcInfo = null;
IFileInfo fileInfo = null;
IFolderInfo folderInfo = null;
ITool holderTool = null;
IToolChain holderTc = null;
if(bObj instanceof ITool){
holderTool = (ITool)bObj;
rcInfo = holderTool.getParentResourceInfo();
} else if(bObj instanceof IFileInfo) {
fileInfo = (IFileInfo)bObj;
rcInfo = fileInfo;
} else if (bObj instanceof IFolderInfo) {
folderInfo = (IFolderInfo)bObj;
rcInfo = folderInfo;
holderTc = folderInfo.getToolChain();
} else if (bObj instanceof IToolChain) {
holderTc = (IToolChain)bObj;
folderInfo = holderTc.getParentFolderInfo();
}
if(rcInfo != null && rcInfo.isExtensionElement())
rcInfo = null;
IResourceInfo parentRcInfo = null;
if(rcInfo != null){
IPath optionRcPath = optionRcInfo.getPath();
IPath rcPath = rcInfo.getPath();
if(optionRcPath.isPrefixOf(rcPath)){
parentRcInfo = ((ResourceInfo)optionRcInfo).getParentResourceInfo();
} else {
parentRcInfo = ((ResourceInfo)rcInfo).getParentResourceInfo();
}
}
if(parentRcInfo != null){
if(tool != null){
ITool tools[] = parentRcInfo.getTools();
ITool cur = tool;
ITool found = null;
do{
String id = cur.getId();
ITool []tmp = BuildSettingsUtil.getToolsBySuperClassId(tools, id);
if(tmp.length != 0){
found = tmp[0];
break;
}
if(cur.isExtensionElement())
break;
cur = cur.getSuperClass();
} while(cur != null);
if(found != null){
parentOption = getParentOption(found, option);
if(parentOption != null){
parentObj = found;
}
}
} else if (tCh != null) {
if(parentRcInfo instanceof IFolderInfo){
IToolChain parentTc = ((IFolderInfo)parentRcInfo).getToolChain();
parentOption = getParentOption(parentTc, option);
if(parentOption != null){
parentObj = parentTc;
}
}
}
}
}
if(parentObj == null)
parentOption = null;
if(parentOption == null)
parentOption = option.getSuperClass();
}
if(parentOption != null)
return new OptionData(parentOption,bObj,parentObject);
return new OptionData(parentOption,optionContext.getParent(),parentObj);
return null;
}
private IOption getParentOption(IHoldsOptions holder, IOption option){
IOption cur = option;
IOption found = null;
do {
String id = cur.getId();
found = holder.getOptionBySuperClassId(id);
if(found != null)
break;
if(cur.isExtensionElement())
break;
cur = cur.getSuperClass();
} while (cur != null);
return found;
}
private boolean canHandle(IOptionContextData optionData){
IOption option = optionData.getOption();
if(option == null)

View file

@ -12,9 +12,11 @@ package org.eclipse.cdt.managedbuilder.internal.macros;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.macros.IOptionContextData;
@ -50,15 +52,23 @@ public class OptionContextData implements IOptionContextData {
IBuildObject buildObj = data.getParent();
IToolChain tCh = null;
IHoldsOptions ho = null;
IResourceConfiguration rcCfg = null;
IResourceInfo rcInfo = null;
IFileInfo fileInfo = null;
IFolderInfo folderInfo = null;
if(buildObj instanceof ITool)
ho = (ITool)buildObj;
else if(buildObj instanceof IToolChain)
tCh = (IToolChain)buildObj;
else if(buildObj instanceof IResourceConfiguration)
rcCfg = (IResourceConfiguration)buildObj;
else if(buildObj instanceof IConfiguration)
else if(buildObj instanceof IFileInfo){
fileInfo = (IFileInfo)buildObj;
rcInfo = fileInfo;
}else if(buildObj instanceof IConfiguration)
tCh = ((IConfiguration)buildObj).getToolChain();
else if(buildObj instanceof IFolderInfo){
folderInfo = (IFolderInfo)buildObj;
rcInfo = folderInfo;
tCh = folderInfo.getToolChain();
}
if(ho == null){
IOption option = data.getOption();
@ -74,8 +84,8 @@ public class OptionContextData implements IOptionContextData {
return tCh;
}
tools = tCh.getTools();
} else if(rcCfg != null){
tools = rcCfg.getTools();
} else if(rcInfo != null){
tools = rcInfo.getTools();
}
if(tools != null){