mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +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();
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -508,4 +517,34 @@ public interface IConfiguration extends IBuildObject {
|
|||
*/
|
||||
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
|
||||
IInputType primaryInputType = tool.getPrimaryInputType();
|
||||
if ((primaryInputType != null && !primaryInputType.getMultipleOfType()) ||
|
||||
(inputType == null && tool != fInfo.getToolFromOutputExtension(fCfg.getArtifactExtension()))){
|
||||
(inputType == null && tool != fCfg.getToolFromOutputExtension(fCfg.getArtifactExtension()))){
|
||||
|
||||
BuildStep action = null;
|
||||
BuildIOType argument = null;
|
||||
|
@ -1423,7 +1423,7 @@ public class BuildDescription implements IBuildDescription {
|
|||
}
|
||||
//TODO
|
||||
} else if (VAR_LIBS.equals(var)){
|
||||
ITool libTool = fCfg.getTargetTool();
|
||||
ITool libTool = fCfg.calculateTargetTool();
|
||||
if(libTool == null)
|
||||
libTool = step.getTool();
|
||||
|
||||
|
@ -1515,7 +1515,7 @@ public class BuildDescription implements IBuildDescription {
|
|||
|
||||
public String[] getUserObjs(BuildStep step) {
|
||||
Vector objs = new Vector();
|
||||
ITool tool = fCfg.getTargetTool();
|
||||
ITool tool = fCfg.calculateTargetTool();
|
||||
if(tool == null)
|
||||
tool = step.getTool();
|
||||
|
||||
|
|
|
@ -1640,30 +1640,50 @@ public class Configuration extends BuildObject implements IConfiguration {
|
|||
public ITool calculateTargetTool(){
|
||||
ITool tool = getTargetTool();
|
||||
|
||||
if(tool == null){
|
||||
tool = getToolFromOutputExtension(getArtifactExtension());
|
||||
}
|
||||
|
||||
if(tool == null){
|
||||
IConfiguration extCfg;
|
||||
for(extCfg = this;
|
||||
extCfg != null && !extCfg.isExtensionElement();
|
||||
extCfg = extCfg.getParent()){
|
||||
|
||||
}
|
||||
|
||||
String ext = extCfg != null ? extCfg.getArtifactExtension() :
|
||||
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;
|
||||
}
|
||||
if(extCfg != null){
|
||||
tool = getToolFromOutputExtension(extCfg.getArtifactExtension());
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -405,7 +405,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
*/
|
||||
public String[] getLibsForConfiguration(String extension) {
|
||||
Vector libs = new Vector();
|
||||
ITool tool = getDefaultConfiguration().getTargetTool();
|
||||
ITool tool = getDefaultConfiguration().calculateTargetTool();
|
||||
if(tool == null)
|
||||
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)
|
||||
*/
|
||||
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;
|
||||
IConfiguration config = getDefaultConfiguration();
|
||||
return config.getToolFromInputExtension(sourceExtension);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFromOutputExtension(java.lang.String)
|
||||
*/
|
||||
public ITool getToolFromOutputExtension(String extension) {
|
||||
// Treat a null argument as an empty string
|
||||
String ext = extension == null ? new 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;
|
||||
IConfiguration config = getDefaultConfiguration();
|
||||
return config.getToolFromOutputExtension(extension);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -766,7 +750,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
*/
|
||||
public String[] getUserObjectsForConfiguration(String extension) {
|
||||
Vector objs = new Vector();
|
||||
ITool tool = getDefaultConfiguration().getTargetTool();
|
||||
ITool tool = getDefaultConfiguration().calculateTargetTool();
|
||||
if(tool == null)
|
||||
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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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$
|
||||
String name = cfg.getArtifactName();
|
||||
ITool targetTool = cfg.getTargetTool();
|
||||
ITool targetTool = cfg.calculateTargetTool();
|
||||
if(targetTool != null){
|
||||
IOutputType pot = targetTool.getPrimaryOutputType();
|
||||
String prefix = pot.getOutputPrefix();
|
||||
|
@ -473,7 +473,7 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
|
|||
macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,name);
|
||||
}
|
||||
else if("BuildArtifactFilePrefix".equals(macroName)){ //$NON-NLS-1$
|
||||
ITool targetTool = cfg.getTargetTool();
|
||||
ITool targetTool = cfg.calculateTargetTool();
|
||||
if(targetTool != null){
|
||||
IOutputType pot = targetTool.getPrimaryOutputType();
|
||||
String prefix = pot.getOutputPrefix();
|
||||
|
|
|
@ -1175,10 +1175,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
String postannouncebuildStep = info.getPostannouncebuildStep();
|
||||
String targets = rebuild ? "clean all" : "all"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
ITool targetTool = config.getTargetTool();
|
||||
if (targetTool == null) {
|
||||
targetTool = info.getToolFromOutputExtension(buildTargetExt);
|
||||
}
|
||||
ITool targetTool = config.calculateTargetTool();
|
||||
// if (targetTool == null) {
|
||||
// targetTool = info.getToolFromOutputExtension(buildTargetExt);
|
||||
// }
|
||||
|
||||
// Get all the projects the build target depends on
|
||||
IProject[] refdProjects = null;
|
||||
|
@ -3687,10 +3687,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
int[] doneState = new int[buildTools.length];
|
||||
|
||||
// Identify the target tool
|
||||
ITool targetTool = config.getTargetTool();
|
||||
if (targetTool == null) {
|
||||
targetTool = info.getToolFromOutputExtension(buildTargetExt);
|
||||
}
|
||||
ITool targetTool = config.calculateTargetTool();
|
||||
// if (targetTool == null) {
|
||||
// targetTool = info.getToolFromOutputExtension(buildTargetExt);
|
||||
// }
|
||||
|
||||
// Initialize the tool info array and the done state
|
||||
for (int i=0; i<buildTools.length; i++) {
|
||||
|
|
Loading…
Add table
Reference in a new issue