mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 426628 - Define V=1 env variable by default for Autotools projects
This enables verbose output which is necessary for proper GCC output parsing. Change-Id: I965c50cb4ca3ea46e73efa4d8eb3d7de582deabc Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
This commit is contained in:
parent
12bb52805e
commit
862705bb45
4 changed files with 148 additions and 1 deletions
|
@ -396,6 +396,7 @@
|
|||
name="%Configuration.build.name">
|
||||
<toolChain
|
||||
archList="all"
|
||||
configurationEnvironmentSupplier="org.eclipse.cdt.internal.autotools.core.AutotoolsEnvironmentVariableSupplier"
|
||||
id="org.eclipse.linuxtools.cdt.autotools.core.toolChain"
|
||||
languageSettingsProviders="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser;org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector"
|
||||
name="%Autotools.gnu.toolchain.name"
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 Ericson and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Marc-Andre Laperle (Ericsson) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.autotools.core;
|
||||
|
||||
import org.eclipse.cdt.core.envvar.EnvironmentVariable;
|
||||
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
||||
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
/**
|
||||
* Supplies some default environment variables for the Autotools toolchain. For
|
||||
* example, V=1 to enable verbose output necessary for proper GCC output
|
||||
* parsing.
|
||||
*
|
||||
* @noreference This class is not intended to be referenced by clients.
|
||||
* @noextend This class is not intended to be subclassed by clients.
|
||||
*/
|
||||
public class AutotoolsEnvironmentVariableSupplier implements IConfigurationEnvironmentVariableSupplier {
|
||||
|
||||
private static class VerboseEnvironmentVariable extends EnvironmentVariable implements IBuildEnvironmentVariable {
|
||||
private static final String VERBOSE_VAR_NAME = "V";
|
||||
private static final String VERBOSE_VAR_VALUE = "1";
|
||||
|
||||
private VerboseEnvironmentVariable(String name, String value, int op, String delimiter) {
|
||||
super(name, value, op, delimiter);
|
||||
}
|
||||
|
||||
private static boolean isVar(String name) {
|
||||
// Windows has case insensitive env var names
|
||||
return Platform.getOS().equals(Platform.OS_WIN32) ? name.equalsIgnoreCase(VerboseEnvironmentVariable.VERBOSE_VAR_NAME)
|
||||
: name.equals(VerboseEnvironmentVariable.VERBOSE_VAR_NAME);
|
||||
}
|
||||
|
||||
private static IBuildEnvironmentVariable create(IConfiguration configuration) {
|
||||
return new VerboseEnvironmentVariable(VERBOSE_VAR_NAME, VERBOSE_VAR_VALUE, IEnvironmentVariable.ENVVAR_PREPEND, null);
|
||||
}
|
||||
}
|
||||
|
||||
public IBuildEnvironmentVariable[] getVariables(IConfiguration configuration,
|
||||
IEnvironmentVariableProvider provider) {
|
||||
IBuildEnvironmentVariable path = VerboseEnvironmentVariable.create(configuration);
|
||||
return new IBuildEnvironmentVariable[] { path };
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration,
|
||||
IEnvironmentVariableProvider provider) {
|
||||
if (VerboseEnvironmentVariable.isVar(variableName)) {
|
||||
return VerboseEnvironmentVariable.create(configuration);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 Red Hat Inc..
|
||||
* Copyright (c) 2008, 2015 Red Hat Inc..
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -28,6 +28,7 @@ public class AllAutotoolsTests {
|
|||
suite.addTestSuite(AutotoolsProjectTest1.class);
|
||||
suite.addTestSuite(AutotoolsProjectTest2.class);
|
||||
suite.addTestSuite(AutotoolsVirtualFolderTest.class);
|
||||
suite.addTestSuite(AutotoolsEnvironmentVarTest.class);
|
||||
suite.addTestSuite(UpdateConfigureTest.class);
|
||||
suite.addTest(AutoconfTests.suite());
|
||||
suite.addTest(EditorTests.suite());
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 Ericsson and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Marc-Andre Laperle (Ericsson) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.tests;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class AutotoolsEnvironmentVarTest extends TestCase {
|
||||
|
||||
private IProject testProject;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
if (!ProjectTools.setup())
|
||||
fail("could not perform basic project workspace setup");
|
||||
testProject = ProjectTools.createProject("testProject0");
|
||||
if (testProject == null) {
|
||||
fail("Unable to create test project");
|
||||
}
|
||||
testProject.open(new NullProgressMonitor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a sample project contains the expected environment variables.
|
||||
* For example the verbose environment variable (V=1) necessary for proper
|
||||
* GCC output parsing.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testAutotoolsEnvironmentVar() throws Exception {
|
||||
|
||||
Path p = new Path("zip/project1.zip");
|
||||
ProjectTools.addSourceContainerWithImport(testProject, null, p, null, true);
|
||||
assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID));
|
||||
ICConfigurationDescription cfgDes = CoreModel.getDefault().getProjectDescription(testProject)
|
||||
.getActiveConfiguration();
|
||||
IEnvironmentVariable[] variables = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cfgDes,
|
||||
false);
|
||||
Map<String, IEnvironmentVariable> environmentVariables = new HashMap<>();
|
||||
for (IEnvironmentVariable var : variables) {
|
||||
environmentVariables.put(var.getName(), var);
|
||||
}
|
||||
|
||||
IEnvironmentVariable verboseEnvironmentVariable = environmentVariables.get("V");
|
||||
assertNotNull(verboseEnvironmentVariable);
|
||||
assertEquals("1", verboseEnvironmentVariable.getValue());
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
try {
|
||||
testProject.delete(true, true, null);
|
||||
} catch (Exception e) {
|
||||
// FIXME: Why does a ResourceException occur when deleting the
|
||||
// project??
|
||||
}
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue