mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Fix line endings
This commit is contained in:
parent
52341a3587
commit
bdc33b193c
40 changed files with 34126 additions and 34126 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,67 +1,67 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.tests.suite;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests20;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests_SharedToolOptions;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildEnvironmentTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildMacrosTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildDependencyCalculatorTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildTCSupportedTest;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedCommandLineGeneratorTest;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedProject21MakefileTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedProject30MakefileTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedProjectUpdateTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.MultiVersionSupportTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.OptionEnablementTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ResourceBuildCoreTests;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class AllManagedBuildTests {
|
||||
public static void main(String[] args) {
|
||||
CCorePlugin.getDefault().getCoreModel().getIndexManager().reset();
|
||||
junit.textui.TestRunner.run(AllManagedBuildTests.suite());
|
||||
}
|
||||
public static Test suite() {
|
||||
// May/2005 Turning off all indexing for now because the "original" indexer causes hangs...
|
||||
CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, CCorePlugin.NULL_INDEXER_UNIQUE_ID);
|
||||
// We could enable this later...
|
||||
//CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, "org.eclipse.cdt.core.domsourceindexer");
|
||||
|
||||
TestSuite suite = new TestSuite(
|
||||
"Test for org.eclipse.cdt.managedbuild.core.tests");
|
||||
//$JUnit-BEGIN$
|
||||
// TODO uncoment this
|
||||
suite.addTest(ManagedBuildCoreTests20.suite());
|
||||
suite.addTest(ManagedBuildCoreTests.suite());
|
||||
suite.addTest(ManagedProjectUpdateTests.suite());
|
||||
suite.addTest(ManagedCommandLineGeneratorTest.suite());
|
||||
suite.addTest(ResourceBuildCoreTests.suite());
|
||||
suite.addTest(ManagedProject21MakefileTests.suite());
|
||||
suite.addTest(ManagedProject30MakefileTests.suite());
|
||||
suite.addTest(ManagedBuildCoreTests_SharedToolOptions.suite());
|
||||
suite.addTest(ManagedBuildEnvironmentTests.suite());
|
||||
suite.addTest(ManagedBuildMacrosTests.suite());
|
||||
suite.addTest(ManagedBuildTCSupportedTest.suite());
|
||||
suite.addTest(MultiVersionSupportTests.suite());
|
||||
suite.addTest(OptionEnablementTests.suite());
|
||||
suite.addTest(ManagedBuildDependencyCalculatorTests.suite());
|
||||
//$JUnit-END$
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.tests.suite;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests20;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests_SharedToolOptions;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildEnvironmentTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildMacrosTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildDependencyCalculatorTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildTCSupportedTest;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedCommandLineGeneratorTest;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedProject21MakefileTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedProject30MakefileTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedProjectUpdateTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.MultiVersionSupportTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.OptionEnablementTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ResourceBuildCoreTests;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class AllManagedBuildTests {
|
||||
public static void main(String[] args) {
|
||||
CCorePlugin.getDefault().getCoreModel().getIndexManager().reset();
|
||||
junit.textui.TestRunner.run(AllManagedBuildTests.suite());
|
||||
}
|
||||
public static Test suite() {
|
||||
// May/2005 Turning off all indexing for now because the "original" indexer causes hangs...
|
||||
CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, CCorePlugin.NULL_INDEXER_UNIQUE_ID);
|
||||
// We could enable this later...
|
||||
//CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, "org.eclipse.cdt.core.domsourceindexer");
|
||||
|
||||
TestSuite suite = new TestSuite(
|
||||
"Test for org.eclipse.cdt.managedbuild.core.tests");
|
||||
//$JUnit-BEGIN$
|
||||
// TODO uncoment this
|
||||
suite.addTest(ManagedBuildCoreTests20.suite());
|
||||
suite.addTest(ManagedBuildCoreTests.suite());
|
||||
suite.addTest(ManagedProjectUpdateTests.suite());
|
||||
suite.addTest(ManagedCommandLineGeneratorTest.suite());
|
||||
suite.addTest(ResourceBuildCoreTests.suite());
|
||||
suite.addTest(ManagedProject21MakefileTests.suite());
|
||||
suite.addTest(ManagedProject30MakefileTests.suite());
|
||||
suite.addTest(ManagedBuildCoreTests_SharedToolOptions.suite());
|
||||
suite.addTest(ManagedBuildEnvironmentTests.suite());
|
||||
suite.addTest(ManagedBuildMacrosTests.suite());
|
||||
suite.addTest(ManagedBuildTCSupportedTest.suite());
|
||||
suite.addTest(MultiVersionSupportTests.suite());
|
||||
suite.addTest(OptionEnablementTests.suite());
|
||||
suite.addTest(ManagedBuildDependencyCalculatorTests.suite());
|
||||
//$JUnit-END$
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,240 +1,240 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
* These tests are for the default dependency calculators
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.managedbuilder.core.tests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
|
||||
import org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
||||
|
||||
public class ManagedBuildDependencyCalculatorTests extends TestCase {
|
||||
|
||||
public ManagedBuildDependencyCalculatorTests(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(ManagedBuildDependencyCalculatorTests.class.getName());
|
||||
|
||||
suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalc2"));
|
||||
suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalc3"));
|
||||
suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalcPreBuild"));
|
||||
return suite;
|
||||
}
|
||||
|
||||
private IProject[] createProject(String projName, IPath location, String projectTypeId, boolean containsZip){
|
||||
ArrayList projectList = null;
|
||||
if (containsZip) {
|
||||
File testDir = CTestPlugin.getFileInPlugin(new Path("resources/depCalcProjects/" + projName));
|
||||
if(testDir == null) {
|
||||
fail("Test project directory " + projName + " is missing.");
|
||||
return null;
|
||||
}
|
||||
|
||||
File projectZips[] = testDir.listFiles(new FileFilter(){
|
||||
public boolean accept(File pathname){
|
||||
if(pathname.isDirectory())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
projectList = new ArrayList(projectZips.length);
|
||||
for(int i = 0; i < projectZips.length; i++){
|
||||
try{
|
||||
String projectName = projectZips[i].getName();
|
||||
if(!projectName.endsWith(".zip"))
|
||||
continue;
|
||||
|
||||
projectName = projectName.substring(0,projectName.length()-".zip".length());
|
||||
if(projectName.length() == 0)
|
||||
continue;
|
||||
IProject project = ManagedBuildTestHelper.createProject(projectName, projectZips[i], location, projectTypeId);
|
||||
if(project != null)
|
||||
projectList.add(project);
|
||||
}
|
||||
catch(Exception e){
|
||||
}
|
||||
}
|
||||
if(projectList.size() == 0) {
|
||||
fail("No projects found in test project directory " + testDir.getName() + ". The .zip file may be missing or corrupt.");
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
try{
|
||||
IProject project = ManagedBuildTestHelper.createProject(projName, null, location, projectTypeId);
|
||||
if(project != null)
|
||||
projectList = new ArrayList(1);
|
||||
projectList.add(project);
|
||||
} catch(Exception e){}
|
||||
}
|
||||
|
||||
return (IProject[])projectList.toArray(new IProject[projectList.size()]);
|
||||
}
|
||||
|
||||
private IProject[] createProjects(String projName, IPath location, String projectTypeId, boolean containsZip) {
|
||||
|
||||
// In case the projects need to be updated...
|
||||
IOverwriteQuery queryALL = new IOverwriteQuery(){
|
||||
public String queryOverwrite(String file) {
|
||||
return ALL;
|
||||
}};
|
||||
IOverwriteQuery queryNOALL = new IOverwriteQuery(){
|
||||
public String queryOverwrite(String file) {
|
||||
return NO_ALL;
|
||||
}};
|
||||
|
||||
UpdateManagedProjectManager.setBackupFileOverwriteQuery(queryALL);
|
||||
UpdateManagedProjectManager.setUpdateProjectQuery(queryALL);
|
||||
|
||||
IProject projects[] = createProject(projName, location, projectTypeId, containsZip);
|
||||
return projects;
|
||||
}
|
||||
|
||||
private void buildProjectsWorker(IProject projects[], IPath[] files, boolean compareBenchmark) {
|
||||
if(projects == null || projects.length == 0)
|
||||
return;
|
||||
|
||||
boolean succeeded = true;
|
||||
for (int i = 0; i < projects.length; i++){
|
||||
IProject curProject = projects[i];
|
||||
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(curProject);
|
||||
|
||||
//check whether the managed build info is converted
|
||||
boolean isCompatible = UpdateManagedProjectManager.isCompatibleProject(info);
|
||||
assertTrue(isCompatible);
|
||||
|
||||
if (isCompatible){
|
||||
// Build the project in order to generate the makefiles
|
||||
try{
|
||||
curProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,null);
|
||||
}
|
||||
catch(CoreException e){
|
||||
fail(e.getStatus().getMessage());
|
||||
}
|
||||
catch(OperationCanceledException e){
|
||||
fail("the project \"" + curProject.getName() + "\" build was cancelled, exception message: " + e.getMessage());
|
||||
}
|
||||
|
||||
//compare the generated makefiles to their benchmarks
|
||||
if (files != null && files.length > 0) {
|
||||
if (i == 0) {
|
||||
String configName = info.getDefaultConfiguration().getName();
|
||||
IPath buildDir = Path.fromOSString(configName);
|
||||
if (compareBenchmark)
|
||||
succeeded = ManagedBuildTestHelper.compareBenchmarks(curProject, buildDir, files);
|
||||
else
|
||||
succeeded = ManagedBuildTestHelper.verifyFilesDoNotExist(curProject, buildDir, files);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (succeeded) { // Otherwise leave the projects around for comparison
|
||||
for (int i = 0; i < projects.length; i++)
|
||||
ManagedBuildTestHelper.removeProject(projects[i].getName());
|
||||
}
|
||||
}
|
||||
|
||||
// Build projects and compare benchmarks
|
||||
private void buildProjects(IProject projects[], IPath[] files) {
|
||||
buildProjectsWorker(projects, files, true);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* test for dependency calculation as a side-effect of compilation
|
||||
*/
|
||||
public void test1DepCalc2(){
|
||||
IPath[] makefiles = {
|
||||
Path.fromOSString("makefile"),
|
||||
Path.fromOSString("objects.mk"),
|
||||
Path.fromOSString("sources.mk"),
|
||||
Path.fromOSString("subdir.mk"),
|
||||
// This file is different using Cygwin vs GCC
|
||||
//Path.fromOSString("main.d"),
|
||||
Path.fromOSString("Sources/subdir.mk"),
|
||||
Path.fromOSString("Sources/func1.d"),
|
||||
Path.fromOSString("Sources/func2.d"),
|
||||
Path.fromOSString("Sources/func4.d"),
|
||||
Path.fromOSString("Sources/sub sources/func 3.d"),
|
||||
Path.fromOSString("Sources/sub sources/subdir.mk")};
|
||||
IProject[] projects = createProjects("test1DepCalc2", null, null, true);
|
||||
buildProjects(projects, makefiles);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* test for dependency calculation using Echo, a 2nd conmpilation step, and post-processing
|
||||
*/
|
||||
public void test1DepCalc3(){
|
||||
IPath[] makefiles = {
|
||||
Path.fromOSString("makefile"),
|
||||
Path.fromOSString("objects.mk"),
|
||||
Path.fromOSString("sources.mk"),
|
||||
Path.fromOSString("subdir.mk"),
|
||||
// This file is different using Cygwin vs GCC
|
||||
//Path.fromOSString("main.d"),
|
||||
Path.fromOSString("Sources/subdir.mk"),
|
||||
Path.fromOSString("Sources/func1.d"),
|
||||
Path.fromOSString("Sources/func2.d"),
|
||||
Path.fromOSString("Sources/func4.d"),
|
||||
Path.fromOSString("Sources/sub sources/func 3.d"),
|
||||
Path.fromOSString("Sources/sub sources/subdir.mk")};
|
||||
IProject[] projects = createProjects("test1DepCalc3", null, null, true);
|
||||
buildProjects(projects, makefiles);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* test for dependency calculation that uses a separate, pre-build, step to generate dependency files
|
||||
*/
|
||||
public void test1DepCalcPreBuild(){
|
||||
IPath[] makefiles = {
|
||||
Path.fromOSString("makefile"),
|
||||
Path.fromOSString("objects.mk"),
|
||||
Path.fromOSString("sources.mk"),
|
||||
Path.fromOSString("subdir.mk"),
|
||||
// This file is different using Cygwin vs GCC
|
||||
//Path.fromOSString("main.d"),
|
||||
Path.fromOSString("Sources/subdir.mk"),
|
||||
Path.fromOSString("Sources/func1.d"),
|
||||
Path.fromOSString("Sources/func2.d"),
|
||||
Path.fromOSString("Sources/func4.d"),
|
||||
Path.fromOSString("Sources/sub sources/func 3.d"),
|
||||
Path.fromOSString("Sources/sub sources/subdir.mk")};
|
||||
IProject[] projects = createProjects("test1DepCalcPreBuild", null, null, true);
|
||||
buildProjects(projects, makefiles);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
* These tests are for the default dependency calculators
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.managedbuilder.core.tests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
|
||||
import org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
||||
|
||||
public class ManagedBuildDependencyCalculatorTests extends TestCase {
|
||||
|
||||
public ManagedBuildDependencyCalculatorTests(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(ManagedBuildDependencyCalculatorTests.class.getName());
|
||||
|
||||
suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalc2"));
|
||||
suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalc3"));
|
||||
suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalcPreBuild"));
|
||||
return suite;
|
||||
}
|
||||
|
||||
private IProject[] createProject(String projName, IPath location, String projectTypeId, boolean containsZip){
|
||||
ArrayList projectList = null;
|
||||
if (containsZip) {
|
||||
File testDir = CTestPlugin.getFileInPlugin(new Path("resources/depCalcProjects/" + projName));
|
||||
if(testDir == null) {
|
||||
fail("Test project directory " + projName + " is missing.");
|
||||
return null;
|
||||
}
|
||||
|
||||
File projectZips[] = testDir.listFiles(new FileFilter(){
|
||||
public boolean accept(File pathname){
|
||||
if(pathname.isDirectory())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
projectList = new ArrayList(projectZips.length);
|
||||
for(int i = 0; i < projectZips.length; i++){
|
||||
try{
|
||||
String projectName = projectZips[i].getName();
|
||||
if(!projectName.endsWith(".zip"))
|
||||
continue;
|
||||
|
||||
projectName = projectName.substring(0,projectName.length()-".zip".length());
|
||||
if(projectName.length() == 0)
|
||||
continue;
|
||||
IProject project = ManagedBuildTestHelper.createProject(projectName, projectZips[i], location, projectTypeId);
|
||||
if(project != null)
|
||||
projectList.add(project);
|
||||
}
|
||||
catch(Exception e){
|
||||
}
|
||||
}
|
||||
if(projectList.size() == 0) {
|
||||
fail("No projects found in test project directory " + testDir.getName() + ". The .zip file may be missing or corrupt.");
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
try{
|
||||
IProject project = ManagedBuildTestHelper.createProject(projName, null, location, projectTypeId);
|
||||
if(project != null)
|
||||
projectList = new ArrayList(1);
|
||||
projectList.add(project);
|
||||
} catch(Exception e){}
|
||||
}
|
||||
|
||||
return (IProject[])projectList.toArray(new IProject[projectList.size()]);
|
||||
}
|
||||
|
||||
private IProject[] createProjects(String projName, IPath location, String projectTypeId, boolean containsZip) {
|
||||
|
||||
// In case the projects need to be updated...
|
||||
IOverwriteQuery queryALL = new IOverwriteQuery(){
|
||||
public String queryOverwrite(String file) {
|
||||
return ALL;
|
||||
}};
|
||||
IOverwriteQuery queryNOALL = new IOverwriteQuery(){
|
||||
public String queryOverwrite(String file) {
|
||||
return NO_ALL;
|
||||
}};
|
||||
|
||||
UpdateManagedProjectManager.setBackupFileOverwriteQuery(queryALL);
|
||||
UpdateManagedProjectManager.setUpdateProjectQuery(queryALL);
|
||||
|
||||
IProject projects[] = createProject(projName, location, projectTypeId, containsZip);
|
||||
return projects;
|
||||
}
|
||||
|
||||
private void buildProjectsWorker(IProject projects[], IPath[] files, boolean compareBenchmark) {
|
||||
if(projects == null || projects.length == 0)
|
||||
return;
|
||||
|
||||
boolean succeeded = true;
|
||||
for (int i = 0; i < projects.length; i++){
|
||||
IProject curProject = projects[i];
|
||||
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(curProject);
|
||||
|
||||
//check whether the managed build info is converted
|
||||
boolean isCompatible = UpdateManagedProjectManager.isCompatibleProject(info);
|
||||
assertTrue(isCompatible);
|
||||
|
||||
if (isCompatible){
|
||||
// Build the project in order to generate the makefiles
|
||||
try{
|
||||
curProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,null);
|
||||
}
|
||||
catch(CoreException e){
|
||||
fail(e.getStatus().getMessage());
|
||||
}
|
||||
catch(OperationCanceledException e){
|
||||
fail("the project \"" + curProject.getName() + "\" build was cancelled, exception message: " + e.getMessage());
|
||||
}
|
||||
|
||||
//compare the generated makefiles to their benchmarks
|
||||
if (files != null && files.length > 0) {
|
||||
if (i == 0) {
|
||||
String configName = info.getDefaultConfiguration().getName();
|
||||
IPath buildDir = Path.fromOSString(configName);
|
||||
if (compareBenchmark)
|
||||
succeeded = ManagedBuildTestHelper.compareBenchmarks(curProject, buildDir, files);
|
||||
else
|
||||
succeeded = ManagedBuildTestHelper.verifyFilesDoNotExist(curProject, buildDir, files);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (succeeded) { // Otherwise leave the projects around for comparison
|
||||
for (int i = 0; i < projects.length; i++)
|
||||
ManagedBuildTestHelper.removeProject(projects[i].getName());
|
||||
}
|
||||
}
|
||||
|
||||
// Build projects and compare benchmarks
|
||||
private void buildProjects(IProject projects[], IPath[] files) {
|
||||
buildProjectsWorker(projects, files, true);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* test for dependency calculation as a side-effect of compilation
|
||||
*/
|
||||
public void test1DepCalc2(){
|
||||
IPath[] makefiles = {
|
||||
Path.fromOSString("makefile"),
|
||||
Path.fromOSString("objects.mk"),
|
||||
Path.fromOSString("sources.mk"),
|
||||
Path.fromOSString("subdir.mk"),
|
||||
// This file is different using Cygwin vs GCC
|
||||
//Path.fromOSString("main.d"),
|
||||
Path.fromOSString("Sources/subdir.mk"),
|
||||
Path.fromOSString("Sources/func1.d"),
|
||||
Path.fromOSString("Sources/func2.d"),
|
||||
Path.fromOSString("Sources/func4.d"),
|
||||
Path.fromOSString("Sources/sub sources/func 3.d"),
|
||||
Path.fromOSString("Sources/sub sources/subdir.mk")};
|
||||
IProject[] projects = createProjects("test1DepCalc2", null, null, true);
|
||||
buildProjects(projects, makefiles);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* test for dependency calculation using Echo, a 2nd conmpilation step, and post-processing
|
||||
*/
|
||||
public void test1DepCalc3(){
|
||||
IPath[] makefiles = {
|
||||
Path.fromOSString("makefile"),
|
||||
Path.fromOSString("objects.mk"),
|
||||
Path.fromOSString("sources.mk"),
|
||||
Path.fromOSString("subdir.mk"),
|
||||
// This file is different using Cygwin vs GCC
|
||||
//Path.fromOSString("main.d"),
|
||||
Path.fromOSString("Sources/subdir.mk"),
|
||||
Path.fromOSString("Sources/func1.d"),
|
||||
Path.fromOSString("Sources/func2.d"),
|
||||
Path.fromOSString("Sources/func4.d"),
|
||||
Path.fromOSString("Sources/sub sources/func 3.d"),
|
||||
Path.fromOSString("Sources/sub sources/subdir.mk")};
|
||||
IProject[] projects = createProjects("test1DepCalc3", null, null, true);
|
||||
buildProjects(projects, makefiles);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* test for dependency calculation that uses a separate, pre-build, step to generate dependency files
|
||||
*/
|
||||
public void test1DepCalcPreBuild(){
|
||||
IPath[] makefiles = {
|
||||
Path.fromOSString("makefile"),
|
||||
Path.fromOSString("objects.mk"),
|
||||
Path.fromOSString("sources.mk"),
|
||||
Path.fromOSString("subdir.mk"),
|
||||
// This file is different using Cygwin vs GCC
|
||||
//Path.fromOSString("main.d"),
|
||||
Path.fromOSString("Sources/subdir.mk"),
|
||||
Path.fromOSString("Sources/func1.d"),
|
||||
Path.fromOSString("Sources/func2.d"),
|
||||
Path.fromOSString("Sources/func4.d"),
|
||||
Path.fromOSString("Sources/sub sources/func 3.d"),
|
||||
Path.fromOSString("Sources/sub sources/subdir.mk")};
|
||||
IProject[] projects = createProjects("test1DepCalcPreBuild", null, null, true);
|
||||
buildProjects(projects, makefiles);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,111 +1,111 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2002, 2006 Rational Software Corporation 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:
|
||||
# IBM Rational Software - Initial API and implementation
|
||||
###############################################################################
|
||||
|
||||
# Generated makefile builder messages
|
||||
ManagedMakeBuilder.message.starting = Starting the build for project {0}
|
||||
ManagedMakeBuilder.message.rebuild.makefiles = Regenerating makefiles for project {0}
|
||||
ManagedMakeBuilder.message.update.makefiles = Updating makefiles for project {0}
|
||||
ManagedMakeBuilder.message.incremental = Updating makefiles for project {0}
|
||||
ManagedMakeBuilder.message.updating = Updating project files...
|
||||
ManagedMakeBuilder.message.make = Calling {0} for project {1}
|
||||
ManagedMakeBuilder.message.regen.deps = Regenerating dependency files for {0}
|
||||
ManagedMakeBuilder.message.updating.deps = Updating dependency files for {0}
|
||||
ManagedMakeBuilder.message.creating.markers = Generating markers...
|
||||
ManagedMakeBuilder.message.console.header = **** {0} of configuration {1} for project {2} ****
|
||||
ManagedMakeBuilder.message.no.build = Nothing to build for {0}
|
||||
ManagedMakeBuilder.message.error = Build error
|
||||
ManagedMakeBuilder.message.error.refresh = Error refreshing project
|
||||
ManagedMakeBuilder.message.finished = Build complete for project {0}
|
||||
ManagedMakeBuilder.message.clean.deleting.output=Removing build artifacts from {0}
|
||||
ManagedMakeBuilder.message.clean.build.clean=Trying a make clean in {0}
|
||||
ManagedMakeBuilder.type.clean = Clean-only build
|
||||
ManagedMakeBuider.type.incremental = Build
|
||||
ManagedMakeBuilder.warning.unsupported.configuration=**** WARNING: The "{0}" Configuration may not build ****\n**** because it uses the "{1}" ****\n**** tool-chain that is unsupported on this system. ****\n\n**** Attempting to build... ****
|
||||
|
||||
# Option exception messages
|
||||
Option.error.bad_value_type=Bad value for type
|
||||
|
||||
# Managed build manager exception messages
|
||||
ManagedBuildManager.error.owner_not_null=addTarget: owner not null
|
||||
ManagedBuildManager.error.null_owner=addTarget: null owner
|
||||
ManagedBuildManager.error.owner_not_project=addTarget: owner not project
|
||||
ManagedBuildManager.error.manifest_load_failed_title=Managed Build System Version Error
|
||||
ManagedBuildManager.error.manifest.version.error=The version number defined in the plugin manifest file\n{0}\nis greater than the version of the Managed Build System.\nThe definitions in the manifest file will not be loaded.
|
||||
ManagedBuildManager.error.manifest.header=Managed Build system manifest file error:
|
||||
ManagedBuildManager.error.manifest.resolving=Unable to resolve the {0} identifier {1} in the {2} {3}.
|
||||
ManagedBuildManager.error.manifest.duplicate=Duplicate identifier {1} for element type {0}.
|
||||
ManagedBuildManager.error.manifest.icon=Could not load icon "{0}".
|
||||
ManagedBuildManager.error.manifest.option.category=Option {0} uses a null category that is invalid in its context. The option was ignored.
|
||||
ManagedBuildManager.error.manifest.option.filter=Option {0} uses an unsupported resourceFilter attribute value. The option was ignored.
|
||||
ManagedBuildManager.error.manifest.option.valuehandler=Could not load value handler {0} in option {1}.
|
||||
ManagedBuildManager.error.open_failed_title=Managed Make Project File Error
|
||||
ManagedBuildManager.error.open_failed=The Managed Make project file could not be read because of the following error:\n\n{0}\n\nManaged Make functionality will not be available for this project.
|
||||
ManagedBuildManager.error.write_failed_title=Managed Make Project File Write Error
|
||||
ManagedBuildManager.error.write_failed=The Managed Make project file could not be written because of the following error:\n\n{0}\n
|
||||
ManagedBuildManager.error.read_only=File {0} is read-only.
|
||||
ManagedBuildManager.error.project.version.error=The version number of the project {0} is greater than the Managed Build System version number.
|
||||
ManagedBuildManager.error.id.nomatch=Error loading Managed Make project information for project {0}. The tool definitions used to create the project are not available.
|
||||
ManagedBuildManager.error.project.file.missing=The Managed Make project file for project {0} is missing.
|
||||
# Makefile Generator Messages
|
||||
MakefileGenerator.message.start.file=Building file:
|
||||
MakefileGenerator.message.finish.file=Finished building:
|
||||
MakefileGenerator.message.start.build=Building target:
|
||||
MakefileGenerator.message.finish.build=Finished building target:
|
||||
MakefileGenerator.message.start.dependency=Regenerating dependency file:
|
||||
MakefileGenerator.message.no.target=No tool found that can build the extension specified with the build arrtifact name
|
||||
MakefileGenerator.message.adding.source.folder=Adding folder {0} to sources
|
||||
MakefileGenerator.message.gen.source.makefile=Generating makefile for source folder {0}
|
||||
MakefileGenerator.message.calc.delta=Calculating the delta for project {0}
|
||||
MakefileGenerator.message.finding.sources=Finding source files in project {0}
|
||||
MakefileGenerator.comment.module.list = Every subdirectory with source files must be described here
|
||||
MakefileGenerator.comment.module.variables = Add inputs and outputs from these tool invocations to the build variables
|
||||
MakefileGenerator.comment.source.list = All of the sources participating in the build are defined here
|
||||
MakefileGenerator.comment.build.rule = Each subdirectory must supply rules for building sources it contributes
|
||||
MakefileGenerator.comment.build.toprules = Tool invocations
|
||||
MakefileGenerator.comment.build.alltarget = All Target
|
||||
MakefileGenerator.comment.build.mainbuildtarget = Main-build Target
|
||||
MakefileGenerator.comment.build.toptargets = Other Targets
|
||||
MakefileGenerator.comment.module.make.includes = Include the makefiles for each source subdirectory
|
||||
MakefileGenerator.comment.module.dep.includes = Include automatically-generated dependency list:
|
||||
MakefileGenerator.comment.autodeps=Automatically-generated dependency list:
|
||||
MakefileGenerator.comment.header=Automatically-generated file. Do not edit!
|
||||
MakefileGenerator.error.spaces=Cannot generate makefile for folder with spaces in name
|
||||
MakefileGenerator.warning.no.source=Nothing to build for project {0}
|
||||
MakefileGenerator.error.no.nameprovider=A nameProvider or outputNames must be specified with multipleType == true
|
||||
|
||||
ManagedBuildInfo.message.job.init = Initializing path container for {0}
|
||||
ManagedBuildInfo.message.init.ok = Initializing path container succeeded for {0}
|
||||
|
||||
# Default GNU Makefile Generator messages
|
||||
GnuMakefileGenerator.message.postproc.dep.file=Verifying contents of dependency file {0}
|
||||
|
||||
# Tool strings
|
||||
Tool.default.announcement=Invoking:
|
||||
#Environment loader messages
|
||||
StorableEnvironmentLoader.storeOutputStream.wrong.arguments=Wrong arguments
|
||||
|
||||
#User Defined Macro Supplier
|
||||
UserDefinedMacroSupplier.storeOutputStream.wrong.arguments=Failed to persist macros: Wrong arguments
|
||||
|
||||
# BuildMacroStatus messages
|
||||
BuildMacroStatus.status.macro.undefined=Macro {0} is undefined
|
||||
BuildMacroStatus.status.reference.eachother=Macros {0} and {1} reference each other
|
||||
BuildMacroStatus.status.reference.incorrect=Macro {0} reference is incorrect
|
||||
BuildMacroStatus.status.macro.not.string=Macro {0} is not of String type
|
||||
BuildMacroStatus.status.macro.not.stringlist=Macro {0} is not of String-list type
|
||||
BuildMacroStatus.status.error=Error occured
|
||||
BuildMacroStatus.value.undefined=
|
||||
|
||||
#ResourceChangeHandler messages
|
||||
ResourceChangeHandler.buildInfoSerializationJob=Build Info Serialization
|
||||
|
||||
#ManagedBuilderCorePlugin messages
|
||||
###############################################################################
|
||||
# Copyright (c) 2002, 2006 Rational Software Corporation 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:
|
||||
# IBM Rational Software - Initial API and implementation
|
||||
###############################################################################
|
||||
|
||||
# Generated makefile builder messages
|
||||
ManagedMakeBuilder.message.starting = Starting the build for project {0}
|
||||
ManagedMakeBuilder.message.rebuild.makefiles = Regenerating makefiles for project {0}
|
||||
ManagedMakeBuilder.message.update.makefiles = Updating makefiles for project {0}
|
||||
ManagedMakeBuilder.message.incremental = Updating makefiles for project {0}
|
||||
ManagedMakeBuilder.message.updating = Updating project files...
|
||||
ManagedMakeBuilder.message.make = Calling {0} for project {1}
|
||||
ManagedMakeBuilder.message.regen.deps = Regenerating dependency files for {0}
|
||||
ManagedMakeBuilder.message.updating.deps = Updating dependency files for {0}
|
||||
ManagedMakeBuilder.message.creating.markers = Generating markers...
|
||||
ManagedMakeBuilder.message.console.header = **** {0} of configuration {1} for project {2} ****
|
||||
ManagedMakeBuilder.message.no.build = Nothing to build for {0}
|
||||
ManagedMakeBuilder.message.error = Build error
|
||||
ManagedMakeBuilder.message.error.refresh = Error refreshing project
|
||||
ManagedMakeBuilder.message.finished = Build complete for project {0}
|
||||
ManagedMakeBuilder.message.clean.deleting.output=Removing build artifacts from {0}
|
||||
ManagedMakeBuilder.message.clean.build.clean=Trying a make clean in {0}
|
||||
ManagedMakeBuilder.type.clean = Clean-only build
|
||||
ManagedMakeBuider.type.incremental = Build
|
||||
ManagedMakeBuilder.warning.unsupported.configuration=**** WARNING: The "{0}" Configuration may not build ****\n**** because it uses the "{1}" ****\n**** tool-chain that is unsupported on this system. ****\n\n**** Attempting to build... ****
|
||||
|
||||
# Option exception messages
|
||||
Option.error.bad_value_type=Bad value for type
|
||||
|
||||
# Managed build manager exception messages
|
||||
ManagedBuildManager.error.owner_not_null=addTarget: owner not null
|
||||
ManagedBuildManager.error.null_owner=addTarget: null owner
|
||||
ManagedBuildManager.error.owner_not_project=addTarget: owner not project
|
||||
ManagedBuildManager.error.manifest_load_failed_title=Managed Build System Version Error
|
||||
ManagedBuildManager.error.manifest.version.error=The version number defined in the plugin manifest file\n{0}\nis greater than the version of the Managed Build System.\nThe definitions in the manifest file will not be loaded.
|
||||
ManagedBuildManager.error.manifest.header=Managed Build system manifest file error:
|
||||
ManagedBuildManager.error.manifest.resolving=Unable to resolve the {0} identifier {1} in the {2} {3}.
|
||||
ManagedBuildManager.error.manifest.duplicate=Duplicate identifier {1} for element type {0}.
|
||||
ManagedBuildManager.error.manifest.icon=Could not load icon "{0}".
|
||||
ManagedBuildManager.error.manifest.option.category=Option {0} uses a null category that is invalid in its context. The option was ignored.
|
||||
ManagedBuildManager.error.manifest.option.filter=Option {0} uses an unsupported resourceFilter attribute value. The option was ignored.
|
||||
ManagedBuildManager.error.manifest.option.valuehandler=Could not load value handler {0} in option {1}.
|
||||
ManagedBuildManager.error.open_failed_title=Managed Make Project File Error
|
||||
ManagedBuildManager.error.open_failed=The Managed Make project file could not be read because of the following error:\n\n{0}\n\nManaged Make functionality will not be available for this project.
|
||||
ManagedBuildManager.error.write_failed_title=Managed Make Project File Write Error
|
||||
ManagedBuildManager.error.write_failed=The Managed Make project file could not be written because of the following error:\n\n{0}\n
|
||||
ManagedBuildManager.error.read_only=File {0} is read-only.
|
||||
ManagedBuildManager.error.project.version.error=The version number of the project {0} is greater than the Managed Build System version number.
|
||||
ManagedBuildManager.error.id.nomatch=Error loading Managed Make project information for project {0}. The tool definitions used to create the project are not available.
|
||||
ManagedBuildManager.error.project.file.missing=The Managed Make project file for project {0} is missing.
|
||||
# Makefile Generator Messages
|
||||
MakefileGenerator.message.start.file=Building file:
|
||||
MakefileGenerator.message.finish.file=Finished building:
|
||||
MakefileGenerator.message.start.build=Building target:
|
||||
MakefileGenerator.message.finish.build=Finished building target:
|
||||
MakefileGenerator.message.start.dependency=Regenerating dependency file:
|
||||
MakefileGenerator.message.no.target=No tool found that can build the extension specified with the build arrtifact name
|
||||
MakefileGenerator.message.adding.source.folder=Adding folder {0} to sources
|
||||
MakefileGenerator.message.gen.source.makefile=Generating makefile for source folder {0}
|
||||
MakefileGenerator.message.calc.delta=Calculating the delta for project {0}
|
||||
MakefileGenerator.message.finding.sources=Finding source files in project {0}
|
||||
MakefileGenerator.comment.module.list = Every subdirectory with source files must be described here
|
||||
MakefileGenerator.comment.module.variables = Add inputs and outputs from these tool invocations to the build variables
|
||||
MakefileGenerator.comment.source.list = All of the sources participating in the build are defined here
|
||||
MakefileGenerator.comment.build.rule = Each subdirectory must supply rules for building sources it contributes
|
||||
MakefileGenerator.comment.build.toprules = Tool invocations
|
||||
MakefileGenerator.comment.build.alltarget = All Target
|
||||
MakefileGenerator.comment.build.mainbuildtarget = Main-build Target
|
||||
MakefileGenerator.comment.build.toptargets = Other Targets
|
||||
MakefileGenerator.comment.module.make.includes = Include the makefiles for each source subdirectory
|
||||
MakefileGenerator.comment.module.dep.includes = Include automatically-generated dependency list:
|
||||
MakefileGenerator.comment.autodeps=Automatically-generated dependency list:
|
||||
MakefileGenerator.comment.header=Automatically-generated file. Do not edit!
|
||||
MakefileGenerator.error.spaces=Cannot generate makefile for folder with spaces in name
|
||||
MakefileGenerator.warning.no.source=Nothing to build for project {0}
|
||||
MakefileGenerator.error.no.nameprovider=A nameProvider or outputNames must be specified with multipleType == true
|
||||
|
||||
ManagedBuildInfo.message.job.init = Initializing path container for {0}
|
||||
ManagedBuildInfo.message.init.ok = Initializing path container succeeded for {0}
|
||||
|
||||
# Default GNU Makefile Generator messages
|
||||
GnuMakefileGenerator.message.postproc.dep.file=Verifying contents of dependency file {0}
|
||||
|
||||
# Tool strings
|
||||
Tool.default.announcement=Invoking:
|
||||
#Environment loader messages
|
||||
StorableEnvironmentLoader.storeOutputStream.wrong.arguments=Wrong arguments
|
||||
|
||||
#User Defined Macro Supplier
|
||||
UserDefinedMacroSupplier.storeOutputStream.wrong.arguments=Failed to persist macros: Wrong arguments
|
||||
|
||||
# BuildMacroStatus messages
|
||||
BuildMacroStatus.status.macro.undefined=Macro {0} is undefined
|
||||
BuildMacroStatus.status.reference.eachother=Macros {0} and {1} reference each other
|
||||
BuildMacroStatus.status.reference.incorrect=Macro {0} reference is incorrect
|
||||
BuildMacroStatus.status.macro.not.string=Macro {0} is not of String type
|
||||
BuildMacroStatus.status.macro.not.stringlist=Macro {0} is not of String-list type
|
||||
BuildMacroStatus.status.error=Error occured
|
||||
BuildMacroStatus.value.undefined=
|
||||
|
||||
#ResourceChangeHandler messages
|
||||
ResourceChangeHandler.buildInfoSerializationJob=Build Info Serialization
|
||||
|
||||
#ManagedBuilderCorePlugin messages
|
||||
ManagedBuilderCorePlugin.resourceChangeHandlingInitializationJob=Initializing Resource Change Handling
|
|
@ -1,458 +1,458 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.managedbuilder.internal.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
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.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||
import org.eclipse.core.resources.IResourceChangeListener;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||
import org.eclipse.core.resources.IResourceRuleFactory;
|
||||
import org.eclipse.core.resources.ISaveContext;
|
||||
import org.eclipse.core.resources.ISaveParticipant;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
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.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.core.runtime.jobs.MultiRule;
|
||||
|
||||
public class ResourceChangeHandler implements IResourceChangeListener, ISaveParticipant {
|
||||
|
||||
private class ResourceConfigurationChecker implements IResourceDeltaVisitor{
|
||||
private IResourceDelta fRootDelta;
|
||||
private HashMap fBuildFileGeneratorMap = new HashMap();
|
||||
private HashSet fValidatedFilesSet = new HashSet();
|
||||
private HashSet fModifiedProjects = new HashSet();
|
||||
|
||||
public ResourceConfigurationChecker(IResourceDelta rootDelta){
|
||||
fRootDelta = rootDelta;
|
||||
}
|
||||
|
||||
public IProject[] getModifiedProjects(){
|
||||
return (IProject[])fModifiedProjects.toArray(new IProject[fModifiedProjects.size()]);
|
||||
}
|
||||
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
IResource dResource = delta.getResource();
|
||||
int rcType = dResource.getType();
|
||||
|
||||
if(rcType == IResource.PROJECT || rcType == IResource.FOLDER){
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IProject project = null;
|
||||
IResource rcToCheck = null;
|
||||
switch (delta.getKind()) {
|
||||
case IResourceDelta.REMOVED :
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_TO) == 0 && rcType == IResource.PROJECT) {
|
||||
sendClose((IProject)dResource);
|
||||
break;
|
||||
}
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
||||
IPath path = delta.getMovedToPath();
|
||||
if(path != null){
|
||||
project = root.findMember(path.segment(0)).getProject();
|
||||
if(project != null && rcType == IResource.FOLDER)
|
||||
rcToCheck = root.getFolder(substituteProject(dResource.getFullPath(),project.getName()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
project = dResource.getProject();
|
||||
if(rcType == IResource.FOLDER)
|
||||
rcToCheck = dResource;
|
||||
break;
|
||||
}
|
||||
|
||||
if(project != null) {
|
||||
IManagedBuilderMakefileGenerator makeGen = getInitializedGenerator(project);
|
||||
if(makeGen != null){
|
||||
if(rcToCheck == null || !makeGen.isGeneratedResource(rcToCheck))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (rcType == IResource.FILE && !dResource.isDerived()) {
|
||||
int flags = delta.getFlags();
|
||||
switch (delta.getKind()) {
|
||||
case IResourceDelta.REMOVED :
|
||||
if ((flags & IResourceDelta.MOVED_TO) == 0) {
|
||||
handleDeleteFile(dResource.getFullPath());
|
||||
break;
|
||||
}
|
||||
case IResourceDelta.ADDED :
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((flags & IResourceDelta.MOVED_TO) != 0) {
|
||||
IPath path = delta.getMovedToPath();
|
||||
if (path != null) {
|
||||
handleRenamedFile(
|
||||
dResource.getFullPath(),
|
||||
path);
|
||||
}
|
||||
} else if ((flags & IResourceDelta.MOVED_FROM) != 0) {
|
||||
IPath path = delta.getMovedFromPath();
|
||||
if (path != null) {
|
||||
handleRenamedFile(
|
||||
path,
|
||||
dResource.getFullPath());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true; // visit the children
|
||||
}
|
||||
|
||||
private IPath substituteProject(IPath path, String projectName){
|
||||
return new Path(projectName).makeAbsolute().append(path.removeFirstSegments(1));
|
||||
}
|
||||
|
||||
private void handleRenamedFile(IPath fromPath, IPath toPath){
|
||||
if(!fValidatedFilesSet.add(fromPath))
|
||||
return;
|
||||
|
||||
IProject fromProject = findModifiedProject(fromPath.segment(0));
|
||||
if(fromProject == null)
|
||||
return;
|
||||
IManagedBuilderMakefileGenerator fromMakeGen = getInitializedGenerator(fromProject);
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
if(fromMakeGen == null || fromMakeGen.isGeneratedResource(root.getFile(substituteProject(fromPath,fromProject.getName()))))
|
||||
return;
|
||||
|
||||
IManagedBuildInfo fromInfo = fromProject != null ?
|
||||
ManagedBuildManager.getBuildInfo(fromProject) :
|
||||
null;
|
||||
|
||||
IProject toProject = root.findMember(toPath.uptoSegment(1)).getProject();
|
||||
IManagedBuildInfo toInfo = toProject != null ?
|
||||
ManagedBuildManager.getBuildInfo(toProject) :
|
||||
null;
|
||||
IManagedBuilderMakefileGenerator toMakeGen = toProject != null ?
|
||||
getInitializedGenerator(toProject) :
|
||||
null;
|
||||
if(toMakeGen != null && toMakeGen.isGeneratedResource(root.getFile(toPath)))
|
||||
toInfo = null;
|
||||
|
||||
if(fromInfo == toInfo){
|
||||
//the resource was moved whithing the project scope
|
||||
if(updateResourceConfigurations(fromInfo,fromPath,toPath) && toProject != null)
|
||||
fModifiedProjects.add(toProject);
|
||||
} else {
|
||||
if(fromInfo != null && toInfo != null){
|
||||
//TODO: this is the case when the resource
|
||||
//is moved from one managed project to another
|
||||
//should we handle this?
|
||||
//e.g. add resource configurations to the destination project?
|
||||
}
|
||||
if(fromInfo != null && removeResourceConfigurations(fromInfo,fromPath) && fromProject != null)
|
||||
fModifiedProjects.add(fromProject);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDeleteFile(IPath path){
|
||||
IProject project = findModifiedProject(path.segment(0));
|
||||
if(project != null){
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||
if(info != null
|
||||
&& removeResourceConfigurations(info,path))
|
||||
fModifiedProjects.add(project);
|
||||
}
|
||||
}
|
||||
|
||||
//finds the project geven the initial project name
|
||||
//That is:
|
||||
// if the project of a given name was renamed returns the renamed project
|
||||
// if the project of a given name was removed returns null
|
||||
// if the project of a given name was neither renamed or removed
|
||||
// returns the project of that name or null if the project does not exist
|
||||
//
|
||||
private IProject findModifiedProject(final String oldProjectName){
|
||||
IResourceDelta projectDelta = fRootDelta.findMember(new Path(oldProjectName));
|
||||
boolean replaced = false;
|
||||
if(projectDelta != null) {
|
||||
switch(projectDelta.getKind()){
|
||||
case IResourceDelta.REMOVED :
|
||||
if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) == 0) {
|
||||
return null;
|
||||
}
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
||||
IPath path = projectDelta.getMovedToPath();
|
||||
if(path != null)
|
||||
return ResourcesPlugin.getWorkspace().getRoot().findMember(path).getProject();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final IProject project[] = new IProject[1];
|
||||
try {
|
||||
fRootDelta.accept(new IResourceDeltaVisitor() {
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
IResource dResource = delta.getResource();
|
||||
int rcType = dResource.getType();
|
||||
if(rcType == IResource.ROOT) {
|
||||
return true;
|
||||
} else if(rcType == IResource.PROJECT){
|
||||
switch(delta.getKind()){
|
||||
case IResourceDelta.ADDED :
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
|
||||
IPath path = delta.getMovedFromPath();
|
||||
if (path != null && path.segment(0).equals(oldProjectName)) {
|
||||
project[0] = dResource.getProject();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
|
||||
if(project[0] == null && !replaced)
|
||||
project[0] = ResourcesPlugin.getWorkspace().getRoot().findMember(oldProjectName).getProject();
|
||||
return project[0];
|
||||
}
|
||||
|
||||
private IManagedBuilderMakefileGenerator getInitializedGenerator(IProject project){
|
||||
IManagedBuilderMakefileGenerator makeGen = (IManagedBuilderMakefileGenerator)fBuildFileGeneratorMap.get(project);
|
||||
if (makeGen == null) {
|
||||
try {
|
||||
if (project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
|
||||
// Determine if we can access the build info before actually trying
|
||||
// If not, don't try, to avoid putting up a dialog box warning the user
|
||||
if (!ManagedBuildManager.canGetBuildInfo(project)) return null;
|
||||
|
||||
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
|
||||
if (buildInfo != null){
|
||||
IConfiguration defaultCfg = buildInfo.getDefaultConfiguration();
|
||||
if (defaultCfg != null) {
|
||||
makeGen = ManagedBuildManager.getBuildfileGenerator(defaultCfg);
|
||||
makeGen.initialize(project,buildInfo,new NullProgressMonitor());
|
||||
fBuildFileGeneratorMap.put(project,makeGen);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return makeGen;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendClose(IProject project){
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project,false);
|
||||
if(info != null){
|
||||
IManagedProject managedProj = info.getManagedProject();
|
||||
if (managedProj != null) {
|
||||
IConfiguration cfgs[] = managedProj.getConfigurations();
|
||||
|
||||
for(int i = 0; i < cfgs.length; i++)
|
||||
ManagedBuildManager.performValueHandlerEvent(cfgs[i], IManagedOptionValueHandler.EVENT_CLOSE, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* I R e s o u r c e C h a n g e L i s t e n e r
|
||||
*/
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* Handle the renaming and deletion of project resources
|
||||
* This is necessary in order to update ResourceConfigurations and AdditionalInputs
|
||||
*
|
||||
* @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
|
||||
*/
|
||||
public void resourceChanged(IResourceChangeEvent event) {
|
||||
if (event.getSource() instanceof IWorkspace) {
|
||||
|
||||
switch (event.getType()) {
|
||||
case IResourceChangeEvent.PRE_CLOSE:
|
||||
IResource proj = event.getResource();
|
||||
if(proj instanceof IProject)
|
||||
sendClose((IProject)proj);
|
||||
break;
|
||||
case IResourceChangeEvent.POST_CHANGE :
|
||||
case IResourceChangeEvent.POST_BUILD :
|
||||
case IResourceChangeEvent.PRE_DELETE :
|
||||
IResourceDelta resDelta = event.getDelta();
|
||||
if (resDelta == null) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
ResourceConfigurationChecker rcChecker = new ResourceConfigurationChecker(resDelta);
|
||||
resDelta.accept(rcChecker);
|
||||
|
||||
//saving info for the modified projects
|
||||
initInfoSerialization(rcChecker.getModifiedProjects());
|
||||
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initInfoSerialization(final IProject projects[]){
|
||||
if(projects.length == 0)
|
||||
return;
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IResourceRuleFactory ruleFactory = workspace.getRuleFactory();
|
||||
ISchedulingRule buildInfoSaveRule;
|
||||
if(projects.length == 1){
|
||||
buildInfoSaveRule = ruleFactory.modifyRule(projects[0]);
|
||||
} else {
|
||||
ISchedulingRule rules[] = new ISchedulingRule[projects.length];
|
||||
for(int i = 0; i < rules.length; i++)
|
||||
rules[i] = ruleFactory.modifyRule(projects[i]);
|
||||
buildInfoSaveRule = MultiRule.combine(rules);
|
||||
}
|
||||
|
||||
Job savingJob = new Job(ManagedMakeMessages.getResourceString("ResourceChangeHandler.buildInfoSerializationJob")){ //$NON-NLS-1$
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
for(int i = 0; i < projects.length; i++){
|
||||
ManagedBuildManager.saveBuildInfo(projects[i],true);
|
||||
}
|
||||
return new Status(
|
||||
IStatus.OK,
|
||||
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||
IStatus.OK,
|
||||
new String(),
|
||||
null);
|
||||
}
|
||||
};
|
||||
savingJob.setRule(buildInfoSaveRule);
|
||||
|
||||
savingJob.schedule();
|
||||
}
|
||||
|
||||
private boolean updateResourceConfigurations(IManagedBuildInfo info, IPath oldPath, IPath newPath){
|
||||
boolean changed = false;
|
||||
if(!oldPath.equals(newPath)){
|
||||
IManagedProject mngProj = info.getManagedProject();
|
||||
if(mngProj != null){
|
||||
IConfiguration configs[] = mngProj.getConfigurations();
|
||||
if(configs != null && configs.length > 0){
|
||||
for(int i = 0; i < configs.length; i++){
|
||||
if(updateResourceConfiguration(configs[i],oldPath,newPath))
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean removeResourceConfigurations(IManagedBuildInfo info, IPath path){
|
||||
boolean changed = false;
|
||||
IManagedProject mngProj = info.getManagedProject();
|
||||
if(mngProj != null){
|
||||
IConfiguration configs[] = mngProj.getConfigurations();
|
||||
if(configs != null && configs.length > 0){
|
||||
for(int i = 0; i < configs.length; i++){
|
||||
if(removeResourceConfiguration(configs[i],path))
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean updateResourceConfiguration(IConfiguration config, IPath oldPath, IPath newPath){
|
||||
IResourceConfiguration rcCfg = config.getResourceConfiguration(oldPath.toString());
|
||||
if(rcCfg != null && !oldPath.equals(newPath)){
|
||||
config.removeResourceConfiguration(rcCfg);
|
||||
rcCfg.setResourcePath(newPath.toString());
|
||||
((Configuration)config).addResourceConfiguration((ResourceConfiguration)rcCfg);
|
||||
config.setRebuildState(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean removeResourceConfiguration(IConfiguration config, IPath path){
|
||||
IResourceConfiguration rcCfg = config.getResourceConfiguration(path.toString());
|
||||
if(rcCfg != null){
|
||||
config.removeResourceConfiguration(rcCfg);
|
||||
config.setRebuildState(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* I S a v e P a r t i c i p a n t
|
||||
*/
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void saving(ISaveContext context) throws CoreException {
|
||||
// No state to be saved by the plug-in, but request a
|
||||
// resource delta to be used on next activation.
|
||||
context.needDelta();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#doneSaving(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void doneSaving(ISaveContext context) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void prepareToSave(ISaveContext context) throws CoreException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#rollback(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void rollback(ISaveContext context) {
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2005 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.managedbuilder.internal.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
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.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||
import org.eclipse.core.resources.IResourceChangeListener;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||
import org.eclipse.core.resources.IResourceRuleFactory;
|
||||
import org.eclipse.core.resources.ISaveContext;
|
||||
import org.eclipse.core.resources.ISaveParticipant;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
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.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.core.runtime.jobs.MultiRule;
|
||||
|
||||
public class ResourceChangeHandler implements IResourceChangeListener, ISaveParticipant {
|
||||
|
||||
private class ResourceConfigurationChecker implements IResourceDeltaVisitor{
|
||||
private IResourceDelta fRootDelta;
|
||||
private HashMap fBuildFileGeneratorMap = new HashMap();
|
||||
private HashSet fValidatedFilesSet = new HashSet();
|
||||
private HashSet fModifiedProjects = new HashSet();
|
||||
|
||||
public ResourceConfigurationChecker(IResourceDelta rootDelta){
|
||||
fRootDelta = rootDelta;
|
||||
}
|
||||
|
||||
public IProject[] getModifiedProjects(){
|
||||
return (IProject[])fModifiedProjects.toArray(new IProject[fModifiedProjects.size()]);
|
||||
}
|
||||
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
IResource dResource = delta.getResource();
|
||||
int rcType = dResource.getType();
|
||||
|
||||
if(rcType == IResource.PROJECT || rcType == IResource.FOLDER){
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IProject project = null;
|
||||
IResource rcToCheck = null;
|
||||
switch (delta.getKind()) {
|
||||
case IResourceDelta.REMOVED :
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_TO) == 0 && rcType == IResource.PROJECT) {
|
||||
sendClose((IProject)dResource);
|
||||
break;
|
||||
}
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
||||
IPath path = delta.getMovedToPath();
|
||||
if(path != null){
|
||||
project = root.findMember(path.segment(0)).getProject();
|
||||
if(project != null && rcType == IResource.FOLDER)
|
||||
rcToCheck = root.getFolder(substituteProject(dResource.getFullPath(),project.getName()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
project = dResource.getProject();
|
||||
if(rcType == IResource.FOLDER)
|
||||
rcToCheck = dResource;
|
||||
break;
|
||||
}
|
||||
|
||||
if(project != null) {
|
||||
IManagedBuilderMakefileGenerator makeGen = getInitializedGenerator(project);
|
||||
if(makeGen != null){
|
||||
if(rcToCheck == null || !makeGen.isGeneratedResource(rcToCheck))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (rcType == IResource.FILE && !dResource.isDerived()) {
|
||||
int flags = delta.getFlags();
|
||||
switch (delta.getKind()) {
|
||||
case IResourceDelta.REMOVED :
|
||||
if ((flags & IResourceDelta.MOVED_TO) == 0) {
|
||||
handleDeleteFile(dResource.getFullPath());
|
||||
break;
|
||||
}
|
||||
case IResourceDelta.ADDED :
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((flags & IResourceDelta.MOVED_TO) != 0) {
|
||||
IPath path = delta.getMovedToPath();
|
||||
if (path != null) {
|
||||
handleRenamedFile(
|
||||
dResource.getFullPath(),
|
||||
path);
|
||||
}
|
||||
} else if ((flags & IResourceDelta.MOVED_FROM) != 0) {
|
||||
IPath path = delta.getMovedFromPath();
|
||||
if (path != null) {
|
||||
handleRenamedFile(
|
||||
path,
|
||||
dResource.getFullPath());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true; // visit the children
|
||||
}
|
||||
|
||||
private IPath substituteProject(IPath path, String projectName){
|
||||
return new Path(projectName).makeAbsolute().append(path.removeFirstSegments(1));
|
||||
}
|
||||
|
||||
private void handleRenamedFile(IPath fromPath, IPath toPath){
|
||||
if(!fValidatedFilesSet.add(fromPath))
|
||||
return;
|
||||
|
||||
IProject fromProject = findModifiedProject(fromPath.segment(0));
|
||||
if(fromProject == null)
|
||||
return;
|
||||
IManagedBuilderMakefileGenerator fromMakeGen = getInitializedGenerator(fromProject);
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
if(fromMakeGen == null || fromMakeGen.isGeneratedResource(root.getFile(substituteProject(fromPath,fromProject.getName()))))
|
||||
return;
|
||||
|
||||
IManagedBuildInfo fromInfo = fromProject != null ?
|
||||
ManagedBuildManager.getBuildInfo(fromProject) :
|
||||
null;
|
||||
|
||||
IProject toProject = root.findMember(toPath.uptoSegment(1)).getProject();
|
||||
IManagedBuildInfo toInfo = toProject != null ?
|
||||
ManagedBuildManager.getBuildInfo(toProject) :
|
||||
null;
|
||||
IManagedBuilderMakefileGenerator toMakeGen = toProject != null ?
|
||||
getInitializedGenerator(toProject) :
|
||||
null;
|
||||
if(toMakeGen != null && toMakeGen.isGeneratedResource(root.getFile(toPath)))
|
||||
toInfo = null;
|
||||
|
||||
if(fromInfo == toInfo){
|
||||
//the resource was moved whithing the project scope
|
||||
if(updateResourceConfigurations(fromInfo,fromPath,toPath) && toProject != null)
|
||||
fModifiedProjects.add(toProject);
|
||||
} else {
|
||||
if(fromInfo != null && toInfo != null){
|
||||
//TODO: this is the case when the resource
|
||||
//is moved from one managed project to another
|
||||
//should we handle this?
|
||||
//e.g. add resource configurations to the destination project?
|
||||
}
|
||||
if(fromInfo != null && removeResourceConfigurations(fromInfo,fromPath) && fromProject != null)
|
||||
fModifiedProjects.add(fromProject);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDeleteFile(IPath path){
|
||||
IProject project = findModifiedProject(path.segment(0));
|
||||
if(project != null){
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||
if(info != null
|
||||
&& removeResourceConfigurations(info,path))
|
||||
fModifiedProjects.add(project);
|
||||
}
|
||||
}
|
||||
|
||||
//finds the project geven the initial project name
|
||||
//That is:
|
||||
// if the project of a given name was renamed returns the renamed project
|
||||
// if the project of a given name was removed returns null
|
||||
// if the project of a given name was neither renamed or removed
|
||||
// returns the project of that name or null if the project does not exist
|
||||
//
|
||||
private IProject findModifiedProject(final String oldProjectName){
|
||||
IResourceDelta projectDelta = fRootDelta.findMember(new Path(oldProjectName));
|
||||
boolean replaced = false;
|
||||
if(projectDelta != null) {
|
||||
switch(projectDelta.getKind()){
|
||||
case IResourceDelta.REMOVED :
|
||||
if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) == 0) {
|
||||
return null;
|
||||
}
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
||||
IPath path = projectDelta.getMovedToPath();
|
||||
if(path != null)
|
||||
return ResourcesPlugin.getWorkspace().getRoot().findMember(path).getProject();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final IProject project[] = new IProject[1];
|
||||
try {
|
||||
fRootDelta.accept(new IResourceDeltaVisitor() {
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
IResource dResource = delta.getResource();
|
||||
int rcType = dResource.getType();
|
||||
if(rcType == IResource.ROOT) {
|
||||
return true;
|
||||
} else if(rcType == IResource.PROJECT){
|
||||
switch(delta.getKind()){
|
||||
case IResourceDelta.ADDED :
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
|
||||
IPath path = delta.getMovedFromPath();
|
||||
if (path != null && path.segment(0).equals(oldProjectName)) {
|
||||
project[0] = dResource.getProject();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
|
||||
if(project[0] == null && !replaced)
|
||||
project[0] = ResourcesPlugin.getWorkspace().getRoot().findMember(oldProjectName).getProject();
|
||||
return project[0];
|
||||
}
|
||||
|
||||
private IManagedBuilderMakefileGenerator getInitializedGenerator(IProject project){
|
||||
IManagedBuilderMakefileGenerator makeGen = (IManagedBuilderMakefileGenerator)fBuildFileGeneratorMap.get(project);
|
||||
if (makeGen == null) {
|
||||
try {
|
||||
if (project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
|
||||
// Determine if we can access the build info before actually trying
|
||||
// If not, don't try, to avoid putting up a dialog box warning the user
|
||||
if (!ManagedBuildManager.canGetBuildInfo(project)) return null;
|
||||
|
||||
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
|
||||
if (buildInfo != null){
|
||||
IConfiguration defaultCfg = buildInfo.getDefaultConfiguration();
|
||||
if (defaultCfg != null) {
|
||||
makeGen = ManagedBuildManager.getBuildfileGenerator(defaultCfg);
|
||||
makeGen.initialize(project,buildInfo,new NullProgressMonitor());
|
||||
fBuildFileGeneratorMap.put(project,makeGen);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return makeGen;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendClose(IProject project){
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project,false);
|
||||
if(info != null){
|
||||
IManagedProject managedProj = info.getManagedProject();
|
||||
if (managedProj != null) {
|
||||
IConfiguration cfgs[] = managedProj.getConfigurations();
|
||||
|
||||
for(int i = 0; i < cfgs.length; i++)
|
||||
ManagedBuildManager.performValueHandlerEvent(cfgs[i], IManagedOptionValueHandler.EVENT_CLOSE, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* I R e s o u r c e C h a n g e L i s t e n e r
|
||||
*/
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* Handle the renaming and deletion of project resources
|
||||
* This is necessary in order to update ResourceConfigurations and AdditionalInputs
|
||||
*
|
||||
* @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
|
||||
*/
|
||||
public void resourceChanged(IResourceChangeEvent event) {
|
||||
if (event.getSource() instanceof IWorkspace) {
|
||||
|
||||
switch (event.getType()) {
|
||||
case IResourceChangeEvent.PRE_CLOSE:
|
||||
IResource proj = event.getResource();
|
||||
if(proj instanceof IProject)
|
||||
sendClose((IProject)proj);
|
||||
break;
|
||||
case IResourceChangeEvent.POST_CHANGE :
|
||||
case IResourceChangeEvent.POST_BUILD :
|
||||
case IResourceChangeEvent.PRE_DELETE :
|
||||
IResourceDelta resDelta = event.getDelta();
|
||||
if (resDelta == null) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
ResourceConfigurationChecker rcChecker = new ResourceConfigurationChecker(resDelta);
|
||||
resDelta.accept(rcChecker);
|
||||
|
||||
//saving info for the modified projects
|
||||
initInfoSerialization(rcChecker.getModifiedProjects());
|
||||
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initInfoSerialization(final IProject projects[]){
|
||||
if(projects.length == 0)
|
||||
return;
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IResourceRuleFactory ruleFactory = workspace.getRuleFactory();
|
||||
ISchedulingRule buildInfoSaveRule;
|
||||
if(projects.length == 1){
|
||||
buildInfoSaveRule = ruleFactory.modifyRule(projects[0]);
|
||||
} else {
|
||||
ISchedulingRule rules[] = new ISchedulingRule[projects.length];
|
||||
for(int i = 0; i < rules.length; i++)
|
||||
rules[i] = ruleFactory.modifyRule(projects[i]);
|
||||
buildInfoSaveRule = MultiRule.combine(rules);
|
||||
}
|
||||
|
||||
Job savingJob = new Job(ManagedMakeMessages.getResourceString("ResourceChangeHandler.buildInfoSerializationJob")){ //$NON-NLS-1$
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
for(int i = 0; i < projects.length; i++){
|
||||
ManagedBuildManager.saveBuildInfo(projects[i],true);
|
||||
}
|
||||
return new Status(
|
||||
IStatus.OK,
|
||||
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||
IStatus.OK,
|
||||
new String(),
|
||||
null);
|
||||
}
|
||||
};
|
||||
savingJob.setRule(buildInfoSaveRule);
|
||||
|
||||
savingJob.schedule();
|
||||
}
|
||||
|
||||
private boolean updateResourceConfigurations(IManagedBuildInfo info, IPath oldPath, IPath newPath){
|
||||
boolean changed = false;
|
||||
if(!oldPath.equals(newPath)){
|
||||
IManagedProject mngProj = info.getManagedProject();
|
||||
if(mngProj != null){
|
||||
IConfiguration configs[] = mngProj.getConfigurations();
|
||||
if(configs != null && configs.length > 0){
|
||||
for(int i = 0; i < configs.length; i++){
|
||||
if(updateResourceConfiguration(configs[i],oldPath,newPath))
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean removeResourceConfigurations(IManagedBuildInfo info, IPath path){
|
||||
boolean changed = false;
|
||||
IManagedProject mngProj = info.getManagedProject();
|
||||
if(mngProj != null){
|
||||
IConfiguration configs[] = mngProj.getConfigurations();
|
||||
if(configs != null && configs.length > 0){
|
||||
for(int i = 0; i < configs.length; i++){
|
||||
if(removeResourceConfiguration(configs[i],path))
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean updateResourceConfiguration(IConfiguration config, IPath oldPath, IPath newPath){
|
||||
IResourceConfiguration rcCfg = config.getResourceConfiguration(oldPath.toString());
|
||||
if(rcCfg != null && !oldPath.equals(newPath)){
|
||||
config.removeResourceConfiguration(rcCfg);
|
||||
rcCfg.setResourcePath(newPath.toString());
|
||||
((Configuration)config).addResourceConfiguration((ResourceConfiguration)rcCfg);
|
||||
config.setRebuildState(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean removeResourceConfiguration(IConfiguration config, IPath path){
|
||||
IResourceConfiguration rcCfg = config.getResourceConfiguration(path.toString());
|
||||
if(rcCfg != null){
|
||||
config.removeResourceConfiguration(rcCfg);
|
||||
config.setRebuildState(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* I S a v e P a r t i c i p a n t
|
||||
*/
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void saving(ISaveContext context) throws CoreException {
|
||||
// No state to be saved by the plug-in, but request a
|
||||
// resource delta to be used on next activation.
|
||||
context.needDelta();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#doneSaving(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void doneSaving(ISaveContext context) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void prepareToSave(ISaveContext context) throws CoreException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#rollback(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void rollback(ISaveContext context) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,79 +1,79 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* @since 3.1
|
||||
*
|
||||
* A Tool dependency calculator may implement this interface or
|
||||
* IManagedDependencyCommands or IManagedDependencyPreBuild.
|
||||
* An object implementing the interface is returned from a call to
|
||||
* IManagedDependencyGenerator2.getDependencySourceInfo.
|
||||
*
|
||||
* Discussion of Dependency Calculation:
|
||||
*
|
||||
* There are two major, and multiple minor, modes of dependency calculation
|
||||
* supported by the MBS. The major modes are:
|
||||
*
|
||||
* 1. The build file generator invokes tool integrator provided methods
|
||||
* that calculate all dependencies using whatever method the tool
|
||||
* integrator wants. The build file generator then adds the dependencies
|
||||
* to the build file using the appropriate build file syntax.
|
||||
* This type of dependency calculator implements the
|
||||
* IManagedDependencyCalculator interface defined in this module.
|
||||
*
|
||||
* One minor mode of this mode is to use a dependency calculator provided
|
||||
* by a language integration (e.g. C, C++ or Fortran) that uses the
|
||||
* language's parsing support to return information regarding source file
|
||||
* dependencies. An example of this is using the C/C++ Indexer to
|
||||
* compute dependencies.
|
||||
*
|
||||
* 2. The build file generator and the tool-chain cooperate in creating and
|
||||
* using separate "dependency" files. In this case, dependency calculation
|
||||
* is done at "build time", rather than at "build file generation time" as
|
||||
* in mode #1. This currently supports the GNU concept of using .d files
|
||||
* in GNU make. See the IManagedDependencyCommands and
|
||||
* IManagedDependencyPreBuild interfaces for more information.
|
||||
*
|
||||
*/
|
||||
|
||||
public interface IManagedDependencyCalculator extends IManagedDependencyInfo {
|
||||
|
||||
/**
|
||||
* Returns the list of source file specific dependencies.
|
||||
*
|
||||
* The paths can be either relative to the project directory, or absolute
|
||||
* in the file system.
|
||||
*
|
||||
* @return IPath[]
|
||||
*/
|
||||
public IPath[] getDependencies();
|
||||
|
||||
/**
|
||||
* Returns the list of source file specific additional targets that the
|
||||
* source file creates. Most source files will return null. An example
|
||||
* of where additional targets should be returned is for a Fortran 90
|
||||
* source file that creates one or more Fortran Modules.
|
||||
*
|
||||
* Note that these output files that are dependencies to other invocations
|
||||
* of the same tool can be specified here, or as another output type
|
||||
* of the tool. If the output file can be used as the input of a different
|
||||
* tool, then use the output type mechanism.
|
||||
*
|
||||
* The paths can be either relative to the top build directory, or absolute
|
||||
* in the file system.
|
||||
*
|
||||
* @return IPath[]
|
||||
*/
|
||||
public IPath[] getAdditionalTargets();
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* @since 3.1
|
||||
*
|
||||
* A Tool dependency calculator may implement this interface or
|
||||
* IManagedDependencyCommands or IManagedDependencyPreBuild.
|
||||
* An object implementing the interface is returned from a call to
|
||||
* IManagedDependencyGenerator2.getDependencySourceInfo.
|
||||
*
|
||||
* Discussion of Dependency Calculation:
|
||||
*
|
||||
* There are two major, and multiple minor, modes of dependency calculation
|
||||
* supported by the MBS. The major modes are:
|
||||
*
|
||||
* 1. The build file generator invokes tool integrator provided methods
|
||||
* that calculate all dependencies using whatever method the tool
|
||||
* integrator wants. The build file generator then adds the dependencies
|
||||
* to the build file using the appropriate build file syntax.
|
||||
* This type of dependency calculator implements the
|
||||
* IManagedDependencyCalculator interface defined in this module.
|
||||
*
|
||||
* One minor mode of this mode is to use a dependency calculator provided
|
||||
* by a language integration (e.g. C, C++ or Fortran) that uses the
|
||||
* language's parsing support to return information regarding source file
|
||||
* dependencies. An example of this is using the C/C++ Indexer to
|
||||
* compute dependencies.
|
||||
*
|
||||
* 2. The build file generator and the tool-chain cooperate in creating and
|
||||
* using separate "dependency" files. In this case, dependency calculation
|
||||
* is done at "build time", rather than at "build file generation time" as
|
||||
* in mode #1. This currently supports the GNU concept of using .d files
|
||||
* in GNU make. See the IManagedDependencyCommands and
|
||||
* IManagedDependencyPreBuild interfaces for more information.
|
||||
*
|
||||
*/
|
||||
|
||||
public interface IManagedDependencyCalculator extends IManagedDependencyInfo {
|
||||
|
||||
/**
|
||||
* Returns the list of source file specific dependencies.
|
||||
*
|
||||
* The paths can be either relative to the project directory, or absolute
|
||||
* in the file system.
|
||||
*
|
||||
* @return IPath[]
|
||||
*/
|
||||
public IPath[] getDependencies();
|
||||
|
||||
/**
|
||||
* Returns the list of source file specific additional targets that the
|
||||
* source file creates. Most source files will return null. An example
|
||||
* of where additional targets should be returned is for a Fortran 90
|
||||
* source file that creates one or more Fortran Modules.
|
||||
*
|
||||
* Note that these output files that are dependencies to other invocations
|
||||
* of the same tool can be specified here, or as another output type
|
||||
* of the tool. If the output file can be used as the input of a different
|
||||
* tool, then use the output type mechanism.
|
||||
*
|
||||
* The paths can be either relative to the top build directory, or absolute
|
||||
* in the file system.
|
||||
*
|
||||
* @return IPath[]
|
||||
*/
|
||||
public IPath[] getAdditionalTargets();
|
||||
}
|
||||
|
|
|
@ -1,168 +1,168 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* @since 3.1
|
||||
*
|
||||
* A Tool dependency calculator may implement this interface or
|
||||
* IManagedDependencyCalculator or IManagedDependencyPreBuild.
|
||||
* An object implementing the interface is returned from a call to
|
||||
* IManagedDependencyGenerator2.getDependencySourceInfo.
|
||||
*
|
||||
* Discussion of Dependency Calculation:
|
||||
*
|
||||
* There are two major, and multiple minor, modes of dependency calculation
|
||||
* supported by the MBS. The major modes are:
|
||||
*
|
||||
* 1. The build file generator invokes tool integrator provided methods
|
||||
* that calculate all dependencies using whatever method the tool
|
||||
* integrator wants. The build file generator then adds the dependencies
|
||||
* to the build file using the appropriate build file syntax.
|
||||
* See the IManagedDependencyCalculator interface for more information.
|
||||
*
|
||||
* 2. The build file generator and the tool-chain cooperate in creating and
|
||||
* using separate "dependency" files. The build file generator calls
|
||||
* the dependency calculator to get the dependency file names and to get
|
||||
* commands that need to be added to the build file. In this case,
|
||||
* dependency calculation is done at "build time", rather than at
|
||||
* "build file generation time" as in mode #1. This currently
|
||||
* supports the GNU concept of using .d files in GNU make.
|
||||
*
|
||||
* There are multiple ways that these separate dependency files can
|
||||
* be created by the tool-chain and used by the builder.
|
||||
*
|
||||
* a. In some cases (e.g., Fortran 90 using modules) the dependency files
|
||||
* must be created/updated prior to invoking the build of the project
|
||||
* artifact (e.g., an application). In this case, the dependency
|
||||
* generation step must occur separately before the main build.
|
||||
* See the IManagedDependencyPreBuild interface for more information.
|
||||
*
|
||||
* b. In other cases (e.g., C/C++) the dependency files can be created as
|
||||
* a side effect of the main build. This implies that the up to date
|
||||
* dependency files are not required for the current build, but for
|
||||
* the next build. C/C++ builds can be treated in this manner as is
|
||||
* described in the following link:
|
||||
* http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution
|
||||
*
|
||||
* Use the IManagedDependencyCommands interface defined in this file
|
||||
* for this mode.
|
||||
*
|
||||
* Two sub-scenarios of this mode are to:
|
||||
*
|
||||
* Create dependency files in the same invocation of the tool that
|
||||
* creates the tool's build artifact - by adding additional options
|
||||
* to the tool invocation command line.
|
||||
*
|
||||
* Create dependency files in a separate invocation of the tool, or
|
||||
* by the invocation of another tool.
|
||||
*
|
||||
* MBS can also help in the generation of the dependency files. Prior to
|
||||
* CDT 3.1, MBS and gcc cooperated in generating dependency files using the
|
||||
* following steps:
|
||||
*
|
||||
* 1. Gcc is invoked to perform the compilation that generates the object
|
||||
* file.
|
||||
*
|
||||
* 2. An "echo" command creates the .d file, adding the name of the .d
|
||||
* file to the beginning of the newly created .d file. Note that this
|
||||
* causes problems with some implementations of "echo" that don't
|
||||
* work exactly the way that we want (e.g., it doesn't support the -n
|
||||
* switch).
|
||||
|
||||
* 3. Gcc is invoked again with the appropriate additional command line
|
||||
* options to append its dependency file information to the .d file
|
||||
* that was created by "echo".
|
||||
*
|
||||
* 4. Steps 1 - 3 are invoked in the make file. Step 4 occurs after the
|
||||
* make invocation has finished. In step 4, MBS code post-processes
|
||||
* the .d files to add a dummy dependency for each header file, for
|
||||
* the reason explained in the link above.
|
||||
*
|
||||
* This mode is no longer used by the default gcc implementation, but can
|
||||
* still be used by selecting the DefaultGCCDependencyCalculator.
|
||||
*
|
||||
*
|
||||
* Note for GNU make: these separate dependency files are "include"d by
|
||||
* a main makefile. Therefore, if the dependency files are required to
|
||||
* be up to date before the main build begins, they must be updated by
|
||||
* a separate invocation of make. Also, the configuration "clean" step
|
||||
* must be invoked by a separate invocation of make. This is so that
|
||||
* we can exclude the dependency files for a "make clean" invocation
|
||||
* using syntax like:
|
||||
*
|
||||
* ifneq ($(MAKECMDGOALS), clean)
|
||||
* -include $(DEPS)
|
||||
* endif
|
||||
*
|
||||
* Otherwise, because GNU make attempts to re-make make files, we
|
||||
* can end up with out of date or missing dependency files being
|
||||
* re-generated and then immediately "clean"ed.
|
||||
*/
|
||||
|
||||
public interface IManagedDependencyCommands extends IManagedDependencyInfo {
|
||||
|
||||
/**
|
||||
* Returns the list of generated dependency files.
|
||||
*
|
||||
* The paths can be either relative to the top build directory, or absolute
|
||||
* in the file system.
|
||||
*
|
||||
* @return IPath[]
|
||||
*/
|
||||
public IPath[] getDependencyFiles();
|
||||
|
||||
/**
|
||||
* Returns the command lines to be invoked before the normal tool invocation
|
||||
* to calculate dependencies.
|
||||
*
|
||||
* @return String[] This can be null or an empty array if no dependency
|
||||
* generation command needs to be invoked before the normal
|
||||
* tool invocation.
|
||||
*/
|
||||
public String[] getPreToolDependencyCommands();
|
||||
|
||||
/**
|
||||
* Returns the command line options to be used to calculate dependencies.
|
||||
* The options are added to the normal tool invocation.
|
||||
*
|
||||
* @return String[] This can be null or an empty array if no additional
|
||||
* arguments need to be added to the tool invocation.
|
||||
* SHOULD THIS RETURN AN IOption[]?
|
||||
*/
|
||||
public String[] getDependencyCommandOptions();
|
||||
// IMPLEMENTATION NOTE: This should be called from addRuleFromSource for both resconfig & non-resconfig
|
||||
|
||||
/**
|
||||
* Returns the command lines to be invoked after the normal tool invocation
|
||||
* to calculate dependencies.
|
||||
*
|
||||
* @return String[] This can be null or an empty array if no dependency
|
||||
* generation commands needs to be invoked after the normal
|
||||
* tool invocation
|
||||
*/
|
||||
public String[] getPostToolDependencyCommands();
|
||||
|
||||
/**
|
||||
* Returns true if the command lines and/or options returned by this interface
|
||||
* are not specific to the particular source file, but are only specific to,
|
||||
* at most, the configuration and tool. If the build context is a resource
|
||||
* configuration, this method should return false if any of the command lines
|
||||
* and/or options are different than if the build context were the parent
|
||||
* configuration. This can be used by the build file generator in helping
|
||||
* to determine if a "pattern" (generic) rule can be used.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areCommandsGeneric();
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* @since 3.1
|
||||
*
|
||||
* A Tool dependency calculator may implement this interface or
|
||||
* IManagedDependencyCalculator or IManagedDependencyPreBuild.
|
||||
* An object implementing the interface is returned from a call to
|
||||
* IManagedDependencyGenerator2.getDependencySourceInfo.
|
||||
*
|
||||
* Discussion of Dependency Calculation:
|
||||
*
|
||||
* There are two major, and multiple minor, modes of dependency calculation
|
||||
* supported by the MBS. The major modes are:
|
||||
*
|
||||
* 1. The build file generator invokes tool integrator provided methods
|
||||
* that calculate all dependencies using whatever method the tool
|
||||
* integrator wants. The build file generator then adds the dependencies
|
||||
* to the build file using the appropriate build file syntax.
|
||||
* See the IManagedDependencyCalculator interface for more information.
|
||||
*
|
||||
* 2. The build file generator and the tool-chain cooperate in creating and
|
||||
* using separate "dependency" files. The build file generator calls
|
||||
* the dependency calculator to get the dependency file names and to get
|
||||
* commands that need to be added to the build file. In this case,
|
||||
* dependency calculation is done at "build time", rather than at
|
||||
* "build file generation time" as in mode #1. This currently
|
||||
* supports the GNU concept of using .d files in GNU make.
|
||||
*
|
||||
* There are multiple ways that these separate dependency files can
|
||||
* be created by the tool-chain and used by the builder.
|
||||
*
|
||||
* a. In some cases (e.g., Fortran 90 using modules) the dependency files
|
||||
* must be created/updated prior to invoking the build of the project
|
||||
* artifact (e.g., an application). In this case, the dependency
|
||||
* generation step must occur separately before the main build.
|
||||
* See the IManagedDependencyPreBuild interface for more information.
|
||||
*
|
||||
* b. In other cases (e.g., C/C++) the dependency files can be created as
|
||||
* a side effect of the main build. This implies that the up to date
|
||||
* dependency files are not required for the current build, but for
|
||||
* the next build. C/C++ builds can be treated in this manner as is
|
||||
* described in the following link:
|
||||
* http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution
|
||||
*
|
||||
* Use the IManagedDependencyCommands interface defined in this file
|
||||
* for this mode.
|
||||
*
|
||||
* Two sub-scenarios of this mode are to:
|
||||
*
|
||||
* Create dependency files in the same invocation of the tool that
|
||||
* creates the tool's build artifact - by adding additional options
|
||||
* to the tool invocation command line.
|
||||
*
|
||||
* Create dependency files in a separate invocation of the tool, or
|
||||
* by the invocation of another tool.
|
||||
*
|
||||
* MBS can also help in the generation of the dependency files. Prior to
|
||||
* CDT 3.1, MBS and gcc cooperated in generating dependency files using the
|
||||
* following steps:
|
||||
*
|
||||
* 1. Gcc is invoked to perform the compilation that generates the object
|
||||
* file.
|
||||
*
|
||||
* 2. An "echo" command creates the .d file, adding the name of the .d
|
||||
* file to the beginning of the newly created .d file. Note that this
|
||||
* causes problems with some implementations of "echo" that don't
|
||||
* work exactly the way that we want (e.g., it doesn't support the -n
|
||||
* switch).
|
||||
|
||||
* 3. Gcc is invoked again with the appropriate additional command line
|
||||
* options to append its dependency file information to the .d file
|
||||
* that was created by "echo".
|
||||
*
|
||||
* 4. Steps 1 - 3 are invoked in the make file. Step 4 occurs after the
|
||||
* make invocation has finished. In step 4, MBS code post-processes
|
||||
* the .d files to add a dummy dependency for each header file, for
|
||||
* the reason explained in the link above.
|
||||
*
|
||||
* This mode is no longer used by the default gcc implementation, but can
|
||||
* still be used by selecting the DefaultGCCDependencyCalculator.
|
||||
*
|
||||
*
|
||||
* Note for GNU make: these separate dependency files are "include"d by
|
||||
* a main makefile. Therefore, if the dependency files are required to
|
||||
* be up to date before the main build begins, they must be updated by
|
||||
* a separate invocation of make. Also, the configuration "clean" step
|
||||
* must be invoked by a separate invocation of make. This is so that
|
||||
* we can exclude the dependency files for a "make clean" invocation
|
||||
* using syntax like:
|
||||
*
|
||||
* ifneq ($(MAKECMDGOALS), clean)
|
||||
* -include $(DEPS)
|
||||
* endif
|
||||
*
|
||||
* Otherwise, because GNU make attempts to re-make make files, we
|
||||
* can end up with out of date or missing dependency files being
|
||||
* re-generated and then immediately "clean"ed.
|
||||
*/
|
||||
|
||||
public interface IManagedDependencyCommands extends IManagedDependencyInfo {
|
||||
|
||||
/**
|
||||
* Returns the list of generated dependency files.
|
||||
*
|
||||
* The paths can be either relative to the top build directory, or absolute
|
||||
* in the file system.
|
||||
*
|
||||
* @return IPath[]
|
||||
*/
|
||||
public IPath[] getDependencyFiles();
|
||||
|
||||
/**
|
||||
* Returns the command lines to be invoked before the normal tool invocation
|
||||
* to calculate dependencies.
|
||||
*
|
||||
* @return String[] This can be null or an empty array if no dependency
|
||||
* generation command needs to be invoked before the normal
|
||||
* tool invocation.
|
||||
*/
|
||||
public String[] getPreToolDependencyCommands();
|
||||
|
||||
/**
|
||||
* Returns the command line options to be used to calculate dependencies.
|
||||
* The options are added to the normal tool invocation.
|
||||
*
|
||||
* @return String[] This can be null or an empty array if no additional
|
||||
* arguments need to be added to the tool invocation.
|
||||
* SHOULD THIS RETURN AN IOption[]?
|
||||
*/
|
||||
public String[] getDependencyCommandOptions();
|
||||
// IMPLEMENTATION NOTE: This should be called from addRuleFromSource for both resconfig & non-resconfig
|
||||
|
||||
/**
|
||||
* Returns the command lines to be invoked after the normal tool invocation
|
||||
* to calculate dependencies.
|
||||
*
|
||||
* @return String[] This can be null or an empty array if no dependency
|
||||
* generation commands needs to be invoked after the normal
|
||||
* tool invocation
|
||||
*/
|
||||
public String[] getPostToolDependencyCommands();
|
||||
|
||||
/**
|
||||
* Returns true if the command lines and/or options returned by this interface
|
||||
* are not specific to the particular source file, but are only specific to,
|
||||
* at most, the configuration and tool. If the build context is a resource
|
||||
* configuration, this method should return false if any of the command lines
|
||||
* and/or options are different than if the build context were the parent
|
||||
* configuration. This can be used by the build file generator in helping
|
||||
* to determine if a "pattern" (generic) rule can be used.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areCommandsGeneric();
|
||||
}
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
* @deprecated 3.1
|
||||
*
|
||||
* Use IManagedDependencyGenerator2 instead.
|
||||
*/
|
||||
public interface IManagedDependencyGenerator extends IManagedDependencyGeneratorType {
|
||||
|
||||
public IResource[] findDependencies(IResource resource, IProject project);
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info);
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
* @deprecated 3.1
|
||||
*
|
||||
* Use IManagedDependencyGenerator2 instead.
|
||||
*/
|
||||
public interface IManagedDependencyGenerator extends IManagedDependencyGeneratorType {
|
||||
|
||||
public IResource[] findDependencies(IResource resource, IProject project);
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info);
|
||||
}
|
||||
|
|
|
@ -1,114 +1,114 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation of IManagedDependencyGenerator
|
||||
* Intel - Initial API and implementation of IManagedDependencyGenerator2
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
|
||||
/**
|
||||
* @since 3.1
|
||||
*
|
||||
* A Tool dependency calculator must implement this interface. This interface
|
||||
* replaces IManagedDependencyGenerator which is deprecated.
|
||||
*
|
||||
* Discussion of Dependency Calculation:
|
||||
*
|
||||
* There are two major, and multiple minor, modes of dependency calculation
|
||||
* supported by the MBS. The major modes are:
|
||||
*
|
||||
* 1. The build file generator invokes tool integrator provided methods
|
||||
* that calculate all dependencies using whatever method the tool
|
||||
* integrator wants. The build file generator then adds the dependencies
|
||||
* to the build file using the appropriate build file syntax.
|
||||
* This is a TYPE_CUSTOM dependency calculator as defined below.
|
||||
* See the IManagedDependencyCalculator interface for more information.
|
||||
*
|
||||
* 2. The build file generator and the tool-chain cooperate in creating and
|
||||
* using separate "dependency" files. In this case, dependency calculation
|
||||
* is done at "build time", rather than at "build file generation time" as
|
||||
* in mode #1. This currently supports the GNU concept of using .d files
|
||||
* in GNU make.
|
||||
* This is either a TYPE_BUILD_COMMANDS dependency calculator or a
|
||||
* TYPE_PREBUILD_COMMANDS dependency calculator as defined below.
|
||||
* See the IManagedDependencyCommands and IManagedDependencyPreBuild
|
||||
* interfaces for more information.
|
||||
*
|
||||
*/
|
||||
|
||||
public interface IManagedDependencyGenerator2 extends IManagedDependencyGeneratorType {
|
||||
|
||||
/**
|
||||
* Returns an instance of IManagedDependencyInfo for this source file.
|
||||
* IManagedDependencyCalculator, IManagedDependencyCommands
|
||||
* and IManagedDependencyPreBuild are all derived from
|
||||
* IManagedDependencyInfo, and any one of the three can be returned.
|
||||
* This is called when getCalculatorType returns TYPE_BUILD_COMMANDS,
|
||||
* TYPE_CUSTOM or TYPE_PREBUILD_COMMANDS.
|
||||
*
|
||||
* @param source The source file for which dependencies should be calculated
|
||||
* The IPath can be either relative to the project directory, or absolute in the file system.
|
||||
* @param buildContext The IConfiguration or IResourceConfiguration that
|
||||
* contains the context in which the source file will be built
|
||||
* @param tool The tool associated with the source file
|
||||
* @param topBuildDirectory The top build directory of the configuration. This is
|
||||
* the working directory for the tool. This IPath is relative to the project directory.
|
||||
* @return IManagedDependencyInfo
|
||||
*/
|
||||
public IManagedDependencyInfo getDependencySourceInfo(
|
||||
IPath source,
|
||||
IBuildObject buildContext,
|
||||
ITool tool,
|
||||
IPath topBuildDirectory);
|
||||
|
||||
/**
|
||||
* Returns the file extension used by dependency files created
|
||||
* by this dependency generator.
|
||||
* This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or
|
||||
* TYPE_PREBUILD_COMMANDS.
|
||||
*
|
||||
* @param buildContext The IConfiguration that contains the context of the build
|
||||
* @param tool The tool associated with the dependency generator.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getDependencyFileExtension(
|
||||
IConfiguration buildContext,
|
||||
ITool tool);
|
||||
|
||||
/**
|
||||
* Called to allow the dependency calculator to post-process dependency files.
|
||||
* This method is called after the build has completed for at least every
|
||||
* dependency file that has changed, and possibly for those that have not
|
||||
* changed as well. It may also be called with dependency files created by
|
||||
* another tool. This method should be able to recognize dependency files
|
||||
* that don't belong to it, or that it has already post-processed.
|
||||
* This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or
|
||||
* TYPE_PREBUILD_COMMANDS.
|
||||
*
|
||||
* @param dependencyFile The dependency file
|
||||
* The IPath can be either relative to the top build directory, or absolute in the file system.
|
||||
* @param buildContext The IConfiguration that contains the context of the build
|
||||
* @param tool The tool associated with the dependency generator. Note that this is
|
||||
* not necessarily the tool that created the dependency file
|
||||
* @param topBuildDirectory The top build directory of the project. This is
|
||||
* the working directory for the tool.
|
||||
*
|
||||
* @return boolean True if the method modified the dependency (e.g., .d) file
|
||||
*/
|
||||
public boolean postProcessDependencyFile(
|
||||
IPath dependencyFile,
|
||||
IConfiguration buildContext,
|
||||
ITool tool,
|
||||
IPath topBuildDirectory);
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation of IManagedDependencyGenerator
|
||||
* Intel - Initial API and implementation of IManagedDependencyGenerator2
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
|
||||
/**
|
||||
* @since 3.1
|
||||
*
|
||||
* A Tool dependency calculator must implement this interface. This interface
|
||||
* replaces IManagedDependencyGenerator which is deprecated.
|
||||
*
|
||||
* Discussion of Dependency Calculation:
|
||||
*
|
||||
* There are two major, and multiple minor, modes of dependency calculation
|
||||
* supported by the MBS. The major modes are:
|
||||
*
|
||||
* 1. The build file generator invokes tool integrator provided methods
|
||||
* that calculate all dependencies using whatever method the tool
|
||||
* integrator wants. The build file generator then adds the dependencies
|
||||
* to the build file using the appropriate build file syntax.
|
||||
* This is a TYPE_CUSTOM dependency calculator as defined below.
|
||||
* See the IManagedDependencyCalculator interface for more information.
|
||||
*
|
||||
* 2. The build file generator and the tool-chain cooperate in creating and
|
||||
* using separate "dependency" files. In this case, dependency calculation
|
||||
* is done at "build time", rather than at "build file generation time" as
|
||||
* in mode #1. This currently supports the GNU concept of using .d files
|
||||
* in GNU make.
|
||||
* This is either a TYPE_BUILD_COMMANDS dependency calculator or a
|
||||
* TYPE_PREBUILD_COMMANDS dependency calculator as defined below.
|
||||
* See the IManagedDependencyCommands and IManagedDependencyPreBuild
|
||||
* interfaces for more information.
|
||||
*
|
||||
*/
|
||||
|
||||
public interface IManagedDependencyGenerator2 extends IManagedDependencyGeneratorType {
|
||||
|
||||
/**
|
||||
* Returns an instance of IManagedDependencyInfo for this source file.
|
||||
* IManagedDependencyCalculator, IManagedDependencyCommands
|
||||
* and IManagedDependencyPreBuild are all derived from
|
||||
* IManagedDependencyInfo, and any one of the three can be returned.
|
||||
* This is called when getCalculatorType returns TYPE_BUILD_COMMANDS,
|
||||
* TYPE_CUSTOM or TYPE_PREBUILD_COMMANDS.
|
||||
*
|
||||
* @param source The source file for which dependencies should be calculated
|
||||
* The IPath can be either relative to the project directory, or absolute in the file system.
|
||||
* @param buildContext The IConfiguration or IResourceConfiguration that
|
||||
* contains the context in which the source file will be built
|
||||
* @param tool The tool associated with the source file
|
||||
* @param topBuildDirectory The top build directory of the configuration. This is
|
||||
* the working directory for the tool. This IPath is relative to the project directory.
|
||||
* @return IManagedDependencyInfo
|
||||
*/
|
||||
public IManagedDependencyInfo getDependencySourceInfo(
|
||||
IPath source,
|
||||
IBuildObject buildContext,
|
||||
ITool tool,
|
||||
IPath topBuildDirectory);
|
||||
|
||||
/**
|
||||
* Returns the file extension used by dependency files created
|
||||
* by this dependency generator.
|
||||
* This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or
|
||||
* TYPE_PREBUILD_COMMANDS.
|
||||
*
|
||||
* @param buildContext The IConfiguration that contains the context of the build
|
||||
* @param tool The tool associated with the dependency generator.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getDependencyFileExtension(
|
||||
IConfiguration buildContext,
|
||||
ITool tool);
|
||||
|
||||
/**
|
||||
* Called to allow the dependency calculator to post-process dependency files.
|
||||
* This method is called after the build has completed for at least every
|
||||
* dependency file that has changed, and possibly for those that have not
|
||||
* changed as well. It may also be called with dependency files created by
|
||||
* another tool. This method should be able to recognize dependency files
|
||||
* that don't belong to it, or that it has already post-processed.
|
||||
* This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or
|
||||
* TYPE_PREBUILD_COMMANDS.
|
||||
*
|
||||
* @param dependencyFile The dependency file
|
||||
* The IPath can be either relative to the top build directory, or absolute in the file system.
|
||||
* @param buildContext The IConfiguration that contains the context of the build
|
||||
* @param tool The tool associated with the dependency generator. Note that this is
|
||||
* not necessarily the tool that created the dependency file
|
||||
* @param topBuildDirectory The top build directory of the project. This is
|
||||
* the working directory for the tool.
|
||||
*
|
||||
* @return boolean True if the method modified the dependency (e.g., .d) file
|
||||
*/
|
||||
public boolean postProcessDependencyFile(
|
||||
IPath dependencyFile,
|
||||
IConfiguration buildContext,
|
||||
ITool tool,
|
||||
IPath topBuildDirectory);
|
||||
}
|
||||
|
|
|
@ -1,87 +1,87 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
/**
|
||||
* @since 3.1
|
||||
*
|
||||
* IManagedDependencyGenerator (deprecated) and IManagedDependencyGenerator2
|
||||
* extend this interface.
|
||||
*
|
||||
* Discussion of Dependency Calculation:
|
||||
*
|
||||
* There are two major, and multiple minor, modes of dependency calculation
|
||||
* supported by the MBS. The major modes are:
|
||||
*
|
||||
* 1. The build file generator invokes tool integrator provided methods
|
||||
* that calculate all dependencies using whatever method the tool
|
||||
* integrator wants. The build file generator then adds the dependencies
|
||||
* to the build file using the appropriate build file syntax.
|
||||
* This is a TYPE_CUSTOM dependency calculator as defined below.
|
||||
* See the IManagedDependencyCalculator interface for more information.
|
||||
*
|
||||
* 2. The build file generator and the tool-chain cooperate in creating and
|
||||
* using separate "dependency" files. In this case, dependency calculation
|
||||
* is done at "build time", rather than at "build file generation time" as
|
||||
* in mode #1. This currently supports the GNU concept of using .d files
|
||||
* in GNU make.
|
||||
* This is either a TYPE_BUILD_COMMANDS dependency calculator or a
|
||||
* TYPE_PREBUILD_COMMANDS dependency calculator as defined below.
|
||||
* See the IManagedDependencyCommands and IManagedDependencyPreBuild
|
||||
* interfaces for more information.
|
||||
*
|
||||
*/
|
||||
|
||||
public interface IManagedDependencyGeneratorType {
|
||||
/**
|
||||
* Constants returned by getCalculatorType
|
||||
*/
|
||||
public int TYPE_NODEPS = 0; // Deprecated - use TYPE_NODEPENDENCIES
|
||||
public int TYPE_COMMAND = 1; // Deprecated - use TYPE_BUILD_COMMANDS
|
||||
public int TYPE_INDEXER = 2; // Deprecated - use TYPE_CUSTOM
|
||||
public int TYPE_EXTERNAL = 3; // Deprecated - use TYPE_CUSTOM
|
||||
public int TYPE_OLD_TYPE_LIMIT = 3;
|
||||
|
||||
// Use these types
|
||||
public int TYPE_NODEPENDENCIES = 4;
|
||||
public int TYPE_BUILD_COMMANDS = 5;
|
||||
public int TYPE_PREBUILD_COMMANDS = 6;
|
||||
public int TYPE_CUSTOM = 7;
|
||||
|
||||
/**
|
||||
* Returns the type of dependency generator that is implemented.
|
||||
*
|
||||
* TYPE_NODEPENDENCIES indicates that no dependency generator is
|
||||
* supplied or needed.
|
||||
* TYPE_CUSTOM indicates that a custom, "build file generation time"
|
||||
* dependency calculator is implemented. Note that the dependency
|
||||
* calculator will be called when the makefile is generated, and
|
||||
* for every source file that is built by this tool in the build
|
||||
* file, not just for those that have changed since the last build
|
||||
* file generation.
|
||||
* TYPE_BUILD_COMMANDS indicates that command lines or options will
|
||||
* be returned to be used to calculate dependencies. These
|
||||
* commands/options are added to the build file to perform dependency
|
||||
* calculation at "build time". This currently supports
|
||||
* compilers/tools that generate .d files either as a
|
||||
* side-effect of tool invocation, or as a separate step that is
|
||||
* invoked immediately before or after the tool invocation.
|
||||
* TYPE_PREBUILD_COMMANDS indicates that a separate build step is
|
||||
* invoked, prior to the the normal build steps, to update the
|
||||
* dependency information. These commands are added to the build
|
||||
* file to perform dependency calculation at "build time". Note
|
||||
* that this step will be invoked every time a build is done in
|
||||
* order to determine if dependency files need to be re-generated.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getCalculatorType();
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
/**
|
||||
* @since 3.1
|
||||
*
|
||||
* IManagedDependencyGenerator (deprecated) and IManagedDependencyGenerator2
|
||||
* extend this interface.
|
||||
*
|
||||
* Discussion of Dependency Calculation:
|
||||
*
|
||||
* There are two major, and multiple minor, modes of dependency calculation
|
||||
* supported by the MBS. The major modes are:
|
||||
*
|
||||
* 1. The build file generator invokes tool integrator provided methods
|
||||
* that calculate all dependencies using whatever method the tool
|
||||
* integrator wants. The build file generator then adds the dependencies
|
||||
* to the build file using the appropriate build file syntax.
|
||||
* This is a TYPE_CUSTOM dependency calculator as defined below.
|
||||
* See the IManagedDependencyCalculator interface for more information.
|
||||
*
|
||||
* 2. The build file generator and the tool-chain cooperate in creating and
|
||||
* using separate "dependency" files. In this case, dependency calculation
|
||||
* is done at "build time", rather than at "build file generation time" as
|
||||
* in mode #1. This currently supports the GNU concept of using .d files
|
||||
* in GNU make.
|
||||
* This is either a TYPE_BUILD_COMMANDS dependency calculator or a
|
||||
* TYPE_PREBUILD_COMMANDS dependency calculator as defined below.
|
||||
* See the IManagedDependencyCommands and IManagedDependencyPreBuild
|
||||
* interfaces for more information.
|
||||
*
|
||||
*/
|
||||
|
||||
public interface IManagedDependencyGeneratorType {
|
||||
/**
|
||||
* Constants returned by getCalculatorType
|
||||
*/
|
||||
public int TYPE_NODEPS = 0; // Deprecated - use TYPE_NODEPENDENCIES
|
||||
public int TYPE_COMMAND = 1; // Deprecated - use TYPE_BUILD_COMMANDS
|
||||
public int TYPE_INDEXER = 2; // Deprecated - use TYPE_CUSTOM
|
||||
public int TYPE_EXTERNAL = 3; // Deprecated - use TYPE_CUSTOM
|
||||
public int TYPE_OLD_TYPE_LIMIT = 3;
|
||||
|
||||
// Use these types
|
||||
public int TYPE_NODEPENDENCIES = 4;
|
||||
public int TYPE_BUILD_COMMANDS = 5;
|
||||
public int TYPE_PREBUILD_COMMANDS = 6;
|
||||
public int TYPE_CUSTOM = 7;
|
||||
|
||||
/**
|
||||
* Returns the type of dependency generator that is implemented.
|
||||
*
|
||||
* TYPE_NODEPENDENCIES indicates that no dependency generator is
|
||||
* supplied or needed.
|
||||
* TYPE_CUSTOM indicates that a custom, "build file generation time"
|
||||
* dependency calculator is implemented. Note that the dependency
|
||||
* calculator will be called when the makefile is generated, and
|
||||
* for every source file that is built by this tool in the build
|
||||
* file, not just for those that have changed since the last build
|
||||
* file generation.
|
||||
* TYPE_BUILD_COMMANDS indicates that command lines or options will
|
||||
* be returned to be used to calculate dependencies. These
|
||||
* commands/options are added to the build file to perform dependency
|
||||
* calculation at "build time". This currently supports
|
||||
* compilers/tools that generate .d files either as a
|
||||
* side-effect of tool invocation, or as a separate step that is
|
||||
* invoked immediately before or after the tool invocation.
|
||||
* TYPE_PREBUILD_COMMANDS indicates that a separate build step is
|
||||
* invoked, prior to the the normal build steps, to update the
|
||||
* dependency information. These commands are added to the build
|
||||
* file to perform dependency calculation at "build time". Note
|
||||
* that this step will be invoked every time a build is done in
|
||||
* order to determine if dependency files need to be re-generated.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getCalculatorType();
|
||||
}
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* @since 3.1
|
||||
*
|
||||
* This interface is the base interface for IManagedDependencyCalculator,
|
||||
* IManagedDependencyCommands and IManagedDependencyPreBuild. See these
|
||||
* interfaces and IManagedDependencyGenerator2 for more information on
|
||||
* writing a dependency calculator.
|
||||
*
|
||||
* The methods below simply return the arguments passed to the
|
||||
* IManagedDependencyGenerator2.getDependency*Info call that created the
|
||||
* IManagedDependencyInfo instance.
|
||||
*
|
||||
*/
|
||||
public interface IManagedDependencyInfo {
|
||||
public IPath getSource();
|
||||
public IBuildObject getBuildContext();
|
||||
public ITool getTool();
|
||||
public IPath getTopBuildDirectory();
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* @since 3.1
|
||||
*
|
||||
* This interface is the base interface for IManagedDependencyCalculator,
|
||||
* IManagedDependencyCommands and IManagedDependencyPreBuild. See these
|
||||
* interfaces and IManagedDependencyGenerator2 for more information on
|
||||
* writing a dependency calculator.
|
||||
*
|
||||
* The methods below simply return the arguments passed to the
|
||||
* IManagedDependencyGenerator2.getDependency*Info call that created the
|
||||
* IManagedDependencyInfo instance.
|
||||
*
|
||||
*/
|
||||
public interface IManagedDependencyInfo {
|
||||
public IPath getSource();
|
||||
public IBuildObject getBuildContext();
|
||||
public ITool getTool();
|
||||
public IPath getTopBuildDirectory();
|
||||
}
|
||||
|
|
|
@ -1,136 +1,136 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* @since 3.1
|
||||
*
|
||||
* A Tool dependency calculator may implement this interface or
|
||||
* IManagedDependencyCalculator or IManagedDependencyCommands.
|
||||
* An object implementing the interface is returned from a call to
|
||||
* IManagedDependencyGenerator2.getDependencySourceInfo.
|
||||
*
|
||||
* Discussion of Dependency Calculation:
|
||||
*
|
||||
* There are two major, and multiple minor, modes of dependency calculation
|
||||
* supported by the MBS. The major modes are:
|
||||
*
|
||||
* 1. The build file generator invokes tool integrator provided methods
|
||||
* that calculate all dependencies using whatever method the tool
|
||||
* integrator wants. The build file generator then adds the dependencies
|
||||
* to the build file using the appropriate build file syntax.
|
||||
* See the IManagedDependencyCalculator interface for more information.
|
||||
*
|
||||
* 2. The build file generator and the tool-chain cooperate in creating and
|
||||
* using separate "dependency" files. The build file generator calls
|
||||
* the dependency calculator to get the dependency file names and to get
|
||||
* commands that need to be added to the build file. In this case,
|
||||
* dependency calculation is done at "build time", rather than at
|
||||
* "build file generation time" as in mode #1. This currently
|
||||
* supports the GNU concept of using .d files in GNU make.
|
||||
*
|
||||
* There are multiple ways that these separate dependency files can
|
||||
* be created by the tool-chain and used by the builder.
|
||||
*
|
||||
* a. In some cases (e.g., Fortran 90 using modules) the dependency files
|
||||
* must be created/updated prior to invoking the build of the project
|
||||
* artifact (e.g., an application). In this case, the dependency
|
||||
* generation step must occur separately before the main build.
|
||||
* Use the IManagedDependencyPreBuild interface defined in this file
|
||||
* for this mode.
|
||||
*
|
||||
* b. In other cases (e.g., C/C++) the dependency files can be created as
|
||||
* a side effect of the main build. This implies that the up to date
|
||||
* dependency files are not required for the current build, but for
|
||||
* the next build. C/C++ builds can be treated in this manner as is
|
||||
* described in the following link:
|
||||
* http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution
|
||||
*
|
||||
* See the IManagedDependencyCommands interface for more information.
|
||||
*
|
||||
*
|
||||
* Note for GNU make: these separate dependency files are "include"d by
|
||||
* a main makefile. Make performs special processing on make files:
|
||||
*
|
||||
* "To this end, after reading in all makefiles, make will consider
|
||||
* each as a goal target and attempt to update it. If a makefile has a
|
||||
* rule which says how to update it (found either in that very
|
||||
* makefile or in another one)..., it will be updated if necessary.
|
||||
* After all makefiles have been checked, if any have actually been
|
||||
* changed, make starts with a clean slate and reads all the makefiles
|
||||
* over again."
|
||||
*
|
||||
* We can use this to ensure that the dependency files are up to date
|
||||
* by adding rules to the make file for generating the dependency files.
|
||||
* These rules are returned by the call to getDependencyCommands.
|
||||
* However, this has a significant problem when we don’t want to build
|
||||
* the build target, but only want to “clean” the configuration,
|
||||
* for example. If we invoke make just to clean the configuration,
|
||||
* make will still update the dependency files if necessary, thereby
|
||||
* re-generating the dependency files only to immediately delete them.
|
||||
* The workaround suggested by the make documentation is to check for
|
||||
* an invocation using the “clean” target, and to not include the
|
||||
* dependency files it that case. For example,
|
||||
*
|
||||
* ifneq ($(MAKECMDGOALS),clean)
|
||||
* include $(DEPS)
|
||||
* endif
|
||||
*
|
||||
* The restriction with this is that it only works if “clean” is the only
|
||||
* target specified on the make command line. Therefore, the build
|
||||
* "clean" step must be invoked separately.
|
||||
*/
|
||||
|
||||
public interface IManagedDependencyPreBuild extends IManagedDependencyInfo {
|
||||
|
||||
/**
|
||||
* Returns the list of generated dependency files.
|
||||
*
|
||||
* The paths can be either relative to the top build directory, or absolute
|
||||
* in the file system.
|
||||
*
|
||||
* @return IPath[]
|
||||
*/
|
||||
public IPath[] getDependencyFiles();
|
||||
|
||||
/**
|
||||
* Returns the name to be used in the build file to identify the separate
|
||||
* build step. Note that this name should be unique to the tool since
|
||||
* multiple tools in a tool-chain may be using this method of
|
||||
* dependency calculation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getBuildStepName();
|
||||
|
||||
/**
|
||||
* Returns the command line(s) to be invoked in the separate
|
||||
* dependencies pre-build step.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getDependencyCommands();
|
||||
|
||||
/**
|
||||
* Returns true if the command lines returned by this interface
|
||||
* are not specific to the particular source file, but are only specific to,
|
||||
* at most, the configuration and tool. If the build context is a resource
|
||||
* configuration, this method should return false if any of the command lines
|
||||
* are different than if the build context were the parent configuration.
|
||||
* This can be used by the build file generator in helping to determine if
|
||||
* a "pattern" (generic) rule can be used.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areCommandsGeneric();
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* @since 3.1
|
||||
*
|
||||
* A Tool dependency calculator may implement this interface or
|
||||
* IManagedDependencyCalculator or IManagedDependencyCommands.
|
||||
* An object implementing the interface is returned from a call to
|
||||
* IManagedDependencyGenerator2.getDependencySourceInfo.
|
||||
*
|
||||
* Discussion of Dependency Calculation:
|
||||
*
|
||||
* There are two major, and multiple minor, modes of dependency calculation
|
||||
* supported by the MBS. The major modes are:
|
||||
*
|
||||
* 1. The build file generator invokes tool integrator provided methods
|
||||
* that calculate all dependencies using whatever method the tool
|
||||
* integrator wants. The build file generator then adds the dependencies
|
||||
* to the build file using the appropriate build file syntax.
|
||||
* See the IManagedDependencyCalculator interface for more information.
|
||||
*
|
||||
* 2. The build file generator and the tool-chain cooperate in creating and
|
||||
* using separate "dependency" files. The build file generator calls
|
||||
* the dependency calculator to get the dependency file names and to get
|
||||
* commands that need to be added to the build file. In this case,
|
||||
* dependency calculation is done at "build time", rather than at
|
||||
* "build file generation time" as in mode #1. This currently
|
||||
* supports the GNU concept of using .d files in GNU make.
|
||||
*
|
||||
* There are multiple ways that these separate dependency files can
|
||||
* be created by the tool-chain and used by the builder.
|
||||
*
|
||||
* a. In some cases (e.g., Fortran 90 using modules) the dependency files
|
||||
* must be created/updated prior to invoking the build of the project
|
||||
* artifact (e.g., an application). In this case, the dependency
|
||||
* generation step must occur separately before the main build.
|
||||
* Use the IManagedDependencyPreBuild interface defined in this file
|
||||
* for this mode.
|
||||
*
|
||||
* b. In other cases (e.g., C/C++) the dependency files can be created as
|
||||
* a side effect of the main build. This implies that the up to date
|
||||
* dependency files are not required for the current build, but for
|
||||
* the next build. C/C++ builds can be treated in this manner as is
|
||||
* described in the following link:
|
||||
* http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution
|
||||
*
|
||||
* See the IManagedDependencyCommands interface for more information.
|
||||
*
|
||||
*
|
||||
* Note for GNU make: these separate dependency files are "include"d by
|
||||
* a main makefile. Make performs special processing on make files:
|
||||
*
|
||||
* "To this end, after reading in all makefiles, make will consider
|
||||
* each as a goal target and attempt to update it. If a makefile has a
|
||||
* rule which says how to update it (found either in that very
|
||||
* makefile or in another one)..., it will be updated if necessary.
|
||||
* After all makefiles have been checked, if any have actually been
|
||||
* changed, make starts with a clean slate and reads all the makefiles
|
||||
* over again."
|
||||
*
|
||||
* We can use this to ensure that the dependency files are up to date
|
||||
* by adding rules to the make file for generating the dependency files.
|
||||
* These rules are returned by the call to getDependencyCommands.
|
||||
* However, this has a significant problem when we don�t want to build
|
||||
* the build target, but only want to �clean� the configuration,
|
||||
* for example. If we invoke make just to clean the configuration,
|
||||
* make will still update the dependency files if necessary, thereby
|
||||
* re-generating the dependency files only to immediately delete them.
|
||||
* The workaround suggested by the make documentation is to check for
|
||||
* an invocation using the �clean� target, and to not include the
|
||||
* dependency files it that case. For example,
|
||||
*
|
||||
* ifneq ($(MAKECMDGOALS),clean)
|
||||
* include $(DEPS)
|
||||
* endif
|
||||
*
|
||||
* The restriction with this is that it only works if �clean� is the only
|
||||
* target specified on the make command line. Therefore, the build
|
||||
* "clean" step must be invoked separately.
|
||||
*/
|
||||
|
||||
public interface IManagedDependencyPreBuild extends IManagedDependencyInfo {
|
||||
|
||||
/**
|
||||
* Returns the list of generated dependency files.
|
||||
*
|
||||
* The paths can be either relative to the top build directory, or absolute
|
||||
* in the file system.
|
||||
*
|
||||
* @return IPath[]
|
||||
*/
|
||||
public IPath[] getDependencyFiles();
|
||||
|
||||
/**
|
||||
* Returns the name to be used in the build file to identify the separate
|
||||
* build step. Note that this name should be unique to the tool since
|
||||
* multiple tools in a tool-chain may be using this method of
|
||||
* dependency calculation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getBuildStepName();
|
||||
|
||||
/**
|
||||
* Returns the command line(s) to be invoked in the separate
|
||||
* dependencies pre-build step.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getDependencyCommands();
|
||||
|
||||
/**
|
||||
* Returns true if the command lines returned by this interface
|
||||
* are not specific to the particular source file, but are only specific to,
|
||||
* at most, the configuration and tool. If the build context is a resource
|
||||
* configuration, this method should return false if any of the command lines
|
||||
* are different than if the build context were the parent configuration.
|
||||
* This can be used by the build file generator in helping to determine if
|
||||
* a "pattern" (generic) rule can be used.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areCommandsGeneric();
|
||||
}
|
||||
|
|
|
@ -1,300 +1,300 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
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.IManagedCommandLineGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
|
||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerator {
|
||||
|
||||
private static final String EMPTY_STRING = new String();
|
||||
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
public final String WHITESPACE = " "; //$NON-NLS-1$
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
public IResource[] findDependencies(IResource resource, IProject project) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
return TYPE_COMMAND;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
|
||||
*/
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
|
||||
/*
|
||||
* For a given input, <path>/<resource_name>.<ext>, return a string containing
|
||||
* echo -n $(@:%.<out_ext>=%.d) '<path>/' >> $(@:%.<out_ext>=%.d) && \
|
||||
* <tool_command> -P -MM -MG <tool_flags> $< >> $(@:%.<out_ext>=%.d)
|
||||
*
|
||||
*/
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
// Get what we need to create the dependency generation command
|
||||
IConfiguration config = info.getDefaultConfiguration();
|
||||
|
||||
// We need to check whether we have any resource specific build information.
|
||||
IResourceConfiguration resConfig = null;
|
||||
if( config != null ) resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
|
||||
|
||||
String inputExtension = resource.getFileExtension();
|
||||
String outputExtension = info.getOutputExtension(inputExtension);
|
||||
|
||||
// Work out the build-relative path for the output files
|
||||
IContainer resourceLocation = resource.getParent();
|
||||
String relativePath = new String();
|
||||
if (resourceLocation != null) {
|
||||
relativePath += resourceLocation.getProjectRelativePath().toString();
|
||||
}
|
||||
if (relativePath.length() > 0) {
|
||||
relativePath += IManagedBuilderMakefileGenerator.SEPARATOR;
|
||||
}
|
||||
|
||||
// Calculate the dependency rule
|
||||
// <path>/$(@:%.<out_ext>=%.d)
|
||||
String depRule = "'$(@:%." + //$NON-NLS-1$
|
||||
outputExtension +
|
||||
"=%." + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.DEP_EXT +
|
||||
")'"; //$NON-NLS-1$
|
||||
|
||||
// Add the rule that will actually create the right format for the dep
|
||||
buffer.append(IManagedBuilderMakefileGenerator.TAB +
|
||||
IManagedBuilderMakefileGenerator.ECHO +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"-n" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
depRule +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"$(dir $@)" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
">" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
depRule +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
IManagedBuilderMakefileGenerator.LOGICAL_AND +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
IManagedBuilderMakefileGenerator.LINEBREAK);
|
||||
|
||||
// Add the line that will do the work to calculate dependencies
|
||||
IManagedCommandLineInfo cmdLInfo = null;
|
||||
String buildCmd = null;
|
||||
String[] inputs= new String[1]; inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO;
|
||||
String outflag = ""; //$NON-NLS-1$
|
||||
String outputPrefix = ""; //$NON-NLS-1$
|
||||
String outputFile = ""; //$NON-NLS-1$
|
||||
ITool[] tools;
|
||||
if( resConfig != null && (tools = resConfig.getToolsToInvoke()) != null && tools.length > 0) {
|
||||
ITool tool = tools[0];
|
||||
String cmd = tool.getToolCommand();
|
||||
//try to resolve the build macros in the tool command
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
// does the resource have spaces in its name?
|
||||
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
|
||||
// use fully qualified strings
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
cmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
cmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
}
|
||||
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
String[] toolFlags = null;
|
||||
try {
|
||||
toolFlags = tool.getToolCommandFlags(resource.getLocation(),null);
|
||||
} catch( BuildException ex ) {
|
||||
// TODO add some routines to catch this
|
||||
toolFlags = EMPTY_STRING_ARRAY;
|
||||
}
|
||||
String[] flags = new String[toolFlags.length + 4];
|
||||
flags[0] = "-MM"; //$NON-NLS-1$
|
||||
flags[1] = "-MG"; //$NON-NLS-1$
|
||||
flags[2] = "-P"; //$NON-NLS-1$
|
||||
flags[3] = "-w"; //$NON-NLS-1$
|
||||
for (int i=0; i<toolFlags.length; i++) {
|
||||
flags[4+i] = toolFlags[i];
|
||||
}
|
||||
IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
|
||||
cmdLInfo = cmdLGen.generateCommandLineInfo( tool, cmd, flags, outflag, outputPrefix,
|
||||
outputFile, inputs, tool.getCommandLinePattern() );
|
||||
buildCmd = cmdLInfo.getCommandLine();
|
||||
|
||||
// resolve any remaining macros in the command after it has been generated
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
// does the resource have spaces in its name?
|
||||
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
|
||||
// use fully qualified strings
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
}
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
buildCmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
ITool tool = null;
|
||||
tools = config.getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tmp = tools[index];
|
||||
if (tmp.buildsFileType(inputExtension)) {
|
||||
tool = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String cmd = tool != null ? tool.getToolCommand() : null;
|
||||
|
||||
//try to resolve the build macros in the tool command
|
||||
try{
|
||||
String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(cmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),null,null,tool));
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
String buildFlags = "-MM -MG -P -w " + info.getToolFlagsForSource(inputExtension, resource.getLocation(), null); //$NON-NLS-1$
|
||||
String[] flags = buildFlags.split( "\\s" ); //$NON-NLS-1$
|
||||
cmdLInfo = info.generateToolCommandLineInfo( inputExtension, flags, outflag, outputPrefix,
|
||||
outputFile, inputs, resource.getLocation(), null);
|
||||
// The command to build
|
||||
if( cmdLInfo == null ) buildCmd =
|
||||
cmd +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"-MM -MG -P -w " + //$NON-NLS-1$
|
||||
buildFlags +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
IManagedBuilderMakefileGenerator.IN_MACRO;
|
||||
else {
|
||||
buildCmd = cmdLInfo.getCommandLine();
|
||||
}
|
||||
|
||||
// resolve any remaining macros in the command after it has been
|
||||
// generated
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
// does the resource have spaces in its name?
|
||||
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
|
||||
// use fully qualified strings
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
}
|
||||
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
buildCmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e) {
|
||||
}
|
||||
}
|
||||
|
||||
buffer.append(IManagedBuilderMakefileGenerator.TAB +
|
||||
buildCmd +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
">>" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE + depRule );
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
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.IManagedCommandLineGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
|
||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerator {
|
||||
|
||||
private static final String EMPTY_STRING = new String();
|
||||
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
public final String WHITESPACE = " "; //$NON-NLS-1$
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
public IResource[] findDependencies(IResource resource, IProject project) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
return TYPE_COMMAND;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
|
||||
*/
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
|
||||
/*
|
||||
* For a given input, <path>/<resource_name>.<ext>, return a string containing
|
||||
* echo -n $(@:%.<out_ext>=%.d) '<path>/' >> $(@:%.<out_ext>=%.d) && \
|
||||
* <tool_command> -P -MM -MG <tool_flags> $< >> $(@:%.<out_ext>=%.d)
|
||||
*
|
||||
*/
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
// Get what we need to create the dependency generation command
|
||||
IConfiguration config = info.getDefaultConfiguration();
|
||||
|
||||
// We need to check whether we have any resource specific build information.
|
||||
IResourceConfiguration resConfig = null;
|
||||
if( config != null ) resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
|
||||
|
||||
String inputExtension = resource.getFileExtension();
|
||||
String outputExtension = info.getOutputExtension(inputExtension);
|
||||
|
||||
// Work out the build-relative path for the output files
|
||||
IContainer resourceLocation = resource.getParent();
|
||||
String relativePath = new String();
|
||||
if (resourceLocation != null) {
|
||||
relativePath += resourceLocation.getProjectRelativePath().toString();
|
||||
}
|
||||
if (relativePath.length() > 0) {
|
||||
relativePath += IManagedBuilderMakefileGenerator.SEPARATOR;
|
||||
}
|
||||
|
||||
// Calculate the dependency rule
|
||||
// <path>/$(@:%.<out_ext>=%.d)
|
||||
String depRule = "'$(@:%." + //$NON-NLS-1$
|
||||
outputExtension +
|
||||
"=%." + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.DEP_EXT +
|
||||
")'"; //$NON-NLS-1$
|
||||
|
||||
// Add the rule that will actually create the right format for the dep
|
||||
buffer.append(IManagedBuilderMakefileGenerator.TAB +
|
||||
IManagedBuilderMakefileGenerator.ECHO +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"-n" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
depRule +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"$(dir $@)" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
">" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
depRule +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
IManagedBuilderMakefileGenerator.LOGICAL_AND +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
IManagedBuilderMakefileGenerator.LINEBREAK);
|
||||
|
||||
// Add the line that will do the work to calculate dependencies
|
||||
IManagedCommandLineInfo cmdLInfo = null;
|
||||
String buildCmd = null;
|
||||
String[] inputs= new String[1]; inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO;
|
||||
String outflag = ""; //$NON-NLS-1$
|
||||
String outputPrefix = ""; //$NON-NLS-1$
|
||||
String outputFile = ""; //$NON-NLS-1$
|
||||
ITool[] tools;
|
||||
if( resConfig != null && (tools = resConfig.getToolsToInvoke()) != null && tools.length > 0) {
|
||||
ITool tool = tools[0];
|
||||
String cmd = tool.getToolCommand();
|
||||
//try to resolve the build macros in the tool command
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
// does the resource have spaces in its name?
|
||||
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
|
||||
// use fully qualified strings
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
cmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
cmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
}
|
||||
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
String[] toolFlags = null;
|
||||
try {
|
||||
toolFlags = tool.getToolCommandFlags(resource.getLocation(),null);
|
||||
} catch( BuildException ex ) {
|
||||
// TODO add some routines to catch this
|
||||
toolFlags = EMPTY_STRING_ARRAY;
|
||||
}
|
||||
String[] flags = new String[toolFlags.length + 4];
|
||||
flags[0] = "-MM"; //$NON-NLS-1$
|
||||
flags[1] = "-MG"; //$NON-NLS-1$
|
||||
flags[2] = "-P"; //$NON-NLS-1$
|
||||
flags[3] = "-w"; //$NON-NLS-1$
|
||||
for (int i=0; i<toolFlags.length; i++) {
|
||||
flags[4+i] = toolFlags[i];
|
||||
}
|
||||
IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
|
||||
cmdLInfo = cmdLGen.generateCommandLineInfo( tool, cmd, flags, outflag, outputPrefix,
|
||||
outputFile, inputs, tool.getCommandLinePattern() );
|
||||
buildCmd = cmdLInfo.getCommandLine();
|
||||
|
||||
// resolve any remaining macros in the command after it has been generated
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
// does the resource have spaces in its name?
|
||||
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
|
||||
// use fully qualified strings
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
}
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
buildCmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
ITool tool = null;
|
||||
tools = config.getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tmp = tools[index];
|
||||
if (tmp.buildsFileType(inputExtension)) {
|
||||
tool = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String cmd = tool != null ? tool.getToolCommand() : null;
|
||||
|
||||
//try to resolve the build macros in the tool command
|
||||
try{
|
||||
String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(cmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),null,null,tool));
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
String buildFlags = "-MM -MG -P -w " + info.getToolFlagsForSource(inputExtension, resource.getLocation(), null); //$NON-NLS-1$
|
||||
String[] flags = buildFlags.split( "\\s" ); //$NON-NLS-1$
|
||||
cmdLInfo = info.generateToolCommandLineInfo( inputExtension, flags, outflag, outputPrefix,
|
||||
outputFile, inputs, resource.getLocation(), null);
|
||||
// The command to build
|
||||
if( cmdLInfo == null ) buildCmd =
|
||||
cmd +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"-MM -MG -P -w " + //$NON-NLS-1$
|
||||
buildFlags +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
IManagedBuilderMakefileGenerator.IN_MACRO;
|
||||
else {
|
||||
buildCmd = cmdLInfo.getCommandLine();
|
||||
}
|
||||
|
||||
// resolve any remaining macros in the command after it has been
|
||||
// generated
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
// does the resource have spaces in its name?
|
||||
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
|
||||
// use fully qualified strings
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
}
|
||||
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
buildCmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e) {
|
||||
}
|
||||
}
|
||||
|
||||
buffer.append(IManagedBuilderMakefileGenerator.TAB +
|
||||
buildCmd +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
">>" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE + depRule );
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,70 +1,70 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* This dependency calculator uses the GCC -MMD -MF -MP -MT options in order to
|
||||
* generate .d files as a side effect of compilation.
|
||||
* See bugzilla 108715 for the discussion of dependency management that led to
|
||||
* the creation of this dependency calculator. Note also that this technique
|
||||
* exhibits the failure modes discussed in comment #5.
|
||||
*
|
||||
* This dependency calculator uses the class DefaultGCCDependencyCalculator2Commands
|
||||
* which implements the per-source command information
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
public class DefaultGCCDependencyCalculator2 implements
|
||||
IManagedDependencyGenerator2 {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
return TYPE_BUILD_COMMANDS;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencyFileExtension(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool)
|
||||
*/
|
||||
public String getDependencyFileExtension(IConfiguration buildContext, ITool tool) {
|
||||
return IManagedBuilderMakefileGenerator.DEP_EXT;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencySourceInfo(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
public IManagedDependencyInfo getDependencySourceInfo(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
return new DefaultGCCDependencyCalculator2Commands(source, buildContext, tool, topBuildDirectory);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#postProcessDependencyFile(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
public boolean postProcessDependencyFile(IPath dependencyFile, IConfiguration buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
// Nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* This dependency calculator uses the GCC -MMD -MF -MP -MT options in order to
|
||||
* generate .d files as a side effect of compilation.
|
||||
* See bugzilla 108715 for the discussion of dependency management that led to
|
||||
* the creation of this dependency calculator. Note also that this technique
|
||||
* exhibits the failure modes discussed in comment #5.
|
||||
*
|
||||
* This dependency calculator uses the class DefaultGCCDependencyCalculator2Commands
|
||||
* which implements the per-source command information
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
public class DefaultGCCDependencyCalculator2 implements
|
||||
IManagedDependencyGenerator2 {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
return TYPE_BUILD_COMMANDS;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencyFileExtension(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool)
|
||||
*/
|
||||
public String getDependencyFileExtension(IConfiguration buildContext, ITool tool) {
|
||||
return IManagedBuilderMakefileGenerator.DEP_EXT;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencySourceInfo(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
public IManagedDependencyInfo getDependencySourceInfo(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
return new DefaultGCCDependencyCalculator2Commands(source, buildContext, tool, topBuildDirectory);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#postProcessDependencyFile(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
public boolean postProcessDependencyFile(IPath dependencyFile, IConfiguration buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
// Nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,203 +1,203 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.resources.IProject;;
|
||||
|
||||
/**
|
||||
* This dependency calculator uses the GCC -MMD -MF -MP -MT options in order to
|
||||
* generate .d files as a side effect of compilation.
|
||||
* See bugzilla 108715 for the discussion of dependency management that led to
|
||||
* the creation of this dependency calculator. Note also that this technique
|
||||
* exhibits the failure modes discussed in comment #5.
|
||||
*
|
||||
* This class is used with DefaultGCCDependencyCalculator2.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
public class DefaultGCCDependencyCalculator2Commands implements
|
||||
IManagedDependencyCommands {
|
||||
|
||||
// Member variables set by the constructor
|
||||
IPath source;
|
||||
IBuildObject buildContext;
|
||||
ITool tool;
|
||||
IPath topBuildDirectory;
|
||||
|
||||
// Other Member variables
|
||||
IProject project;
|
||||
IPath sourceLocation;
|
||||
IPath outputLocation;
|
||||
boolean needExplicitRuleForFile;
|
||||
Boolean genericCommands = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source The source file for which dependencies should be calculated
|
||||
* The IPath can be either relative to the project directory, or absolute in the file system.
|
||||
* @param buildContext The IConfiguration or IResourceConfiguration that
|
||||
* contains the context in which the source file will be built
|
||||
* @param tool The tool associated with the source file
|
||||
* @param topBuildDirectory The top build directory of the configuration. This is
|
||||
* the working directory for the tool. This IPath is relative to the project directory.
|
||||
*/
|
||||
public DefaultGCCDependencyCalculator2Commands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
this.source = source;
|
||||
this.buildContext = buildContext;
|
||||
this.tool = tool;
|
||||
this.topBuildDirectory = topBuildDirectory;
|
||||
|
||||
// Compute the project
|
||||
if (buildContext instanceof IConfiguration) {
|
||||
IConfiguration config = (IConfiguration)buildContext;
|
||||
project = (IProject)config.getOwner();
|
||||
} else if (buildContext instanceof IResourceConfiguration) {
|
||||
IResourceConfiguration resConfig = (IResourceConfiguration)buildContext;
|
||||
project = (IProject)resConfig.getOwner();
|
||||
}
|
||||
|
||||
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
|
||||
outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]);
|
||||
|
||||
// A separate rule is needed for the resource in the case where explicit file-specific macros
|
||||
// are referenced, or if the resource contains special characters in its path (e.g., whitespace)
|
||||
needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) ||
|
||||
MacroResolver.getReferencedExplitFileMacros(tool).length > 0
|
||||
|| MacroResolver.getReferencedExplitFileMacros(
|
||||
tool.getToolCommand(),
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation, outputLocation,
|
||||
null, tool)).length > 0;
|
||||
|
||||
if (needExplicitRuleForFile) genericCommands = new Boolean(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#areCommandsGeneric()
|
||||
*/
|
||||
public boolean areCommandsGeneric() {
|
||||
if (genericCommands == null) genericCommands = new Boolean(true);
|
||||
return genericCommands.booleanValue();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyCommandOptions()
|
||||
*/
|
||||
public String[] getDependencyCommandOptions() {
|
||||
|
||||
String[] options = new String[4];
|
||||
// -MMD
|
||||
options[0] = "-MMD"; //$NON-NLS-1$
|
||||
// -MP
|
||||
options[1] = "-MP"; //$NON-NLS-1$
|
||||
// -MF$(@:%.o=%.d)
|
||||
options[2] = "-MF\"$(@:%.o=%.d)\""; //$NON-NLS-1$
|
||||
//options[2] = "-MF\"${OutputDirRelPath}${OutputFileBaseName}.d\""; //$NON-NLS-1$
|
||||
if( buildContext instanceof IResourceConfiguration || needExplicitRuleForFile ) {
|
||||
IPath outPath = getDependencyFiles()[0];
|
||||
// -MT"dependecy-file-name"
|
||||
String optTxt = "-MT\""; //$NON-NLS-1$
|
||||
optTxt += GnuMakefileGenerator.escapeWhitespaces(outPath.toString()) + "\""; //$NON-NLS-1$
|
||||
options[3] = optTxt;
|
||||
} else {
|
||||
// -MT"$(@:%.o=%.d) %.o"
|
||||
options[3] = "-MT\"$(@:%.o=%.d)\""; //$NON-NLS-1$
|
||||
//options[3] = "-MT\"${OutputDirRelPath}${OutputFileBaseName}.d\""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyFiles()
|
||||
*/
|
||||
public IPath[] getDependencyFiles() {
|
||||
// The source file is project relative and the dependency file is top build directory relative
|
||||
// Remove the source extension and add the dependency extension
|
||||
IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT);
|
||||
// Remember that the source folder hierarchy and the build output folder hierarchy are the same
|
||||
// but if this is a generated resource, then it may already be under the top build directory
|
||||
if (!depFilePath.isAbsolute()) {
|
||||
if (topBuildDirectory.isPrefixOf(depFilePath)) {
|
||||
depFilePath = depFilePath.removeFirstSegments(1);
|
||||
}
|
||||
}
|
||||
IPath[] paths = new IPath[1];
|
||||
paths[0] = depFilePath;
|
||||
return paths;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPostToolDependencyCommands()
|
||||
*/
|
||||
public String[] getPostToolDependencyCommands() {
|
||||
// Nothing
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPreToolDependencyCommands()
|
||||
*/
|
||||
public String[] getPreToolDependencyCommands() {
|
||||
// Nothing
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext()
|
||||
*/
|
||||
public IBuildObject getBuildContext() {
|
||||
return buildContext;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource()
|
||||
*/
|
||||
public IPath getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool()
|
||||
*/
|
||||
public ITool getTool() {
|
||||
return tool;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory()
|
||||
*/
|
||||
public IPath getTopBuildDirectory() {
|
||||
return topBuildDirectory;
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.resources.IProject;;
|
||||
|
||||
/**
|
||||
* This dependency calculator uses the GCC -MMD -MF -MP -MT options in order to
|
||||
* generate .d files as a side effect of compilation.
|
||||
* See bugzilla 108715 for the discussion of dependency management that led to
|
||||
* the creation of this dependency calculator. Note also that this technique
|
||||
* exhibits the failure modes discussed in comment #5.
|
||||
*
|
||||
* This class is used with DefaultGCCDependencyCalculator2.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
public class DefaultGCCDependencyCalculator2Commands implements
|
||||
IManagedDependencyCommands {
|
||||
|
||||
// Member variables set by the constructor
|
||||
IPath source;
|
||||
IBuildObject buildContext;
|
||||
ITool tool;
|
||||
IPath topBuildDirectory;
|
||||
|
||||
// Other Member variables
|
||||
IProject project;
|
||||
IPath sourceLocation;
|
||||
IPath outputLocation;
|
||||
boolean needExplicitRuleForFile;
|
||||
Boolean genericCommands = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source The source file for which dependencies should be calculated
|
||||
* The IPath can be either relative to the project directory, or absolute in the file system.
|
||||
* @param buildContext The IConfiguration or IResourceConfiguration that
|
||||
* contains the context in which the source file will be built
|
||||
* @param tool The tool associated with the source file
|
||||
* @param topBuildDirectory The top build directory of the configuration. This is
|
||||
* the working directory for the tool. This IPath is relative to the project directory.
|
||||
*/
|
||||
public DefaultGCCDependencyCalculator2Commands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
this.source = source;
|
||||
this.buildContext = buildContext;
|
||||
this.tool = tool;
|
||||
this.topBuildDirectory = topBuildDirectory;
|
||||
|
||||
// Compute the project
|
||||
if (buildContext instanceof IConfiguration) {
|
||||
IConfiguration config = (IConfiguration)buildContext;
|
||||
project = (IProject)config.getOwner();
|
||||
} else if (buildContext instanceof IResourceConfiguration) {
|
||||
IResourceConfiguration resConfig = (IResourceConfiguration)buildContext;
|
||||
project = (IProject)resConfig.getOwner();
|
||||
}
|
||||
|
||||
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
|
||||
outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]);
|
||||
|
||||
// A separate rule is needed for the resource in the case where explicit file-specific macros
|
||||
// are referenced, or if the resource contains special characters in its path (e.g., whitespace)
|
||||
needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) ||
|
||||
MacroResolver.getReferencedExplitFileMacros(tool).length > 0
|
||||
|| MacroResolver.getReferencedExplitFileMacros(
|
||||
tool.getToolCommand(),
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation, outputLocation,
|
||||
null, tool)).length > 0;
|
||||
|
||||
if (needExplicitRuleForFile) genericCommands = new Boolean(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#areCommandsGeneric()
|
||||
*/
|
||||
public boolean areCommandsGeneric() {
|
||||
if (genericCommands == null) genericCommands = new Boolean(true);
|
||||
return genericCommands.booleanValue();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyCommandOptions()
|
||||
*/
|
||||
public String[] getDependencyCommandOptions() {
|
||||
|
||||
String[] options = new String[4];
|
||||
// -MMD
|
||||
options[0] = "-MMD"; //$NON-NLS-1$
|
||||
// -MP
|
||||
options[1] = "-MP"; //$NON-NLS-1$
|
||||
// -MF$(@:%.o=%.d)
|
||||
options[2] = "-MF\"$(@:%.o=%.d)\""; //$NON-NLS-1$
|
||||
//options[2] = "-MF\"${OutputDirRelPath}${OutputFileBaseName}.d\""; //$NON-NLS-1$
|
||||
if( buildContext instanceof IResourceConfiguration || needExplicitRuleForFile ) {
|
||||
IPath outPath = getDependencyFiles()[0];
|
||||
// -MT"dependecy-file-name"
|
||||
String optTxt = "-MT\""; //$NON-NLS-1$
|
||||
optTxt += GnuMakefileGenerator.escapeWhitespaces(outPath.toString()) + "\""; //$NON-NLS-1$
|
||||
options[3] = optTxt;
|
||||
} else {
|
||||
// -MT"$(@:%.o=%.d) %.o"
|
||||
options[3] = "-MT\"$(@:%.o=%.d)\""; //$NON-NLS-1$
|
||||
//options[3] = "-MT\"${OutputDirRelPath}${OutputFileBaseName}.d\""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyFiles()
|
||||
*/
|
||||
public IPath[] getDependencyFiles() {
|
||||
// The source file is project relative and the dependency file is top build directory relative
|
||||
// Remove the source extension and add the dependency extension
|
||||
IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT);
|
||||
// Remember that the source folder hierarchy and the build output folder hierarchy are the same
|
||||
// but if this is a generated resource, then it may already be under the top build directory
|
||||
if (!depFilePath.isAbsolute()) {
|
||||
if (topBuildDirectory.isPrefixOf(depFilePath)) {
|
||||
depFilePath = depFilePath.removeFirstSegments(1);
|
||||
}
|
||||
}
|
||||
IPath[] paths = new IPath[1];
|
||||
paths[0] = depFilePath;
|
||||
return paths;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPostToolDependencyCommands()
|
||||
*/
|
||||
public String[] getPostToolDependencyCommands() {
|
||||
// Nothing
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPreToolDependencyCommands()
|
||||
*/
|
||||
public String[] getPreToolDependencyCommands() {
|
||||
// Nothing
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext()
|
||||
*/
|
||||
public IBuildObject getBuildContext() {
|
||||
return buildContext;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource()
|
||||
*/
|
||||
public IPath getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool()
|
||||
*/
|
||||
public ITool getTool() {
|
||||
return tool;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory()
|
||||
*/
|
||||
public IPath getTopBuildDirectory() {
|
||||
return topBuildDirectory;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,98 +1,98 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* This dependency calculator uses the same dependency management technique as the
|
||||
* DefaultGCCDependencyCalculator. That is:
|
||||
*
|
||||
* 1. An echo command creates the dependency file (.d).
|
||||
* 2. A second invocation of the compiler is made in order to append to the dependency file.
|
||||
* The additional options -MM -MG -P -w are added to the command line.
|
||||
* 3. The dependency files are post-processed to add the empty header rules.
|
||||
*
|
||||
* This dependency calculator uses the class DefaultGCCDependencyCalculator3Commands
|
||||
* which implements the per-source command information
|
||||
*
|
||||
* This is an example dependency calculator that is not used by the CDT GCC tool-chain.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
public class DefaultGCCDependencyCalculator3 implements
|
||||
IManagedDependencyGenerator2 {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
return TYPE_BUILD_COMMANDS;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencyFileExtension(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool)
|
||||
*/
|
||||
public String getDependencyFileExtension(IConfiguration buildContext, ITool tool) {
|
||||
return IManagedBuilderMakefileGenerator.DEP_EXT;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencySourceInfo(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
public IManagedDependencyInfo getDependencySourceInfo(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
return new DefaultGCCDependencyCalculator3Commands(source, buildContext, tool, topBuildDirectory);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#postProcessDependencyFile(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
public boolean postProcessDependencyFile(IPath dependencyFile, IConfiguration buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
try {
|
||||
IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
|
||||
IFile makefile;
|
||||
IPath makefilePath;
|
||||
if (dependencyFile.isAbsolute()) {
|
||||
makefilePath = dependencyFile;
|
||||
} else {
|
||||
makefilePath = topBuildDirectory.append(dependencyFile);
|
||||
}
|
||||
IPath rootPath = root.getLocation();
|
||||
if (rootPath.isPrefixOf(makefilePath)) {
|
||||
makefilePath = makefilePath.removeFirstSegments(rootPath.segmentCount());
|
||||
}
|
||||
makefile = root.getFile(makefilePath);
|
||||
return GnuMakefileGenerator.populateDummyTargets(buildContext, makefile, false);
|
||||
} catch (CoreException e) {
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* This dependency calculator uses the same dependency management technique as the
|
||||
* DefaultGCCDependencyCalculator. That is:
|
||||
*
|
||||
* 1. An echo command creates the dependency file (.d).
|
||||
* 2. A second invocation of the compiler is made in order to append to the dependency file.
|
||||
* The additional options -MM -MG -P -w are added to the command line.
|
||||
* 3. The dependency files are post-processed to add the empty header rules.
|
||||
*
|
||||
* This dependency calculator uses the class DefaultGCCDependencyCalculator3Commands
|
||||
* which implements the per-source command information
|
||||
*
|
||||
* This is an example dependency calculator that is not used by the CDT GCC tool-chain.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
public class DefaultGCCDependencyCalculator3 implements
|
||||
IManagedDependencyGenerator2 {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
return TYPE_BUILD_COMMANDS;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencyFileExtension(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool)
|
||||
*/
|
||||
public String getDependencyFileExtension(IConfiguration buildContext, ITool tool) {
|
||||
return IManagedBuilderMakefileGenerator.DEP_EXT;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencySourceInfo(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
public IManagedDependencyInfo getDependencySourceInfo(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
return new DefaultGCCDependencyCalculator3Commands(source, buildContext, tool, topBuildDirectory);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#postProcessDependencyFile(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
public boolean postProcessDependencyFile(IPath dependencyFile, IConfiguration buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
try {
|
||||
IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
|
||||
IFile makefile;
|
||||
IPath makefilePath;
|
||||
if (dependencyFile.isAbsolute()) {
|
||||
makefilePath = dependencyFile;
|
||||
} else {
|
||||
makefilePath = topBuildDirectory.append(dependencyFile);
|
||||
}
|
||||
IPath rootPath = root.getLocation();
|
||||
if (rootPath.isPrefixOf(makefilePath)) {
|
||||
makefilePath = makefilePath.removeFirstSegments(rootPath.segmentCount());
|
||||
}
|
||||
makefile = root.getFile(makefilePath);
|
||||
return GnuMakefileGenerator.populateDummyTargets(buildContext, makefile, false);
|
||||
} catch (CoreException e) {
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,330 +1,330 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
|
||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.resources.IProject;;
|
||||
|
||||
/**
|
||||
* This dependency calculator uses the same dependency management technique as the
|
||||
* DefaultGCCDependencyCalculator. That is:
|
||||
*
|
||||
* 1. An echo command creates the dependency file (.d).
|
||||
* 2. A second invocation of the compiler is made in order to append to the dependency file.
|
||||
* The additional options -MM -MG -P -w are added to the command line.
|
||||
* 3. The dependency files are post-processed to add the empty header rules.
|
||||
*
|
||||
* This class is used with DefaultGCCDependencyCalculator3.
|
||||
*
|
||||
* This is an example dependency calculator that is not used by the CDT GCC tool-chain.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
public class DefaultGCCDependencyCalculator3Commands implements
|
||||
IManagedDependencyCommands {
|
||||
|
||||
private static final String EMPTY_STRING = new String();
|
||||
|
||||
// Member variables set by the constructor
|
||||
IPath source;
|
||||
IBuildObject buildContext;
|
||||
ITool tool;
|
||||
IPath topBuildDirectory;
|
||||
|
||||
// Other Member variables
|
||||
IProject project;
|
||||
IConfiguration config;
|
||||
IResourceConfiguration resConfig;
|
||||
IPath sourceLocation;
|
||||
IPath outputLocation;
|
||||
boolean needExplicitRuleForFile;
|
||||
boolean genericCommands = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source The source file for which dependencies should be calculated
|
||||
* The IPath can be either relative to the project directory, or absolute in the file system.
|
||||
* @param buildContext The IConfiguration or IResourceConfiguration that
|
||||
* contains the context in which the source file will be built
|
||||
* @param tool The tool associated with the source file
|
||||
* @param topBuildDirectory The top build directory of the configuration. This is
|
||||
* the working directory for the tool. This IPath is relative to the project directory.
|
||||
*/
|
||||
public DefaultGCCDependencyCalculator3Commands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
this.source = source;
|
||||
this.buildContext = buildContext;
|
||||
this.tool = tool;
|
||||
this.topBuildDirectory = topBuildDirectory;
|
||||
|
||||
// Compute the project
|
||||
if (buildContext instanceof IConfiguration) {
|
||||
resConfig = null;
|
||||
config = (IConfiguration)buildContext;
|
||||
project = (IProject)config.getOwner();
|
||||
} else if (buildContext instanceof IResourceConfiguration) {
|
||||
resConfig = (IResourceConfiguration)buildContext;
|
||||
config = resConfig.getParent();
|
||||
project = (IProject)resConfig.getOwner();
|
||||
}
|
||||
|
||||
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
|
||||
outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]);
|
||||
|
||||
// A separate rule is needed for the resource in the case where explicit file-specific macros
|
||||
// are referenced, or if the resource contains special characters in its path (e.g., whitespace)
|
||||
needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) ||
|
||||
MacroResolver.getReferencedExplitFileMacros(tool).length > 0
|
||||
|| MacroResolver.getReferencedExplitFileMacros(
|
||||
tool.getToolCommand(),
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation, outputLocation,
|
||||
null, tool)).length > 0;
|
||||
|
||||
if (buildContext instanceof IResourceConfiguration || needExplicitRuleForFile)
|
||||
genericCommands = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#areCommandsGeneric()
|
||||
*/
|
||||
public boolean areCommandsGeneric() {
|
||||
return genericCommands;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyCommandOptions()
|
||||
*/
|
||||
public String[] getDependencyCommandOptions() {
|
||||
// Nothing
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyFiles()
|
||||
*/
|
||||
public IPath[] getDependencyFiles() {
|
||||
// The source file is project relative and the dependency file is top build directory relative
|
||||
// Remove the source extension and add the dependency extension
|
||||
IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT);
|
||||
// Remember that the source folder hierarchy and the build output folder hierarchy are the same
|
||||
// but if this is a generated resource, then it may already be under the top build directory
|
||||
if (!depFilePath.isAbsolute()) {
|
||||
if (topBuildDirectory.isPrefixOf(depFilePath)) {
|
||||
depFilePath = depFilePath.removeFirstSegments(1);
|
||||
}
|
||||
}
|
||||
IPath[] paths = new IPath[1];
|
||||
paths[0] = depFilePath;
|
||||
return paths;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPostToolDependencyCommands()
|
||||
*/
|
||||
public String[] getPostToolDependencyCommands() {
|
||||
/*
|
||||
* For a given input, <path>/<resource_name>.<ext>, return a string containing
|
||||
* echo -n $(@:%.<out_ext>=%.d) '<path>/' >> $(@:%.<out_ext>=%.d) && \
|
||||
* <tool_command> -P -MM -MG <tool_flags> $< >> $(@:%.<out_ext>=%.d)
|
||||
*
|
||||
*/
|
||||
String[] commands = new String[2];
|
||||
|
||||
// Get what we need to create the dependency generation command
|
||||
String inputExtension = source.getFileExtension();
|
||||
String outputExtension = tool.getOutputExtension(inputExtension);
|
||||
|
||||
// Calculate the dependency rule
|
||||
// <path>/$(@:%.<out_ext>=%.d)
|
||||
String depRule = "'$(@:%." + //$NON-NLS-1$
|
||||
outputExtension +
|
||||
"=%." + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.DEP_EXT +
|
||||
")'"; //$NON-NLS-1$
|
||||
|
||||
// Add the Echo command that will actually create the right format for the dep
|
||||
commands[0] =
|
||||
IManagedBuilderMakefileGenerator.TAB +
|
||||
IManagedBuilderMakefileGenerator.ECHO +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"-n" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
depRule +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"$(dir $@)" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
">" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
depRule;
|
||||
|
||||
// Add the line that will do the work to calculate dependencies
|
||||
IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
|
||||
IManagedCommandLineInfo cmdLInfo = null;
|
||||
String buildCmd = null;
|
||||
String[] inputs= new String[1]; inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO;
|
||||
String outputFile = ""; //$NON-NLS-1$
|
||||
String outflag = ""; //$NON-NLS-1$
|
||||
String outputPrefix = ""; //$NON-NLS-1$
|
||||
String cmd = tool.getToolCommand();
|
||||
//try to resolve the build macros in the tool command
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
if (!needExplicitRuleForFile) {
|
||||
resolvedCommand = provider.resolveValueToMakefileFormat(
|
||||
cmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
} else {
|
||||
// if we need an explicit rule then don't use any builder
|
||||
// variables, resolve everything
|
||||
// to explicit strings
|
||||
resolvedCommand = provider.resolveValue(
|
||||
cmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
}
|
||||
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
String[] toolFlags = null;
|
||||
try {
|
||||
toolFlags = tool.getToolCommandFlags(sourceLocation, outputLocation);
|
||||
} catch( BuildException ex ) {
|
||||
toolFlags = new String[0];
|
||||
}
|
||||
String[] flags = new String[toolFlags.length + 4];
|
||||
flags[0] = "-MM"; //$NON-NLS-1$
|
||||
flags[1] = "-MG"; //$NON-NLS-1$
|
||||
flags[2] = "-P"; //$NON-NLS-1$
|
||||
flags[3] = "-w"; //$NON-NLS-1$
|
||||
for (int i=0; i<toolFlags.length; i++) {
|
||||
flags[4+i] = toolFlags[i];
|
||||
}
|
||||
IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
|
||||
cmdLInfo = cmdLGen.generateCommandLineInfo( tool, cmd, flags, outflag, outputPrefix,
|
||||
outputFile, inputs, tool.getCommandLinePattern() );
|
||||
|
||||
// The command to build
|
||||
buildCmd = cmdLInfo.getCommandLine();
|
||||
|
||||
// resolve any remaining macros in the command after it has been generated
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
if (!needExplicitRuleForFile) {
|
||||
resolvedCommand = provider.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
} else {
|
||||
// if we need an explicit rule then don't use any builder
|
||||
// variables, resolve everything to explicit strings
|
||||
resolvedCommand = provider.resolveValue(
|
||||
buildCmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
}
|
||||
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
buildCmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
commands[1] =
|
||||
IManagedBuilderMakefileGenerator.TAB +
|
||||
buildCmd +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
">>" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE + depRule;
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPreToolDependencyCommands()
|
||||
*/
|
||||
public String[] getPreToolDependencyCommands() {
|
||||
// Nothing
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext()
|
||||
*/
|
||||
public IBuildObject getBuildContext() {
|
||||
return buildContext;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource()
|
||||
*/
|
||||
public IPath getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool()
|
||||
*/
|
||||
public ITool getTool() {
|
||||
return tool;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory()
|
||||
*/
|
||||
public IPath getTopBuildDirectory() {
|
||||
return topBuildDirectory;
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
|
||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.resources.IProject;;
|
||||
|
||||
/**
|
||||
* This dependency calculator uses the same dependency management technique as the
|
||||
* DefaultGCCDependencyCalculator. That is:
|
||||
*
|
||||
* 1. An echo command creates the dependency file (.d).
|
||||
* 2. A second invocation of the compiler is made in order to append to the dependency file.
|
||||
* The additional options -MM -MG -P -w are added to the command line.
|
||||
* 3. The dependency files are post-processed to add the empty header rules.
|
||||
*
|
||||
* This class is used with DefaultGCCDependencyCalculator3.
|
||||
*
|
||||
* This is an example dependency calculator that is not used by the CDT GCC tool-chain.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
public class DefaultGCCDependencyCalculator3Commands implements
|
||||
IManagedDependencyCommands {
|
||||
|
||||
private static final String EMPTY_STRING = new String();
|
||||
|
||||
// Member variables set by the constructor
|
||||
IPath source;
|
||||
IBuildObject buildContext;
|
||||
ITool tool;
|
||||
IPath topBuildDirectory;
|
||||
|
||||
// Other Member variables
|
||||
IProject project;
|
||||
IConfiguration config;
|
||||
IResourceConfiguration resConfig;
|
||||
IPath sourceLocation;
|
||||
IPath outputLocation;
|
||||
boolean needExplicitRuleForFile;
|
||||
boolean genericCommands = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source The source file for which dependencies should be calculated
|
||||
* The IPath can be either relative to the project directory, or absolute in the file system.
|
||||
* @param buildContext The IConfiguration or IResourceConfiguration that
|
||||
* contains the context in which the source file will be built
|
||||
* @param tool The tool associated with the source file
|
||||
* @param topBuildDirectory The top build directory of the configuration. This is
|
||||
* the working directory for the tool. This IPath is relative to the project directory.
|
||||
*/
|
||||
public DefaultGCCDependencyCalculator3Commands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
this.source = source;
|
||||
this.buildContext = buildContext;
|
||||
this.tool = tool;
|
||||
this.topBuildDirectory = topBuildDirectory;
|
||||
|
||||
// Compute the project
|
||||
if (buildContext instanceof IConfiguration) {
|
||||
resConfig = null;
|
||||
config = (IConfiguration)buildContext;
|
||||
project = (IProject)config.getOwner();
|
||||
} else if (buildContext instanceof IResourceConfiguration) {
|
||||
resConfig = (IResourceConfiguration)buildContext;
|
||||
config = resConfig.getParent();
|
||||
project = (IProject)resConfig.getOwner();
|
||||
}
|
||||
|
||||
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
|
||||
outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]);
|
||||
|
||||
// A separate rule is needed for the resource in the case where explicit file-specific macros
|
||||
// are referenced, or if the resource contains special characters in its path (e.g., whitespace)
|
||||
needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) ||
|
||||
MacroResolver.getReferencedExplitFileMacros(tool).length > 0
|
||||
|| MacroResolver.getReferencedExplitFileMacros(
|
||||
tool.getToolCommand(),
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation, outputLocation,
|
||||
null, tool)).length > 0;
|
||||
|
||||
if (buildContext instanceof IResourceConfiguration || needExplicitRuleForFile)
|
||||
genericCommands = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#areCommandsGeneric()
|
||||
*/
|
||||
public boolean areCommandsGeneric() {
|
||||
return genericCommands;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyCommandOptions()
|
||||
*/
|
||||
public String[] getDependencyCommandOptions() {
|
||||
// Nothing
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyFiles()
|
||||
*/
|
||||
public IPath[] getDependencyFiles() {
|
||||
// The source file is project relative and the dependency file is top build directory relative
|
||||
// Remove the source extension and add the dependency extension
|
||||
IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT);
|
||||
// Remember that the source folder hierarchy and the build output folder hierarchy are the same
|
||||
// but if this is a generated resource, then it may already be under the top build directory
|
||||
if (!depFilePath.isAbsolute()) {
|
||||
if (topBuildDirectory.isPrefixOf(depFilePath)) {
|
||||
depFilePath = depFilePath.removeFirstSegments(1);
|
||||
}
|
||||
}
|
||||
IPath[] paths = new IPath[1];
|
||||
paths[0] = depFilePath;
|
||||
return paths;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPostToolDependencyCommands()
|
||||
*/
|
||||
public String[] getPostToolDependencyCommands() {
|
||||
/*
|
||||
* For a given input, <path>/<resource_name>.<ext>, return a string containing
|
||||
* echo -n $(@:%.<out_ext>=%.d) '<path>/' >> $(@:%.<out_ext>=%.d) && \
|
||||
* <tool_command> -P -MM -MG <tool_flags> $< >> $(@:%.<out_ext>=%.d)
|
||||
*
|
||||
*/
|
||||
String[] commands = new String[2];
|
||||
|
||||
// Get what we need to create the dependency generation command
|
||||
String inputExtension = source.getFileExtension();
|
||||
String outputExtension = tool.getOutputExtension(inputExtension);
|
||||
|
||||
// Calculate the dependency rule
|
||||
// <path>/$(@:%.<out_ext>=%.d)
|
||||
String depRule = "'$(@:%." + //$NON-NLS-1$
|
||||
outputExtension +
|
||||
"=%." + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.DEP_EXT +
|
||||
")'"; //$NON-NLS-1$
|
||||
|
||||
// Add the Echo command that will actually create the right format for the dep
|
||||
commands[0] =
|
||||
IManagedBuilderMakefileGenerator.TAB +
|
||||
IManagedBuilderMakefileGenerator.ECHO +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"-n" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
depRule +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"$(dir $@)" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
">" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
depRule;
|
||||
|
||||
// Add the line that will do the work to calculate dependencies
|
||||
IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
|
||||
IManagedCommandLineInfo cmdLInfo = null;
|
||||
String buildCmd = null;
|
||||
String[] inputs= new String[1]; inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO;
|
||||
String outputFile = ""; //$NON-NLS-1$
|
||||
String outflag = ""; //$NON-NLS-1$
|
||||
String outputPrefix = ""; //$NON-NLS-1$
|
||||
String cmd = tool.getToolCommand();
|
||||
//try to resolve the build macros in the tool command
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
if (!needExplicitRuleForFile) {
|
||||
resolvedCommand = provider.resolveValueToMakefileFormat(
|
||||
cmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
} else {
|
||||
// if we need an explicit rule then don't use any builder
|
||||
// variables, resolve everything
|
||||
// to explicit strings
|
||||
resolvedCommand = provider.resolveValue(
|
||||
cmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
}
|
||||
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
String[] toolFlags = null;
|
||||
try {
|
||||
toolFlags = tool.getToolCommandFlags(sourceLocation, outputLocation);
|
||||
} catch( BuildException ex ) {
|
||||
toolFlags = new String[0];
|
||||
}
|
||||
String[] flags = new String[toolFlags.length + 4];
|
||||
flags[0] = "-MM"; //$NON-NLS-1$
|
||||
flags[1] = "-MG"; //$NON-NLS-1$
|
||||
flags[2] = "-P"; //$NON-NLS-1$
|
||||
flags[3] = "-w"; //$NON-NLS-1$
|
||||
for (int i=0; i<toolFlags.length; i++) {
|
||||
flags[4+i] = toolFlags[i];
|
||||
}
|
||||
IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
|
||||
cmdLInfo = cmdLGen.generateCommandLineInfo( tool, cmd, flags, outflag, outputPrefix,
|
||||
outputFile, inputs, tool.getCommandLinePattern() );
|
||||
|
||||
// The command to build
|
||||
buildCmd = cmdLInfo.getCommandLine();
|
||||
|
||||
// resolve any remaining macros in the command after it has been generated
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
if (!needExplicitRuleForFile) {
|
||||
resolvedCommand = provider.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
} else {
|
||||
// if we need an explicit rule then don't use any builder
|
||||
// variables, resolve everything to explicit strings
|
||||
resolvedCommand = provider.resolveValue(
|
||||
buildCmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
}
|
||||
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
buildCmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
commands[1] =
|
||||
IManagedBuilderMakefileGenerator.TAB +
|
||||
buildCmd +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
">>" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE + depRule;
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPreToolDependencyCommands()
|
||||
*/
|
||||
public String[] getPreToolDependencyCommands() {
|
||||
// Nothing
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext()
|
||||
*/
|
||||
public IBuildObject getBuildContext() {
|
||||
return buildContext;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource()
|
||||
*/
|
||||
public IPath getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool()
|
||||
*/
|
||||
public ITool getTool() {
|
||||
return tool;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory()
|
||||
*/
|
||||
public IPath getTopBuildDirectory() {
|
||||
return topBuildDirectory;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
|
||||
/**
|
||||
* This dependency calculator uses the GCC -MM -MF -MP -MT options in order to
|
||||
* generate .d files as separate step prior to the source compilations.
|
||||
*
|
||||
* This dependency calculator uses the class DefaultGCCDependencyCalculatorPreBuildCommands
|
||||
* which implements the per-source command information
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
public class DefaultGCCDependencyCalculatorPreBuild implements
|
||||
IManagedDependencyGenerator2 {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
return TYPE_PREBUILD_COMMANDS;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencyFileExtension(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool)
|
||||
*/
|
||||
public String getDependencyFileExtension(IConfiguration buildContext, ITool tool) {
|
||||
return IManagedBuilderMakefileGenerator.DEP_EXT;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencySourceInfo(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
public IManagedDependencyInfo getDependencySourceInfo(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
return new DefaultGCCDependencyCalculatorPreBuildCommands(source, buildContext, tool, topBuildDirectory);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#postProcessDependencyFile(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
public boolean postProcessDependencyFile(IPath dependencyFile, IConfiguration buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
// Nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
|
||||
/**
|
||||
* This dependency calculator uses the GCC -MM -MF -MP -MT options in order to
|
||||
* generate .d files as separate step prior to the source compilations.
|
||||
*
|
||||
* This dependency calculator uses the class DefaultGCCDependencyCalculatorPreBuildCommands
|
||||
* which implements the per-source command information
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
public class DefaultGCCDependencyCalculatorPreBuild implements
|
||||
IManagedDependencyGenerator2 {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
return TYPE_PREBUILD_COMMANDS;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencyFileExtension(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool)
|
||||
*/
|
||||
public String getDependencyFileExtension(IConfiguration buildContext, ITool tool) {
|
||||
return IManagedBuilderMakefileGenerator.DEP_EXT;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencySourceInfo(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
public IManagedDependencyInfo getDependencySourceInfo(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
return new DefaultGCCDependencyCalculatorPreBuildCommands(source, buildContext, tool, topBuildDirectory);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#postProcessDependencyFile(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
public boolean postProcessDependencyFile(IPath dependencyFile, IConfiguration buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
// Nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,306 +1,306 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
|
||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyPreBuild;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* This dependency calculator uses the GCC -MM -MF -MP -MT options in order to
|
||||
* generate .d files as separate step prior to the source compilations.
|
||||
*
|
||||
* This dependency calculator uses the class DefaultGCCDependencyCalculatorPreBuildCommands
|
||||
* which implements the per-source command information
|
||||
*
|
||||
* This class is used with DefaultGCCDependencyCalculatorPreBuild.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
public class DefaultGCCDependencyCalculatorPreBuildCommands implements IManagedDependencyPreBuild {
|
||||
|
||||
private static final String EMPTY_STRING = new String();
|
||||
|
||||
// Member variables set by the constructor
|
||||
IPath source;
|
||||
IBuildObject buildContext;
|
||||
ITool tool;
|
||||
IPath topBuildDirectory;
|
||||
|
||||
// Other Member variables
|
||||
IProject project;
|
||||
IPath sourceLocation;
|
||||
IPath outputLocation;
|
||||
boolean needExplicitRuleForFile;
|
||||
Boolean genericCommands = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source The source file for which dependencies should be calculated
|
||||
* The IPath can be either relative to the project directory, or absolute in the file system.
|
||||
* @param buildContext The IConfiguration or IResourceConfiguration that
|
||||
* contains the context in which the source file will be built
|
||||
* @param tool The tool associated with the source file
|
||||
* @param topBuildDirectory The top build directory of the configuration. This is
|
||||
* the working directory for the tool. This IPath is relative to the project directory.
|
||||
*/
|
||||
public DefaultGCCDependencyCalculatorPreBuildCommands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
this.source = source;
|
||||
this.buildContext = buildContext;
|
||||
this.tool = tool;
|
||||
this.topBuildDirectory = topBuildDirectory;
|
||||
|
||||
// Compute the project
|
||||
if (buildContext instanceof IConfiguration) {
|
||||
IConfiguration config = (IConfiguration)buildContext;
|
||||
project = (IProject)config.getOwner();
|
||||
} else if (buildContext instanceof IResourceConfiguration) {
|
||||
IResourceConfiguration resConfig = (IResourceConfiguration)buildContext;
|
||||
project = (IProject)resConfig.getOwner();
|
||||
}
|
||||
|
||||
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
|
||||
outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]);
|
||||
|
||||
// A separate rule is needed for the resource in the case where explicit file-specific macros
|
||||
// are referenced, or if the resource contains special characters in its path (e.g., whitespace)
|
||||
needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) ||
|
||||
MacroResolver.getReferencedExplitFileMacros(tool).length > 0
|
||||
|| MacroResolver.getReferencedExplitFileMacros(
|
||||
tool.getToolCommand(),
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation, outputLocation,
|
||||
null, tool)).length > 0;
|
||||
|
||||
if (needExplicitRuleForFile) genericCommands = new Boolean(false);
|
||||
}
|
||||
|
||||
public boolean areCommandsGeneric() {
|
||||
if (genericCommands != null) return genericCommands.booleanValue();
|
||||
// If the context is a Configuration, yes
|
||||
if (buildContext instanceof IConfiguration) {
|
||||
genericCommands = new Boolean(true);
|
||||
return true;
|
||||
}
|
||||
// If the context is a Resource Configuration, determine if it overrides any
|
||||
// of its parent configuration's options that would affect dependency file
|
||||
// generation.
|
||||
// TODO
|
||||
genericCommands = new Boolean(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getBuildStepName() {
|
||||
return new String("GCC_DEPENDS"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public String[] getDependencyCommands() {
|
||||
|
||||
String[] commands = new String[1];
|
||||
String depCmd = EMPTY_STRING;
|
||||
IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
|
||||
|
||||
// Get and resolve the command
|
||||
String cmd = tool.getToolCommand();
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
if (!needExplicitRuleForFile) {
|
||||
resolvedCommand = provider.resolveValueToMakefileFormat(
|
||||
cmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
} else {
|
||||
// if we need an explicit rule then don't use any builder
|
||||
// variables, resolve everything
|
||||
// to explicit strings
|
||||
resolvedCommand = provider.resolveValue(
|
||||
cmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
}
|
||||
|
||||
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e) {
|
||||
}
|
||||
|
||||
IManagedCommandLineInfo cmdLInfo = null;
|
||||
|
||||
// Set up the command line options that will generate the dependency file
|
||||
Vector options = new Vector();
|
||||
// -w
|
||||
options.add("-w"); //$NON-NLS-1$
|
||||
// -MM
|
||||
options.add("-MM"); //$NON-NLS-1$
|
||||
// -MP
|
||||
options.add("-MP"); //$NON-NLS-1$
|
||||
|
||||
String optTxt;
|
||||
|
||||
if( buildContext instanceof IResourceConfiguration || needExplicitRuleForFile ) {
|
||||
IPath outPath = getDependencyFiles()[0];
|
||||
// -MT"dependecy-file-name"
|
||||
optTxt = "-MT\""; //$NON-NLS-1$
|
||||
optTxt += GnuMakefileGenerator.escapeWhitespaces(outPath.toString()) + "\""; //$NON-NLS-1$
|
||||
options.add(optTxt);
|
||||
// -MT"object-file-filename"
|
||||
optTxt = "-MT\""; //$NON-NLS-1$
|
||||
optTxt += GnuMakefileGenerator.escapeWhitespaces((outPath.removeFileExtension()).toString());
|
||||
String outExt = tool.getOutputExtension(source.getFileExtension());
|
||||
if (outExt != null) optTxt += "." + outExt; //$NON-NLS-1$
|
||||
optTxt += "\""; //$NON-NLS-1$
|
||||
options.add(optTxt);
|
||||
} else {
|
||||
// -MT"$@"
|
||||
options.add("-MT\"$@\""); //$NON-NLS-1$
|
||||
// -MT'$(@:%.d=%.o)'
|
||||
optTxt = "-MT\"$(@:%.d=%.o)\""; //$NON-NLS-1$
|
||||
//optTxt = "-MT\"${OutputDirRelPath}${OutputFileBaseName}";
|
||||
//if (outExt != null) optTxt += "." + outExt;
|
||||
//optTxt += "\""; //$NON-NLS-1$
|
||||
options.add(optTxt);
|
||||
}
|
||||
|
||||
// Save the -I, -D, -U options and discard the rest
|
||||
try {
|
||||
String[] allFlags = tool.getToolCommandFlags(sourceLocation, outputLocation);
|
||||
for (int i=0; i<allFlags.length; i++) {
|
||||
if (allFlags[i].startsWith("-I") || //$NON-NLS-1$
|
||||
allFlags[i].startsWith("-D") || //$NON-NLS-1$
|
||||
allFlags[i].startsWith("-U")) { //$NON-NLS-1$
|
||||
options.add(allFlags[i]);
|
||||
}
|
||||
}
|
||||
} catch( BuildException ex ) {
|
||||
}
|
||||
|
||||
// Call the command line generator
|
||||
IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
|
||||
String[] flags = (String[])options.toArray(new String[options.size()]);
|
||||
String[] inputs = new String[1];
|
||||
inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO;
|
||||
cmdLInfo = cmdLGen.generateCommandLineInfo(
|
||||
tool, cmd, flags, "-MF", EMPTY_STRING, //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.OUT_MACRO,
|
||||
inputs,
|
||||
tool.getCommandLinePattern() );
|
||||
|
||||
// The command to build
|
||||
if (cmdLInfo != null) {
|
||||
depCmd = cmdLInfo.getCommandLine();
|
||||
|
||||
// resolve any remaining macros in the command after it has been
|
||||
// generated
|
||||
try {
|
||||
String resolvedCommand;
|
||||
if (!needExplicitRuleForFile) {
|
||||
resolvedCommand = provider.resolveValueToMakefileFormat(
|
||||
depCmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
} else {
|
||||
// if we need an explicit rule then don't use any builder
|
||||
// variables, resolve everything to explicit strings
|
||||
resolvedCommand = provider.resolveValue(
|
||||
depCmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
}
|
||||
|
||||
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
depCmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e) {
|
||||
}
|
||||
}
|
||||
|
||||
commands[0] = depCmd;
|
||||
return commands;
|
||||
}
|
||||
|
||||
public IPath[] getDependencyFiles() {
|
||||
// The source file is project relative and the dependency file is top build directory relative
|
||||
// Remove the source extension and add the dependency extension
|
||||
IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT);
|
||||
// Remember that the source folder hierarchy and the build output folder hierarchy are the same
|
||||
// but if this is a generated resource, then it may already be under the top build directory
|
||||
if (!depFilePath.isAbsolute()) {
|
||||
if (topBuildDirectory.isPrefixOf(depFilePath)) {
|
||||
depFilePath = depFilePath.removeFirstSegments(1);
|
||||
}
|
||||
}
|
||||
IPath[] paths = new IPath[1];
|
||||
paths[0] = depFilePath;
|
||||
return paths;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext()
|
||||
*/
|
||||
public IBuildObject getBuildContext() {
|
||||
return buildContext;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource()
|
||||
*/
|
||||
public IPath getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool()
|
||||
*/
|
||||
public ITool getTool() {
|
||||
return tool;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory()
|
||||
*/
|
||||
public IPath getTopBuildDirectory() {
|
||||
return topBuildDirectory;
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
|
||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyPreBuild;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* This dependency calculator uses the GCC -MM -MF -MP -MT options in order to
|
||||
* generate .d files as separate step prior to the source compilations.
|
||||
*
|
||||
* This dependency calculator uses the class DefaultGCCDependencyCalculatorPreBuildCommands
|
||||
* which implements the per-source command information
|
||||
*
|
||||
* This class is used with DefaultGCCDependencyCalculatorPreBuild.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
public class DefaultGCCDependencyCalculatorPreBuildCommands implements IManagedDependencyPreBuild {
|
||||
|
||||
private static final String EMPTY_STRING = new String();
|
||||
|
||||
// Member variables set by the constructor
|
||||
IPath source;
|
||||
IBuildObject buildContext;
|
||||
ITool tool;
|
||||
IPath topBuildDirectory;
|
||||
|
||||
// Other Member variables
|
||||
IProject project;
|
||||
IPath sourceLocation;
|
||||
IPath outputLocation;
|
||||
boolean needExplicitRuleForFile;
|
||||
Boolean genericCommands = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source The source file for which dependencies should be calculated
|
||||
* The IPath can be either relative to the project directory, or absolute in the file system.
|
||||
* @param buildContext The IConfiguration or IResourceConfiguration that
|
||||
* contains the context in which the source file will be built
|
||||
* @param tool The tool associated with the source file
|
||||
* @param topBuildDirectory The top build directory of the configuration. This is
|
||||
* the working directory for the tool. This IPath is relative to the project directory.
|
||||
*/
|
||||
public DefaultGCCDependencyCalculatorPreBuildCommands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
|
||||
this.source = source;
|
||||
this.buildContext = buildContext;
|
||||
this.tool = tool;
|
||||
this.topBuildDirectory = topBuildDirectory;
|
||||
|
||||
// Compute the project
|
||||
if (buildContext instanceof IConfiguration) {
|
||||
IConfiguration config = (IConfiguration)buildContext;
|
||||
project = (IProject)config.getOwner();
|
||||
} else if (buildContext instanceof IResourceConfiguration) {
|
||||
IResourceConfiguration resConfig = (IResourceConfiguration)buildContext;
|
||||
project = (IProject)resConfig.getOwner();
|
||||
}
|
||||
|
||||
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
|
||||
outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]);
|
||||
|
||||
// A separate rule is needed for the resource in the case where explicit file-specific macros
|
||||
// are referenced, or if the resource contains special characters in its path (e.g., whitespace)
|
||||
needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) ||
|
||||
MacroResolver.getReferencedExplitFileMacros(tool).length > 0
|
||||
|| MacroResolver.getReferencedExplitFileMacros(
|
||||
tool.getToolCommand(),
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation, outputLocation,
|
||||
null, tool)).length > 0;
|
||||
|
||||
if (needExplicitRuleForFile) genericCommands = new Boolean(false);
|
||||
}
|
||||
|
||||
public boolean areCommandsGeneric() {
|
||||
if (genericCommands != null) return genericCommands.booleanValue();
|
||||
// If the context is a Configuration, yes
|
||||
if (buildContext instanceof IConfiguration) {
|
||||
genericCommands = new Boolean(true);
|
||||
return true;
|
||||
}
|
||||
// If the context is a Resource Configuration, determine if it overrides any
|
||||
// of its parent configuration's options that would affect dependency file
|
||||
// generation.
|
||||
// TODO
|
||||
genericCommands = new Boolean(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getBuildStepName() {
|
||||
return new String("GCC_DEPENDS"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public String[] getDependencyCommands() {
|
||||
|
||||
String[] commands = new String[1];
|
||||
String depCmd = EMPTY_STRING;
|
||||
IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
|
||||
|
||||
// Get and resolve the command
|
||||
String cmd = tool.getToolCommand();
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
if (!needExplicitRuleForFile) {
|
||||
resolvedCommand = provider.resolveValueToMakefileFormat(
|
||||
cmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
} else {
|
||||
// if we need an explicit rule then don't use any builder
|
||||
// variables, resolve everything
|
||||
// to explicit strings
|
||||
resolvedCommand = provider.resolveValue(
|
||||
cmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
}
|
||||
|
||||
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e) {
|
||||
}
|
||||
|
||||
IManagedCommandLineInfo cmdLInfo = null;
|
||||
|
||||
// Set up the command line options that will generate the dependency file
|
||||
Vector options = new Vector();
|
||||
// -w
|
||||
options.add("-w"); //$NON-NLS-1$
|
||||
// -MM
|
||||
options.add("-MM"); //$NON-NLS-1$
|
||||
// -MP
|
||||
options.add("-MP"); //$NON-NLS-1$
|
||||
|
||||
String optTxt;
|
||||
|
||||
if( buildContext instanceof IResourceConfiguration || needExplicitRuleForFile ) {
|
||||
IPath outPath = getDependencyFiles()[0];
|
||||
// -MT"dependecy-file-name"
|
||||
optTxt = "-MT\""; //$NON-NLS-1$
|
||||
optTxt += GnuMakefileGenerator.escapeWhitespaces(outPath.toString()) + "\""; //$NON-NLS-1$
|
||||
options.add(optTxt);
|
||||
// -MT"object-file-filename"
|
||||
optTxt = "-MT\""; //$NON-NLS-1$
|
||||
optTxt += GnuMakefileGenerator.escapeWhitespaces((outPath.removeFileExtension()).toString());
|
||||
String outExt = tool.getOutputExtension(source.getFileExtension());
|
||||
if (outExt != null) optTxt += "." + outExt; //$NON-NLS-1$
|
||||
optTxt += "\""; //$NON-NLS-1$
|
||||
options.add(optTxt);
|
||||
} else {
|
||||
// -MT"$@"
|
||||
options.add("-MT\"$@\""); //$NON-NLS-1$
|
||||
// -MT'$(@:%.d=%.o)'
|
||||
optTxt = "-MT\"$(@:%.d=%.o)\""; //$NON-NLS-1$
|
||||
//optTxt = "-MT\"${OutputDirRelPath}${OutputFileBaseName}";
|
||||
//if (outExt != null) optTxt += "." + outExt;
|
||||
//optTxt += "\""; //$NON-NLS-1$
|
||||
options.add(optTxt);
|
||||
}
|
||||
|
||||
// Save the -I, -D, -U options and discard the rest
|
||||
try {
|
||||
String[] allFlags = tool.getToolCommandFlags(sourceLocation, outputLocation);
|
||||
for (int i=0; i<allFlags.length; i++) {
|
||||
if (allFlags[i].startsWith("-I") || //$NON-NLS-1$
|
||||
allFlags[i].startsWith("-D") || //$NON-NLS-1$
|
||||
allFlags[i].startsWith("-U")) { //$NON-NLS-1$
|
||||
options.add(allFlags[i]);
|
||||
}
|
||||
}
|
||||
} catch( BuildException ex ) {
|
||||
}
|
||||
|
||||
// Call the command line generator
|
||||
IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
|
||||
String[] flags = (String[])options.toArray(new String[options.size()]);
|
||||
String[] inputs = new String[1];
|
||||
inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO;
|
||||
cmdLInfo = cmdLGen.generateCommandLineInfo(
|
||||
tool, cmd, flags, "-MF", EMPTY_STRING, //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.OUT_MACRO,
|
||||
inputs,
|
||||
tool.getCommandLinePattern() );
|
||||
|
||||
// The command to build
|
||||
if (cmdLInfo != null) {
|
||||
depCmd = cmdLInfo.getCommandLine();
|
||||
|
||||
// resolve any remaining macros in the command after it has been
|
||||
// generated
|
||||
try {
|
||||
String resolvedCommand;
|
||||
if (!needExplicitRuleForFile) {
|
||||
resolvedCommand = provider.resolveValueToMakefileFormat(
|
||||
depCmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
} else {
|
||||
// if we need an explicit rule then don't use any builder
|
||||
// variables, resolve everything to explicit strings
|
||||
resolvedCommand = provider.resolveValue(
|
||||
depCmd,
|
||||
EMPTY_STRING,
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, tool));
|
||||
}
|
||||
|
||||
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
depCmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e) {
|
||||
}
|
||||
}
|
||||
|
||||
commands[0] = depCmd;
|
||||
return commands;
|
||||
}
|
||||
|
||||
public IPath[] getDependencyFiles() {
|
||||
// The source file is project relative and the dependency file is top build directory relative
|
||||
// Remove the source extension and add the dependency extension
|
||||
IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT);
|
||||
// Remember that the source folder hierarchy and the build output folder hierarchy are the same
|
||||
// but if this is a generated resource, then it may already be under the top build directory
|
||||
if (!depFilePath.isAbsolute()) {
|
||||
if (topBuildDirectory.isPrefixOf(depFilePath)) {
|
||||
depFilePath = depFilePath.removeFirstSegments(1);
|
||||
}
|
||||
}
|
||||
IPath[] paths = new IPath[1];
|
||||
paths[0] = depFilePath;
|
||||
return paths;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext()
|
||||
*/
|
||||
public IBuildObject getBuildContext() {
|
||||
return buildContext;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource()
|
||||
*/
|
||||
public IPath getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool()
|
||||
*/
|
||||
public ITool getTool() {
|
||||
return tool;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory()
|
||||
*/
|
||||
public IPath getTopBuildDirectory() {
|
||||
return topBuildDirectory;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class contains the desciption of a group of generated dependency files,
|
||||
* e.g., .d files created by compilations
|
||||
*
|
||||
*/
|
||||
|
||||
public class GnuDependencyGroupInfo {
|
||||
|
||||
// Member Variables
|
||||
String groupBuildVar;
|
||||
boolean conditionallyInclude;
|
||||
ArrayList groupFiles;
|
||||
|
||||
// Constructor
|
||||
public GnuDependencyGroupInfo(String groupName, boolean bConditionallyInclude) {
|
||||
groupBuildVar = groupName;
|
||||
conditionallyInclude = bConditionallyInclude;
|
||||
// Note: not yet needed
|
||||
groupFiles = null;
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class contains the desciption of a group of generated dependency files,
|
||||
* e.g., .d files created by compilations
|
||||
*
|
||||
*/
|
||||
|
||||
public class GnuDependencyGroupInfo {
|
||||
|
||||
// Member Variables
|
||||
String groupBuildVar;
|
||||
boolean conditionallyInclude;
|
||||
ArrayList groupFiles;
|
||||
|
||||
// Constructor
|
||||
public GnuDependencyGroupInfo(String groupName, boolean bConditionallyInclude) {
|
||||
groupBuildVar = groupName;
|
||||
conditionallyInclude = bConditionallyInclude;
|
||||
// Note: not yet needed
|
||||
groupFiles = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,122 +1,122 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* This interface returns information about a Tool's inputs
|
||||
* and outputs while a Gnu makefile is being generated.
|
||||
*/
|
||||
public interface IManagedBuildGnuToolInfo {
|
||||
public final String DOT = "."; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the tool's inputs have been calculated,
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areInputsCalculated();
|
||||
|
||||
/**
|
||||
* Returns the tool's inputs in command line format. This will use
|
||||
* variables rather than actual file names as appropriate.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getCommandInputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's input file names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getEnumeratedInputs();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the tool's outputs have been calculated,
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areOutputsCalculated();
|
||||
|
||||
/**
|
||||
* Returns the tool's outputs in command line format. This will use
|
||||
* variables rather than actual file names as appropriate.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getCommandOutputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's primary output file names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getEnumeratedPrimaryOutputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's secondary output file names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getEnumeratedSecondaryOutputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's output variable names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getOutputVariables();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the tool's dependencies have been calculated,
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areDependenciesCalculated();
|
||||
|
||||
/**
|
||||
* Returns the tool's dependencies in command line format. This will use
|
||||
* variables rather than actual file names as appropriate.
|
||||
* Dependencies are top build directory relative.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getCommandDependencies();
|
||||
|
||||
/**
|
||||
* Returns the tool's additional targets as determined by the
|
||||
* dependency calculator.
|
||||
* Additional targets are top build directory relative
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getAdditionalTargets();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's input dependencies.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
//public Vector getEnumeratedDependencies();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this is the target tool
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isTargetTool();
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* This interface returns information about a Tool's inputs
|
||||
* and outputs while a Gnu makefile is being generated.
|
||||
*/
|
||||
public interface IManagedBuildGnuToolInfo {
|
||||
public final String DOT = "."; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the tool's inputs have been calculated,
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areInputsCalculated();
|
||||
|
||||
/**
|
||||
* Returns the tool's inputs in command line format. This will use
|
||||
* variables rather than actual file names as appropriate.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getCommandInputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's input file names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getEnumeratedInputs();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the tool's outputs have been calculated,
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areOutputsCalculated();
|
||||
|
||||
/**
|
||||
* Returns the tool's outputs in command line format. This will use
|
||||
* variables rather than actual file names as appropriate.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getCommandOutputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's primary output file names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getEnumeratedPrimaryOutputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's secondary output file names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getEnumeratedSecondaryOutputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's output variable names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getOutputVariables();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the tool's dependencies have been calculated,
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areDependenciesCalculated();
|
||||
|
||||
/**
|
||||
* Returns the tool's dependencies in command line format. This will use
|
||||
* variables rather than actual file names as appropriate.
|
||||
* Dependencies are top build directory relative.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getCommandDependencies();
|
||||
|
||||
/**
|
||||
* Returns the tool's additional targets as determined by the
|
||||
* dependency calculator.
|
||||
* Additional targets are top build directory relative
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getAdditionalTargets();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's input dependencies.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
//public Vector getEnumeratedDependencies();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this is the target tool
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isTargetTool();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,87 +1,87 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.search.PathCollector;
|
||||
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public class DefaultIndexerDependencyCalculator implements IManagedDependencyGenerator {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
public IResource[] findDependencies(IResource resource, IProject project) {
|
||||
PathCollector pathCollector = new PathCollector();
|
||||
ICSearchScope scope = SearchEngine.createWorkspaceScope();
|
||||
CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(), ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES, ICSearchConstants.EXACT_MATCH, true);
|
||||
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.performConcurrentJob(
|
||||
new PatternSearchJob(
|
||||
(CSearchPattern) pattern,
|
||||
scope,
|
||||
pathCollector,
|
||||
indexManager),
|
||||
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
|
||||
null, null);
|
||||
|
||||
// We will get back an array of resource names relative to the workspace
|
||||
String[] deps = pathCollector.getPaths();
|
||||
|
||||
// Convert them to something useful
|
||||
List depList = new ArrayList();
|
||||
IResource res = null;
|
||||
IWorkspaceRoot root = null;
|
||||
if (project != null) {
|
||||
root = project.getWorkspace().getRoot();
|
||||
}
|
||||
for (int index = 0; index < deps.length; ++index) {
|
||||
res = root.findMember(deps[index]);
|
||||
if (res != null) {
|
||||
depList.add(res);
|
||||
}
|
||||
}
|
||||
|
||||
return (IResource[]) depList.toArray(new IResource[depList.size()]);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
// Tell the
|
||||
return TYPE_EXTERNAL;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
|
||||
*/
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
|
||||
// There is no command
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.search.PathCollector;
|
||||
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public class DefaultIndexerDependencyCalculator implements IManagedDependencyGenerator {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
public IResource[] findDependencies(IResource resource, IProject project) {
|
||||
PathCollector pathCollector = new PathCollector();
|
||||
ICSearchScope scope = SearchEngine.createWorkspaceScope();
|
||||
CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(), ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES, ICSearchConstants.EXACT_MATCH, true);
|
||||
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.performConcurrentJob(
|
||||
new PatternSearchJob(
|
||||
(CSearchPattern) pattern,
|
||||
scope,
|
||||
pathCollector,
|
||||
indexManager),
|
||||
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
|
||||
null, null);
|
||||
|
||||
// We will get back an array of resource names relative to the workspace
|
||||
String[] deps = pathCollector.getPaths();
|
||||
|
||||
// Convert them to something useful
|
||||
List depList = new ArrayList();
|
||||
IResource res = null;
|
||||
IWorkspaceRoot root = null;
|
||||
if (project != null) {
|
||||
root = project.getWorkspace().getRoot();
|
||||
}
|
||||
for (int index = 0; index < deps.length; ++index) {
|
||||
res = root.findMember(deps[index]);
|
||||
if (res != null) {
|
||||
depList.add(res);
|
||||
}
|
||||
}
|
||||
|
||||
return (IResource[]) depList.toArray(new IResource[depList.size()]);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
// Tell the
|
||||
return TYPE_EXTERNAL;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
|
||||
*/
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
|
||||
// There is no command
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,64 +1,64 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.ui.actions;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.*;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.action.Action;
|
||||
|
||||
/**
|
||||
* Action which changes active build configuration of the current project to
|
||||
* the given one.
|
||||
*/
|
||||
public class BuildConfigAction extends Action {
|
||||
|
||||
private String fConfigName = null;
|
||||
private HashSet fProjects = null;
|
||||
|
||||
/**
|
||||
* Constructs the action.
|
||||
* @param projects List of selected managed-built projects
|
||||
* @param configName Build configuration name
|
||||
* @param accel Number to be used as accelerator
|
||||
*/
|
||||
public BuildConfigAction(HashSet projects, String configName, String displayName, int accel) {
|
||||
super("&" + accel + " " + displayName); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
fProjects = projects;
|
||||
fConfigName = configName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jface.action.IAction#run()
|
||||
*/
|
||||
public void run() {
|
||||
Iterator iter = fProjects.iterator();
|
||||
while (iter.hasNext()) {
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)iter.next());
|
||||
if (info != null && info.isValid()) {
|
||||
IConfiguration[] configs = info.getManagedProject().getConfigurations();
|
||||
int i = 0;
|
||||
for (; i < configs.length; i++) {
|
||||
if (configs[i].getName().equals(fConfigName)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i != configs.length) {
|
||||
info.setDefaultConfiguration(configs[i]);
|
||||
info.setSelectedConfiguration(configs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.ui.actions;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.*;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.action.Action;
|
||||
|
||||
/**
|
||||
* Action which changes active build configuration of the current project to
|
||||
* the given one.
|
||||
*/
|
||||
public class BuildConfigAction extends Action {
|
||||
|
||||
private String fConfigName = null;
|
||||
private HashSet fProjects = null;
|
||||
|
||||
/**
|
||||
* Constructs the action.
|
||||
* @param projects List of selected managed-built projects
|
||||
* @param configName Build configuration name
|
||||
* @param accel Number to be used as accelerator
|
||||
*/
|
||||
public BuildConfigAction(HashSet projects, String configName, String displayName, int accel) {
|
||||
super("&" + accel + " " + displayName); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
fProjects = projects;
|
||||
fConfigName = configName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jface.action.IAction#run()
|
||||
*/
|
||||
public void run() {
|
||||
Iterator iter = fProjects.iterator();
|
||||
while (iter.hasNext()) {
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)iter.next());
|
||||
if (info != null && info.isValid()) {
|
||||
IConfiguration[] configs = info.getManagedProject().getConfigurations();
|
||||
int i = 0;
|
||||
for (; i < configs.length; i++) {
|
||||
if (configs[i].getName().equals(fConfigName)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i != configs.length) {
|
||||
info.setDefaultConfiguration(configs[i]);
|
||||
info.setSelectedConfiguration(configs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,215 +1,215 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.ui.actions;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.eclipse.cdt.core.model.*;
|
||||
import org.eclipse.cdt.managedbuilder.core.*;
|
||||
import org.eclipse.core.resources.*;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.action.*;
|
||||
import org.eclipse.jface.viewers.*;
|
||||
import org.eclipse.swt.widgets.*;
|
||||
|
||||
/**
|
||||
* Base class for build configuration actions.
|
||||
*/
|
||||
public class ChangeBuildConfigActionBase {
|
||||
|
||||
/**
|
||||
* List of selected managed-built projects
|
||||
*/
|
||||
protected HashSet fProjects = new HashSet();
|
||||
|
||||
/**
|
||||
* Fills the menu with build configurations which are common for all selected projects
|
||||
* @param menu The menu to fill
|
||||
*/
|
||||
protected void fillMenu(Menu menu) {
|
||||
if (menu == null) {
|
||||
// This should not happen
|
||||
return;
|
||||
}
|
||||
|
||||
MenuItem[] items = menu.getItems();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i].dispose();
|
||||
}
|
||||
|
||||
TreeSet configNames = new TreeSet();
|
||||
Iterator projIter = fProjects.iterator();
|
||||
String sCurrentConfig = null;
|
||||
boolean bCurrentConfig = true;
|
||||
while (projIter.hasNext()) {
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)projIter.next());
|
||||
if (info != null && info.isValid()) {
|
||||
if (bCurrentConfig) {
|
||||
String sNewConfig = info.getDefaultConfiguration().getName();
|
||||
if (sCurrentConfig == null) {
|
||||
sCurrentConfig = sNewConfig;
|
||||
}
|
||||
else {
|
||||
if (!sCurrentConfig.equals(sNewConfig)) {
|
||||
bCurrentConfig = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
IConfiguration[] configs = info.getManagedProject().getConfigurations();
|
||||
for (int i = 0; i < configs.length; i++) {
|
||||
configNames.add(configs[i].getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Iterator confIter = configNames.iterator();
|
||||
int accel = 0;
|
||||
while (confIter.hasNext()) {
|
||||
String sName = (String)confIter.next();
|
||||
String sDesc = null;
|
||||
projIter = fProjects.iterator();
|
||||
boolean commonName = true;
|
||||
boolean commonDesc = true;
|
||||
boolean firstProj = true;
|
||||
while (projIter.hasNext()) {
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)projIter.next());
|
||||
if (info != null && info.isValid()) {
|
||||
IConfiguration[] configs = info.getManagedProject().getConfigurations();
|
||||
int i = 0;
|
||||
for (; i < configs.length; i++) {
|
||||
if (configs[i].getName().equals(sName)) {
|
||||
String sNewDesc = configs[i].getDescription();
|
||||
if (sNewDesc.equals("")) { //$NON-NLS-1$
|
||||
sNewDesc = null;
|
||||
}
|
||||
if (commonDesc) {
|
||||
if (firstProj) {
|
||||
sDesc = sNewDesc;
|
||||
firstProj = false;
|
||||
} else if (sNewDesc == null && sDesc != null || sNewDesc != null && !sNewDesc.equals(sDesc)) {
|
||||
commonDesc = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == configs.length) {
|
||||
commonName = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (commonName) {
|
||||
StringBuffer builder = new StringBuffer(sName);
|
||||
if (commonDesc) {
|
||||
if (sDesc != null) {
|
||||
builder.append(" ("); //$NON-NLS-1$
|
||||
builder.append(sDesc);
|
||||
builder.append(")"); //$NON-NLS-1$
|
||||
}
|
||||
} else {
|
||||
builder.append(" (...)"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
IAction action = new BuildConfigAction(fProjects, sName, builder.toString(), accel + 1);
|
||||
if (bCurrentConfig && sCurrentConfig.equals(sName)) {
|
||||
action.setChecked(true);
|
||||
}
|
||||
ActionContributionItem item = new ActionContributionItem(action);
|
||||
item.fill(menu, -1);
|
||||
accel++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* selectionChanged() event handler. Fills the list of managed-built projects
|
||||
* based on the selection. If some non-managed-built projects are selected,
|
||||
* disables the action.
|
||||
* @param action The action
|
||||
* @param selection The selection
|
||||
*/
|
||||
protected void onSelectionChanged(IAction action, ISelection selection) {
|
||||
fProjects.clear();
|
||||
|
||||
if (!action.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean found = false;
|
||||
if (selection != null && selection instanceof IStructuredSelection) {
|
||||
Iterator iter = ((IStructuredSelection)selection).iterator();
|
||||
while (iter.hasNext()) {
|
||||
Object selItem = iter.next();
|
||||
IProject project = null;
|
||||
if (selItem instanceof ICElement) {
|
||||
ICProject cproject = ((ICElement)selItem).getCProject();
|
||||
if (cproject != null) {
|
||||
project = cproject.getProject();
|
||||
}
|
||||
}
|
||||
else if (selItem instanceof IResource) {
|
||||
project = ((IResource)selItem).getProject();
|
||||
}
|
||||
if (project != null) {
|
||||
try {
|
||||
if (project != null && !project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
|
||||
project = null;
|
||||
}
|
||||
}
|
||||
catch (CoreException xE) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
if (project != null) {
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||
if (info != null && info.isValid()) {
|
||||
fProjects.add(project);
|
||||
}
|
||||
} else {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean enable = false;
|
||||
if (!found && !fProjects.isEmpty()) {
|
||||
Iterator iter = fProjects.iterator();
|
||||
IProject first = (IProject)iter.next();
|
||||
IConfiguration[] firstConfigs = ManagedBuildManager.getBuildInfo(first).getManagedProject().getConfigurations();
|
||||
for (int i = 0; i < firstConfigs.length; i++)
|
||||
{
|
||||
boolean common = true;
|
||||
iter = fProjects.iterator();
|
||||
while (iter.hasNext()) {
|
||||
IProject current = (IProject)iter.next();
|
||||
IConfiguration[] currentConfigs = ManagedBuildManager.getBuildInfo(current).getManagedProject().getConfigurations();
|
||||
int j = 0;
|
||||
for (; j < currentConfigs.length; j++) {
|
||||
if (firstConfigs[i].getName().equals(currentConfigs[j].getName())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == currentConfigs.length) {
|
||||
common = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (common) {
|
||||
enable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
action.setEnabled(enable);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.ui.actions;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.eclipse.cdt.core.model.*;
|
||||
import org.eclipse.cdt.managedbuilder.core.*;
|
||||
import org.eclipse.core.resources.*;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.action.*;
|
||||
import org.eclipse.jface.viewers.*;
|
||||
import org.eclipse.swt.widgets.*;
|
||||
|
||||
/**
|
||||
* Base class for build configuration actions.
|
||||
*/
|
||||
public class ChangeBuildConfigActionBase {
|
||||
|
||||
/**
|
||||
* List of selected managed-built projects
|
||||
*/
|
||||
protected HashSet fProjects = new HashSet();
|
||||
|
||||
/**
|
||||
* Fills the menu with build configurations which are common for all selected projects
|
||||
* @param menu The menu to fill
|
||||
*/
|
||||
protected void fillMenu(Menu menu) {
|
||||
if (menu == null) {
|
||||
// This should not happen
|
||||
return;
|
||||
}
|
||||
|
||||
MenuItem[] items = menu.getItems();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i].dispose();
|
||||
}
|
||||
|
||||
TreeSet configNames = new TreeSet();
|
||||
Iterator projIter = fProjects.iterator();
|
||||
String sCurrentConfig = null;
|
||||
boolean bCurrentConfig = true;
|
||||
while (projIter.hasNext()) {
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)projIter.next());
|
||||
if (info != null && info.isValid()) {
|
||||
if (bCurrentConfig) {
|
||||
String sNewConfig = info.getDefaultConfiguration().getName();
|
||||
if (sCurrentConfig == null) {
|
||||
sCurrentConfig = sNewConfig;
|
||||
}
|
||||
else {
|
||||
if (!sCurrentConfig.equals(sNewConfig)) {
|
||||
bCurrentConfig = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
IConfiguration[] configs = info.getManagedProject().getConfigurations();
|
||||
for (int i = 0; i < configs.length; i++) {
|
||||
configNames.add(configs[i].getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Iterator confIter = configNames.iterator();
|
||||
int accel = 0;
|
||||
while (confIter.hasNext()) {
|
||||
String sName = (String)confIter.next();
|
||||
String sDesc = null;
|
||||
projIter = fProjects.iterator();
|
||||
boolean commonName = true;
|
||||
boolean commonDesc = true;
|
||||
boolean firstProj = true;
|
||||
while (projIter.hasNext()) {
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)projIter.next());
|
||||
if (info != null && info.isValid()) {
|
||||
IConfiguration[] configs = info.getManagedProject().getConfigurations();
|
||||
int i = 0;
|
||||
for (; i < configs.length; i++) {
|
||||
if (configs[i].getName().equals(sName)) {
|
||||
String sNewDesc = configs[i].getDescription();
|
||||
if (sNewDesc.equals("")) { //$NON-NLS-1$
|
||||
sNewDesc = null;
|
||||
}
|
||||
if (commonDesc) {
|
||||
if (firstProj) {
|
||||
sDesc = sNewDesc;
|
||||
firstProj = false;
|
||||
} else if (sNewDesc == null && sDesc != null || sNewDesc != null && !sNewDesc.equals(sDesc)) {
|
||||
commonDesc = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == configs.length) {
|
||||
commonName = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (commonName) {
|
||||
StringBuffer builder = new StringBuffer(sName);
|
||||
if (commonDesc) {
|
||||
if (sDesc != null) {
|
||||
builder.append(" ("); //$NON-NLS-1$
|
||||
builder.append(sDesc);
|
||||
builder.append(")"); //$NON-NLS-1$
|
||||
}
|
||||
} else {
|
||||
builder.append(" (...)"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
IAction action = new BuildConfigAction(fProjects, sName, builder.toString(), accel + 1);
|
||||
if (bCurrentConfig && sCurrentConfig.equals(sName)) {
|
||||
action.setChecked(true);
|
||||
}
|
||||
ActionContributionItem item = new ActionContributionItem(action);
|
||||
item.fill(menu, -1);
|
||||
accel++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* selectionChanged() event handler. Fills the list of managed-built projects
|
||||
* based on the selection. If some non-managed-built projects are selected,
|
||||
* disables the action.
|
||||
* @param action The action
|
||||
* @param selection The selection
|
||||
*/
|
||||
protected void onSelectionChanged(IAction action, ISelection selection) {
|
||||
fProjects.clear();
|
||||
|
||||
if (!action.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean found = false;
|
||||
if (selection != null && selection instanceof IStructuredSelection) {
|
||||
Iterator iter = ((IStructuredSelection)selection).iterator();
|
||||
while (iter.hasNext()) {
|
||||
Object selItem = iter.next();
|
||||
IProject project = null;
|
||||
if (selItem instanceof ICElement) {
|
||||
ICProject cproject = ((ICElement)selItem).getCProject();
|
||||
if (cproject != null) {
|
||||
project = cproject.getProject();
|
||||
}
|
||||
}
|
||||
else if (selItem instanceof IResource) {
|
||||
project = ((IResource)selItem).getProject();
|
||||
}
|
||||
if (project != null) {
|
||||
try {
|
||||
if (project != null && !project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
|
||||
project = null;
|
||||
}
|
||||
}
|
||||
catch (CoreException xE) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
if (project != null) {
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||
if (info != null && info.isValid()) {
|
||||
fProjects.add(project);
|
||||
}
|
||||
} else {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean enable = false;
|
||||
if (!found && !fProjects.isEmpty()) {
|
||||
Iterator iter = fProjects.iterator();
|
||||
IProject first = (IProject)iter.next();
|
||||
IConfiguration[] firstConfigs = ManagedBuildManager.getBuildInfo(first).getManagedProject().getConfigurations();
|
||||
for (int i = 0; i < firstConfigs.length; i++)
|
||||
{
|
||||
boolean common = true;
|
||||
iter = fProjects.iterator();
|
||||
while (iter.hasNext()) {
|
||||
IProject current = (IProject)iter.next();
|
||||
IConfiguration[] currentConfigs = ManagedBuildManager.getBuildInfo(current).getManagedProject().getConfigurations();
|
||||
int j = 0;
|
||||
for (; j < currentConfigs.length; j++) {
|
||||
if (firstConfigs[i].getName().equals(currentConfigs[j].getName())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == currentConfigs.length) {
|
||||
common = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (common) {
|
||||
enable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
action.setEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue