1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 571381: Generate BUILD_ARTIFACT* symbols in makefile

The symbols generated are:
* BUILD_ARTIFACT_NAME
  Value of "Artifact name" field defined in the build configuration
* BUILD_ARTIFACT_EXTENSION
  Value of "Artifact extension" field defined in the build configuration
* BUILD_ARTIFACT_PREFIX
  Value of "Output prefix" field defined in the build configuration
* BUILD_ARTIFACT
  Assembly of the other values to build the target file name

The above symbols make it easier to extend the generated makefile using
the provided makefile hooks "makefile.init", "makefile.defs" and
"makefile.targets". There is no longer need to duplicate the name of
the target artifact in the hooks files.
The hooks can for example be used when the post-build step is not
flexible enough. By placing the post-build step in makefile.targets,
when done properly, will let the user have full control over the
sequence, including parallelism, for the required steps.

Contributed by STMicroelectronics

Change-Id: I163917837b65cb397eb5943c4357a54e9576cf42
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
This commit is contained in:
Torbjörn SVENSSON 2021-02-19 18:10:38 +01:00 committed by Torbjörn Svensson
parent 73491800ac
commit 07d8edaf28
33 changed files with 215 additions and 0 deletions

View file

@ -21,6 +21,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := test1DepCalc2
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -21,6 +21,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := test1DepCalc3
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -21,6 +21,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := test1DepCalcPreBuild
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -34,6 +34,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := test12
BUILD_ARTIFACT_EXTENSION := exe
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -34,6 +34,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := test20
BUILD_ARTIFACT_EXTENSION := exe
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -20,6 +20,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := MBS2dot1
BUILD_ARTIFACT_EXTENSION := exe
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -35,6 +35,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := Test21CXX
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -19,6 +19,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := linkedFolder
BUILD_ARTIFACT_EXTENSION := a
BUILD_ARTIFACT_PREFIX := lib
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -19,6 +19,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := linkedLib
BUILD_ARTIFACT_EXTENSION := a
BUILD_ARTIFACT_PREFIX := lib
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -34,6 +34,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := testResCfg
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -19,6 +19,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := testSingleExe
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -31,6 +31,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := testDoubleSO
BUILD_ARTIFACT_EXTENSION := so
BUILD_ARTIFACT_PREFIX := lib
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -13,6 +13,11 @@ RM := rm -rf
-include ../makefile.defs
BUILD_ARTIFACT_NAME := CDTFortranTest1
BUILD_ARTIFACT_EXTENSION := exe
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -15,6 +15,11 @@ RM := rm -rf
-include ../makefile.defs
BUILD_ARTIFACT_NAME := CDTFortranTest2
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -13,6 +13,11 @@ RM := rm -rf
-include ../makefile.defs
BUILD_ARTIFACT_NAME := TestATO
BUILD_ARTIFACT_EXTENSION := out
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -20,6 +20,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := TestCopyandDeploy
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
EXECUTABLES += \
USER_OBJS.foo \

View file

@ -31,6 +31,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := DeleteFile
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -19,6 +19,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := inputTypeOption
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -19,6 +19,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := linkedFolder
BUILD_ARTIFACT_EXTENSION := a
BUILD_ARTIFACT_PREFIX := lib
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -19,6 +19,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := linkedLib
BUILD_ARTIFACT_EXTENSION := a
BUILD_ARTIFACT_PREFIX := lib
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -34,6 +34,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := multiResConfig
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -31,6 +31,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := preAndPostBuildSteps
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -19,6 +19,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := rcbsBasicTest
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -19,6 +19,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := singleFileExe
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -20,6 +20,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := testwithspaces
BUILD_ARTIFACT_EXTENSION := a
BUILD_ARTIFACT_PREFIX := lib
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -19,6 +19,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := Test30_1
BUILD_ARTIFACT_EXTENSION := so.4.5.6
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
TEST30_1_GNU_SO_DEPLOY_OUTPUT_OUTPUTS += \
default.so.4.5.6 \

View file

@ -14,6 +14,11 @@ RM := rm -rf
-include ../makefile.defs
BUILD_ARTIFACT_NAME := test30_2
BUILD_ARTIFACT_EXTENSION := tmp
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
TAROUT += \
new.tar \

View file

@ -19,6 +19,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := test
BUILD_ARTIFACT_EXTENSION := exe
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -13,6 +13,11 @@ RM := rm
-include ../makefile.defs
BUILD_ARTIFACT_NAME := testMacroSupportInBuildDefinitions
BUILD_ARTIFACT_EXTENSION := tar
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -19,6 +19,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := twoFileSO
BUILD_ARTIFACT_EXTENSION := SOS
BUILD_ARTIFACT_PREFIX := lib
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -42,6 +42,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := test_40
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -42,6 +42,11 @@ endif
-include ../makefile.defs
BUILD_ARTIFACT_NAME := test_40
BUILD_ARTIFACT_EXTENSION :=
BUILD_ARTIFACT_PREFIX :=
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target

View file

@ -1263,6 +1263,61 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Include makefile.defs supplemental makefile
buffer.append("-include ").append(reachProjectRoot()).append(SEPARATOR).append(MAKEFILE_DEFS).append(NEWLINE); //$NON-NLS-1$
String ext = config.getArtifactExtension();
// try to resolve the build macros in the artifact extension
try {
ext = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(ext, EMPTY_STRING,
WHITESPACE, IBuildMacroProvider.CONTEXT_CONFIGURATION, config);
} catch (BuildMacroException e) {
}
String name = config.getArtifactName();
// try to resolve the build macros in the artifact name
try {
String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(name,
EMPTY_STRING, WHITESPACE, IBuildMacroProvider.CONTEXT_CONFIGURATION, config);
if ((resolved = resolved.trim()).length() > 0) {
name = resolved;
}
} catch (BuildMacroException e) {
}
String prefix = EMPTY_STRING;
ITool targetTool = config.calculateTargetTool();
if (targetTool != null) {
prefix = targetTool.getOutputPrefix();
if (prefix == null) {
prefix = EMPTY_STRING;
}
}
// try to resolve the build macros in the artifact prefix
try {
String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(prefix,
EMPTY_STRING, WHITESPACE, IBuildMacroProvider.CONTEXT_CONFIGURATION, config);
if ((resolved = resolved.trim()).length() > 0) {
prefix = resolved;
}
} catch (BuildMacroException e) {
}
@SuppressWarnings("nls")
String[][] buildArtifactVars = new String[][] { //
{ "BUILD_ARTIFACT_NAME", name }, //
{ "BUILD_ARTIFACT_EXTENSION", ext }, //
{ "BUILD_ARTIFACT_PREFIX", prefix }, //
{ "BUILD_ARTIFACT",
"$(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)" }, //
};
buffer.append(NEWLINE);
for (String[] var : buildArtifactVars) {
buffer.append(var[0]).append(" :="); //$NON-NLS-1$
if (!var[1].isEmpty()) {
buffer.append(WHITESPACE).append(var[1]);
}
buffer.append(NEWLINE);
}
return (buffer.append(NEWLINE));
}