From a1a02bed3ccafb744d01ce24a9e9216a51023ddf Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 11 Feb 2006 01:57:34 +0000 Subject: [PATCH] New feature: Now jam defines a variable JAM_TARGETS, which contains the targets given on the command line (respectively "all", if none has been given). The contents of the variable can be changed from within the Jamrules/Jamfiles. The targets that are in JAM_TARGETS after Jamfile parsing is done, are those that will be built (and their dependencies, of course). This allows for interesting build system features. git-svn-id: file:///srv/svn/repos/haiku/buildtools/trunk@16345 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- jam/Jamfile | 6 +++++- jam/jam.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/jam/Jamfile b/jam/Jamfile index c5fb0cf586..f6492f85d8 100644 --- a/jam/Jamfile +++ b/jam/Jamfile @@ -52,10 +52,14 @@ if $(OS) = NT { CCFLAGS += /DNT ; } ### LOCAL CHANGE # -# Include header caching. +# Include: +# * header caching +# * jamfile caching +# * definition of JAM_TARGETS variable # DEFINES += OPT_HEADER_CACHE_EXT ; DEFINES += OPT_JAMFILE_CACHE_EXT ; +DEFINES += OPT_JAM_TARGETS_VARIABLE_EXT ; # ### LOCAL CHANGE diff --git a/jam/jam.c b/jam/jam.c index 7a69ccd791..5bf427ce4e 100644 --- a/jam/jam.c +++ b/jam/jam.c @@ -320,6 +320,26 @@ main( int argc, char **argv, char **arg_environ ) var_defines( (const char **)use_environ ); +#ifdef OPT_JAM_TARGETS_VARIABLE_EXT + /* define the variable JAM_TARGETS containing the targets specified on + the command line */ + { + LIST *l = L0; + int i; + char **targets = argv; + int targetCount = argc; + if (targetCount == 0) { + targets = (char**)&all; + targetCount = 1; + } + + for (i = 0; i < targetCount; i++) + l = list_new( l, targets[i], 0 ); + + var_set( "JAM_TARGETS", l, VAR_SET ); + } +#endif + /* Load up variables set on command line. */ for( n = 0; s = getoptval( optv, 's', n ); n++ ) @@ -368,6 +388,35 @@ main( int argc, char **argv, char **arg_environ ) globs.noexec++; } +#ifdef OPT_JAM_TARGETS_VARIABLE_EXT + /* get value of variable JAM_TARGETS and build the targets */ + { + LIST *l = var_get( "JAM_TARGETS" ); + int targetCount = list_length(l); + char **targets; + int i; + + if (targetCount == 0) { + /* No targets. Nothing to do. */ + exit( EXITOK ); + } + + targets = malloc(targetCount * sizeof(char*)); + if (!targets) { + printf( "Memory allocation failed!\n" ); + exit( EXITBAD ); + } + + for (i = 0; i < targetCount; i++) { + targets[i] = (char*)l->string; + l = l->next; + } + + argv = targets; + argc = targetCount; + } +#endif + /* Now make target */ if( !argc )