mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +02:00
target tool calculation now works when the targetTool is not specified with the tool-chain
This commit is contained in:
parent
f9fa5b5f7f
commit
c39dabe4c2
6 changed files with 92 additions and 49 deletions
|
@ -259,7 +259,16 @@ public interface IConfiguration extends IBuildObject {
|
||||||
public ITool[] getTools();
|
public ITool[] getTools();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the tool in this configuration that creates the build artifact.
|
* Returns the tool in this configuration specified with
|
||||||
|
* the toolChain#targetTool attribute that creates the build artifact
|
||||||
|
*
|
||||||
|
* NOTE: This method returns null in case the toolChain definition
|
||||||
|
* does not have the targetTool attribute or if the attribute does not
|
||||||
|
* refer to the appropriate tool.
|
||||||
|
* For the target tool calculation the IConfiguration#calculateTargetTool()
|
||||||
|
* method should be used
|
||||||
|
*
|
||||||
|
* @see IConfiguration#calculateTargetTool()
|
||||||
*
|
*
|
||||||
* @return ITool
|
* @return ITool
|
||||||
*/
|
*/
|
||||||
|
@ -508,4 +517,34 @@ public interface IConfiguration extends IBuildObject {
|
||||||
*/
|
*/
|
||||||
public boolean needsFullRebuild();
|
public boolean needsFullRebuild();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the configuration target tool.
|
||||||
|
*
|
||||||
|
* @return ITool or null if not found
|
||||||
|
*
|
||||||
|
* @since 3.1
|
||||||
|
*/
|
||||||
|
public ITool calculateTargetTool();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a <code>ITool</code> for the tool associated with the
|
||||||
|
* output extension.
|
||||||
|
*
|
||||||
|
* @param extension the file extension of the output file
|
||||||
|
* @return ITool
|
||||||
|
*
|
||||||
|
* @since 3.1
|
||||||
|
*/
|
||||||
|
public ITool getToolFromOutputExtension(String extension);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a <code>ITool</code> for the tool associated with the
|
||||||
|
* input extension.
|
||||||
|
*
|
||||||
|
* @param extension the file extension of the input file
|
||||||
|
* @return ITool
|
||||||
|
*
|
||||||
|
* @since 3.1
|
||||||
|
*/
|
||||||
|
public ITool getToolFromInputExtension(String sourceExtension);
|
||||||
}
|
}
|
||||||
|
|
|
@ -566,7 +566,7 @@ public class BuildDescription implements IBuildDescription {
|
||||||
// Generate the step to build this source file
|
// Generate the step to build this source file
|
||||||
IInputType primaryInputType = tool.getPrimaryInputType();
|
IInputType primaryInputType = tool.getPrimaryInputType();
|
||||||
if ((primaryInputType != null && !primaryInputType.getMultipleOfType()) ||
|
if ((primaryInputType != null && !primaryInputType.getMultipleOfType()) ||
|
||||||
(inputType == null && tool != fInfo.getToolFromOutputExtension(fCfg.getArtifactExtension()))){
|
(inputType == null && tool != fCfg.getToolFromOutputExtension(fCfg.getArtifactExtension()))){
|
||||||
|
|
||||||
BuildStep action = null;
|
BuildStep action = null;
|
||||||
BuildIOType argument = null;
|
BuildIOType argument = null;
|
||||||
|
@ -1423,7 +1423,7 @@ public class BuildDescription implements IBuildDescription {
|
||||||
}
|
}
|
||||||
//TODO
|
//TODO
|
||||||
} else if (VAR_LIBS.equals(var)){
|
} else if (VAR_LIBS.equals(var)){
|
||||||
ITool libTool = fCfg.getTargetTool();
|
ITool libTool = fCfg.calculateTargetTool();
|
||||||
if(libTool == null)
|
if(libTool == null)
|
||||||
libTool = step.getTool();
|
libTool = step.getTool();
|
||||||
|
|
||||||
|
@ -1515,7 +1515,7 @@ public class BuildDescription implements IBuildDescription {
|
||||||
|
|
||||||
public String[] getUserObjs(BuildStep step) {
|
public String[] getUserObjs(BuildStep step) {
|
||||||
Vector objs = new Vector();
|
Vector objs = new Vector();
|
||||||
ITool tool = fCfg.getTargetTool();
|
ITool tool = fCfg.calculateTargetTool();
|
||||||
if(tool == null)
|
if(tool == null)
|
||||||
tool = step.getTool();
|
tool = step.getTool();
|
||||||
|
|
||||||
|
|
|
@ -1640,30 +1640,50 @@ public class Configuration extends BuildObject implements IConfiguration {
|
||||||
public ITool calculateTargetTool(){
|
public ITool calculateTargetTool(){
|
||||||
ITool tool = getTargetTool();
|
ITool tool = getTargetTool();
|
||||||
|
|
||||||
|
if(tool == null){
|
||||||
|
tool = getToolFromOutputExtension(getArtifactExtension());
|
||||||
|
}
|
||||||
|
|
||||||
if(tool == null){
|
if(tool == null){
|
||||||
IConfiguration extCfg;
|
IConfiguration extCfg;
|
||||||
for(extCfg = this;
|
for(extCfg = this;
|
||||||
extCfg != null && !extCfg.isExtensionElement();
|
extCfg != null && !extCfg.isExtensionElement();
|
||||||
extCfg = extCfg.getParent()){
|
extCfg = extCfg.getParent()){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String ext = extCfg != null ? extCfg.getArtifactExtension() :
|
if(extCfg != null){
|
||||||
getArtifactExtension();
|
tool = getToolFromOutputExtension(extCfg.getArtifactExtension());
|
||||||
|
|
||||||
// Get all the tools for the current config
|
|
||||||
ITool[] tools = getFilteredTools();
|
|
||||||
for (int index = 0; index < tools.length; index++) {
|
|
||||||
ITool t = tools[index];
|
|
||||||
if (t.producesFileType(ext)) {
|
|
||||||
tool = t;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ITool getToolFromOutputExtension(String extension) {
|
||||||
|
// Treat a null argument as an empty string
|
||||||
|
String ext = extension == null ? EMPTY_STRING : extension;
|
||||||
|
// Get all the tools for the current config
|
||||||
|
ITool[] tools = getFilteredTools();
|
||||||
|
for (int index = 0; index < tools.length; index++) {
|
||||||
|
ITool tool = tools[index];
|
||||||
|
if (tool.producesFileType(ext)) {
|
||||||
|
return tool;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITool getToolFromInputExtension(String sourceExtension) {
|
||||||
|
// Get all the tools for the current config
|
||||||
|
ITool[] tools = getFilteredTools();
|
||||||
|
for (int index = 0; index < tools.length; index++) {
|
||||||
|
ITool tool = tools[index];
|
||||||
|
if (tool.buildsFileType(sourceExtension)) {
|
||||||
|
return tool;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The resource delta passed to the builder is not always up-to-date
|
* The resource delta passed to the builder is not always up-to-date
|
||||||
|
|
|
@ -405,7 +405,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
*/
|
*/
|
||||||
public String[] getLibsForConfiguration(String extension) {
|
public String[] getLibsForConfiguration(String extension) {
|
||||||
Vector libs = new Vector();
|
Vector libs = new Vector();
|
||||||
ITool tool = getDefaultConfiguration().getTargetTool();
|
ITool tool = getDefaultConfiguration().calculateTargetTool();
|
||||||
if(tool == null)
|
if(tool == null)
|
||||||
tool = getToolFromOutputExtension(extension);
|
tool = getToolFromOutputExtension(extension);
|
||||||
|
|
||||||
|
@ -668,32 +668,16 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFromInputExtension(java.lang.String)
|
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFromInputExtension(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public ITool getToolFromInputExtension(String sourceExtension) {
|
public ITool getToolFromInputExtension(String sourceExtension) {
|
||||||
// Get all the tools for the current config
|
IConfiguration config = getDefaultConfiguration();
|
||||||
ITool[] tools = getFilteredTools();
|
return config.getToolFromInputExtension(sourceExtension);
|
||||||
for (int index = 0; index < tools.length; index++) {
|
|
||||||
ITool tool = tools[index];
|
|
||||||
if (tool.buildsFileType(sourceExtension)) {
|
|
||||||
return tool;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFromOutputExtension(java.lang.String)
|
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFromOutputExtension(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public ITool getToolFromOutputExtension(String extension) {
|
public ITool getToolFromOutputExtension(String extension) {
|
||||||
// Treat a null argument as an empty string
|
IConfiguration config = getDefaultConfiguration();
|
||||||
String ext = extension == null ? new String() : extension;
|
return config.getToolFromOutputExtension(extension);
|
||||||
// Get all the tools for the current config
|
|
||||||
ITool[] tools = getFilteredTools();
|
|
||||||
for (int index = 0; index < tools.length; index++) {
|
|
||||||
ITool tool = tools[index];
|
|
||||||
if (tool.producesFileType(ext)) {
|
|
||||||
return tool;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -766,7 +750,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
*/
|
*/
|
||||||
public String[] getUserObjectsForConfiguration(String extension) {
|
public String[] getUserObjectsForConfiguration(String extension) {
|
||||||
Vector objs = new Vector();
|
Vector objs = new Vector();
|
||||||
ITool tool = getDefaultConfiguration().getTargetTool();
|
ITool tool = getDefaultConfiguration().calculateTargetTool();
|
||||||
if(tool == null)
|
if(tool == null)
|
||||||
tool = getToolFromOutputExtension(extension);
|
tool = getToolFromOutputExtension(extension);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005 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
|
||||||
|
@ -412,7 +412,7 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
|
||||||
}
|
}
|
||||||
else if("BuildArtifactFileBaseName".equals(macroName)){ //$NON-NLS-1$
|
else if("BuildArtifactFileBaseName".equals(macroName)){ //$NON-NLS-1$
|
||||||
String name = cfg.getArtifactName();
|
String name = cfg.getArtifactName();
|
||||||
ITool targetTool = cfg.getTargetTool();
|
ITool targetTool = cfg.calculateTargetTool();
|
||||||
if(targetTool != null){
|
if(targetTool != null){
|
||||||
IOutputType pot = targetTool.getPrimaryOutputType();
|
IOutputType pot = targetTool.getPrimaryOutputType();
|
||||||
String prefix = pot.getOutputPrefix();
|
String prefix = pot.getOutputPrefix();
|
||||||
|
@ -473,7 +473,7 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
|
||||||
macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,name);
|
macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,name);
|
||||||
}
|
}
|
||||||
else if("BuildArtifactFilePrefix".equals(macroName)){ //$NON-NLS-1$
|
else if("BuildArtifactFilePrefix".equals(macroName)){ //$NON-NLS-1$
|
||||||
ITool targetTool = cfg.getTargetTool();
|
ITool targetTool = cfg.calculateTargetTool();
|
||||||
if(targetTool != null){
|
if(targetTool != null){
|
||||||
IOutputType pot = targetTool.getPrimaryOutputType();
|
IOutputType pot = targetTool.getPrimaryOutputType();
|
||||||
String prefix = pot.getOutputPrefix();
|
String prefix = pot.getOutputPrefix();
|
||||||
|
|
|
@ -1175,10 +1175,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
||||||
String postannouncebuildStep = info.getPostannouncebuildStep();
|
String postannouncebuildStep = info.getPostannouncebuildStep();
|
||||||
String targets = rebuild ? "clean all" : "all"; //$NON-NLS-1$ //$NON-NLS-2$
|
String targets = rebuild ? "clean all" : "all"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
ITool targetTool = config.getTargetTool();
|
ITool targetTool = config.calculateTargetTool();
|
||||||
if (targetTool == null) {
|
// if (targetTool == null) {
|
||||||
targetTool = info.getToolFromOutputExtension(buildTargetExt);
|
// targetTool = info.getToolFromOutputExtension(buildTargetExt);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Get all the projects the build target depends on
|
// Get all the projects the build target depends on
|
||||||
IProject[] refdProjects = null;
|
IProject[] refdProjects = null;
|
||||||
|
@ -3687,10 +3687,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
||||||
int[] doneState = new int[buildTools.length];
|
int[] doneState = new int[buildTools.length];
|
||||||
|
|
||||||
// Identify the target tool
|
// Identify the target tool
|
||||||
ITool targetTool = config.getTargetTool();
|
ITool targetTool = config.calculateTargetTool();
|
||||||
if (targetTool == null) {
|
// if (targetTool == null) {
|
||||||
targetTool = info.getToolFromOutputExtension(buildTargetExt);
|
// targetTool = info.getToolFromOutputExtension(buildTargetExt);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Initialize the tool info array and the done state
|
// Initialize the tool info array and the done state
|
||||||
for (int i=0; i<buildTools.length; i++) {
|
for (int i=0; i<buildTools.length; i++) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue