New handy build system feature: It is now possible to pass a command

line to jam that contains build targets and that will be executed by
the build system after building the targets and replacing their
occurrences in the command line by their paths. The keyword indicating
such a command line is "run", targets are marked by a leading ":".
E.g.:

  jam -q run ':<build>xres' -l :libtracker.so

This builds the xres tool for the host platform and libtracker.so for
Haiku, and afterwards lists the resources libtracker.so contains. Note,
that this feature requires using Haiku's jam version.

The functionality is implemented by the new RunCommandLine rule, which
can, of course, also be used in the UserBuildConfig.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20598 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2007-04-06 03:14:58 +00:00
parent f51c147043
commit 2c24a1a9f6
2 changed files with 73 additions and 6 deletions
+15 -6
View File
@@ -11,13 +11,22 @@
# directory paths and the like.
# If the target to be built is "all" (i.e. the default) and we're in the output
# directory, the root directory of the build system, or in "src/", we change the
# target to be built to "haiku-image".
# analyze an optionally replace jam's target parameters
HAIKU_ORIGINAL_JAM_TARGETS = $(JAM_TARGETS) ;
if $(JAM_TARGETS) = all {
if ! $(INVOCATION_SUBDIR) || $(INVOCATION_SUBDIR) = src {
JAM_TARGETS = haiku-image ;
if $(JAM_TARGETS) {
# If the target to be built is "all" (i.e. the default) and we're in the
# output directory, the root directory of the build system, or in "src/", we
# change the target to be built to "haiku-image".
if $(JAM_TARGETS) = all {
if ! $(INVOCATION_SUBDIR) || $(INVOCATION_SUBDIR) = src {
JAM_TARGETS = haiku-image ;
}
# The "run" target allows for running arbitrary command lines containing
# build system targets, which are built and replaced accordingly.
} else if $(JAM_TARGETS[1]) = run && $(JAM_TARGETS[2]) {
local run = [ RunCommandLine $(JAM_TARGETS[2-]) ] ;
JAM_TARGETS = $(run) ;
}
}
+58
View File
@@ -159,3 +159,61 @@ rule NewUniqueTarget basename
local id = [ NextID ] ;
return $(basename[1]:E=_target:G=unique!target)_$(id) ;
}
# pragma mark - RunCommandLine
rule RunCommandLine commandLine
{
# RunCommandLine <commandLine>
#
# Creates a pseudo target that, when made by jam, causes the supplied shell
# command line to be executed. Elements of <commandLine> with the prefix ":"
# are replaced by the rule. After stripping the prefix such a string specifies
# a build system target and the finally executed command line will contain
# a path to the target instead.
# The pseudo target will depend on all targets thus identified. Each
# invocation of this rule creates a different pseudo target, which is
# returned to the caller.
# collect the targets in the command line and replace them by $targetX*
# variables
local substitutedCommandLine ;
local targets ;
local targetVarName = target ;
local i ;
for i in $(commandLine) {
# targets are marked by the ":" prefix
local target = [ Match :(.*) : $(i) ] ;
if $(target) {
targets += $(target) ;
targetVarName = $(targetVarName)X ;
i = "$"$(targetVarName) ;
}
substitutedCommandLine += $(i) ;
}
# define the "run" target
local run = [ NewUniqueTarget run ] ;
COMMAND_LINE on $(run) = $(substitutedCommandLine) ;
NotFile $(run) ;
Always $(run) ;
Depends $(run) : $(targets) ;
RunCommandLine1 $(run) : $(targets) ;
return $(run) ;
}
actions RunCommandLine1 {
target=target;
for t in $(2) ; do
target+=X
eval "${target}=${t}"
done
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
$(COMMAND_LINE)
}