1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 01:05:38 +02:00

Fix line endings

This commit is contained in:
Leo Treggiari 2006-03-07 18:33:01 +00:00
parent 52341a3587
commit bdc33b193c
40 changed files with 34126 additions and 34126 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,67 +1,67 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others. * Copyright (c) 2004, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.tests.suite; package org.eclipse.cdt.managedbuilder.tests.suite;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests; import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests20; import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests20;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests_SharedToolOptions; import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests_SharedToolOptions;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildEnvironmentTests; import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildEnvironmentTests;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildMacrosTests; import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildMacrosTests;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildDependencyCalculatorTests; import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildDependencyCalculatorTests;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildTCSupportedTest; import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildTCSupportedTest;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedCommandLineGeneratorTest; import org.eclipse.cdt.managedbuilder.core.tests.ManagedCommandLineGeneratorTest;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedProject21MakefileTests; import org.eclipse.cdt.managedbuilder.core.tests.ManagedProject21MakefileTests;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedProject30MakefileTests; import org.eclipse.cdt.managedbuilder.core.tests.ManagedProject30MakefileTests;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedProjectUpdateTests; import org.eclipse.cdt.managedbuilder.core.tests.ManagedProjectUpdateTests;
import org.eclipse.cdt.managedbuilder.core.tests.MultiVersionSupportTests; import org.eclipse.cdt.managedbuilder.core.tests.MultiVersionSupportTests;
import org.eclipse.cdt.managedbuilder.core.tests.OptionEnablementTests; import org.eclipse.cdt.managedbuilder.core.tests.OptionEnablementTests;
import org.eclipse.cdt.managedbuilder.core.tests.ResourceBuildCoreTests; import org.eclipse.cdt.managedbuilder.core.tests.ResourceBuildCoreTests;
/** /**
* *
*/ */
public class AllManagedBuildTests { public class AllManagedBuildTests {
public static void main(String[] args) { public static void main(String[] args) {
CCorePlugin.getDefault().getCoreModel().getIndexManager().reset(); CCorePlugin.getDefault().getCoreModel().getIndexManager().reset();
junit.textui.TestRunner.run(AllManagedBuildTests.suite()); junit.textui.TestRunner.run(AllManagedBuildTests.suite());
} }
public static Test suite() { public static Test suite() {
// May/2005 Turning off all indexing for now because the "original" indexer causes hangs... // 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); CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, CCorePlugin.NULL_INDEXER_UNIQUE_ID);
// We could enable this later... // We could enable this later...
//CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, "org.eclipse.cdt.core.domsourceindexer"); //CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, "org.eclipse.cdt.core.domsourceindexer");
TestSuite suite = new TestSuite( TestSuite suite = new TestSuite(
"Test for org.eclipse.cdt.managedbuild.core.tests"); "Test for org.eclipse.cdt.managedbuild.core.tests");
//$JUnit-BEGIN$ //$JUnit-BEGIN$
// TODO uncoment this // TODO uncoment this
suite.addTest(ManagedBuildCoreTests20.suite()); suite.addTest(ManagedBuildCoreTests20.suite());
suite.addTest(ManagedBuildCoreTests.suite()); suite.addTest(ManagedBuildCoreTests.suite());
suite.addTest(ManagedProjectUpdateTests.suite()); suite.addTest(ManagedProjectUpdateTests.suite());
suite.addTest(ManagedCommandLineGeneratorTest.suite()); suite.addTest(ManagedCommandLineGeneratorTest.suite());
suite.addTest(ResourceBuildCoreTests.suite()); suite.addTest(ResourceBuildCoreTests.suite());
suite.addTest(ManagedProject21MakefileTests.suite()); suite.addTest(ManagedProject21MakefileTests.suite());
suite.addTest(ManagedProject30MakefileTests.suite()); suite.addTest(ManagedProject30MakefileTests.suite());
suite.addTest(ManagedBuildCoreTests_SharedToolOptions.suite()); suite.addTest(ManagedBuildCoreTests_SharedToolOptions.suite());
suite.addTest(ManagedBuildEnvironmentTests.suite()); suite.addTest(ManagedBuildEnvironmentTests.suite());
suite.addTest(ManagedBuildMacrosTests.suite()); suite.addTest(ManagedBuildMacrosTests.suite());
suite.addTest(ManagedBuildTCSupportedTest.suite()); suite.addTest(ManagedBuildTCSupportedTest.suite());
suite.addTest(MultiVersionSupportTests.suite()); suite.addTest(MultiVersionSupportTests.suite());
suite.addTest(OptionEnablementTests.suite()); suite.addTest(OptionEnablementTests.suite());
suite.addTest(ManagedBuildDependencyCalculatorTests.suite()); suite.addTest(ManagedBuildDependencyCalculatorTests.suite());
//$JUnit-END$ //$JUnit-END$
return suite; return suite;
} }
} }

View file

@ -1,240 +1,240 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
/********************************************************************** /**********************************************************************
* These tests are for the default dependency calculators * These tests are for the default dependency calculators
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.managedbuilder.core.tests; package org.eclipse.cdt.managedbuilder.core.tests;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.util.ArrayList; import java.util.ArrayList;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager; import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
import org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin; import org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin;
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper; import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.ui.dialogs.IOverwriteQuery; import org.eclipse.ui.dialogs.IOverwriteQuery;
public class ManagedBuildDependencyCalculatorTests extends TestCase { public class ManagedBuildDependencyCalculatorTests extends TestCase {
public ManagedBuildDependencyCalculatorTests(String name) { public ManagedBuildDependencyCalculatorTests(String name) {
super(name); super(name);
} }
public static Test suite() { public static Test suite() {
TestSuite suite = new TestSuite(ManagedBuildDependencyCalculatorTests.class.getName()); TestSuite suite = new TestSuite(ManagedBuildDependencyCalculatorTests.class.getName());
suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalc2")); suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalc2"));
suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalc3")); suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalc3"));
suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalcPreBuild")); suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalcPreBuild"));
return suite; return suite;
} }
private IProject[] createProject(String projName, IPath location, String projectTypeId, boolean containsZip){ private IProject[] createProject(String projName, IPath location, String projectTypeId, boolean containsZip){
ArrayList projectList = null; ArrayList projectList = null;
if (containsZip) { if (containsZip) {
File testDir = CTestPlugin.getFileInPlugin(new Path("resources/depCalcProjects/" + projName)); File testDir = CTestPlugin.getFileInPlugin(new Path("resources/depCalcProjects/" + projName));
if(testDir == null) { if(testDir == null) {
fail("Test project directory " + projName + " is missing."); fail("Test project directory " + projName + " is missing.");
return null; return null;
} }
File projectZips[] = testDir.listFiles(new FileFilter(){ File projectZips[] = testDir.listFiles(new FileFilter(){
public boolean accept(File pathname){ public boolean accept(File pathname){
if(pathname.isDirectory()) if(pathname.isDirectory())
return false; return false;
return true; return true;
} }
}); });
projectList = new ArrayList(projectZips.length); projectList = new ArrayList(projectZips.length);
for(int i = 0; i < projectZips.length; i++){ for(int i = 0; i < projectZips.length; i++){
try{ try{
String projectName = projectZips[i].getName(); String projectName = projectZips[i].getName();
if(!projectName.endsWith(".zip")) if(!projectName.endsWith(".zip"))
continue; continue;
projectName = projectName.substring(0,projectName.length()-".zip".length()); projectName = projectName.substring(0,projectName.length()-".zip".length());
if(projectName.length() == 0) if(projectName.length() == 0)
continue; continue;
IProject project = ManagedBuildTestHelper.createProject(projectName, projectZips[i], location, projectTypeId); IProject project = ManagedBuildTestHelper.createProject(projectName, projectZips[i], location, projectTypeId);
if(project != null) if(project != null)
projectList.add(project); projectList.add(project);
} }
catch(Exception e){ catch(Exception e){
} }
} }
if(projectList.size() == 0) { if(projectList.size() == 0) {
fail("No projects found in test project directory " + testDir.getName() + ". The .zip file may be missing or corrupt."); fail("No projects found in test project directory " + testDir.getName() + ". The .zip file may be missing or corrupt.");
return null; return null;
} }
} else { } else {
try{ try{
IProject project = ManagedBuildTestHelper.createProject(projName, null, location, projectTypeId); IProject project = ManagedBuildTestHelper.createProject(projName, null, location, projectTypeId);
if(project != null) if(project != null)
projectList = new ArrayList(1); projectList = new ArrayList(1);
projectList.add(project); projectList.add(project);
} catch(Exception e){} } catch(Exception e){}
} }
return (IProject[])projectList.toArray(new IProject[projectList.size()]); return (IProject[])projectList.toArray(new IProject[projectList.size()]);
} }
private IProject[] createProjects(String projName, IPath location, String projectTypeId, boolean containsZip) { private IProject[] createProjects(String projName, IPath location, String projectTypeId, boolean containsZip) {
// In case the projects need to be updated... // In case the projects need to be updated...
IOverwriteQuery queryALL = new IOverwriteQuery(){ IOverwriteQuery queryALL = new IOverwriteQuery(){
public String queryOverwrite(String file) { public String queryOverwrite(String file) {
return ALL; return ALL;
}}; }};
IOverwriteQuery queryNOALL = new IOverwriteQuery(){ IOverwriteQuery queryNOALL = new IOverwriteQuery(){
public String queryOverwrite(String file) { public String queryOverwrite(String file) {
return NO_ALL; return NO_ALL;
}}; }};
UpdateManagedProjectManager.setBackupFileOverwriteQuery(queryALL); UpdateManagedProjectManager.setBackupFileOverwriteQuery(queryALL);
UpdateManagedProjectManager.setUpdateProjectQuery(queryALL); UpdateManagedProjectManager.setUpdateProjectQuery(queryALL);
IProject projects[] = createProject(projName, location, projectTypeId, containsZip); IProject projects[] = createProject(projName, location, projectTypeId, containsZip);
return projects; return projects;
} }
private void buildProjectsWorker(IProject projects[], IPath[] files, boolean compareBenchmark) { private void buildProjectsWorker(IProject projects[], IPath[] files, boolean compareBenchmark) {
if(projects == null || projects.length == 0) if(projects == null || projects.length == 0)
return; return;
boolean succeeded = true; boolean succeeded = true;
for (int i = 0; i < projects.length; i++){ for (int i = 0; i < projects.length; i++){
IProject curProject = projects[i]; IProject curProject = projects[i];
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(curProject); IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(curProject);
//check whether the managed build info is converted //check whether the managed build info is converted
boolean isCompatible = UpdateManagedProjectManager.isCompatibleProject(info); boolean isCompatible = UpdateManagedProjectManager.isCompatibleProject(info);
assertTrue(isCompatible); assertTrue(isCompatible);
if (isCompatible){ if (isCompatible){
// Build the project in order to generate the makefiles // Build the project in order to generate the makefiles
try{ try{
curProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,null); curProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,null);
} }
catch(CoreException e){ catch(CoreException e){
fail(e.getStatus().getMessage()); fail(e.getStatus().getMessage());
} }
catch(OperationCanceledException e){ catch(OperationCanceledException e){
fail("the project \"" + curProject.getName() + "\" build was cancelled, exception message: " + e.getMessage()); fail("the project \"" + curProject.getName() + "\" build was cancelled, exception message: " + e.getMessage());
} }
//compare the generated makefiles to their benchmarks //compare the generated makefiles to their benchmarks
if (files != null && files.length > 0) { if (files != null && files.length > 0) {
if (i == 0) { if (i == 0) {
String configName = info.getDefaultConfiguration().getName(); String configName = info.getDefaultConfiguration().getName();
IPath buildDir = Path.fromOSString(configName); IPath buildDir = Path.fromOSString(configName);
if (compareBenchmark) if (compareBenchmark)
succeeded = ManagedBuildTestHelper.compareBenchmarks(curProject, buildDir, files); succeeded = ManagedBuildTestHelper.compareBenchmarks(curProject, buildDir, files);
else else
succeeded = ManagedBuildTestHelper.verifyFilesDoNotExist(curProject, buildDir, files); succeeded = ManagedBuildTestHelper.verifyFilesDoNotExist(curProject, buildDir, files);
} }
} }
} }
} }
if (succeeded) { // Otherwise leave the projects around for comparison if (succeeded) { // Otherwise leave the projects around for comparison
for (int i = 0; i < projects.length; i++) for (int i = 0; i < projects.length; i++)
ManagedBuildTestHelper.removeProject(projects[i].getName()); ManagedBuildTestHelper.removeProject(projects[i].getName());
} }
} }
// Build projects and compare benchmarks // Build projects and compare benchmarks
private void buildProjects(IProject projects[], IPath[] files) { private void buildProjects(IProject projects[], IPath[] files) {
buildProjectsWorker(projects, files, true); buildProjectsWorker(projects, files, true);
} }
/* (non-Javadoc) /* (non-Javadoc)
* test for dependency calculation as a side-effect of compilation * test for dependency calculation as a side-effect of compilation
*/ */
public void test1DepCalc2(){ public void test1DepCalc2(){
IPath[] makefiles = { IPath[] makefiles = {
Path.fromOSString("makefile"), Path.fromOSString("makefile"),
Path.fromOSString("objects.mk"), Path.fromOSString("objects.mk"),
Path.fromOSString("sources.mk"), Path.fromOSString("sources.mk"),
Path.fromOSString("subdir.mk"), Path.fromOSString("subdir.mk"),
// This file is different using Cygwin vs GCC // This file is different using Cygwin vs GCC
//Path.fromOSString("main.d"), //Path.fromOSString("main.d"),
Path.fromOSString("Sources/subdir.mk"), Path.fromOSString("Sources/subdir.mk"),
Path.fromOSString("Sources/func1.d"), Path.fromOSString("Sources/func1.d"),
Path.fromOSString("Sources/func2.d"), Path.fromOSString("Sources/func2.d"),
Path.fromOSString("Sources/func4.d"), Path.fromOSString("Sources/func4.d"),
Path.fromOSString("Sources/sub sources/func 3.d"), Path.fromOSString("Sources/sub sources/func 3.d"),
Path.fromOSString("Sources/sub sources/subdir.mk")}; Path.fromOSString("Sources/sub sources/subdir.mk")};
IProject[] projects = createProjects("test1DepCalc2", null, null, true); IProject[] projects = createProjects("test1DepCalc2", null, null, true);
buildProjects(projects, makefiles); buildProjects(projects, makefiles);
} }
/* (non-Javadoc) /* (non-Javadoc)
* test for dependency calculation using Echo, a 2nd conmpilation step, and post-processing * test for dependency calculation using Echo, a 2nd conmpilation step, and post-processing
*/ */
public void test1DepCalc3(){ public void test1DepCalc3(){
IPath[] makefiles = { IPath[] makefiles = {
Path.fromOSString("makefile"), Path.fromOSString("makefile"),
Path.fromOSString("objects.mk"), Path.fromOSString("objects.mk"),
Path.fromOSString("sources.mk"), Path.fromOSString("sources.mk"),
Path.fromOSString("subdir.mk"), Path.fromOSString("subdir.mk"),
// This file is different using Cygwin vs GCC // This file is different using Cygwin vs GCC
//Path.fromOSString("main.d"), //Path.fromOSString("main.d"),
Path.fromOSString("Sources/subdir.mk"), Path.fromOSString("Sources/subdir.mk"),
Path.fromOSString("Sources/func1.d"), Path.fromOSString("Sources/func1.d"),
Path.fromOSString("Sources/func2.d"), Path.fromOSString("Sources/func2.d"),
Path.fromOSString("Sources/func4.d"), Path.fromOSString("Sources/func4.d"),
Path.fromOSString("Sources/sub sources/func 3.d"), Path.fromOSString("Sources/sub sources/func 3.d"),
Path.fromOSString("Sources/sub sources/subdir.mk")}; Path.fromOSString("Sources/sub sources/subdir.mk")};
IProject[] projects = createProjects("test1DepCalc3", null, null, true); IProject[] projects = createProjects("test1DepCalc3", null, null, true);
buildProjects(projects, makefiles); buildProjects(projects, makefiles);
} }
/* (non-Javadoc) /* (non-Javadoc)
* test for dependency calculation that uses a separate, pre-build, step to generate dependency files * test for dependency calculation that uses a separate, pre-build, step to generate dependency files
*/ */
public void test1DepCalcPreBuild(){ public void test1DepCalcPreBuild(){
IPath[] makefiles = { IPath[] makefiles = {
Path.fromOSString("makefile"), Path.fromOSString("makefile"),
Path.fromOSString("objects.mk"), Path.fromOSString("objects.mk"),
Path.fromOSString("sources.mk"), Path.fromOSString("sources.mk"),
Path.fromOSString("subdir.mk"), Path.fromOSString("subdir.mk"),
// This file is different using Cygwin vs GCC // This file is different using Cygwin vs GCC
//Path.fromOSString("main.d"), //Path.fromOSString("main.d"),
Path.fromOSString("Sources/subdir.mk"), Path.fromOSString("Sources/subdir.mk"),
Path.fromOSString("Sources/func1.d"), Path.fromOSString("Sources/func1.d"),
Path.fromOSString("Sources/func2.d"), Path.fromOSString("Sources/func2.d"),
Path.fromOSString("Sources/func4.d"), Path.fromOSString("Sources/func4.d"),
Path.fromOSString("Sources/sub sources/func 3.d"), Path.fromOSString("Sources/sub sources/func 3.d"),
Path.fromOSString("Sources/sub sources/subdir.mk")}; Path.fromOSString("Sources/sub sources/subdir.mk")};
IProject[] projects = createProjects("test1DepCalcPreBuild", null, null, true); IProject[] projects = createProjects("test1DepCalcPreBuild", null, null, true);
buildProjects(projects, makefiles); buildProjects(projects, makefiles);
} }
} }

View file

@ -1,111 +1,111 @@
############################################################################### ###############################################################################
# Copyright (c) 2002, 2006 Rational Software Corporation and others. # Copyright (c) 2002, 2006 Rational Software Corporation and others.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html # http://www.eclipse.org/legal/epl-v10.html
# #
# Contributors: # Contributors:
# IBM Rational Software - Initial API and implementation # IBM Rational Software - Initial API and implementation
############################################################################### ###############################################################################
# Generated makefile builder messages # Generated makefile builder messages
ManagedMakeBuilder.message.starting = Starting the build for project {0} ManagedMakeBuilder.message.starting = Starting the build for project {0}
ManagedMakeBuilder.message.rebuild.makefiles = Regenerating makefiles for project {0} ManagedMakeBuilder.message.rebuild.makefiles = Regenerating makefiles for project {0}
ManagedMakeBuilder.message.update.makefiles = Updating makefiles for project {0} ManagedMakeBuilder.message.update.makefiles = Updating makefiles for project {0}
ManagedMakeBuilder.message.incremental = Updating makefiles for project {0} ManagedMakeBuilder.message.incremental = Updating makefiles for project {0}
ManagedMakeBuilder.message.updating = Updating project files... ManagedMakeBuilder.message.updating = Updating project files...
ManagedMakeBuilder.message.make = Calling {0} for project {1} ManagedMakeBuilder.message.make = Calling {0} for project {1}
ManagedMakeBuilder.message.regen.deps = Regenerating dependency files for {0} ManagedMakeBuilder.message.regen.deps = Regenerating dependency files for {0}
ManagedMakeBuilder.message.updating.deps = Updating dependency files for {0} ManagedMakeBuilder.message.updating.deps = Updating dependency files for {0}
ManagedMakeBuilder.message.creating.markers = Generating markers... ManagedMakeBuilder.message.creating.markers = Generating markers...
ManagedMakeBuilder.message.console.header = **** {0} of configuration {1} for project {2} **** ManagedMakeBuilder.message.console.header = **** {0} of configuration {1} for project {2} ****
ManagedMakeBuilder.message.no.build = Nothing to build for {0} ManagedMakeBuilder.message.no.build = Nothing to build for {0}
ManagedMakeBuilder.message.error = Build error ManagedMakeBuilder.message.error = Build error
ManagedMakeBuilder.message.error.refresh = Error refreshing project ManagedMakeBuilder.message.error.refresh = Error refreshing project
ManagedMakeBuilder.message.finished = Build complete for project {0} ManagedMakeBuilder.message.finished = Build complete for project {0}
ManagedMakeBuilder.message.clean.deleting.output=Removing build artifacts from {0} ManagedMakeBuilder.message.clean.deleting.output=Removing build artifacts from {0}
ManagedMakeBuilder.message.clean.build.clean=Trying a make clean in {0} ManagedMakeBuilder.message.clean.build.clean=Trying a make clean in {0}
ManagedMakeBuilder.type.clean = Clean-only build ManagedMakeBuilder.type.clean = Clean-only build
ManagedMakeBuider.type.incremental = 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... **** 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 exception messages
Option.error.bad_value_type=Bad value for type Option.error.bad_value_type=Bad value for type
# Managed build manager exception messages # Managed build manager exception messages
ManagedBuildManager.error.owner_not_null=addTarget: owner not null ManagedBuildManager.error.owner_not_null=addTarget: owner not null
ManagedBuildManager.error.null_owner=addTarget: null owner ManagedBuildManager.error.null_owner=addTarget: null owner
ManagedBuildManager.error.owner_not_project=addTarget: owner not project ManagedBuildManager.error.owner_not_project=addTarget: owner not project
ManagedBuildManager.error.manifest_load_failed_title=Managed Build System Version Error 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.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.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.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.duplicate=Duplicate identifier {1} for element type {0}.
ManagedBuildManager.error.manifest.icon=Could not load icon "{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.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.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.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_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.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_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.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.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.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.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. ManagedBuildManager.error.project.file.missing=The Managed Make project file for project {0} is missing.
# Makefile Generator Messages # Makefile Generator Messages
MakefileGenerator.message.start.file=Building file: MakefileGenerator.message.start.file=Building file:
MakefileGenerator.message.finish.file=Finished building: MakefileGenerator.message.finish.file=Finished building:
MakefileGenerator.message.start.build=Building target: MakefileGenerator.message.start.build=Building target:
MakefileGenerator.message.finish.build=Finished building target: MakefileGenerator.message.finish.build=Finished building target:
MakefileGenerator.message.start.dependency=Regenerating dependency file: 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.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.adding.source.folder=Adding folder {0} to sources
MakefileGenerator.message.gen.source.makefile=Generating makefile for source folder {0} MakefileGenerator.message.gen.source.makefile=Generating makefile for source folder {0}
MakefileGenerator.message.calc.delta=Calculating the delta for project {0} MakefileGenerator.message.calc.delta=Calculating the delta for project {0}
MakefileGenerator.message.finding.sources=Finding source files in 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.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.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.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.rule = Each subdirectory must supply rules for building sources it contributes
MakefileGenerator.comment.build.toprules = Tool invocations MakefileGenerator.comment.build.toprules = Tool invocations
MakefileGenerator.comment.build.alltarget = All Target MakefileGenerator.comment.build.alltarget = All Target
MakefileGenerator.comment.build.mainbuildtarget = Main-build Target MakefileGenerator.comment.build.mainbuildtarget = Main-build Target
MakefileGenerator.comment.build.toptargets = Other Targets MakefileGenerator.comment.build.toptargets = Other Targets
MakefileGenerator.comment.module.make.includes = Include the makefiles for each source subdirectory MakefileGenerator.comment.module.make.includes = Include the makefiles for each source subdirectory
MakefileGenerator.comment.module.dep.includes = Include automatically-generated dependency list: MakefileGenerator.comment.module.dep.includes = Include automatically-generated dependency list:
MakefileGenerator.comment.autodeps=Automatically-generated dependency list: MakefileGenerator.comment.autodeps=Automatically-generated dependency list:
MakefileGenerator.comment.header=Automatically-generated file. Do not edit! MakefileGenerator.comment.header=Automatically-generated file. Do not edit!
MakefileGenerator.error.spaces=Cannot generate makefile for folder with spaces in name MakefileGenerator.error.spaces=Cannot generate makefile for folder with spaces in name
MakefileGenerator.warning.no.source=Nothing to build for project {0} MakefileGenerator.warning.no.source=Nothing to build for project {0}
MakefileGenerator.error.no.nameprovider=A nameProvider or outputNames must be specified with multipleType == true 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.job.init = Initializing path container for {0}
ManagedBuildInfo.message.init.ok = Initializing path container succeeded for {0} ManagedBuildInfo.message.init.ok = Initializing path container succeeded for {0}
# Default GNU Makefile Generator messages # Default GNU Makefile Generator messages
GnuMakefileGenerator.message.postproc.dep.file=Verifying contents of dependency file {0} GnuMakefileGenerator.message.postproc.dep.file=Verifying contents of dependency file {0}
# Tool strings # Tool strings
Tool.default.announcement=Invoking: Tool.default.announcement=Invoking:
#Environment loader messages #Environment loader messages
StorableEnvironmentLoader.storeOutputStream.wrong.arguments=Wrong arguments StorableEnvironmentLoader.storeOutputStream.wrong.arguments=Wrong arguments
#User Defined Macro Supplier #User Defined Macro Supplier
UserDefinedMacroSupplier.storeOutputStream.wrong.arguments=Failed to persist macros: Wrong arguments UserDefinedMacroSupplier.storeOutputStream.wrong.arguments=Failed to persist macros: Wrong arguments
# BuildMacroStatus messages # BuildMacroStatus messages
BuildMacroStatus.status.macro.undefined=Macro {0} is undefined BuildMacroStatus.status.macro.undefined=Macro {0} is undefined
BuildMacroStatus.status.reference.eachother=Macros {0} and {1} reference each other BuildMacroStatus.status.reference.eachother=Macros {0} and {1} reference each other
BuildMacroStatus.status.reference.incorrect=Macro {0} reference is incorrect 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.string=Macro {0} is not of String type
BuildMacroStatus.status.macro.not.stringlist=Macro {0} is not of String-list type BuildMacroStatus.status.macro.not.stringlist=Macro {0} is not of String-list type
BuildMacroStatus.status.error=Error occured BuildMacroStatus.status.error=Error occured
BuildMacroStatus.value.undefined= BuildMacroStatus.value.undefined=
#ResourceChangeHandler messages #ResourceChangeHandler messages
ResourceChangeHandler.buildInfoSerializationJob=Build Info Serialization ResourceChangeHandler.buildInfoSerializationJob=Build Info Serialization
#ManagedBuilderCorePlugin messages #ManagedBuilderCorePlugin messages
ManagedBuilderCorePlugin.resourceChangeHandlingInitializationJob=Initializing Resource Change Handling ManagedBuilderCorePlugin.resourceChangeHandlingInitializationJob=Initializing Resource Change Handling

View file

@ -1,458 +1,458 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005 Intel Corporation and others. * Copyright (c) 2005 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core; package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler; import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.IManagedProject; import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator; import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor; import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IResourceRuleFactory; import org.eclipse.core.resources.IResourceRuleFactory;
import org.eclipse.core.resources.ISaveContext; import org.eclipse.core.resources.ISaveContext;
import org.eclipse.core.resources.ISaveParticipant; import org.eclipse.core.resources.ISaveParticipant;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.MultiRule; import org.eclipse.core.runtime.jobs.MultiRule;
public class ResourceChangeHandler implements IResourceChangeListener, ISaveParticipant { public class ResourceChangeHandler implements IResourceChangeListener, ISaveParticipant {
private class ResourceConfigurationChecker implements IResourceDeltaVisitor{ private class ResourceConfigurationChecker implements IResourceDeltaVisitor{
private IResourceDelta fRootDelta; private IResourceDelta fRootDelta;
private HashMap fBuildFileGeneratorMap = new HashMap(); private HashMap fBuildFileGeneratorMap = new HashMap();
private HashSet fValidatedFilesSet = new HashSet(); private HashSet fValidatedFilesSet = new HashSet();
private HashSet fModifiedProjects = new HashSet(); private HashSet fModifiedProjects = new HashSet();
public ResourceConfigurationChecker(IResourceDelta rootDelta){ public ResourceConfigurationChecker(IResourceDelta rootDelta){
fRootDelta = rootDelta; fRootDelta = rootDelta;
} }
public IProject[] getModifiedProjects(){ public IProject[] getModifiedProjects(){
return (IProject[])fModifiedProjects.toArray(new IProject[fModifiedProjects.size()]); return (IProject[])fModifiedProjects.toArray(new IProject[fModifiedProjects.size()]);
} }
public boolean visit(IResourceDelta delta) throws CoreException { public boolean visit(IResourceDelta delta) throws CoreException {
IResource dResource = delta.getResource(); IResource dResource = delta.getResource();
int rcType = dResource.getType(); int rcType = dResource.getType();
if(rcType == IResource.PROJECT || rcType == IResource.FOLDER){ if(rcType == IResource.PROJECT || rcType == IResource.FOLDER){
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = null; IProject project = null;
IResource rcToCheck = null; IResource rcToCheck = null;
switch (delta.getKind()) { switch (delta.getKind()) {
case IResourceDelta.REMOVED : case IResourceDelta.REMOVED :
if ((delta.getFlags() & IResourceDelta.MOVED_TO) == 0 && rcType == IResource.PROJECT) { if ((delta.getFlags() & IResourceDelta.MOVED_TO) == 0 && rcType == IResource.PROJECT) {
sendClose((IProject)dResource); sendClose((IProject)dResource);
break; break;
} }
case IResourceDelta.CHANGED : case IResourceDelta.CHANGED :
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) { if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
IPath path = delta.getMovedToPath(); IPath path = delta.getMovedToPath();
if(path != null){ if(path != null){
project = root.findMember(path.segment(0)).getProject(); project = root.findMember(path.segment(0)).getProject();
if(project != null && rcType == IResource.FOLDER) if(project != null && rcType == IResource.FOLDER)
rcToCheck = root.getFolder(substituteProject(dResource.getFullPath(),project.getName())); rcToCheck = root.getFolder(substituteProject(dResource.getFullPath(),project.getName()));
} }
break; break;
} }
default: default:
project = dResource.getProject(); project = dResource.getProject();
if(rcType == IResource.FOLDER) if(rcType == IResource.FOLDER)
rcToCheck = dResource; rcToCheck = dResource;
break; break;
} }
if(project != null) { if(project != null) {
IManagedBuilderMakefileGenerator makeGen = getInitializedGenerator(project); IManagedBuilderMakefileGenerator makeGen = getInitializedGenerator(project);
if(makeGen != null){ if(makeGen != null){
if(rcToCheck == null || !makeGen.isGeneratedResource(rcToCheck)) if(rcToCheck == null || !makeGen.isGeneratedResource(rcToCheck))
return true; return true;
} }
} }
return false; return false;
} else if (rcType == IResource.FILE && !dResource.isDerived()) { } else if (rcType == IResource.FILE && !dResource.isDerived()) {
int flags = delta.getFlags(); int flags = delta.getFlags();
switch (delta.getKind()) { switch (delta.getKind()) {
case IResourceDelta.REMOVED : case IResourceDelta.REMOVED :
if ((flags & IResourceDelta.MOVED_TO) == 0) { if ((flags & IResourceDelta.MOVED_TO) == 0) {
handleDeleteFile(dResource.getFullPath()); handleDeleteFile(dResource.getFullPath());
break; break;
} }
case IResourceDelta.ADDED : case IResourceDelta.ADDED :
case IResourceDelta.CHANGED : case IResourceDelta.CHANGED :
if ((flags & IResourceDelta.MOVED_TO) != 0) { if ((flags & IResourceDelta.MOVED_TO) != 0) {
IPath path = delta.getMovedToPath(); IPath path = delta.getMovedToPath();
if (path != null) { if (path != null) {
handleRenamedFile( handleRenamedFile(
dResource.getFullPath(), dResource.getFullPath(),
path); path);
} }
} else if ((flags & IResourceDelta.MOVED_FROM) != 0) { } else if ((flags & IResourceDelta.MOVED_FROM) != 0) {
IPath path = delta.getMovedFromPath(); IPath path = delta.getMovedFromPath();
if (path != null) { if (path != null) {
handleRenamedFile( handleRenamedFile(
path, path,
dResource.getFullPath()); dResource.getFullPath());
} }
} }
break; break;
default: default:
break; break;
} }
return false; return false;
} }
return true; // visit the children return true; // visit the children
} }
private IPath substituteProject(IPath path, String projectName){ private IPath substituteProject(IPath path, String projectName){
return new Path(projectName).makeAbsolute().append(path.removeFirstSegments(1)); return new Path(projectName).makeAbsolute().append(path.removeFirstSegments(1));
} }
private void handleRenamedFile(IPath fromPath, IPath toPath){ private void handleRenamedFile(IPath fromPath, IPath toPath){
if(!fValidatedFilesSet.add(fromPath)) if(!fValidatedFilesSet.add(fromPath))
return; return;
IProject fromProject = findModifiedProject(fromPath.segment(0)); IProject fromProject = findModifiedProject(fromPath.segment(0));
if(fromProject == null) if(fromProject == null)
return; return;
IManagedBuilderMakefileGenerator fromMakeGen = getInitializedGenerator(fromProject); IManagedBuilderMakefileGenerator fromMakeGen = getInitializedGenerator(fromProject);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
if(fromMakeGen == null || fromMakeGen.isGeneratedResource(root.getFile(substituteProject(fromPath,fromProject.getName())))) if(fromMakeGen == null || fromMakeGen.isGeneratedResource(root.getFile(substituteProject(fromPath,fromProject.getName()))))
return; return;
IManagedBuildInfo fromInfo = fromProject != null ? IManagedBuildInfo fromInfo = fromProject != null ?
ManagedBuildManager.getBuildInfo(fromProject) : ManagedBuildManager.getBuildInfo(fromProject) :
null; null;
IProject toProject = root.findMember(toPath.uptoSegment(1)).getProject(); IProject toProject = root.findMember(toPath.uptoSegment(1)).getProject();
IManagedBuildInfo toInfo = toProject != null ? IManagedBuildInfo toInfo = toProject != null ?
ManagedBuildManager.getBuildInfo(toProject) : ManagedBuildManager.getBuildInfo(toProject) :
null; null;
IManagedBuilderMakefileGenerator toMakeGen = toProject != null ? IManagedBuilderMakefileGenerator toMakeGen = toProject != null ?
getInitializedGenerator(toProject) : getInitializedGenerator(toProject) :
null; null;
if(toMakeGen != null && toMakeGen.isGeneratedResource(root.getFile(toPath))) if(toMakeGen != null && toMakeGen.isGeneratedResource(root.getFile(toPath)))
toInfo = null; toInfo = null;
if(fromInfo == toInfo){ if(fromInfo == toInfo){
//the resource was moved whithing the project scope //the resource was moved whithing the project scope
if(updateResourceConfigurations(fromInfo,fromPath,toPath) && toProject != null) if(updateResourceConfigurations(fromInfo,fromPath,toPath) && toProject != null)
fModifiedProjects.add(toProject); fModifiedProjects.add(toProject);
} else { } else {
if(fromInfo != null && toInfo != null){ if(fromInfo != null && toInfo != null){
//TODO: this is the case when the resource //TODO: this is the case when the resource
//is moved from one managed project to another //is moved from one managed project to another
//should we handle this? //should we handle this?
//e.g. add resource configurations to the destination project? //e.g. add resource configurations to the destination project?
} }
if(fromInfo != null && removeResourceConfigurations(fromInfo,fromPath) && fromProject != null) if(fromInfo != null && removeResourceConfigurations(fromInfo,fromPath) && fromProject != null)
fModifiedProjects.add(fromProject); fModifiedProjects.add(fromProject);
} }
} }
private void handleDeleteFile(IPath path){ private void handleDeleteFile(IPath path){
IProject project = findModifiedProject(path.segment(0)); IProject project = findModifiedProject(path.segment(0));
if(project != null){ if(project != null){
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
if(info != null if(info != null
&& removeResourceConfigurations(info,path)) && removeResourceConfigurations(info,path))
fModifiedProjects.add(project); fModifiedProjects.add(project);
} }
} }
//finds the project geven the initial project name //finds the project geven the initial project name
//That is: //That is:
// if the project of a given name was renamed returns the renamed project // 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 removed returns null
// if the project of a given name was neither renamed or removed // 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 // returns the project of that name or null if the project does not exist
// //
private IProject findModifiedProject(final String oldProjectName){ private IProject findModifiedProject(final String oldProjectName){
IResourceDelta projectDelta = fRootDelta.findMember(new Path(oldProjectName)); IResourceDelta projectDelta = fRootDelta.findMember(new Path(oldProjectName));
boolean replaced = false; boolean replaced = false;
if(projectDelta != null) { if(projectDelta != null) {
switch(projectDelta.getKind()){ switch(projectDelta.getKind()){
case IResourceDelta.REMOVED : case IResourceDelta.REMOVED :
if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) == 0) { if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) == 0) {
return null; return null;
} }
case IResourceDelta.CHANGED : case IResourceDelta.CHANGED :
if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) { if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
IPath path = projectDelta.getMovedToPath(); IPath path = projectDelta.getMovedToPath();
if(path != null) if(path != null)
return ResourcesPlugin.getWorkspace().getRoot().findMember(path).getProject(); return ResourcesPlugin.getWorkspace().getRoot().findMember(path).getProject();
} }
break; break;
} }
} }
final IProject project[] = new IProject[1]; final IProject project[] = new IProject[1];
try { try {
fRootDelta.accept(new IResourceDeltaVisitor() { fRootDelta.accept(new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) throws CoreException { public boolean visit(IResourceDelta delta) throws CoreException {
IResource dResource = delta.getResource(); IResource dResource = delta.getResource();
int rcType = dResource.getType(); int rcType = dResource.getType();
if(rcType == IResource.ROOT) { if(rcType == IResource.ROOT) {
return true; return true;
} else if(rcType == IResource.PROJECT){ } else if(rcType == IResource.PROJECT){
switch(delta.getKind()){ switch(delta.getKind()){
case IResourceDelta.ADDED : case IResourceDelta.ADDED :
case IResourceDelta.CHANGED : case IResourceDelta.CHANGED :
if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) { if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
IPath path = delta.getMovedFromPath(); IPath path = delta.getMovedFromPath();
if (path != null && path.segment(0).equals(oldProjectName)) { if (path != null && path.segment(0).equals(oldProjectName)) {
project[0] = dResource.getProject(); project[0] = dResource.getProject();
} }
} }
break; break;
default: default:
break; break;
} }
} }
return false; return false;
} }
}); });
} catch (CoreException e) { } catch (CoreException e) {
} }
if(project[0] == null && !replaced) if(project[0] == null && !replaced)
project[0] = ResourcesPlugin.getWorkspace().getRoot().findMember(oldProjectName).getProject(); project[0] = ResourcesPlugin.getWorkspace().getRoot().findMember(oldProjectName).getProject();
return project[0]; return project[0];
} }
private IManagedBuilderMakefileGenerator getInitializedGenerator(IProject project){ private IManagedBuilderMakefileGenerator getInitializedGenerator(IProject project){
IManagedBuilderMakefileGenerator makeGen = (IManagedBuilderMakefileGenerator)fBuildFileGeneratorMap.get(project); IManagedBuilderMakefileGenerator makeGen = (IManagedBuilderMakefileGenerator)fBuildFileGeneratorMap.get(project);
if (makeGen == null) { if (makeGen == null) {
try { try {
if (project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) { if (project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
// Determine if we can access the build info before actually trying // 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 not, don't try, to avoid putting up a dialog box warning the user
if (!ManagedBuildManager.canGetBuildInfo(project)) return null; if (!ManagedBuildManager.canGetBuildInfo(project)) return null;
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project); IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
if (buildInfo != null){ if (buildInfo != null){
IConfiguration defaultCfg = buildInfo.getDefaultConfiguration(); IConfiguration defaultCfg = buildInfo.getDefaultConfiguration();
if (defaultCfg != null) { if (defaultCfg != null) {
makeGen = ManagedBuildManager.getBuildfileGenerator(defaultCfg); makeGen = ManagedBuildManager.getBuildfileGenerator(defaultCfg);
makeGen.initialize(project,buildInfo,new NullProgressMonitor()); makeGen.initialize(project,buildInfo,new NullProgressMonitor());
fBuildFileGeneratorMap.put(project,makeGen); fBuildFileGeneratorMap.put(project,makeGen);
} }
} }
} }
} catch (CoreException e){ } catch (CoreException e){
return null; return null;
} }
} }
return makeGen; return makeGen;
} }
} }
public void sendClose(IProject project){ public void sendClose(IProject project){
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project,false); IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project,false);
if(info != null){ if(info != null){
IManagedProject managedProj = info.getManagedProject(); IManagedProject managedProj = info.getManagedProject();
if (managedProj != null) { if (managedProj != null) {
IConfiguration cfgs[] = managedProj.getConfigurations(); IConfiguration cfgs[] = managedProj.getConfigurations();
for(int i = 0; i < cfgs.length; i++) for(int i = 0; i < cfgs.length; i++)
ManagedBuildManager.performValueHandlerEvent(cfgs[i], IManagedOptionValueHandler.EVENT_CLOSE, true); 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 * 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) /* (non-Javadoc)
* *
* Handle the renaming and deletion of project resources * Handle the renaming and deletion of project resources
* This is necessary in order to update ResourceConfigurations and AdditionalInputs * This is necessary in order to update ResourceConfigurations and AdditionalInputs
* *
* @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
*/ */
public void resourceChanged(IResourceChangeEvent event) { public void resourceChanged(IResourceChangeEvent event) {
if (event.getSource() instanceof IWorkspace) { if (event.getSource() instanceof IWorkspace) {
switch (event.getType()) { switch (event.getType()) {
case IResourceChangeEvent.PRE_CLOSE: case IResourceChangeEvent.PRE_CLOSE:
IResource proj = event.getResource(); IResource proj = event.getResource();
if(proj instanceof IProject) if(proj instanceof IProject)
sendClose((IProject)proj); sendClose((IProject)proj);
break; break;
case IResourceChangeEvent.POST_CHANGE : case IResourceChangeEvent.POST_CHANGE :
case IResourceChangeEvent.POST_BUILD : case IResourceChangeEvent.POST_BUILD :
case IResourceChangeEvent.PRE_DELETE : case IResourceChangeEvent.PRE_DELETE :
IResourceDelta resDelta = event.getDelta(); IResourceDelta resDelta = event.getDelta();
if (resDelta == null) { if (resDelta == null) {
break; break;
} }
try { try {
ResourceConfigurationChecker rcChecker = new ResourceConfigurationChecker(resDelta); ResourceConfigurationChecker rcChecker = new ResourceConfigurationChecker(resDelta);
resDelta.accept(rcChecker); resDelta.accept(rcChecker);
//saving info for the modified projects //saving info for the modified projects
initInfoSerialization(rcChecker.getModifiedProjects()); initInfoSerialization(rcChecker.getModifiedProjects());
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
} }
break; break;
default : default :
break; break;
} }
} }
} }
private void initInfoSerialization(final IProject projects[]){ private void initInfoSerialization(final IProject projects[]){
if(projects.length == 0) if(projects.length == 0)
return; return;
IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspace workspace = ResourcesPlugin.getWorkspace();
IResourceRuleFactory ruleFactory = workspace.getRuleFactory(); IResourceRuleFactory ruleFactory = workspace.getRuleFactory();
ISchedulingRule buildInfoSaveRule; ISchedulingRule buildInfoSaveRule;
if(projects.length == 1){ if(projects.length == 1){
buildInfoSaveRule = ruleFactory.modifyRule(projects[0]); buildInfoSaveRule = ruleFactory.modifyRule(projects[0]);
} else { } else {
ISchedulingRule rules[] = new ISchedulingRule[projects.length]; ISchedulingRule rules[] = new ISchedulingRule[projects.length];
for(int i = 0; i < rules.length; i++) for(int i = 0; i < rules.length; i++)
rules[i] = ruleFactory.modifyRule(projects[i]); rules[i] = ruleFactory.modifyRule(projects[i]);
buildInfoSaveRule = MultiRule.combine(rules); buildInfoSaveRule = MultiRule.combine(rules);
} }
Job savingJob = new Job(ManagedMakeMessages.getResourceString("ResourceChangeHandler.buildInfoSerializationJob")){ //$NON-NLS-1$ Job savingJob = new Job(ManagedMakeMessages.getResourceString("ResourceChangeHandler.buildInfoSerializationJob")){ //$NON-NLS-1$
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
for(int i = 0; i < projects.length; i++){ for(int i = 0; i < projects.length; i++){
ManagedBuildManager.saveBuildInfo(projects[i],true); ManagedBuildManager.saveBuildInfo(projects[i],true);
} }
return new Status( return new Status(
IStatus.OK, IStatus.OK,
ManagedBuilderCorePlugin.getUniqueIdentifier(), ManagedBuilderCorePlugin.getUniqueIdentifier(),
IStatus.OK, IStatus.OK,
new String(), new String(),
null); null);
} }
}; };
savingJob.setRule(buildInfoSaveRule); savingJob.setRule(buildInfoSaveRule);
savingJob.schedule(); savingJob.schedule();
} }
private boolean updateResourceConfigurations(IManagedBuildInfo info, IPath oldPath, IPath newPath){ private boolean updateResourceConfigurations(IManagedBuildInfo info, IPath oldPath, IPath newPath){
boolean changed = false; boolean changed = false;
if(!oldPath.equals(newPath)){ if(!oldPath.equals(newPath)){
IManagedProject mngProj = info.getManagedProject(); IManagedProject mngProj = info.getManagedProject();
if(mngProj != null){ if(mngProj != null){
IConfiguration configs[] = mngProj.getConfigurations(); IConfiguration configs[] = mngProj.getConfigurations();
if(configs != null && configs.length > 0){ if(configs != null && configs.length > 0){
for(int i = 0; i < configs.length; i++){ for(int i = 0; i < configs.length; i++){
if(updateResourceConfiguration(configs[i],oldPath,newPath)) if(updateResourceConfiguration(configs[i],oldPath,newPath))
changed = true; changed = true;
} }
} }
} }
} }
return changed; return changed;
} }
private boolean removeResourceConfigurations(IManagedBuildInfo info, IPath path){ private boolean removeResourceConfigurations(IManagedBuildInfo info, IPath path){
boolean changed = false; boolean changed = false;
IManagedProject mngProj = info.getManagedProject(); IManagedProject mngProj = info.getManagedProject();
if(mngProj != null){ if(mngProj != null){
IConfiguration configs[] = mngProj.getConfigurations(); IConfiguration configs[] = mngProj.getConfigurations();
if(configs != null && configs.length > 0){ if(configs != null && configs.length > 0){
for(int i = 0; i < configs.length; i++){ for(int i = 0; i < configs.length; i++){
if(removeResourceConfiguration(configs[i],path)) if(removeResourceConfiguration(configs[i],path))
changed = true; changed = true;
} }
} }
} }
return changed; return changed;
} }
private boolean updateResourceConfiguration(IConfiguration config, IPath oldPath, IPath newPath){ private boolean updateResourceConfiguration(IConfiguration config, IPath oldPath, IPath newPath){
IResourceConfiguration rcCfg = config.getResourceConfiguration(oldPath.toString()); IResourceConfiguration rcCfg = config.getResourceConfiguration(oldPath.toString());
if(rcCfg != null && !oldPath.equals(newPath)){ if(rcCfg != null && !oldPath.equals(newPath)){
config.removeResourceConfiguration(rcCfg); config.removeResourceConfiguration(rcCfg);
rcCfg.setResourcePath(newPath.toString()); rcCfg.setResourcePath(newPath.toString());
((Configuration)config).addResourceConfiguration((ResourceConfiguration)rcCfg); ((Configuration)config).addResourceConfiguration((ResourceConfiguration)rcCfg);
config.setRebuildState(true); config.setRebuildState(true);
return true; return true;
} }
return false; return false;
} }
private boolean removeResourceConfiguration(IConfiguration config, IPath path){ private boolean removeResourceConfiguration(IConfiguration config, IPath path){
IResourceConfiguration rcCfg = config.getResourceConfiguration(path.toString()); IResourceConfiguration rcCfg = config.getResourceConfiguration(path.toString());
if(rcCfg != null){ if(rcCfg != null){
config.removeResourceConfiguration(rcCfg); config.removeResourceConfiguration(rcCfg);
config.setRebuildState(true); config.setRebuildState(true);
return true; return true;
} }
return false; return false;
} }
/* /*
* I S a v e P a r t i c i p a n t * I S a v e P a r t i c i p a n t
*/ */
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext) * @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext)
*/ */
public void saving(ISaveContext context) throws CoreException { public void saving(ISaveContext context) throws CoreException {
// No state to be saved by the plug-in, but request a // No state to be saved by the plug-in, but request a
// resource delta to be used on next activation. // resource delta to be used on next activation.
context.needDelta(); context.needDelta();
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.core.resources.ISaveParticipant#doneSaving(org.eclipse.core.resources.ISaveContext) * @see org.eclipse.core.resources.ISaveParticipant#doneSaving(org.eclipse.core.resources.ISaveContext)
*/ */
public void doneSaving(ISaveContext context) { public void doneSaving(ISaveContext context) {
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(org.eclipse.core.resources.ISaveContext) * @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(org.eclipse.core.resources.ISaveContext)
*/ */
public void prepareToSave(ISaveContext context) throws CoreException { public void prepareToSave(ISaveContext context) throws CoreException {
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.core.resources.ISaveParticipant#rollback(org.eclipse.core.resources.ISaveContext) * @see org.eclipse.core.resources.ISaveParticipant#rollback(org.eclipse.core.resources.ISaveContext)
*/ */
public void rollback(ISaveContext context) { public void rollback(ISaveContext context) {
} }
} }

View file

@ -1,79 +1,79 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen; package org.eclipse.cdt.managedbuilder.makegen;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
/** /**
* @since 3.1 * @since 3.1
* *
* A Tool dependency calculator may implement this interface or * A Tool dependency calculator may implement this interface or
* IManagedDependencyCommands or IManagedDependencyPreBuild. * IManagedDependencyCommands or IManagedDependencyPreBuild.
* An object implementing the interface is returned from a call to * An object implementing the interface is returned from a call to
* IManagedDependencyGenerator2.getDependencySourceInfo. * IManagedDependencyGenerator2.getDependencySourceInfo.
* *
* Discussion of Dependency Calculation: * Discussion of Dependency Calculation:
* *
* There are two major, and multiple minor, modes of dependency calculation * There are two major, and multiple minor, modes of dependency calculation
* supported by the MBS. The major modes are: * supported by the MBS. The major modes are:
* *
* 1. The build file generator invokes tool integrator provided methods * 1. The build file generator invokes tool integrator provided methods
* that calculate all dependencies using whatever method the tool * that calculate all dependencies using whatever method the tool
* integrator wants. The build file generator then adds the dependencies * integrator wants. The build file generator then adds the dependencies
* to the build file using the appropriate build file syntax. * to the build file using the appropriate build file syntax.
* This type of dependency calculator implements the * This type of dependency calculator implements the
* IManagedDependencyCalculator interface defined in this module. * IManagedDependencyCalculator interface defined in this module.
* *
* One minor mode of this mode is to use a dependency calculator provided * 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 * by a language integration (e.g. C, C++ or Fortran) that uses the
* language's parsing support to return information regarding source file * language's parsing support to return information regarding source file
* dependencies. An example of this is using the C/C++ Indexer to * dependencies. An example of this is using the C/C++ Indexer to
* compute dependencies. * compute dependencies.
* *
* 2. The build file generator and the tool-chain cooperate in creating and * 2. The build file generator and the tool-chain cooperate in creating and
* using separate "dependency" files. In this case, dependency calculation * using separate "dependency" files. In this case, dependency calculation
* is done at "build time", rather than at "build file generation time" as * 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 mode #1. This currently supports the GNU concept of using .d files
* in GNU make. See the IManagedDependencyCommands and * in GNU make. See the IManagedDependencyCommands and
* IManagedDependencyPreBuild interfaces for more information. * IManagedDependencyPreBuild interfaces for more information.
* *
*/ */
public interface IManagedDependencyCalculator extends IManagedDependencyInfo { public interface IManagedDependencyCalculator extends IManagedDependencyInfo {
/** /**
* Returns the list of source file specific dependencies. * Returns the list of source file specific dependencies.
* *
* The paths can be either relative to the project directory, or absolute * The paths can be either relative to the project directory, or absolute
* in the file system. * in the file system.
* *
* @return IPath[] * @return IPath[]
*/ */
public IPath[] getDependencies(); public IPath[] getDependencies();
/** /**
* Returns the list of source file specific additional targets that the * Returns the list of source file specific additional targets that the
* source file creates. Most source files will return null. An example * source file creates. Most source files will return null. An example
* of where additional targets should be returned is for a Fortran 90 * of where additional targets should be returned is for a Fortran 90
* source file that creates one or more Fortran Modules. * source file that creates one or more Fortran Modules.
* *
* Note that these output files that are dependencies to other invocations * 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 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 * of the tool. If the output file can be used as the input of a different
* tool, then use the output type mechanism. * tool, then use the output type mechanism.
* *
* The paths can be either relative to the top build directory, or absolute * The paths can be either relative to the top build directory, or absolute
* in the file system. * in the file system.
* *
* @return IPath[] * @return IPath[]
*/ */
public IPath[] getAdditionalTargets(); public IPath[] getAdditionalTargets();
} }

View file

@ -1,168 +1,168 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen; package org.eclipse.cdt.managedbuilder.makegen;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
/** /**
* @since 3.1 * @since 3.1
* *
* A Tool dependency calculator may implement this interface or * A Tool dependency calculator may implement this interface or
* IManagedDependencyCalculator or IManagedDependencyPreBuild. * IManagedDependencyCalculator or IManagedDependencyPreBuild.
* An object implementing the interface is returned from a call to * An object implementing the interface is returned from a call to
* IManagedDependencyGenerator2.getDependencySourceInfo. * IManagedDependencyGenerator2.getDependencySourceInfo.
* *
* Discussion of Dependency Calculation: * Discussion of Dependency Calculation:
* *
* There are two major, and multiple minor, modes of dependency calculation * There are two major, and multiple minor, modes of dependency calculation
* supported by the MBS. The major modes are: * supported by the MBS. The major modes are:
* *
* 1. The build file generator invokes tool integrator provided methods * 1. The build file generator invokes tool integrator provided methods
* that calculate all dependencies using whatever method the tool * that calculate all dependencies using whatever method the tool
* integrator wants. The build file generator then adds the dependencies * integrator wants. The build file generator then adds the dependencies
* to the build file using the appropriate build file syntax. * to the build file using the appropriate build file syntax.
* See the IManagedDependencyCalculator interface for more information. * See the IManagedDependencyCalculator interface for more information.
* *
* 2. The build file generator and the tool-chain cooperate in creating and * 2. The build file generator and the tool-chain cooperate in creating and
* using separate "dependency" files. The build file generator calls * using separate "dependency" files. The build file generator calls
* the dependency calculator to get the dependency file names and to get * 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, * commands that need to be added to the build file. In this case,
* dependency calculation is done at "build time", rather than at * dependency calculation is done at "build time", rather than at
* "build file generation time" as in mode #1. This currently * "build file generation time" as in mode #1. This currently
* supports the GNU concept of using .d files in GNU make. * supports the GNU concept of using .d files in GNU make.
* *
* There are multiple ways that these separate dependency files can * There are multiple ways that these separate dependency files can
* be created by the tool-chain and used by the builder. * be created by the tool-chain and used by the builder.
* *
* a. In some cases (e.g., Fortran 90 using modules) the dependency files * 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 * must be created/updated prior to invoking the build of the project
* artifact (e.g., an application). In this case, the dependency * artifact (e.g., an application). In this case, the dependency
* generation step must occur separately before the main build. * generation step must occur separately before the main build.
* See the IManagedDependencyPreBuild interface for more information. * See the IManagedDependencyPreBuild interface for more information.
* *
* b. In other cases (e.g., C/C++) the dependency files can be created as * 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 * 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 * 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 * the next build. C/C++ builds can be treated in this manner as is
* described in the following link: * described in the following link:
* http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution * http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution
* *
* Use the IManagedDependencyCommands interface defined in this file * Use the IManagedDependencyCommands interface defined in this file
* for this mode. * for this mode.
* *
* Two sub-scenarios of this mode are to: * Two sub-scenarios of this mode are to:
* *
* Create dependency files in the same invocation of the tool that * Create dependency files in the same invocation of the tool that
* creates the tool's build artifact - by adding additional options * creates the tool's build artifact - by adding additional options
* to the tool invocation command line. * to the tool invocation command line.
* *
* Create dependency files in a separate invocation of the tool, or * Create dependency files in a separate invocation of the tool, or
* by the invocation of another tool. * by the invocation of another tool.
* *
* MBS can also help in the generation of the dependency files. Prior to * 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 * CDT 3.1, MBS and gcc cooperated in generating dependency files using the
* following steps: * following steps:
* *
* 1. Gcc is invoked to perform the compilation that generates the object * 1. Gcc is invoked to perform the compilation that generates the object
* file. * file.
* *
* 2. An "echo" command creates the .d file, adding the name of the .d * 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 * file to the beginning of the newly created .d file. Note that this
* causes problems with some implementations of "echo" that don't * 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 * work exactly the way that we want (e.g., it doesn't support the -n
* switch). * switch).
* 3. Gcc is invoked again with the appropriate additional command line * 3. Gcc is invoked again with the appropriate additional command line
* options to append its dependency file information to the .d file * options to append its dependency file information to the .d file
* that was created by "echo". * that was created by "echo".
* *
* 4. Steps 1 - 3 are invoked in the make file. Step 4 occurs after the * 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 * 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 .d files to add a dummy dependency for each header file, for
* the reason explained in the link above. * the reason explained in the link above.
* *
* This mode is no longer used by the default gcc implementation, but can * This mode is no longer used by the default gcc implementation, but can
* still be used by selecting the DefaultGCCDependencyCalculator. * still be used by selecting the DefaultGCCDependencyCalculator.
* *
* *
* Note for GNU make: these separate dependency files are "include"d by * Note for GNU make: these separate dependency files are "include"d by
* a main makefile. Therefore, if the dependency files are required to * 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 * be up to date before the main build begins, they must be updated by
* a separate invocation of make. Also, the configuration "clean" step * a separate invocation of make. Also, the configuration "clean" step
* must be invoked by a separate invocation of make. This is so that * must be invoked by a separate invocation of make. This is so that
* we can exclude the dependency files for a "make clean" invocation * we can exclude the dependency files for a "make clean" invocation
* using syntax like: * using syntax like:
* *
* ifneq ($(MAKECMDGOALS), clean) * ifneq ($(MAKECMDGOALS), clean)
* -include $(DEPS) * -include $(DEPS)
* endif * endif
* *
* Otherwise, because GNU make attempts to re-make make files, we * Otherwise, because GNU make attempts to re-make make files, we
* can end up with out of date or missing dependency files being * can end up with out of date or missing dependency files being
* re-generated and then immediately "clean"ed. * re-generated and then immediately "clean"ed.
*/ */
public interface IManagedDependencyCommands extends IManagedDependencyInfo { public interface IManagedDependencyCommands extends IManagedDependencyInfo {
/** /**
* Returns the list of generated dependency files. * Returns the list of generated dependency files.
* *
* The paths can be either relative to the top build directory, or absolute * The paths can be either relative to the top build directory, or absolute
* in the file system. * in the file system.
* *
* @return IPath[] * @return IPath[]
*/ */
public IPath[] getDependencyFiles(); public IPath[] getDependencyFiles();
/** /**
* Returns the command lines to be invoked before the normal tool invocation * Returns the command lines to be invoked before the normal tool invocation
* to calculate dependencies. * to calculate dependencies.
* *
* @return String[] This can be null or an empty array if no dependency * @return String[] This can be null or an empty array if no dependency
* generation command needs to be invoked before the normal * generation command needs to be invoked before the normal
* tool invocation. * tool invocation.
*/ */
public String[] getPreToolDependencyCommands(); public String[] getPreToolDependencyCommands();
/** /**
* Returns the command line options to be used to calculate dependencies. * Returns the command line options to be used to calculate dependencies.
* The options are added to the normal tool invocation. * The options are added to the normal tool invocation.
* *
* @return String[] This can be null or an empty array if no additional * @return String[] This can be null or an empty array if no additional
* arguments need to be added to the tool invocation. * arguments need to be added to the tool invocation.
* SHOULD THIS RETURN AN IOption[]? * SHOULD THIS RETURN AN IOption[]?
*/ */
public String[] getDependencyCommandOptions(); public String[] getDependencyCommandOptions();
// IMPLEMENTATION NOTE: This should be called from addRuleFromSource for both resconfig & non-resconfig // 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 * Returns the command lines to be invoked after the normal tool invocation
* to calculate dependencies. * to calculate dependencies.
* *
* @return String[] This can be null or an empty array if no dependency * @return String[] This can be null or an empty array if no dependency
* generation commands needs to be invoked after the normal * generation commands needs to be invoked after the normal
* tool invocation * tool invocation
*/ */
public String[] getPostToolDependencyCommands(); public String[] getPostToolDependencyCommands();
/** /**
* Returns true if the command lines and/or options returned by this interface * 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, * 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 * 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 * 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 * 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 * configuration. This can be used by the build file generator in helping
* to determine if a "pattern" (generic) rule can be used. * to determine if a "pattern" (generic) rule can be used.
* *
* @return boolean * @return boolean
*/ */
public boolean areCommandsGeneric(); public boolean areCommandsGeneric();
} }

View file

@ -1,27 +1,27 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others. * Copyright (c) 2004, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen; package org.eclipse.cdt.managedbuilder.makegen;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
/** /**
* @since 2.0 * @since 2.0
* @deprecated 3.1 * @deprecated 3.1
* *
* Use IManagedDependencyGenerator2 instead. * Use IManagedDependencyGenerator2 instead.
*/ */
public interface IManagedDependencyGenerator extends IManagedDependencyGeneratorType { public interface IManagedDependencyGenerator extends IManagedDependencyGeneratorType {
public IResource[] findDependencies(IResource resource, IProject project); public IResource[] findDependencies(IResource resource, IProject project);
public String getDependencyCommand(IResource resource, IManagedBuildInfo info); public String getDependencyCommand(IResource resource, IManagedBuildInfo info);
} }

View file

@ -1,114 +1,114 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2006 IBM Corporation and others. * Copyright (c) 2005, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation of IManagedDependencyGenerator * IBM - Initial API and implementation of IManagedDependencyGenerator
* Intel - Initial API and implementation of IManagedDependencyGenerator2 * Intel - Initial API and implementation of IManagedDependencyGenerator2
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen; package org.eclipse.cdt.managedbuilder.makegen;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
/** /**
* @since 3.1 * @since 3.1
* *
* A Tool dependency calculator must implement this interface. This interface * A Tool dependency calculator must implement this interface. This interface
* replaces IManagedDependencyGenerator which is deprecated. * replaces IManagedDependencyGenerator which is deprecated.
* *
* Discussion of Dependency Calculation: * Discussion of Dependency Calculation:
* *
* There are two major, and multiple minor, modes of dependency calculation * There are two major, and multiple minor, modes of dependency calculation
* supported by the MBS. The major modes are: * supported by the MBS. The major modes are:
* *
* 1. The build file generator invokes tool integrator provided methods * 1. The build file generator invokes tool integrator provided methods
* that calculate all dependencies using whatever method the tool * that calculate all dependencies using whatever method the tool
* integrator wants. The build file generator then adds the dependencies * integrator wants. The build file generator then adds the dependencies
* to the build file using the appropriate build file syntax. * to the build file using the appropriate build file syntax.
* This is a TYPE_CUSTOM dependency calculator as defined below. * This is a TYPE_CUSTOM dependency calculator as defined below.
* See the IManagedDependencyCalculator interface for more information. * See the IManagedDependencyCalculator interface for more information.
* *
* 2. The build file generator and the tool-chain cooperate in creating and * 2. The build file generator and the tool-chain cooperate in creating and
* using separate "dependency" files. In this case, dependency calculation * using separate "dependency" files. In this case, dependency calculation
* is done at "build time", rather than at "build file generation time" as * 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 mode #1. This currently supports the GNU concept of using .d files
* in GNU make. * in GNU make.
* This is either a TYPE_BUILD_COMMANDS dependency calculator or a * This is either a TYPE_BUILD_COMMANDS dependency calculator or a
* TYPE_PREBUILD_COMMANDS dependency calculator as defined below. * TYPE_PREBUILD_COMMANDS dependency calculator as defined below.
* See the IManagedDependencyCommands and IManagedDependencyPreBuild * See the IManagedDependencyCommands and IManagedDependencyPreBuild
* interfaces for more information. * interfaces for more information.
* *
*/ */
public interface IManagedDependencyGenerator2 extends IManagedDependencyGeneratorType { public interface IManagedDependencyGenerator2 extends IManagedDependencyGeneratorType {
/** /**
* Returns an instance of IManagedDependencyInfo for this source file. * Returns an instance of IManagedDependencyInfo for this source file.
* IManagedDependencyCalculator, IManagedDependencyCommands * IManagedDependencyCalculator, IManagedDependencyCommands
* and IManagedDependencyPreBuild are all derived from * and IManagedDependencyPreBuild are all derived from
* IManagedDependencyInfo, and any one of the three can be returned. * IManagedDependencyInfo, and any one of the three can be returned.
* This is called when getCalculatorType returns TYPE_BUILD_COMMANDS, * This is called when getCalculatorType returns TYPE_BUILD_COMMANDS,
* TYPE_CUSTOM or TYPE_PREBUILD_COMMANDS. * TYPE_CUSTOM or TYPE_PREBUILD_COMMANDS.
* *
* @param source The source file for which dependencies should be calculated * @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. * The IPath can be either relative to the project directory, or absolute in the file system.
* @param buildContext The IConfiguration or IResourceConfiguration that * @param buildContext The IConfiguration or IResourceConfiguration that
* contains the context in which the source file will be built * contains the context in which the source file will be built
* @param tool The tool associated with the source file * @param tool The tool associated with the source file
* @param topBuildDirectory The top build directory of the configuration. This is * @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. * the working directory for the tool. This IPath is relative to the project directory.
* @return IManagedDependencyInfo * @return IManagedDependencyInfo
*/ */
public IManagedDependencyInfo getDependencySourceInfo( public IManagedDependencyInfo getDependencySourceInfo(
IPath source, IPath source,
IBuildObject buildContext, IBuildObject buildContext,
ITool tool, ITool tool,
IPath topBuildDirectory); IPath topBuildDirectory);
/** /**
* Returns the file extension used by dependency files created * Returns the file extension used by dependency files created
* by this dependency generator. * by this dependency generator.
* This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or * This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or
* TYPE_PREBUILD_COMMANDS. * TYPE_PREBUILD_COMMANDS.
* *
* @param buildContext The IConfiguration that contains the context of the build * @param buildContext The IConfiguration that contains the context of the build
* @param tool The tool associated with the dependency generator. * @param tool The tool associated with the dependency generator.
* *
* @return String * @return String
*/ */
public String getDependencyFileExtension( public String getDependencyFileExtension(
IConfiguration buildContext, IConfiguration buildContext,
ITool tool); ITool tool);
/** /**
* Called to allow the dependency calculator to post-process dependency files. * Called to allow the dependency calculator to post-process dependency files.
* This method is called after the build has completed for at least every * 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 * 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 * changed as well. It may also be called with dependency files created by
* another tool. This method should be able to recognize dependency files * another tool. This method should be able to recognize dependency files
* that don't belong to it, or that it has already post-processed. * that don't belong to it, or that it has already post-processed.
* This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or * This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or
* TYPE_PREBUILD_COMMANDS. * TYPE_PREBUILD_COMMANDS.
* *
* @param dependencyFile The dependency file * @param dependencyFile The dependency file
* The IPath can be either relative to the top build directory, or absolute in the file system. * 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 buildContext The IConfiguration that contains the context of the build
* @param tool The tool associated with the dependency generator. Note that this is * @param tool The tool associated with the dependency generator. Note that this is
* not necessarily the tool that created the dependency file * not necessarily the tool that created the dependency file
* @param topBuildDirectory The top build directory of the project. This is * @param topBuildDirectory The top build directory of the project. This is
* the working directory for the tool. * the working directory for the tool.
* *
* @return boolean True if the method modified the dependency (e.g., .d) file * @return boolean True if the method modified the dependency (e.g., .d) file
*/ */
public boolean postProcessDependencyFile( public boolean postProcessDependencyFile(
IPath dependencyFile, IPath dependencyFile,
IConfiguration buildContext, IConfiguration buildContext,
ITool tool, ITool tool,
IPath topBuildDirectory); IPath topBuildDirectory);
} }

View file

@ -1,87 +1,87 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen; package org.eclipse.cdt.managedbuilder.makegen;
/** /**
* @since 3.1 * @since 3.1
* *
* IManagedDependencyGenerator (deprecated) and IManagedDependencyGenerator2 * IManagedDependencyGenerator (deprecated) and IManagedDependencyGenerator2
* extend this interface. * extend this interface.
* *
* Discussion of Dependency Calculation: * Discussion of Dependency Calculation:
* *
* There are two major, and multiple minor, modes of dependency calculation * There are two major, and multiple minor, modes of dependency calculation
* supported by the MBS. The major modes are: * supported by the MBS. The major modes are:
* *
* 1. The build file generator invokes tool integrator provided methods * 1. The build file generator invokes tool integrator provided methods
* that calculate all dependencies using whatever method the tool * that calculate all dependencies using whatever method the tool
* integrator wants. The build file generator then adds the dependencies * integrator wants. The build file generator then adds the dependencies
* to the build file using the appropriate build file syntax. * to the build file using the appropriate build file syntax.
* This is a TYPE_CUSTOM dependency calculator as defined below. * This is a TYPE_CUSTOM dependency calculator as defined below.
* See the IManagedDependencyCalculator interface for more information. * See the IManagedDependencyCalculator interface for more information.
* *
* 2. The build file generator and the tool-chain cooperate in creating and * 2. The build file generator and the tool-chain cooperate in creating and
* using separate "dependency" files. In this case, dependency calculation * using separate "dependency" files. In this case, dependency calculation
* is done at "build time", rather than at "build file generation time" as * 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 mode #1. This currently supports the GNU concept of using .d files
* in GNU make. * in GNU make.
* This is either a TYPE_BUILD_COMMANDS dependency calculator or a * This is either a TYPE_BUILD_COMMANDS dependency calculator or a
* TYPE_PREBUILD_COMMANDS dependency calculator as defined below. * TYPE_PREBUILD_COMMANDS dependency calculator as defined below.
* See the IManagedDependencyCommands and IManagedDependencyPreBuild * See the IManagedDependencyCommands and IManagedDependencyPreBuild
* interfaces for more information. * interfaces for more information.
* *
*/ */
public interface IManagedDependencyGeneratorType { public interface IManagedDependencyGeneratorType {
/** /**
* Constants returned by getCalculatorType * Constants returned by getCalculatorType
*/ */
public int TYPE_NODEPS = 0; // Deprecated - use TYPE_NODEPENDENCIES public int TYPE_NODEPS = 0; // Deprecated - use TYPE_NODEPENDENCIES
public int TYPE_COMMAND = 1; // Deprecated - use TYPE_BUILD_COMMANDS public int TYPE_COMMAND = 1; // Deprecated - use TYPE_BUILD_COMMANDS
public int TYPE_INDEXER = 2; // Deprecated - use TYPE_CUSTOM public int TYPE_INDEXER = 2; // Deprecated - use TYPE_CUSTOM
public int TYPE_EXTERNAL = 3; // Deprecated - use TYPE_CUSTOM public int TYPE_EXTERNAL = 3; // Deprecated - use TYPE_CUSTOM
public int TYPE_OLD_TYPE_LIMIT = 3; public int TYPE_OLD_TYPE_LIMIT = 3;
// Use these types // Use these types
public int TYPE_NODEPENDENCIES = 4; public int TYPE_NODEPENDENCIES = 4;
public int TYPE_BUILD_COMMANDS = 5; public int TYPE_BUILD_COMMANDS = 5;
public int TYPE_PREBUILD_COMMANDS = 6; public int TYPE_PREBUILD_COMMANDS = 6;
public int TYPE_CUSTOM = 7; public int TYPE_CUSTOM = 7;
/** /**
* Returns the type of dependency generator that is implemented. * Returns the type of dependency generator that is implemented.
* *
* TYPE_NODEPENDENCIES indicates that no dependency generator is * TYPE_NODEPENDENCIES indicates that no dependency generator is
* supplied or needed. * supplied or needed.
* TYPE_CUSTOM indicates that a custom, "build file generation time" * TYPE_CUSTOM indicates that a custom, "build file generation time"
* dependency calculator is implemented. Note that the dependency * dependency calculator is implemented. Note that the dependency
* calculator will be called when the makefile is generated, and * calculator will be called when the makefile is generated, and
* for every source file that is built by this tool in the build * 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, not just for those that have changed since the last build
* file generation. * file generation.
* TYPE_BUILD_COMMANDS indicates that command lines or options will * TYPE_BUILD_COMMANDS indicates that command lines or options will
* be returned to be used to calculate dependencies. These * be returned to be used to calculate dependencies. These
* commands/options are added to the build file to perform dependency * commands/options are added to the build file to perform dependency
* calculation at "build time". This currently supports * calculation at "build time". This currently supports
* compilers/tools that generate .d files either as a * compilers/tools that generate .d files either as a
* side-effect of tool invocation, or as a separate step that is * side-effect of tool invocation, or as a separate step that is
* invoked immediately before or after the tool invocation. * invoked immediately before or after the tool invocation.
* TYPE_PREBUILD_COMMANDS indicates that a separate build step is * TYPE_PREBUILD_COMMANDS indicates that a separate build step is
* invoked, prior to the the normal build steps, to update the * invoked, prior to the the normal build steps, to update the
* dependency information. These commands are added to the build * dependency information. These commands are added to the build
* file to perform dependency calculation at "build time". Note * file to perform dependency calculation at "build time". Note
* that this step will be invoked every time a build is done in * that this step will be invoked every time a build is done in
* order to determine if dependency files need to be re-generated. * order to determine if dependency files need to be re-generated.
* *
* @return int * @return int
*/ */
public int getCalculatorType(); public int getCalculatorType();
} }

View file

@ -1,35 +1,35 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen; package org.eclipse.cdt.managedbuilder.makegen;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
/** /**
* @since 3.1 * @since 3.1
* *
* This interface is the base interface for IManagedDependencyCalculator, * This interface is the base interface for IManagedDependencyCalculator,
* IManagedDependencyCommands and IManagedDependencyPreBuild. See these * IManagedDependencyCommands and IManagedDependencyPreBuild. See these
* interfaces and IManagedDependencyGenerator2 for more information on * interfaces and IManagedDependencyGenerator2 for more information on
* writing a dependency calculator. * writing a dependency calculator.
* *
* The methods below simply return the arguments passed to the * The methods below simply return the arguments passed to the
* IManagedDependencyGenerator2.getDependency*Info call that created the * IManagedDependencyGenerator2.getDependency*Info call that created the
* IManagedDependencyInfo instance. * IManagedDependencyInfo instance.
* *
*/ */
public interface IManagedDependencyInfo { public interface IManagedDependencyInfo {
public IPath getSource(); public IPath getSource();
public IBuildObject getBuildContext(); public IBuildObject getBuildContext();
public ITool getTool(); public ITool getTool();
public IPath getTopBuildDirectory(); public IPath getTopBuildDirectory();
} }

View file

@ -1,136 +1,136 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen; package org.eclipse.cdt.managedbuilder.makegen;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
/** /**
* @since 3.1 * @since 3.1
* *
* A Tool dependency calculator may implement this interface or * A Tool dependency calculator may implement this interface or
* IManagedDependencyCalculator or IManagedDependencyCommands. * IManagedDependencyCalculator or IManagedDependencyCommands.
* An object implementing the interface is returned from a call to * An object implementing the interface is returned from a call to
* IManagedDependencyGenerator2.getDependencySourceInfo. * IManagedDependencyGenerator2.getDependencySourceInfo.
* *
* Discussion of Dependency Calculation: * Discussion of Dependency Calculation:
* *
* There are two major, and multiple minor, modes of dependency calculation * There are two major, and multiple minor, modes of dependency calculation
* supported by the MBS. The major modes are: * supported by the MBS. The major modes are:
* *
* 1. The build file generator invokes tool integrator provided methods * 1. The build file generator invokes tool integrator provided methods
* that calculate all dependencies using whatever method the tool * that calculate all dependencies using whatever method the tool
* integrator wants. The build file generator then adds the dependencies * integrator wants. The build file generator then adds the dependencies
* to the build file using the appropriate build file syntax. * to the build file using the appropriate build file syntax.
* See the IManagedDependencyCalculator interface for more information. * See the IManagedDependencyCalculator interface for more information.
* *
* 2. The build file generator and the tool-chain cooperate in creating and * 2. The build file generator and the tool-chain cooperate in creating and
* using separate "dependency" files. The build file generator calls * using separate "dependency" files. The build file generator calls
* the dependency calculator to get the dependency file names and to get * 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, * commands that need to be added to the build file. In this case,
* dependency calculation is done at "build time", rather than at * dependency calculation is done at "build time", rather than at
* "build file generation time" as in mode #1. This currently * "build file generation time" as in mode #1. This currently
* supports the GNU concept of using .d files in GNU make. * supports the GNU concept of using .d files in GNU make.
* *
* There are multiple ways that these separate dependency files can * There are multiple ways that these separate dependency files can
* be created by the tool-chain and used by the builder. * be created by the tool-chain and used by the builder.
* *
* a. In some cases (e.g., Fortran 90 using modules) the dependency files * 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 * must be created/updated prior to invoking the build of the project
* artifact (e.g., an application). In this case, the dependency * artifact (e.g., an application). In this case, the dependency
* generation step must occur separately before the main build. * generation step must occur separately before the main build.
* Use the IManagedDependencyPreBuild interface defined in this file * Use the IManagedDependencyPreBuild interface defined in this file
* for this mode. * for this mode.
* *
* b. In other cases (e.g., C/C++) the dependency files can be created as * 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 * 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 * 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 * the next build. C/C++ builds can be treated in this manner as is
* described in the following link: * described in the following link:
* http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution * http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution
* *
* See the IManagedDependencyCommands interface for more information. * See the IManagedDependencyCommands interface for more information.
* *
* *
* Note for GNU make: these separate dependency files are "include"d by * Note for GNU make: these separate dependency files are "include"d by
* a main makefile. Make performs special processing on make files: * a main makefile. Make performs special processing on make files:
* *
* "To this end, after reading in all makefiles, make will consider * "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 * 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 * rule which says how to update it (found either in that very
* makefile or in another one)..., it will be updated if necessary. * makefile or in another one)..., it will be updated if necessary.
* After all makefiles have been checked, if any have actually been * After all makefiles have been checked, if any have actually been
* changed, make starts with a clean slate and reads all the makefiles * changed, make starts with a clean slate and reads all the makefiles
* over again." * over again."
* *
* We can use this to ensure that the dependency files are up to date * 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. * by adding rules to the make file for generating the dependency files.
* These rules are returned by the call to getDependencyCommands. * These rules are returned by the call to getDependencyCommands.
* However, this has a significant problem when we dont want to build * However, this has a significant problem when we dont want to build
* the build target, but only want to clean the configuration, * the build target, but only want to clean the configuration,
* for example. If we invoke make just 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 * make will still update the dependency files if necessary, thereby
* re-generating the dependency files only to immediately delete them. * re-generating the dependency files only to immediately delete them.
* The workaround suggested by the make documentation is to check for * The workaround suggested by the make documentation is to check for
* an invocation using the clean target, and to not include the * an invocation using the clean target, and to not include the
* dependency files it that case. For example, * dependency files it that case. For example,
* *
* ifneq ($(MAKECMDGOALS),clean) * ifneq ($(MAKECMDGOALS),clean)
* include $(DEPS) * include $(DEPS)
* endif * endif
* *
* The restriction with this is that it only works if clean is the only * The restriction with this is that it only works if clean is the only
* target specified on the make command line. Therefore, the build * target specified on the make command line. Therefore, the build
* "clean" step must be invoked separately. * "clean" step must be invoked separately.
*/ */
public interface IManagedDependencyPreBuild extends IManagedDependencyInfo { public interface IManagedDependencyPreBuild extends IManagedDependencyInfo {
/** /**
* Returns the list of generated dependency files. * Returns the list of generated dependency files.
* *
* The paths can be either relative to the top build directory, or absolute * The paths can be either relative to the top build directory, or absolute
* in the file system. * in the file system.
* *
* @return IPath[] * @return IPath[]
*/ */
public IPath[] getDependencyFiles(); public IPath[] getDependencyFiles();
/** /**
* Returns the name to be used in the build file to identify the separate * 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 * 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 * multiple tools in a tool-chain may be using this method of
* dependency calculation. * dependency calculation.
* *
* @return String * @return String
*/ */
public String getBuildStepName(); public String getBuildStepName();
/** /**
* Returns the command line(s) to be invoked in the separate * Returns the command line(s) to be invoked in the separate
* dependencies pre-build step. * dependencies pre-build step.
* *
* @return String[] * @return String[]
*/ */
public String[] getDependencyCommands(); public String[] getDependencyCommands();
/** /**
* Returns true if the command lines returned by this interface * Returns true if the command lines returned by this interface
* are not specific to the particular source file, but are only specific to, * 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 * 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 * configuration, this method should return false if any of the command lines
* are different than if the build context were the parent configuration. * 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 * This can be used by the build file generator in helping to determine if
* a "pattern" (generic) rule can be used. * a "pattern" (generic) rule can be used.
* *
* @return boolean * @return boolean
*/ */
public boolean areCommandsGeneric(); public boolean areCommandsGeneric();
} }

View file

@ -1,300 +1,300 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others. * Copyright (c) 2004, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu; package org.eclipse.cdt.managedbuilder.makegen.gnu;
import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator; import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo; import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData; import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException; import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator; import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
/** /**
* @since 2.0 * @since 2.0
*/ */
public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerator { public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerator {
private static final String EMPTY_STRING = new String(); private static final String EMPTY_STRING = new String();
private static final String[] EMPTY_STRING_ARRAY = new String[0]; private static final String[] EMPTY_STRING_ARRAY = new String[0];
public final String WHITESPACE = " "; //$NON-NLS-1$ public final String WHITESPACE = " "; //$NON-NLS-1$
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource) * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
*/ */
public IResource[] findDependencies(IResource resource, IProject project) { public IResource[] findDependencies(IResource resource, IProject project) {
return null; return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
*/ */
public int getCalculatorType() { public int getCalculatorType() {
return TYPE_COMMAND; return TYPE_COMMAND;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
*/ */
public String getDependencyCommand(IResource resource, IManagedBuildInfo info) { public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
/* /*
* For a given input, <path>/<resource_name>.<ext>, return a string containing * For a given input, <path>/<resource_name>.<ext>, return a string containing
* echo -n $(@:%.<out_ext>=%.d) '<path>/' >> $(@:%.<out_ext>=%.d) && \ * echo -n $(@:%.<out_ext>=%.d) '<path>/' >> $(@:%.<out_ext>=%.d) && \
* <tool_command> -P -MM -MG <tool_flags> $< >> $(@:%.<out_ext>=%.d) * <tool_command> -P -MM -MG <tool_flags> $< >> $(@:%.<out_ext>=%.d)
* *
*/ */
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
// Get what we need to create the dependency generation command // Get what we need to create the dependency generation command
IConfiguration config = info.getDefaultConfiguration(); IConfiguration config = info.getDefaultConfiguration();
// We need to check whether we have any resource specific build information. // We need to check whether we have any resource specific build information.
IResourceConfiguration resConfig = null; IResourceConfiguration resConfig = null;
if( config != null ) resConfig = config.getResourceConfiguration(resource.getFullPath().toString()); if( config != null ) resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
String inputExtension = resource.getFileExtension(); String inputExtension = resource.getFileExtension();
String outputExtension = info.getOutputExtension(inputExtension); String outputExtension = info.getOutputExtension(inputExtension);
// Work out the build-relative path for the output files // Work out the build-relative path for the output files
IContainer resourceLocation = resource.getParent(); IContainer resourceLocation = resource.getParent();
String relativePath = new String(); String relativePath = new String();
if (resourceLocation != null) { if (resourceLocation != null) {
relativePath += resourceLocation.getProjectRelativePath().toString(); relativePath += resourceLocation.getProjectRelativePath().toString();
} }
if (relativePath.length() > 0) { if (relativePath.length() > 0) {
relativePath += IManagedBuilderMakefileGenerator.SEPARATOR; relativePath += IManagedBuilderMakefileGenerator.SEPARATOR;
} }
// Calculate the dependency rule // Calculate the dependency rule
// <path>/$(@:%.<out_ext>=%.d) // <path>/$(@:%.<out_ext>=%.d)
String depRule = "'$(@:%." + //$NON-NLS-1$ String depRule = "'$(@:%." + //$NON-NLS-1$
outputExtension + outputExtension +
"=%." + //$NON-NLS-1$ "=%." + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.DEP_EXT + IManagedBuilderMakefileGenerator.DEP_EXT +
")'"; //$NON-NLS-1$ ")'"; //$NON-NLS-1$
// Add the rule that will actually create the right format for the dep // Add the rule that will actually create the right format for the dep
buffer.append(IManagedBuilderMakefileGenerator.TAB + buffer.append(IManagedBuilderMakefileGenerator.TAB +
IManagedBuilderMakefileGenerator.ECHO + IManagedBuilderMakefileGenerator.ECHO +
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
"-n" + //$NON-NLS-1$ "-n" + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
depRule + depRule +
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
"$(dir $@)" + //$NON-NLS-1$ "$(dir $@)" + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
">" + //$NON-NLS-1$ ">" + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
depRule + depRule +
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
IManagedBuilderMakefileGenerator.LOGICAL_AND + IManagedBuilderMakefileGenerator.LOGICAL_AND +
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
IManagedBuilderMakefileGenerator.LINEBREAK); IManagedBuilderMakefileGenerator.LINEBREAK);
// Add the line that will do the work to calculate dependencies // Add the line that will do the work to calculate dependencies
IManagedCommandLineInfo cmdLInfo = null; IManagedCommandLineInfo cmdLInfo = null;
String buildCmd = null; String buildCmd = null;
String[] inputs= new String[1]; inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO; String[] inputs= new String[1]; inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO;
String outflag = ""; //$NON-NLS-1$ String outflag = ""; //$NON-NLS-1$
String outputPrefix = ""; //$NON-NLS-1$ String outputPrefix = ""; //$NON-NLS-1$
String outputFile = ""; //$NON-NLS-1$ String outputFile = ""; //$NON-NLS-1$
ITool[] tools; ITool[] tools;
if( resConfig != null && (tools = resConfig.getToolsToInvoke()) != null && tools.length > 0) { if( resConfig != null && (tools = resConfig.getToolsToInvoke()) != null && tools.length > 0) {
ITool tool = tools[0]; ITool tool = tools[0];
String cmd = tool.getToolCommand(); String cmd = tool.getToolCommand();
//try to resolve the build macros in the tool command //try to resolve the build macros in the tool command
try { try {
String resolvedCommand = null; String resolvedCommand = null;
// does the resource have spaces in its name? // does the resource have spaces in its name?
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) { if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
// use fully qualified strings // use fully qualified strings
resolvedCommand = ManagedBuildManager resolvedCommand = ManagedBuildManager
.getBuildMacroProvider() .getBuildMacroProvider()
.resolveValueToMakefileFormat( .resolveValueToMakefileFormat(
cmd, cmd,
"", //$NON-NLS-1$ "", //$NON-NLS-1$
" ", //$NON-NLS-1$ " ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(resource.getLocation(), new FileContextData(resource.getLocation(),
null, null, tool)); null, null, tool));
} else { } else {
// use builder variables // use builder variables
resolvedCommand = ManagedBuildManager resolvedCommand = ManagedBuildManager
.getBuildMacroProvider() .getBuildMacroProvider()
.resolveValueToMakefileFormat( .resolveValueToMakefileFormat(
cmd, cmd,
"", //$NON-NLS-1$ "", //$NON-NLS-1$
" ", //$NON-NLS-1$ " ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(resource.getLocation(), new FileContextData(resource.getLocation(),
null, null, tool)); null, null, tool));
} }
if((resolvedCommand = resolvedCommand.trim()).length() > 0) if((resolvedCommand = resolvedCommand.trim()).length() > 0)
cmd = resolvedCommand; cmd = resolvedCommand;
} catch (BuildMacroException e){ } catch (BuildMacroException e){
} }
String[] toolFlags = null; String[] toolFlags = null;
try { try {
toolFlags = tool.getToolCommandFlags(resource.getLocation(),null); toolFlags = tool.getToolCommandFlags(resource.getLocation(),null);
} catch( BuildException ex ) { } catch( BuildException ex ) {
// TODO add some routines to catch this // TODO add some routines to catch this
toolFlags = EMPTY_STRING_ARRAY; toolFlags = EMPTY_STRING_ARRAY;
} }
String[] flags = new String[toolFlags.length + 4]; String[] flags = new String[toolFlags.length + 4];
flags[0] = "-MM"; //$NON-NLS-1$ flags[0] = "-MM"; //$NON-NLS-1$
flags[1] = "-MG"; //$NON-NLS-1$ flags[1] = "-MG"; //$NON-NLS-1$
flags[2] = "-P"; //$NON-NLS-1$ flags[2] = "-P"; //$NON-NLS-1$
flags[3] = "-w"; //$NON-NLS-1$ flags[3] = "-w"; //$NON-NLS-1$
for (int i=0; i<toolFlags.length; i++) { for (int i=0; i<toolFlags.length; i++) {
flags[4+i] = toolFlags[i]; flags[4+i] = toolFlags[i];
} }
IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator(); IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
cmdLInfo = cmdLGen.generateCommandLineInfo( tool, cmd, flags, outflag, outputPrefix, cmdLInfo = cmdLGen.generateCommandLineInfo( tool, cmd, flags, outflag, outputPrefix,
outputFile, inputs, tool.getCommandLinePattern() ); outputFile, inputs, tool.getCommandLinePattern() );
buildCmd = cmdLInfo.getCommandLine(); buildCmd = cmdLInfo.getCommandLine();
// resolve any remaining macros in the command after it has been generated // resolve any remaining macros in the command after it has been generated
try { try {
String resolvedCommand = null; String resolvedCommand = null;
// does the resource have spaces in its name? // does the resource have spaces in its name?
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) { if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
// use fully qualified strings // use fully qualified strings
resolvedCommand = ManagedBuildManager resolvedCommand = ManagedBuildManager
.getBuildMacroProvider() .getBuildMacroProvider()
.resolveValueToMakefileFormat( .resolveValueToMakefileFormat(
buildCmd, buildCmd,
"", //$NON-NLS-1$ "", //$NON-NLS-1$
" ", //$NON-NLS-1$ " ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(resource.getLocation(), new FileContextData(resource.getLocation(),
null, null, tool)); null, null, tool));
} else { } else {
// use builder variables // use builder variables
resolvedCommand = ManagedBuildManager resolvedCommand = ManagedBuildManager
.getBuildMacroProvider() .getBuildMacroProvider()
.resolveValueToMakefileFormat( .resolveValueToMakefileFormat(
buildCmd, buildCmd,
"", //$NON-NLS-1$ "", //$NON-NLS-1$
" ", //$NON-NLS-1$ " ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(resource.getLocation(), new FileContextData(resource.getLocation(),
null, null, tool)); null, null, tool));
} }
if((resolvedCommand = resolvedCommand.trim()).length() > 0) if((resolvedCommand = resolvedCommand.trim()).length() > 0)
buildCmd = resolvedCommand; buildCmd = resolvedCommand;
} catch (BuildMacroException e){ } catch (BuildMacroException e){
} }
} else { } else {
ITool tool = null; ITool tool = null;
tools = config.getFilteredTools(); tools = config.getFilteredTools();
for (int index = 0; index < tools.length; index++) { for (int index = 0; index < tools.length; index++) {
ITool tmp = tools[index]; ITool tmp = tools[index];
if (tmp.buildsFileType(inputExtension)) { if (tmp.buildsFileType(inputExtension)) {
tool = tmp; tool = tmp;
break; break;
} }
} }
String cmd = tool != null ? tool.getToolCommand() : null; String cmd = tool != null ? tool.getToolCommand() : null;
//try to resolve the build macros in the tool command //try to resolve the build macros in the tool command
try{ try{
String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(cmd, String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(cmd,
"", //$NON-NLS-1$ "", //$NON-NLS-1$
" ", //$NON-NLS-1$ " ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(resource.getLocation(),null,null,tool)); new FileContextData(resource.getLocation(),null,null,tool));
if((resolvedCommand = resolvedCommand.trim()).length() > 0) if((resolvedCommand = resolvedCommand.trim()).length() > 0)
cmd = resolvedCommand; cmd = resolvedCommand;
} catch (BuildMacroException e){ } catch (BuildMacroException e){
} }
String buildFlags = "-MM -MG -P -w " + info.getToolFlagsForSource(inputExtension, resource.getLocation(), null); //$NON-NLS-1$ String buildFlags = "-MM -MG -P -w " + info.getToolFlagsForSource(inputExtension, resource.getLocation(), null); //$NON-NLS-1$
String[] flags = buildFlags.split( "\\s" ); //$NON-NLS-1$ String[] flags = buildFlags.split( "\\s" ); //$NON-NLS-1$
cmdLInfo = info.generateToolCommandLineInfo( inputExtension, flags, outflag, outputPrefix, cmdLInfo = info.generateToolCommandLineInfo( inputExtension, flags, outflag, outputPrefix,
outputFile, inputs, resource.getLocation(), null); outputFile, inputs, resource.getLocation(), null);
// The command to build // The command to build
if( cmdLInfo == null ) buildCmd = if( cmdLInfo == null ) buildCmd =
cmd + cmd +
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
"-MM -MG -P -w " + //$NON-NLS-1$ "-MM -MG -P -w " + //$NON-NLS-1$
buildFlags + buildFlags +
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
IManagedBuilderMakefileGenerator.IN_MACRO; IManagedBuilderMakefileGenerator.IN_MACRO;
else { else {
buildCmd = cmdLInfo.getCommandLine(); buildCmd = cmdLInfo.getCommandLine();
} }
// resolve any remaining macros in the command after it has been // resolve any remaining macros in the command after it has been
// generated // generated
try { try {
String resolvedCommand = null; String resolvedCommand = null;
// does the resource have spaces in its name? // does the resource have spaces in its name?
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) { if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
// use fully qualified strings // use fully qualified strings
resolvedCommand = ManagedBuildManager resolvedCommand = ManagedBuildManager
.getBuildMacroProvider() .getBuildMacroProvider()
.resolveValueToMakefileFormat( .resolveValueToMakefileFormat(
buildCmd, buildCmd,
"", //$NON-NLS-1$ "", //$NON-NLS-1$
" ", //$NON-NLS-1$ " ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(resource.getLocation(), new FileContextData(resource.getLocation(),
null, null, tool)); null, null, tool));
} else { } else {
// use builder variables // use builder variables
resolvedCommand = ManagedBuildManager resolvedCommand = ManagedBuildManager
.getBuildMacroProvider() .getBuildMacroProvider()
.resolveValueToMakefileFormat( .resolveValueToMakefileFormat(
buildCmd, buildCmd,
"", //$NON-NLS-1$ "", //$NON-NLS-1$
" ", //$NON-NLS-1$ " ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(resource.getLocation(), new FileContextData(resource.getLocation(),
null, null, tool)); null, null, tool));
} }
if ((resolvedCommand = resolvedCommand.trim()).length() > 0) if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
buildCmd = resolvedCommand; buildCmd = resolvedCommand;
} catch (BuildMacroException e) { } catch (BuildMacroException e) {
} }
} }
buffer.append(IManagedBuilderMakefileGenerator.TAB + buffer.append(IManagedBuilderMakefileGenerator.TAB +
buildCmd + buildCmd +
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
">>" + //$NON-NLS-1$ ">>" + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.WHITESPACE + depRule ); IManagedBuilderMakefileGenerator.WHITESPACE + depRule );
return buffer.toString(); return buffer.toString();
} }
} }

View file

@ -1,70 +1,70 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu; package org.eclipse.cdt.managedbuilder.makegen.gnu;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator; import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
/** /**
* This dependency calculator uses the GCC -MMD -MF -MP -MT options in order to * This dependency calculator uses the GCC -MMD -MF -MP -MT options in order to
* generate .d files as a side effect of compilation. * generate .d files as a side effect of compilation.
* See bugzilla 108715 for the discussion of dependency management that led to * See bugzilla 108715 for the discussion of dependency management that led to
* the creation of this dependency calculator. Note also that this technique * the creation of this dependency calculator. Note also that this technique
* exhibits the failure modes discussed in comment #5. * exhibits the failure modes discussed in comment #5.
* *
* This dependency calculator uses the class DefaultGCCDependencyCalculator2Commands * This dependency calculator uses the class DefaultGCCDependencyCalculator2Commands
* which implements the per-source command information * which implements the per-source command information
* *
* @since 3.1 * @since 3.1
*/ */
public class DefaultGCCDependencyCalculator2 implements public class DefaultGCCDependencyCalculator2 implements
IManagedDependencyGenerator2 { IManagedDependencyGenerator2 {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType()
*/ */
public int getCalculatorType() { public int getCalculatorType() {
return TYPE_BUILD_COMMANDS; return TYPE_BUILD_COMMANDS;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencyFileExtension(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool) * @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) { public String getDependencyFileExtension(IConfiguration buildContext, ITool tool) {
return IManagedBuilderMakefileGenerator.DEP_EXT; return IManagedBuilderMakefileGenerator.DEP_EXT;
} }
/* /*
* (non-Javadoc) * (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) * @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) { public IManagedDependencyInfo getDependencySourceInfo(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
return new DefaultGCCDependencyCalculator2Commands(source, buildContext, tool, topBuildDirectory); return new DefaultGCCDependencyCalculator2Commands(source, buildContext, tool, topBuildDirectory);
} }
/* /*
* (non-Javadoc) * (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) * @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) { public boolean postProcessDependencyFile(IPath dependencyFile, IConfiguration buildContext, ITool tool, IPath topBuildDirectory) {
// Nothing // Nothing
return false; return false;
} }
} }

View file

@ -1,203 +1,203 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu; package org.eclipse.cdt.managedbuilder.makegen.gnu;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData; import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver; import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator; import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.resources.IProject;; import org.eclipse.core.resources.IProject;;
/** /**
* This dependency calculator uses the GCC -MMD -MF -MP -MT options in order to * This dependency calculator uses the GCC -MMD -MF -MP -MT options in order to
* generate .d files as a side effect of compilation. * generate .d files as a side effect of compilation.
* See bugzilla 108715 for the discussion of dependency management that led to * See bugzilla 108715 for the discussion of dependency management that led to
* the creation of this dependency calculator. Note also that this technique * the creation of this dependency calculator. Note also that this technique
* exhibits the failure modes discussed in comment #5. * exhibits the failure modes discussed in comment #5.
* *
* This class is used with DefaultGCCDependencyCalculator2. * This class is used with DefaultGCCDependencyCalculator2.
* *
* @since 3.1 * @since 3.1
*/ */
public class DefaultGCCDependencyCalculator2Commands implements public class DefaultGCCDependencyCalculator2Commands implements
IManagedDependencyCommands { IManagedDependencyCommands {
// Member variables set by the constructor // Member variables set by the constructor
IPath source; IPath source;
IBuildObject buildContext; IBuildObject buildContext;
ITool tool; ITool tool;
IPath topBuildDirectory; IPath topBuildDirectory;
// Other Member variables // Other Member variables
IProject project; IProject project;
IPath sourceLocation; IPath sourceLocation;
IPath outputLocation; IPath outputLocation;
boolean needExplicitRuleForFile; boolean needExplicitRuleForFile;
Boolean genericCommands = null; Boolean genericCommands = null;
/** /**
* Constructor * Constructor
* *
* @param source The source file for which dependencies should be calculated * @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. * The IPath can be either relative to the project directory, or absolute in the file system.
* @param buildContext The IConfiguration or IResourceConfiguration that * @param buildContext The IConfiguration or IResourceConfiguration that
* contains the context in which the source file will be built * contains the context in which the source file will be built
* @param tool The tool associated with the source file * @param tool The tool associated with the source file
* @param topBuildDirectory The top build directory of the configuration. This is * @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. * the working directory for the tool. This IPath is relative to the project directory.
*/ */
public DefaultGCCDependencyCalculator2Commands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) { public DefaultGCCDependencyCalculator2Commands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
this.source = source; this.source = source;
this.buildContext = buildContext; this.buildContext = buildContext;
this.tool = tool; this.tool = tool;
this.topBuildDirectory = topBuildDirectory; this.topBuildDirectory = topBuildDirectory;
// Compute the project // Compute the project
if (buildContext instanceof IConfiguration) { if (buildContext instanceof IConfiguration) {
IConfiguration config = (IConfiguration)buildContext; IConfiguration config = (IConfiguration)buildContext;
project = (IProject)config.getOwner(); project = (IProject)config.getOwner();
} else if (buildContext instanceof IResourceConfiguration) { } else if (buildContext instanceof IResourceConfiguration) {
IResourceConfiguration resConfig = (IResourceConfiguration)buildContext; IResourceConfiguration resConfig = (IResourceConfiguration)buildContext;
project = (IProject)resConfig.getOwner(); project = (IProject)resConfig.getOwner();
} }
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source)); sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]); outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]);
// A separate rule is needed for the resource in the case where explicit file-specific macros // 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) // are referenced, or if the resource contains special characters in its path (e.g., whitespace)
needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) || needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) ||
MacroResolver.getReferencedExplitFileMacros(tool).length > 0 MacroResolver.getReferencedExplitFileMacros(tool).length > 0
|| MacroResolver.getReferencedExplitFileMacros( || MacroResolver.getReferencedExplitFileMacros(
tool.getToolCommand(), tool.getToolCommand(),
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, outputLocation, new FileContextData(sourceLocation, outputLocation,
null, tool)).length > 0; null, tool)).length > 0;
if (needExplicitRuleForFile) genericCommands = new Boolean(false); if (needExplicitRuleForFile) genericCommands = new Boolean(false);
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#areCommandsGeneric() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#areCommandsGeneric()
*/ */
public boolean areCommandsGeneric() { public boolean areCommandsGeneric() {
if (genericCommands == null) genericCommands = new Boolean(true); if (genericCommands == null) genericCommands = new Boolean(true);
return genericCommands.booleanValue(); return genericCommands.booleanValue();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyCommandOptions() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyCommandOptions()
*/ */
public String[] getDependencyCommandOptions() { public String[] getDependencyCommandOptions() {
String[] options = new String[4]; String[] options = new String[4];
// -MMD // -MMD
options[0] = "-MMD"; //$NON-NLS-1$ options[0] = "-MMD"; //$NON-NLS-1$
// -MP // -MP
options[1] = "-MP"; //$NON-NLS-1$ options[1] = "-MP"; //$NON-NLS-1$
// -MF$(@:%.o=%.d) // -MF$(@:%.o=%.d)
options[2] = "-MF\"$(@:%.o=%.d)\""; //$NON-NLS-1$ options[2] = "-MF\"$(@:%.o=%.d)\""; //$NON-NLS-1$
//options[2] = "-MF\"${OutputDirRelPath}${OutputFileBaseName}.d\""; //$NON-NLS-1$ //options[2] = "-MF\"${OutputDirRelPath}${OutputFileBaseName}.d\""; //$NON-NLS-1$
if( buildContext instanceof IResourceConfiguration || needExplicitRuleForFile ) { if( buildContext instanceof IResourceConfiguration || needExplicitRuleForFile ) {
IPath outPath = getDependencyFiles()[0]; IPath outPath = getDependencyFiles()[0];
// -MT"dependecy-file-name" // -MT"dependecy-file-name"
String optTxt = "-MT\""; //$NON-NLS-1$ String optTxt = "-MT\""; //$NON-NLS-1$
optTxt += GnuMakefileGenerator.escapeWhitespaces(outPath.toString()) + "\""; //$NON-NLS-1$ optTxt += GnuMakefileGenerator.escapeWhitespaces(outPath.toString()) + "\""; //$NON-NLS-1$
options[3] = optTxt; options[3] = optTxt;
} else { } else {
// -MT"$(@:%.o=%.d) %.o" // -MT"$(@:%.o=%.d) %.o"
options[3] = "-MT\"$(@:%.o=%.d)\""; //$NON-NLS-1$ options[3] = "-MT\"$(@:%.o=%.d)\""; //$NON-NLS-1$
//options[3] = "-MT\"${OutputDirRelPath}${OutputFileBaseName}.d\""; //$NON-NLS-1$ //options[3] = "-MT\"${OutputDirRelPath}${OutputFileBaseName}.d\""; //$NON-NLS-1$
} }
return options; return options;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyFiles() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyFiles()
*/ */
public IPath[] getDependencyFiles() { public IPath[] getDependencyFiles() {
// The source file is project relative and the dependency file is top build directory relative // The source file is project relative and the dependency file is top build directory relative
// Remove the source extension and add the dependency extension // Remove the source extension and add the dependency extension
IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT); IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT);
// Remember that the source folder hierarchy and the build output folder hierarchy are the same // 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 // but if this is a generated resource, then it may already be under the top build directory
if (!depFilePath.isAbsolute()) { if (!depFilePath.isAbsolute()) {
if (topBuildDirectory.isPrefixOf(depFilePath)) { if (topBuildDirectory.isPrefixOf(depFilePath)) {
depFilePath = depFilePath.removeFirstSegments(1); depFilePath = depFilePath.removeFirstSegments(1);
} }
} }
IPath[] paths = new IPath[1]; IPath[] paths = new IPath[1];
paths[0] = depFilePath; paths[0] = depFilePath;
return paths; return paths;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPostToolDependencyCommands() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPostToolDependencyCommands()
*/ */
public String[] getPostToolDependencyCommands() { public String[] getPostToolDependencyCommands() {
// Nothing // Nothing
return null; return null;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPreToolDependencyCommands() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPreToolDependencyCommands()
*/ */
public String[] getPreToolDependencyCommands() { public String[] getPreToolDependencyCommands() {
// Nothing // Nothing
return null; return null;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext()
*/ */
public IBuildObject getBuildContext() { public IBuildObject getBuildContext() {
return buildContext; return buildContext;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource()
*/ */
public IPath getSource() { public IPath getSource() {
return source; return source;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool()
*/ */
public ITool getTool() { public ITool getTool() {
return tool; return tool;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory()
*/ */
public IPath getTopBuildDirectory() { public IPath getTopBuildDirectory() {
return topBuildDirectory; return topBuildDirectory;
} }
} }

View file

@ -1,98 +1,98 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu; package org.eclipse.cdt.managedbuilder.makegen.gnu;
import java.io.IOException; import java.io.IOException;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator; import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
/** /**
* This dependency calculator uses the same dependency management technique as the * This dependency calculator uses the same dependency management technique as the
* DefaultGCCDependencyCalculator. That is: * DefaultGCCDependencyCalculator. That is:
* *
* 1. An echo command creates the dependency file (.d). * 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. * 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. * 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. * 3. The dependency files are post-processed to add the empty header rules.
* *
* This dependency calculator uses the class DefaultGCCDependencyCalculator3Commands * This dependency calculator uses the class DefaultGCCDependencyCalculator3Commands
* which implements the per-source command information * which implements the per-source command information
* *
* This is an example dependency calculator that is not used by the CDT GCC tool-chain. * This is an example dependency calculator that is not used by the CDT GCC tool-chain.
* *
* @since 3.1 * @since 3.1
*/ */
public class DefaultGCCDependencyCalculator3 implements public class DefaultGCCDependencyCalculator3 implements
IManagedDependencyGenerator2 { IManagedDependencyGenerator2 {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType()
*/ */
public int getCalculatorType() { public int getCalculatorType() {
return TYPE_BUILD_COMMANDS; return TYPE_BUILD_COMMANDS;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencyFileExtension(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool) * @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) { public String getDependencyFileExtension(IConfiguration buildContext, ITool tool) {
return IManagedBuilderMakefileGenerator.DEP_EXT; return IManagedBuilderMakefileGenerator.DEP_EXT;
} }
/* /*
* (non-Javadoc) * (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) * @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) { public IManagedDependencyInfo getDependencySourceInfo(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
return new DefaultGCCDependencyCalculator3Commands(source, buildContext, tool, topBuildDirectory); return new DefaultGCCDependencyCalculator3Commands(source, buildContext, tool, topBuildDirectory);
} }
/* /*
* (non-Javadoc) * (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) * @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) { public boolean postProcessDependencyFile(IPath dependencyFile, IConfiguration buildContext, ITool tool, IPath topBuildDirectory) {
try { try {
IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot(); IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
IFile makefile; IFile makefile;
IPath makefilePath; IPath makefilePath;
if (dependencyFile.isAbsolute()) { if (dependencyFile.isAbsolute()) {
makefilePath = dependencyFile; makefilePath = dependencyFile;
} else { } else {
makefilePath = topBuildDirectory.append(dependencyFile); makefilePath = topBuildDirectory.append(dependencyFile);
} }
IPath rootPath = root.getLocation(); IPath rootPath = root.getLocation();
if (rootPath.isPrefixOf(makefilePath)) { if (rootPath.isPrefixOf(makefilePath)) {
makefilePath = makefilePath.removeFirstSegments(rootPath.segmentCount()); makefilePath = makefilePath.removeFirstSegments(rootPath.segmentCount());
} }
makefile = root.getFile(makefilePath); makefile = root.getFile(makefilePath);
return GnuMakefileGenerator.populateDummyTargets(buildContext, makefile, false); return GnuMakefileGenerator.populateDummyTargets(buildContext, makefile, false);
} catch (CoreException e) { } catch (CoreException e) {
} catch (IOException e) { } catch (IOException e) {
} }
return false; return false;
} }
} }

View file

@ -1,330 +1,330 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu; package org.eclipse.cdt.managedbuilder.makegen.gnu;
import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator; import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo; import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData; import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver; import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException; import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator; import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.resources.IProject;; import org.eclipse.core.resources.IProject;;
/** /**
* This dependency calculator uses the same dependency management technique as the * This dependency calculator uses the same dependency management technique as the
* DefaultGCCDependencyCalculator. That is: * DefaultGCCDependencyCalculator. That is:
* *
* 1. An echo command creates the dependency file (.d). * 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. * 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. * 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. * 3. The dependency files are post-processed to add the empty header rules.
* *
* This class is used with DefaultGCCDependencyCalculator3. * This class is used with DefaultGCCDependencyCalculator3.
* *
* This is an example dependency calculator that is not used by the CDT GCC tool-chain. * This is an example dependency calculator that is not used by the CDT GCC tool-chain.
* *
* @since 3.1 * @since 3.1
*/ */
public class DefaultGCCDependencyCalculator3Commands implements public class DefaultGCCDependencyCalculator3Commands implements
IManagedDependencyCommands { IManagedDependencyCommands {
private static final String EMPTY_STRING = new String(); private static final String EMPTY_STRING = new String();
// Member variables set by the constructor // Member variables set by the constructor
IPath source; IPath source;
IBuildObject buildContext; IBuildObject buildContext;
ITool tool; ITool tool;
IPath topBuildDirectory; IPath topBuildDirectory;
// Other Member variables // Other Member variables
IProject project; IProject project;
IConfiguration config; IConfiguration config;
IResourceConfiguration resConfig; IResourceConfiguration resConfig;
IPath sourceLocation; IPath sourceLocation;
IPath outputLocation; IPath outputLocation;
boolean needExplicitRuleForFile; boolean needExplicitRuleForFile;
boolean genericCommands = true; boolean genericCommands = true;
/** /**
* Constructor * Constructor
* *
* @param source The source file for which dependencies should be calculated * @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. * The IPath can be either relative to the project directory, or absolute in the file system.
* @param buildContext The IConfiguration or IResourceConfiguration that * @param buildContext The IConfiguration or IResourceConfiguration that
* contains the context in which the source file will be built * contains the context in which the source file will be built
* @param tool The tool associated with the source file * @param tool The tool associated with the source file
* @param topBuildDirectory The top build directory of the configuration. This is * @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. * the working directory for the tool. This IPath is relative to the project directory.
*/ */
public DefaultGCCDependencyCalculator3Commands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) { public DefaultGCCDependencyCalculator3Commands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
this.source = source; this.source = source;
this.buildContext = buildContext; this.buildContext = buildContext;
this.tool = tool; this.tool = tool;
this.topBuildDirectory = topBuildDirectory; this.topBuildDirectory = topBuildDirectory;
// Compute the project // Compute the project
if (buildContext instanceof IConfiguration) { if (buildContext instanceof IConfiguration) {
resConfig = null; resConfig = null;
config = (IConfiguration)buildContext; config = (IConfiguration)buildContext;
project = (IProject)config.getOwner(); project = (IProject)config.getOwner();
} else if (buildContext instanceof IResourceConfiguration) { } else if (buildContext instanceof IResourceConfiguration) {
resConfig = (IResourceConfiguration)buildContext; resConfig = (IResourceConfiguration)buildContext;
config = resConfig.getParent(); config = resConfig.getParent();
project = (IProject)resConfig.getOwner(); project = (IProject)resConfig.getOwner();
} }
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source)); sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]); outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]);
// A separate rule is needed for the resource in the case where explicit file-specific macros // 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) // are referenced, or if the resource contains special characters in its path (e.g., whitespace)
needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) || needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) ||
MacroResolver.getReferencedExplitFileMacros(tool).length > 0 MacroResolver.getReferencedExplitFileMacros(tool).length > 0
|| MacroResolver.getReferencedExplitFileMacros( || MacroResolver.getReferencedExplitFileMacros(
tool.getToolCommand(), tool.getToolCommand(),
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, outputLocation, new FileContextData(sourceLocation, outputLocation,
null, tool)).length > 0; null, tool)).length > 0;
if (buildContext instanceof IResourceConfiguration || needExplicitRuleForFile) if (buildContext instanceof IResourceConfiguration || needExplicitRuleForFile)
genericCommands = false; genericCommands = false;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#areCommandsGeneric() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#areCommandsGeneric()
*/ */
public boolean areCommandsGeneric() { public boolean areCommandsGeneric() {
return genericCommands; return genericCommands;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyCommandOptions() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyCommandOptions()
*/ */
public String[] getDependencyCommandOptions() { public String[] getDependencyCommandOptions() {
// Nothing // Nothing
return null; return null;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyFiles() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyFiles()
*/ */
public IPath[] getDependencyFiles() { public IPath[] getDependencyFiles() {
// The source file is project relative and the dependency file is top build directory relative // The source file is project relative and the dependency file is top build directory relative
// Remove the source extension and add the dependency extension // Remove the source extension and add the dependency extension
IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT); IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT);
// Remember that the source folder hierarchy and the build output folder hierarchy are the same // 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 // but if this is a generated resource, then it may already be under the top build directory
if (!depFilePath.isAbsolute()) { if (!depFilePath.isAbsolute()) {
if (topBuildDirectory.isPrefixOf(depFilePath)) { if (topBuildDirectory.isPrefixOf(depFilePath)) {
depFilePath = depFilePath.removeFirstSegments(1); depFilePath = depFilePath.removeFirstSegments(1);
} }
} }
IPath[] paths = new IPath[1]; IPath[] paths = new IPath[1];
paths[0] = depFilePath; paths[0] = depFilePath;
return paths; return paths;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPostToolDependencyCommands() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPostToolDependencyCommands()
*/ */
public String[] getPostToolDependencyCommands() { public String[] getPostToolDependencyCommands() {
/* /*
* For a given input, <path>/<resource_name>.<ext>, return a string containing * For a given input, <path>/<resource_name>.<ext>, return a string containing
* echo -n $(@:%.<out_ext>=%.d) '<path>/' >> $(@:%.<out_ext>=%.d) && \ * echo -n $(@:%.<out_ext>=%.d) '<path>/' >> $(@:%.<out_ext>=%.d) && \
* <tool_command> -P -MM -MG <tool_flags> $< >> $(@:%.<out_ext>=%.d) * <tool_command> -P -MM -MG <tool_flags> $< >> $(@:%.<out_ext>=%.d)
* *
*/ */
String[] commands = new String[2]; String[] commands = new String[2];
// Get what we need to create the dependency generation command // Get what we need to create the dependency generation command
String inputExtension = source.getFileExtension(); String inputExtension = source.getFileExtension();
String outputExtension = tool.getOutputExtension(inputExtension); String outputExtension = tool.getOutputExtension(inputExtension);
// Calculate the dependency rule // Calculate the dependency rule
// <path>/$(@:%.<out_ext>=%.d) // <path>/$(@:%.<out_ext>=%.d)
String depRule = "'$(@:%." + //$NON-NLS-1$ String depRule = "'$(@:%." + //$NON-NLS-1$
outputExtension + outputExtension +
"=%." + //$NON-NLS-1$ "=%." + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.DEP_EXT + IManagedBuilderMakefileGenerator.DEP_EXT +
")'"; //$NON-NLS-1$ ")'"; //$NON-NLS-1$
// Add the Echo command that will actually create the right format for the dep // Add the Echo command that will actually create the right format for the dep
commands[0] = commands[0] =
IManagedBuilderMakefileGenerator.TAB + IManagedBuilderMakefileGenerator.TAB +
IManagedBuilderMakefileGenerator.ECHO + IManagedBuilderMakefileGenerator.ECHO +
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
"-n" + //$NON-NLS-1$ "-n" + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
depRule + depRule +
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
"$(dir $@)" + //$NON-NLS-1$ "$(dir $@)" + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
">" + //$NON-NLS-1$ ">" + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
depRule; depRule;
// Add the line that will do the work to calculate dependencies // Add the line that will do the work to calculate dependencies
IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider(); IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
IManagedCommandLineInfo cmdLInfo = null; IManagedCommandLineInfo cmdLInfo = null;
String buildCmd = null; String buildCmd = null;
String[] inputs= new String[1]; inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO; String[] inputs= new String[1]; inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO;
String outputFile = ""; //$NON-NLS-1$ String outputFile = ""; //$NON-NLS-1$
String outflag = ""; //$NON-NLS-1$ String outflag = ""; //$NON-NLS-1$
String outputPrefix = ""; //$NON-NLS-1$ String outputPrefix = ""; //$NON-NLS-1$
String cmd = tool.getToolCommand(); String cmd = tool.getToolCommand();
//try to resolve the build macros in the tool command //try to resolve the build macros in the tool command
try { try {
String resolvedCommand = null; String resolvedCommand = null;
if (!needExplicitRuleForFile) { if (!needExplicitRuleForFile) {
resolvedCommand = provider.resolveValueToMakefileFormat( resolvedCommand = provider.resolveValueToMakefileFormat(
cmd, cmd,
EMPTY_STRING, EMPTY_STRING,
IManagedBuilderMakefileGenerator.WHITESPACE, IManagedBuilderMakefileGenerator.WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, new FileContextData(sourceLocation,
outputLocation, null, tool)); outputLocation, null, tool));
} else { } else {
// if we need an explicit rule then don't use any builder // if we need an explicit rule then don't use any builder
// variables, resolve everything // variables, resolve everything
// to explicit strings // to explicit strings
resolvedCommand = provider.resolveValue( resolvedCommand = provider.resolveValue(
cmd, cmd,
EMPTY_STRING, EMPTY_STRING,
IManagedBuilderMakefileGenerator.WHITESPACE, IManagedBuilderMakefileGenerator.WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, new FileContextData(sourceLocation,
outputLocation, null, tool)); outputLocation, null, tool));
} }
if((resolvedCommand = resolvedCommand.trim()).length() > 0) if((resolvedCommand = resolvedCommand.trim()).length() > 0)
cmd = resolvedCommand; cmd = resolvedCommand;
} catch (BuildMacroException e){ } catch (BuildMacroException e){
} }
String[] toolFlags = null; String[] toolFlags = null;
try { try {
toolFlags = tool.getToolCommandFlags(sourceLocation, outputLocation); toolFlags = tool.getToolCommandFlags(sourceLocation, outputLocation);
} catch( BuildException ex ) { } catch( BuildException ex ) {
toolFlags = new String[0]; toolFlags = new String[0];
} }
String[] flags = new String[toolFlags.length + 4]; String[] flags = new String[toolFlags.length + 4];
flags[0] = "-MM"; //$NON-NLS-1$ flags[0] = "-MM"; //$NON-NLS-1$
flags[1] = "-MG"; //$NON-NLS-1$ flags[1] = "-MG"; //$NON-NLS-1$
flags[2] = "-P"; //$NON-NLS-1$ flags[2] = "-P"; //$NON-NLS-1$
flags[3] = "-w"; //$NON-NLS-1$ flags[3] = "-w"; //$NON-NLS-1$
for (int i=0; i<toolFlags.length; i++) { for (int i=0; i<toolFlags.length; i++) {
flags[4+i] = toolFlags[i]; flags[4+i] = toolFlags[i];
} }
IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator(); IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
cmdLInfo = cmdLGen.generateCommandLineInfo( tool, cmd, flags, outflag, outputPrefix, cmdLInfo = cmdLGen.generateCommandLineInfo( tool, cmd, flags, outflag, outputPrefix,
outputFile, inputs, tool.getCommandLinePattern() ); outputFile, inputs, tool.getCommandLinePattern() );
// The command to build // The command to build
buildCmd = cmdLInfo.getCommandLine(); buildCmd = cmdLInfo.getCommandLine();
// resolve any remaining macros in the command after it has been generated // resolve any remaining macros in the command after it has been generated
try { try {
String resolvedCommand = null; String resolvedCommand = null;
if (!needExplicitRuleForFile) { if (!needExplicitRuleForFile) {
resolvedCommand = provider.resolveValueToMakefileFormat( resolvedCommand = provider.resolveValueToMakefileFormat(
buildCmd, buildCmd,
EMPTY_STRING, EMPTY_STRING,
IManagedBuilderMakefileGenerator.WHITESPACE, IManagedBuilderMakefileGenerator.WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, new FileContextData(sourceLocation,
outputLocation, null, tool)); outputLocation, null, tool));
} else { } else {
// if we need an explicit rule then don't use any builder // if we need an explicit rule then don't use any builder
// variables, resolve everything to explicit strings // variables, resolve everything to explicit strings
resolvedCommand = provider.resolveValue( resolvedCommand = provider.resolveValue(
buildCmd, buildCmd,
EMPTY_STRING, EMPTY_STRING,
IManagedBuilderMakefileGenerator.WHITESPACE, IManagedBuilderMakefileGenerator.WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, new FileContextData(sourceLocation,
outputLocation, null, tool)); outputLocation, null, tool));
} }
if((resolvedCommand = resolvedCommand.trim()).length() > 0) if((resolvedCommand = resolvedCommand.trim()).length() > 0)
buildCmd = resolvedCommand; buildCmd = resolvedCommand;
} catch (BuildMacroException e){ } catch (BuildMacroException e){
} }
commands[1] = commands[1] =
IManagedBuilderMakefileGenerator.TAB + IManagedBuilderMakefileGenerator.TAB +
buildCmd + buildCmd +
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
">>" + //$NON-NLS-1$ ">>" + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.WHITESPACE + depRule; IManagedBuilderMakefileGenerator.WHITESPACE + depRule;
return commands; return commands;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPreToolDependencyCommands() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPreToolDependencyCommands()
*/ */
public String[] getPreToolDependencyCommands() { public String[] getPreToolDependencyCommands() {
// Nothing // Nothing
return null; return null;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext()
*/ */
public IBuildObject getBuildContext() { public IBuildObject getBuildContext() {
return buildContext; return buildContext;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource()
*/ */
public IPath getSource() { public IPath getSource() {
return source; return source;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool()
*/ */
public ITool getTool() { public ITool getTool() {
return tool; return tool;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory()
*/ */
public IPath getTopBuildDirectory() { public IPath getTopBuildDirectory() {
return topBuildDirectory; return topBuildDirectory;
} }
} }

View file

@ -1,69 +1,69 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu; package org.eclipse.cdt.managedbuilder.makegen.gnu;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator; import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
/** /**
* This dependency calculator uses the GCC -MM -MF -MP -MT options in order to * 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. * generate .d files as separate step prior to the source compilations.
* *
* This dependency calculator uses the class DefaultGCCDependencyCalculatorPreBuildCommands * This dependency calculator uses the class DefaultGCCDependencyCalculatorPreBuildCommands
* which implements the per-source command information * which implements the per-source command information
* *
* @since 3.1 * @since 3.1
*/ */
public class DefaultGCCDependencyCalculatorPreBuild implements public class DefaultGCCDependencyCalculatorPreBuild implements
IManagedDependencyGenerator2 { IManagedDependencyGenerator2 {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType()
*/ */
public int getCalculatorType() { public int getCalculatorType() {
return TYPE_PREBUILD_COMMANDS; return TYPE_PREBUILD_COMMANDS;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencyFileExtension(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool) * @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) { public String getDependencyFileExtension(IConfiguration buildContext, ITool tool) {
return IManagedBuilderMakefileGenerator.DEP_EXT; return IManagedBuilderMakefileGenerator.DEP_EXT;
} }
/* /*
* (non-Javadoc) * (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) * @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) { public IManagedDependencyInfo getDependencySourceInfo(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
return new DefaultGCCDependencyCalculatorPreBuildCommands(source, buildContext, tool, topBuildDirectory); return new DefaultGCCDependencyCalculatorPreBuildCommands(source, buildContext, tool, topBuildDirectory);
} }
/* /*
* (non-Javadoc) * (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) * @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) { public boolean postProcessDependencyFile(IPath dependencyFile, IConfiguration buildContext, ITool tool, IPath topBuildDirectory) {
// Nothing // Nothing
return false; return false;
} }
} }

View file

@ -1,306 +1,306 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu; package org.eclipse.cdt.managedbuilder.makegen.gnu;
import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator; import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo; import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData; import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver; import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException; import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator; import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyPreBuild; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyPreBuild;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import java.util.Vector; import java.util.Vector;
/** /**
* This dependency calculator uses the GCC -MM -MF -MP -MT options in order to * 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. * generate .d files as separate step prior to the source compilations.
* *
* This dependency calculator uses the class DefaultGCCDependencyCalculatorPreBuildCommands * This dependency calculator uses the class DefaultGCCDependencyCalculatorPreBuildCommands
* which implements the per-source command information * which implements the per-source command information
* *
* This class is used with DefaultGCCDependencyCalculatorPreBuild. * This class is used with DefaultGCCDependencyCalculatorPreBuild.
* *
* @since 3.1 * @since 3.1
*/ */
public class DefaultGCCDependencyCalculatorPreBuildCommands implements IManagedDependencyPreBuild { public class DefaultGCCDependencyCalculatorPreBuildCommands implements IManagedDependencyPreBuild {
private static final String EMPTY_STRING = new String(); private static final String EMPTY_STRING = new String();
// Member variables set by the constructor // Member variables set by the constructor
IPath source; IPath source;
IBuildObject buildContext; IBuildObject buildContext;
ITool tool; ITool tool;
IPath topBuildDirectory; IPath topBuildDirectory;
// Other Member variables // Other Member variables
IProject project; IProject project;
IPath sourceLocation; IPath sourceLocation;
IPath outputLocation; IPath outputLocation;
boolean needExplicitRuleForFile; boolean needExplicitRuleForFile;
Boolean genericCommands = null; Boolean genericCommands = null;
/** /**
* Constructor * Constructor
* *
* @param source The source file for which dependencies should be calculated * @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. * The IPath can be either relative to the project directory, or absolute in the file system.
* @param buildContext The IConfiguration or IResourceConfiguration that * @param buildContext The IConfiguration or IResourceConfiguration that
* contains the context in which the source file will be built * contains the context in which the source file will be built
* @param tool The tool associated with the source file * @param tool The tool associated with the source file
* @param topBuildDirectory The top build directory of the configuration. This is * @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. * the working directory for the tool. This IPath is relative to the project directory.
*/ */
public DefaultGCCDependencyCalculatorPreBuildCommands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) { public DefaultGCCDependencyCalculatorPreBuildCommands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
this.source = source; this.source = source;
this.buildContext = buildContext; this.buildContext = buildContext;
this.tool = tool; this.tool = tool;
this.topBuildDirectory = topBuildDirectory; this.topBuildDirectory = topBuildDirectory;
// Compute the project // Compute the project
if (buildContext instanceof IConfiguration) { if (buildContext instanceof IConfiguration) {
IConfiguration config = (IConfiguration)buildContext; IConfiguration config = (IConfiguration)buildContext;
project = (IProject)config.getOwner(); project = (IProject)config.getOwner();
} else if (buildContext instanceof IResourceConfiguration) { } else if (buildContext instanceof IResourceConfiguration) {
IResourceConfiguration resConfig = (IResourceConfiguration)buildContext; IResourceConfiguration resConfig = (IResourceConfiguration)buildContext;
project = (IProject)resConfig.getOwner(); project = (IProject)resConfig.getOwner();
} }
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source)); sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]); outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]);
// A separate rule is needed for the resource in the case where explicit file-specific macros // 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) // are referenced, or if the resource contains special characters in its path (e.g., whitespace)
needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) || needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) ||
MacroResolver.getReferencedExplitFileMacros(tool).length > 0 MacroResolver.getReferencedExplitFileMacros(tool).length > 0
|| MacroResolver.getReferencedExplitFileMacros( || MacroResolver.getReferencedExplitFileMacros(
tool.getToolCommand(), tool.getToolCommand(),
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, outputLocation, new FileContextData(sourceLocation, outputLocation,
null, tool)).length > 0; null, tool)).length > 0;
if (needExplicitRuleForFile) genericCommands = new Boolean(false); if (needExplicitRuleForFile) genericCommands = new Boolean(false);
} }
public boolean areCommandsGeneric() { public boolean areCommandsGeneric() {
if (genericCommands != null) return genericCommands.booleanValue(); if (genericCommands != null) return genericCommands.booleanValue();
// If the context is a Configuration, yes // If the context is a Configuration, yes
if (buildContext instanceof IConfiguration) { if (buildContext instanceof IConfiguration) {
genericCommands = new Boolean(true); genericCommands = new Boolean(true);
return true; return true;
} }
// If the context is a Resource Configuration, determine if it overrides any // If the context is a Resource Configuration, determine if it overrides any
// of its parent configuration's options that would affect dependency file // of its parent configuration's options that would affect dependency file
// generation. // generation.
// TODO // TODO
genericCommands = new Boolean(false); genericCommands = new Boolean(false);
return false; return false;
} }
public String getBuildStepName() { public String getBuildStepName() {
return new String("GCC_DEPENDS"); //$NON-NLS-1$ return new String("GCC_DEPENDS"); //$NON-NLS-1$
} }
public String[] getDependencyCommands() { public String[] getDependencyCommands() {
String[] commands = new String[1]; String[] commands = new String[1];
String depCmd = EMPTY_STRING; String depCmd = EMPTY_STRING;
IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider(); IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
// Get and resolve the command // Get and resolve the command
String cmd = tool.getToolCommand(); String cmd = tool.getToolCommand();
try { try {
String resolvedCommand = null; String resolvedCommand = null;
if (!needExplicitRuleForFile) { if (!needExplicitRuleForFile) {
resolvedCommand = provider.resolveValueToMakefileFormat( resolvedCommand = provider.resolveValueToMakefileFormat(
cmd, cmd,
EMPTY_STRING, EMPTY_STRING,
IManagedBuilderMakefileGenerator.WHITESPACE, IManagedBuilderMakefileGenerator.WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, new FileContextData(sourceLocation,
outputLocation, null, tool)); outputLocation, null, tool));
} else { } else {
// if we need an explicit rule then don't use any builder // if we need an explicit rule then don't use any builder
// variables, resolve everything // variables, resolve everything
// to explicit strings // to explicit strings
resolvedCommand = provider.resolveValue( resolvedCommand = provider.resolveValue(
cmd, cmd,
EMPTY_STRING, EMPTY_STRING,
IManagedBuilderMakefileGenerator.WHITESPACE, IManagedBuilderMakefileGenerator.WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, new FileContextData(sourceLocation,
outputLocation, null, tool)); outputLocation, null, tool));
} }
if ((resolvedCommand = resolvedCommand.trim()).length() > 0) if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
cmd = resolvedCommand; cmd = resolvedCommand;
} catch (BuildMacroException e) { } catch (BuildMacroException e) {
} }
IManagedCommandLineInfo cmdLInfo = null; IManagedCommandLineInfo cmdLInfo = null;
// Set up the command line options that will generate the dependency file // Set up the command line options that will generate the dependency file
Vector options = new Vector(); Vector options = new Vector();
// -w // -w
options.add("-w"); //$NON-NLS-1$ options.add("-w"); //$NON-NLS-1$
// -MM // -MM
options.add("-MM"); //$NON-NLS-1$ options.add("-MM"); //$NON-NLS-1$
// -MP // -MP
options.add("-MP"); //$NON-NLS-1$ options.add("-MP"); //$NON-NLS-1$
String optTxt; String optTxt;
if( buildContext instanceof IResourceConfiguration || needExplicitRuleForFile ) { if( buildContext instanceof IResourceConfiguration || needExplicitRuleForFile ) {
IPath outPath = getDependencyFiles()[0]; IPath outPath = getDependencyFiles()[0];
// -MT"dependecy-file-name" // -MT"dependecy-file-name"
optTxt = "-MT\""; //$NON-NLS-1$ optTxt = "-MT\""; //$NON-NLS-1$
optTxt += GnuMakefileGenerator.escapeWhitespaces(outPath.toString()) + "\""; //$NON-NLS-1$ optTxt += GnuMakefileGenerator.escapeWhitespaces(outPath.toString()) + "\""; //$NON-NLS-1$
options.add(optTxt); options.add(optTxt);
// -MT"object-file-filename" // -MT"object-file-filename"
optTxt = "-MT\""; //$NON-NLS-1$ optTxt = "-MT\""; //$NON-NLS-1$
optTxt += GnuMakefileGenerator.escapeWhitespaces((outPath.removeFileExtension()).toString()); optTxt += GnuMakefileGenerator.escapeWhitespaces((outPath.removeFileExtension()).toString());
String outExt = tool.getOutputExtension(source.getFileExtension()); String outExt = tool.getOutputExtension(source.getFileExtension());
if (outExt != null) optTxt += "." + outExt; //$NON-NLS-1$ if (outExt != null) optTxt += "." + outExt; //$NON-NLS-1$
optTxt += "\""; //$NON-NLS-1$ optTxt += "\""; //$NON-NLS-1$
options.add(optTxt); options.add(optTxt);
} else { } else {
// -MT"$@" // -MT"$@"
options.add("-MT\"$@\""); //$NON-NLS-1$ options.add("-MT\"$@\""); //$NON-NLS-1$
// -MT'$(@:%.d=%.o)' // -MT'$(@:%.d=%.o)'
optTxt = "-MT\"$(@:%.d=%.o)\""; //$NON-NLS-1$ optTxt = "-MT\"$(@:%.d=%.o)\""; //$NON-NLS-1$
//optTxt = "-MT\"${OutputDirRelPath}${OutputFileBaseName}"; //optTxt = "-MT\"${OutputDirRelPath}${OutputFileBaseName}";
//if (outExt != null) optTxt += "." + outExt; //if (outExt != null) optTxt += "." + outExt;
//optTxt += "\""; //$NON-NLS-1$ //optTxt += "\""; //$NON-NLS-1$
options.add(optTxt); options.add(optTxt);
} }
// Save the -I, -D, -U options and discard the rest // Save the -I, -D, -U options and discard the rest
try { try {
String[] allFlags = tool.getToolCommandFlags(sourceLocation, outputLocation); String[] allFlags = tool.getToolCommandFlags(sourceLocation, outputLocation);
for (int i=0; i<allFlags.length; i++) { for (int i=0; i<allFlags.length; i++) {
if (allFlags[i].startsWith("-I") || //$NON-NLS-1$ if (allFlags[i].startsWith("-I") || //$NON-NLS-1$
allFlags[i].startsWith("-D") || //$NON-NLS-1$ allFlags[i].startsWith("-D") || //$NON-NLS-1$
allFlags[i].startsWith("-U")) { //$NON-NLS-1$ allFlags[i].startsWith("-U")) { //$NON-NLS-1$
options.add(allFlags[i]); options.add(allFlags[i]);
} }
} }
} catch( BuildException ex ) { } catch( BuildException ex ) {
} }
// Call the command line generator // Call the command line generator
IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator(); IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
String[] flags = (String[])options.toArray(new String[options.size()]); String[] flags = (String[])options.toArray(new String[options.size()]);
String[] inputs = new String[1]; String[] inputs = new String[1];
inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO; inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO;
cmdLInfo = cmdLGen.generateCommandLineInfo( cmdLInfo = cmdLGen.generateCommandLineInfo(
tool, cmd, flags, "-MF", EMPTY_STRING, //$NON-NLS-1$ tool, cmd, flags, "-MF", EMPTY_STRING, //$NON-NLS-1$
IManagedBuilderMakefileGenerator.OUT_MACRO, IManagedBuilderMakefileGenerator.OUT_MACRO,
inputs, inputs,
tool.getCommandLinePattern() ); tool.getCommandLinePattern() );
// The command to build // The command to build
if (cmdLInfo != null) { if (cmdLInfo != null) {
depCmd = cmdLInfo.getCommandLine(); depCmd = cmdLInfo.getCommandLine();
// resolve any remaining macros in the command after it has been // resolve any remaining macros in the command after it has been
// generated // generated
try { try {
String resolvedCommand; String resolvedCommand;
if (!needExplicitRuleForFile) { if (!needExplicitRuleForFile) {
resolvedCommand = provider.resolveValueToMakefileFormat( resolvedCommand = provider.resolveValueToMakefileFormat(
depCmd, depCmd,
EMPTY_STRING, EMPTY_STRING,
IManagedBuilderMakefileGenerator.WHITESPACE, IManagedBuilderMakefileGenerator.WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, new FileContextData(sourceLocation,
outputLocation, null, tool)); outputLocation, null, tool));
} else { } else {
// if we need an explicit rule then don't use any builder // if we need an explicit rule then don't use any builder
// variables, resolve everything to explicit strings // variables, resolve everything to explicit strings
resolvedCommand = provider.resolveValue( resolvedCommand = provider.resolveValue(
depCmd, depCmd,
EMPTY_STRING, EMPTY_STRING,
IManagedBuilderMakefileGenerator.WHITESPACE, IManagedBuilderMakefileGenerator.WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE, IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, new FileContextData(sourceLocation,
outputLocation, null, tool)); outputLocation, null, tool));
} }
if ((resolvedCommand = resolvedCommand.trim()).length() > 0) if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
depCmd = resolvedCommand; depCmd = resolvedCommand;
} catch (BuildMacroException e) { } catch (BuildMacroException e) {
} }
} }
commands[0] = depCmd; commands[0] = depCmd;
return commands; return commands;
} }
public IPath[] getDependencyFiles() { public IPath[] getDependencyFiles() {
// The source file is project relative and the dependency file is top build directory relative // The source file is project relative and the dependency file is top build directory relative
// Remove the source extension and add the dependency extension // Remove the source extension and add the dependency extension
IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT); IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT);
// Remember that the source folder hierarchy and the build output folder hierarchy are the same // 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 // but if this is a generated resource, then it may already be under the top build directory
if (!depFilePath.isAbsolute()) { if (!depFilePath.isAbsolute()) {
if (topBuildDirectory.isPrefixOf(depFilePath)) { if (topBuildDirectory.isPrefixOf(depFilePath)) {
depFilePath = depFilePath.removeFirstSegments(1); depFilePath = depFilePath.removeFirstSegments(1);
} }
} }
IPath[] paths = new IPath[1]; IPath[] paths = new IPath[1];
paths[0] = depFilePath; paths[0] = depFilePath;
return paths; return paths;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext()
*/ */
public IBuildObject getBuildContext() { public IBuildObject getBuildContext() {
return buildContext; return buildContext;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource()
*/ */
public IPath getSource() { public IPath getSource() {
return source; return source;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool()
*/ */
public ITool getTool() { public ITool getTool() {
return tool; return tool;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory()
*/ */
public IPath getTopBuildDirectory() { public IPath getTopBuildDirectory() {
return topBuildDirectory; return topBuildDirectory;
} }
} }

View file

@ -1,37 +1,37 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu; package org.eclipse.cdt.managedbuilder.makegen.gnu;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* *
* This class contains the desciption of a group of generated dependency files, * This class contains the desciption of a group of generated dependency files,
* e.g., .d files created by compilations * e.g., .d files created by compilations
* *
*/ */
public class GnuDependencyGroupInfo { public class GnuDependencyGroupInfo {
// Member Variables // Member Variables
String groupBuildVar; String groupBuildVar;
boolean conditionallyInclude; boolean conditionallyInclude;
ArrayList groupFiles; ArrayList groupFiles;
// Constructor // Constructor
public GnuDependencyGroupInfo(String groupName, boolean bConditionallyInclude) { public GnuDependencyGroupInfo(String groupName, boolean bConditionallyInclude) {
groupBuildVar = groupName; groupBuildVar = groupName;
conditionallyInclude = bConditionallyInclude; conditionallyInclude = bConditionallyInclude;
// Note: not yet needed // Note: not yet needed
groupFiles = null; groupFiles = null;
} }
} }

View file

@ -1,122 +1,122 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2006 Intel Corporation and others. * Copyright (c) 2005, 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu; package org.eclipse.cdt.managedbuilder.makegen.gnu;
import java.util.Vector; import java.util.Vector;
/** /**
* This interface returns information about a Tool's inputs * This interface returns information about a Tool's inputs
* and outputs while a Gnu makefile is being generated. * and outputs while a Gnu makefile is being generated.
*/ */
public interface IManagedBuildGnuToolInfo { public interface IManagedBuildGnuToolInfo {
public final String DOT = "."; //$NON-NLS-1$ public final String DOT = "."; //$NON-NLS-1$
/** /**
* Returns <code>true</code> if the tool's inputs have been calculated, * Returns <code>true</code> if the tool's inputs have been calculated,
* else <code>false</code>. * else <code>false</code>.
* *
* @return boolean * @return boolean
*/ */
public boolean areInputsCalculated(); public boolean areInputsCalculated();
/** /**
* Returns the tool's inputs in command line format. This will use * Returns the tool's inputs in command line format. This will use
* variables rather than actual file names as appropriate. * variables rather than actual file names as appropriate.
* *
* @return Vector * @return Vector
*/ */
public Vector getCommandInputs(); public Vector getCommandInputs();
/** /**
* Returns the raw list of tool's input file names. * Returns the raw list of tool's input file names.
* *
* @return Vector * @return Vector
*/ */
public Vector getEnumeratedInputs(); public Vector getEnumeratedInputs();
/** /**
* Returns <code>true</code> if the tool's outputs have been calculated, * Returns <code>true</code> if the tool's outputs have been calculated,
* else <code>false</code>. * else <code>false</code>.
* *
* @return boolean * @return boolean
*/ */
public boolean areOutputsCalculated(); public boolean areOutputsCalculated();
/** /**
* Returns the tool's outputs in command line format. This will use * Returns the tool's outputs in command line format. This will use
* variables rather than actual file names as appropriate. * variables rather than actual file names as appropriate.
* *
* @return Vector * @return Vector
*/ */
public Vector getCommandOutputs(); public Vector getCommandOutputs();
/** /**
* Returns the raw list of tool's primary output file names. * Returns the raw list of tool's primary output file names.
* *
* @return Vector * @return Vector
*/ */
public Vector getEnumeratedPrimaryOutputs(); public Vector getEnumeratedPrimaryOutputs();
/** /**
* Returns the raw list of tool's secondary output file names. * Returns the raw list of tool's secondary output file names.
* *
* @return Vector * @return Vector
*/ */
public Vector getEnumeratedSecondaryOutputs(); public Vector getEnumeratedSecondaryOutputs();
/** /**
* Returns the raw list of tool's output variable names. * Returns the raw list of tool's output variable names.
* *
* @return Vector * @return Vector
*/ */
public Vector getOutputVariables(); public Vector getOutputVariables();
/** /**
* Returns <code>true</code> if the tool's dependencies have been calculated, * Returns <code>true</code> if the tool's dependencies have been calculated,
* else <code>false</code>. * else <code>false</code>.
* *
* @return boolean * @return boolean
*/ */
public boolean areDependenciesCalculated(); public boolean areDependenciesCalculated();
/** /**
* Returns the tool's dependencies in command line format. This will use * Returns the tool's dependencies in command line format. This will use
* variables rather than actual file names as appropriate. * variables rather than actual file names as appropriate.
* Dependencies are top build directory relative. * Dependencies are top build directory relative.
* *
* @return Vector * @return Vector
*/ */
public Vector getCommandDependencies(); public Vector getCommandDependencies();
/** /**
* Returns the tool's additional targets as determined by the * Returns the tool's additional targets as determined by the
* dependency calculator. * dependency calculator.
* Additional targets are top build directory relative * Additional targets are top build directory relative
* *
* @return Vector * @return Vector
*/ */
public Vector getAdditionalTargets(); public Vector getAdditionalTargets();
/** /**
* Returns the raw list of tool's input dependencies. * Returns the raw list of tool's input dependencies.
* *
* @return Vector * @return Vector
*/ */
//public Vector getEnumeratedDependencies(); //public Vector getEnumeratedDependencies();
/** /**
* Returns <code>true</code> if this is the target tool * Returns <code>true</code> if this is the target tool
* else <code>false</code>. * else <code>false</code>.
* *
* @return boolean * @return boolean
*/ */
public boolean isTargetTool(); public boolean isTargetTool();
} }

View file

@ -1,87 +1,87 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others. * Copyright (c) 2004, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.internal; package org.eclipse.cdt.managedbuilder.makegen.internal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.search.ICSearchConstants; import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchScope; import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.SearchEngine; import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.search.PathCollector; import org.eclipse.cdt.internal.core.search.PathCollector;
import org.eclipse.cdt.internal.core.search.PatternSearchJob; import org.eclipse.cdt.internal.core.search.PatternSearchJob;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager; import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern; import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
/** /**
* @since 2.0 * @since 2.0
*/ */
public class DefaultIndexerDependencyCalculator implements IManagedDependencyGenerator { public class DefaultIndexerDependencyCalculator implements IManagedDependencyGenerator {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource) * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
*/ */
public IResource[] findDependencies(IResource resource, IProject project) { public IResource[] findDependencies(IResource resource, IProject project) {
PathCollector pathCollector = new PathCollector(); PathCollector pathCollector = new PathCollector();
ICSearchScope scope = SearchEngine.createWorkspaceScope(); ICSearchScope scope = SearchEngine.createWorkspaceScope();
CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(), ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES, ICSearchConstants.EXACT_MATCH, true); CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(), ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES, ICSearchConstants.EXACT_MATCH, true);
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager(); IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
indexManager.performConcurrentJob( indexManager.performConcurrentJob(
new PatternSearchJob( new PatternSearchJob(
(CSearchPattern) pattern, (CSearchPattern) pattern,
scope, scope,
pathCollector, pathCollector,
indexManager), indexManager),
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
null, null); null, null);
// We will get back an array of resource names relative to the workspace // We will get back an array of resource names relative to the workspace
String[] deps = pathCollector.getPaths(); String[] deps = pathCollector.getPaths();
// Convert them to something useful // Convert them to something useful
List depList = new ArrayList(); List depList = new ArrayList();
IResource res = null; IResource res = null;
IWorkspaceRoot root = null; IWorkspaceRoot root = null;
if (project != null) { if (project != null) {
root = project.getWorkspace().getRoot(); root = project.getWorkspace().getRoot();
} }
for (int index = 0; index < deps.length; ++index) { for (int index = 0; index < deps.length; ++index) {
res = root.findMember(deps[index]); res = root.findMember(deps[index]);
if (res != null) { if (res != null) {
depList.add(res); depList.add(res);
} }
} }
return (IResource[]) depList.toArray(new IResource[depList.size()]); return (IResource[]) depList.toArray(new IResource[depList.size()]);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
*/ */
public int getCalculatorType() { public int getCalculatorType() {
// Tell the // Tell the
return TYPE_EXTERNAL; return TYPE_EXTERNAL;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
*/ */
public String getDependencyCommand(IResource resource, IManagedBuildInfo info) { public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
// There is no command // There is no command
return null; return null;
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -1,64 +1,64 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - initial API and implementation * Intel Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.actions; package org.eclipse.cdt.managedbuilder.ui.actions;
import java.util.*; import java.util.*;
import org.eclipse.cdt.managedbuilder.core.*; import org.eclipse.cdt.managedbuilder.core.*;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
/** /**
* Action which changes active build configuration of the current project to * Action which changes active build configuration of the current project to
* the given one. * the given one.
*/ */
public class BuildConfigAction extends Action { public class BuildConfigAction extends Action {
private String fConfigName = null; private String fConfigName = null;
private HashSet fProjects = null; private HashSet fProjects = null;
/** /**
* Constructs the action. * Constructs the action.
* @param projects List of selected managed-built projects * @param projects List of selected managed-built projects
* @param configName Build configuration name * @param configName Build configuration name
* @param accel Number to be used as accelerator * @param accel Number to be used as accelerator
*/ */
public BuildConfigAction(HashSet projects, String configName, String displayName, int accel) { public BuildConfigAction(HashSet projects, String configName, String displayName, int accel) {
super("&" + accel + " " + displayName); //$NON-NLS-1$ //$NON-NLS-2$ super("&" + accel + " " + displayName); //$NON-NLS-1$ //$NON-NLS-2$
fProjects = projects; fProjects = projects;
fConfigName = configName; fConfigName = configName;
} }
/** /**
* @see org.eclipse.jface.action.IAction#run() * @see org.eclipse.jface.action.IAction#run()
*/ */
public void run() { public void run() {
Iterator iter = fProjects.iterator(); Iterator iter = fProjects.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)iter.next()); IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)iter.next());
if (info != null && info.isValid()) { if (info != null && info.isValid()) {
IConfiguration[] configs = info.getManagedProject().getConfigurations(); IConfiguration[] configs = info.getManagedProject().getConfigurations();
int i = 0; int i = 0;
for (; i < configs.length; i++) { for (; i < configs.length; i++) {
if (configs[i].getName().equals(fConfigName)) { if (configs[i].getName().equals(fConfigName)) {
break; break;
} }
} }
if (i != configs.length) { if (i != configs.length) {
info.setDefaultConfiguration(configs[i]); info.setDefaultConfiguration(configs[i]);
info.setSelectedConfiguration(configs[i]); info.setSelectedConfiguration(configs[i]);
} }
} }
} }
} }
} }

View file

@ -1,215 +1,215 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others. * Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - initial API and implementation * Intel Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.actions; package org.eclipse.cdt.managedbuilder.ui.actions;
import java.util.*; import java.util.*;
import org.eclipse.cdt.core.model.*; import org.eclipse.cdt.core.model.*;
import org.eclipse.cdt.managedbuilder.core.*; import org.eclipse.cdt.managedbuilder.core.*;
import org.eclipse.core.resources.*; import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.*; import org.eclipse.jface.action.*;
import org.eclipse.jface.viewers.*; import org.eclipse.jface.viewers.*;
import org.eclipse.swt.widgets.*; import org.eclipse.swt.widgets.*;
/** /**
* Base class for build configuration actions. * Base class for build configuration actions.
*/ */
public class ChangeBuildConfigActionBase { public class ChangeBuildConfigActionBase {
/** /**
* List of selected managed-built projects * List of selected managed-built projects
*/ */
protected HashSet fProjects = new HashSet(); protected HashSet fProjects = new HashSet();
/** /**
* Fills the menu with build configurations which are common for all selected projects * Fills the menu with build configurations which are common for all selected projects
* @param menu The menu to fill * @param menu The menu to fill
*/ */
protected void fillMenu(Menu menu) { protected void fillMenu(Menu menu) {
if (menu == null) { if (menu == null) {
// This should not happen // This should not happen
return; return;
} }
MenuItem[] items = menu.getItems(); MenuItem[] items = menu.getItems();
for (int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; i++) {
items[i].dispose(); items[i].dispose();
} }
TreeSet configNames = new TreeSet(); TreeSet configNames = new TreeSet();
Iterator projIter = fProjects.iterator(); Iterator projIter = fProjects.iterator();
String sCurrentConfig = null; String sCurrentConfig = null;
boolean bCurrentConfig = true; boolean bCurrentConfig = true;
while (projIter.hasNext()) { while (projIter.hasNext()) {
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)projIter.next()); IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)projIter.next());
if (info != null && info.isValid()) { if (info != null && info.isValid()) {
if (bCurrentConfig) { if (bCurrentConfig) {
String sNewConfig = info.getDefaultConfiguration().getName(); String sNewConfig = info.getDefaultConfiguration().getName();
if (sCurrentConfig == null) { if (sCurrentConfig == null) {
sCurrentConfig = sNewConfig; sCurrentConfig = sNewConfig;
} }
else { else {
if (!sCurrentConfig.equals(sNewConfig)) { if (!sCurrentConfig.equals(sNewConfig)) {
bCurrentConfig = false; bCurrentConfig = false;
} }
} }
} }
IConfiguration[] configs = info.getManagedProject().getConfigurations(); IConfiguration[] configs = info.getManagedProject().getConfigurations();
for (int i = 0; i < configs.length; i++) { for (int i = 0; i < configs.length; i++) {
configNames.add(configs[i].getName()); configNames.add(configs[i].getName());
} }
} }
} }
Iterator confIter = configNames.iterator(); Iterator confIter = configNames.iterator();
int accel = 0; int accel = 0;
while (confIter.hasNext()) { while (confIter.hasNext()) {
String sName = (String)confIter.next(); String sName = (String)confIter.next();
String sDesc = null; String sDesc = null;
projIter = fProjects.iterator(); projIter = fProjects.iterator();
boolean commonName = true; boolean commonName = true;
boolean commonDesc = true; boolean commonDesc = true;
boolean firstProj = true; boolean firstProj = true;
while (projIter.hasNext()) { while (projIter.hasNext()) {
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)projIter.next()); IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)projIter.next());
if (info != null && info.isValid()) { if (info != null && info.isValid()) {
IConfiguration[] configs = info.getManagedProject().getConfigurations(); IConfiguration[] configs = info.getManagedProject().getConfigurations();
int i = 0; int i = 0;
for (; i < configs.length; i++) { for (; i < configs.length; i++) {
if (configs[i].getName().equals(sName)) { if (configs[i].getName().equals(sName)) {
String sNewDesc = configs[i].getDescription(); String sNewDesc = configs[i].getDescription();
if (sNewDesc.equals("")) { //$NON-NLS-1$ if (sNewDesc.equals("")) { //$NON-NLS-1$
sNewDesc = null; sNewDesc = null;
} }
if (commonDesc) { if (commonDesc) {
if (firstProj) { if (firstProj) {
sDesc = sNewDesc; sDesc = sNewDesc;
firstProj = false; firstProj = false;
} else if (sNewDesc == null && sDesc != null || sNewDesc != null && !sNewDesc.equals(sDesc)) { } else if (sNewDesc == null && sDesc != null || sNewDesc != null && !sNewDesc.equals(sDesc)) {
commonDesc = false; commonDesc = false;
} }
} }
break; break;
} }
} }
if (i == configs.length) { if (i == configs.length) {
commonName = false; commonName = false;
break; break;
} }
} }
} }
if (commonName) { if (commonName) {
StringBuffer builder = new StringBuffer(sName); StringBuffer builder = new StringBuffer(sName);
if (commonDesc) { if (commonDesc) {
if (sDesc != null) { if (sDesc != null) {
builder.append(" ("); //$NON-NLS-1$ builder.append(" ("); //$NON-NLS-1$
builder.append(sDesc); builder.append(sDesc);
builder.append(")"); //$NON-NLS-1$ builder.append(")"); //$NON-NLS-1$
} }
} else { } else {
builder.append(" (...)"); //$NON-NLS-1$ builder.append(" (...)"); //$NON-NLS-1$
} }
IAction action = new BuildConfigAction(fProjects, sName, builder.toString(), accel + 1); IAction action = new BuildConfigAction(fProjects, sName, builder.toString(), accel + 1);
if (bCurrentConfig && sCurrentConfig.equals(sName)) { if (bCurrentConfig && sCurrentConfig.equals(sName)) {
action.setChecked(true); action.setChecked(true);
} }
ActionContributionItem item = new ActionContributionItem(action); ActionContributionItem item = new ActionContributionItem(action);
item.fill(menu, -1); item.fill(menu, -1);
accel++; accel++;
} }
} }
} }
/** /**
* selectionChanged() event handler. Fills the list of managed-built projects * selectionChanged() event handler. Fills the list of managed-built projects
* based on the selection. If some non-managed-built projects are selected, * based on the selection. If some non-managed-built projects are selected,
* disables the action. * disables the action.
* @param action The action * @param action The action
* @param selection The selection * @param selection The selection
*/ */
protected void onSelectionChanged(IAction action, ISelection selection) { protected void onSelectionChanged(IAction action, ISelection selection) {
fProjects.clear(); fProjects.clear();
if (!action.isEnabled()) { if (!action.isEnabled()) {
return; return;
} }
boolean found = false; boolean found = false;
if (selection != null && selection instanceof IStructuredSelection) { if (selection != null && selection instanceof IStructuredSelection) {
Iterator iter = ((IStructuredSelection)selection).iterator(); Iterator iter = ((IStructuredSelection)selection).iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Object selItem = iter.next(); Object selItem = iter.next();
IProject project = null; IProject project = null;
if (selItem instanceof ICElement) { if (selItem instanceof ICElement) {
ICProject cproject = ((ICElement)selItem).getCProject(); ICProject cproject = ((ICElement)selItem).getCProject();
if (cproject != null) { if (cproject != null) {
project = cproject.getProject(); project = cproject.getProject();
} }
} }
else if (selItem instanceof IResource) { else if (selItem instanceof IResource) {
project = ((IResource)selItem).getProject(); project = ((IResource)selItem).getProject();
} }
if (project != null) { if (project != null) {
try { try {
if (project != null && !project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) { if (project != null && !project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
project = null; project = null;
} }
} }
catch (CoreException xE) { catch (CoreException xE) {
// do nothing // do nothing
} }
} }
if (project != null) { if (project != null) {
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
if (info != null && info.isValid()) { if (info != null && info.isValid()) {
fProjects.add(project); fProjects.add(project);
} }
} else { } else {
found = true; found = true;
break; break;
} }
} }
} }
boolean enable = false; boolean enable = false;
if (!found && !fProjects.isEmpty()) { if (!found && !fProjects.isEmpty()) {
Iterator iter = fProjects.iterator(); Iterator iter = fProjects.iterator();
IProject first = (IProject)iter.next(); IProject first = (IProject)iter.next();
IConfiguration[] firstConfigs = ManagedBuildManager.getBuildInfo(first).getManagedProject().getConfigurations(); IConfiguration[] firstConfigs = ManagedBuildManager.getBuildInfo(first).getManagedProject().getConfigurations();
for (int i = 0; i < firstConfigs.length; i++) for (int i = 0; i < firstConfigs.length; i++)
{ {
boolean common = true; boolean common = true;
iter = fProjects.iterator(); iter = fProjects.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
IProject current = (IProject)iter.next(); IProject current = (IProject)iter.next();
IConfiguration[] currentConfigs = ManagedBuildManager.getBuildInfo(current).getManagedProject().getConfigurations(); IConfiguration[] currentConfigs = ManagedBuildManager.getBuildInfo(current).getManagedProject().getConfigurations();
int j = 0; int j = 0;
for (; j < currentConfigs.length; j++) { for (; j < currentConfigs.length; j++) {
if (firstConfigs[i].getName().equals(currentConfigs[j].getName())) { if (firstConfigs[i].getName().equals(currentConfigs[j].getName())) {
break; break;
} }
} }
if (j == currentConfigs.length) { if (j == currentConfigs.length) {
common = false; common = false;
break; break;
} }
} }
if (common) { if (common) {
enable = true; enable = true;
break; break;
} }
} }
} }
action.setEnabled(enable); action.setEnabled(enable);
} }
} }