diff options
Diffstat (limited to 'tools/build/v2/engine/jam.c')
-rw-r--r-- | tools/build/v2/engine/jam.c | 182 |
1 files changed, 106 insertions, 76 deletions
diff --git a/tools/build/v2/engine/jam.c b/tools/build/v2/engine/jam.c index e11d082bca..09faf85225 100644 --- a/tools/build/v2/engine/jam.c +++ b/tools/build/v2/engine/jam.c @@ -54,18 +54,18 @@ * are layered thus: * * variable|expand - * / | | | - * / | | | - * / | | | - * lists | | pathsys - * \ | | - * \ | | - * \ | | - * newstr | + * / | | + * / | | + * / | | + * lists | pathsys + * \ | + * \ hash + * \ | + * \ | * \ | * \ | * \ | - * hash + * object * * Roughly, the modules are: * @@ -73,8 +73,6 @@ * command.c - maintain lists of commands * compile.c - compile parsed jam statements * execunix.c - execute a shell script on UNIX - * execvms.c - execute a shell script, ala VMS - * expand.c - expand a buffer, given variable values * file*.c - scan directories and archives on * * hash.c - simple in-memory hashing routines * hdrmacro.c - handle header file parsing for filename macro definitions @@ -84,7 +82,7 @@ * lists.c - maintain lists of strings * make.c - bring a target up to date, once rules are in place * make1.c - execute command to bring targets up to date - * newstr.c - string manipulation routines + * object.c - string manipulation routines * option.c - command line option processing * parse.c - make and destroy parse trees as driven by the parser * path*.c - manipulate file names on * @@ -115,14 +113,20 @@ #include "compile.h" #include "builtins.h" #include "rules.h" -#include "newstr.h" +#include "object.h" #include "scan.h" #include "timestamp.h" #include "make.h" #include "strings.h" -#include "expand.h" #include "filesys.h" #include "output.h" +#include "search.h" +#include "class.h" +#include "execcmd.h" +#include "constants.h" +#include "function.h" +#include "pwd.h" +#include "hcache.h" /* Macintosh is "special" */ #ifdef OS_MAC @@ -196,7 +200,6 @@ static void run_unit_tests() execnt_unit_test(); #endif string_unit_test(); - var_expand_unit_test(); } #endif @@ -211,7 +214,9 @@ int anyhow = 0; extern PyObject * bjam_caller ( PyObject * self, PyObject * args ); #endif -char *saved_argv0; +void regex_done(); + +const char *saved_argv0; int main( int argc, char * * argv, char * * arg_environ ) { @@ -223,6 +228,7 @@ int main( int argc, char * * argv, char * * arg_environ ) int arg_c = argc; char * * arg_v = argv; char const * progname = argv[0]; + module_t * environ_module; saved_argv0 = argv[0]; @@ -338,6 +344,8 @@ int main( int argc, char * * argv, char * * arg_environ ) globs.debug[i--] = 1; } + constants_init(); + { PROFILE_ENTER( MAIN ); @@ -377,14 +385,14 @@ int main( int argc, char * * argv, char * * arg_environ ) #endif /* Set JAMDATE. */ - var_set( "JAMDATE", list_new( L0, outf_time(time(0)) ), VAR_SET ); + var_set( root_module(), constant_JAMDATE, list_new( outf_time(time(0)) ), VAR_SET ); /* Set JAM_VERSION. */ - var_set( "JAM_VERSION", - list_new( list_new( list_new( L0, - newstr( VERSION_MAJOR_SYM ) ), - newstr( VERSION_MINOR_SYM ) ), - newstr( VERSION_PATCH_SYM ) ), + var_set( root_module(), constant_JAM_VERSION, + list_push_back( list_push_back( list_new( + object_new( VERSION_MAJOR_SYM ) ), + object_new( VERSION_MINOR_SYM ) ), + object_new( VERSION_PATCH_SYM ) ), VAR_SET ); /* Set JAMUNAME. */ @@ -394,17 +402,17 @@ int main( int argc, char * * argv, char * * arg_environ ) if ( uname( &u ) >= 0 ) { - var_set( "JAMUNAME", - list_new( - list_new( - list_new( - list_new( - list_new( L0, - newstr( u.sysname ) ), - newstr( u.nodename ) ), - newstr( u.release ) ), - newstr( u.version ) ), - newstr( u.machine ) ), VAR_SET ); + var_set( root_module(), constant_JAMUNAME, + list_push_back( + list_push_back( + list_push_back( + list_push_back( + list_new( + object_new( u.sysname ) ), + object_new( u.nodename ) ), + object_new( u.release ) ), + object_new( u.version ) ), + object_new( u.machine ) ), VAR_SET ); } } #endif /* unix */ @@ -414,19 +422,18 @@ int main( int argc, char * * argv, char * * arg_environ ) /* First into the global module, with splitting, for backward * compatibility. */ - var_defines( use_environ, 1 ); + var_defines( root_module(), use_environ, 1 ); + environ_module = bindmodule( constant_ENVIRON ); /* Then into .ENVIRON, without splitting. */ - enter_module( bindmodule(".ENVIRON") ); - var_defines( use_environ, 0 ); - exit_module( bindmodule(".ENVIRON") ); + var_defines( environ_module, use_environ, 0 ); /* * Jam defined variables OS & OSPLAT. We load them after environment, so * that setting OS in environment does not change Jam's notion of the * current platform. */ - var_defines( othersyms, 1 ); + var_defines( root_module(), othersyms, 1 ); /* Load up variables set on command line. */ for ( n = 0; ( s = getoptval( optv, 's', n ) ); ++n ) @@ -434,16 +441,16 @@ int main( int argc, char * * argv, char * * arg_environ ) char *symv[2]; symv[ 0 ] = s; symv[ 1 ] = 0; - var_defines( symv, 1 ); - enter_module( bindmodule(".ENVIRON") ); - var_defines( symv, 0 ); - exit_module( bindmodule(".ENVIRON") ); + var_defines( root_module(), symv, 1 ); + var_defines( environ_module, symv, 0 ); } /* Set the ARGV to reflect the complete list of arguments of invocation. */ for ( n = 0; n < arg_c; ++n ) - var_set( "ARGV", list_new( L0, newstr( arg_v[n] ) ), VAR_APPEND ); + { + var_set( root_module(), constant_ARGV, list_new( object_new( arg_v[n] ) ), VAR_APPEND ); + } /* Initialize built-in rules. */ load_builtins(); @@ -459,29 +466,43 @@ int main( int argc, char * * argv, char * * arg_environ ) } else { - mark_target_for_updating( arg_v[ n ] ); + OBJECT * target = object_new( arg_v[ n ] ); + mark_target_for_updating( target ); + object_free( target ); } } - if (!targets_to_update()) - mark_target_for_updating("all"); + if ( list_empty( targets_to_update() ) ) + { + mark_target_for_updating( constant_all ); + } /* Parse ruleset. */ { FRAME frame[ 1 ]; frame_init( frame ); for ( n = 0; ( s = getoptval( optv, 'f', n ) ); ++n ) - parse_file( s, frame ); + { + OBJECT * filename = object_new( s ); + parse_file( filename, frame ); + object_free( filename ); + } if ( !n ) - parse_file( "+", frame ); + { + parse_file( constant_plus, frame ); + } } status = yyanyerrors(); /* Manually touch -t targets. */ for ( n = 0; ( s = getoptval( optv, 't', n ) ); ++n ) - touch_target( s ); + { + OBJECT * target = object_new( s ); + touch_target( target ); + object_free( target ); + } /* If an output file is specified, set globs.cmdout to that. */ if ( ( s = getoptval( optv, 'o', 0 ) ) ) @@ -498,13 +519,13 @@ int main( int argc, char * * argv, char * * arg_environ ) options. */ { LIST *p = L0; - p = var_get ("PARALLELISM"); - if (p) + p = var_get ( root_module(), constant_PARALLELISM ); + if ( !list_empty( p ) ) { - int j = atoi (p->string); - if (j == -1) + int j = atoi( object_str( list_front( p ) ) ); + if ( j == -1 ) { - printf( "Invalid value of PARALLELISM: %s\n", p->string); + printf( "Invalid value of PARALLELISM: %s\n", object_str( list_front( p ) ) ); } else { @@ -516,11 +537,11 @@ int main( int argc, char * * argv, char * * arg_environ ) /* KEEP_GOING overrides -q option. */ { LIST *p = L0; - p = var_get ("KEEP_GOING"); - if (p) + p = var_get( root_module(), constant_KEEP_GOING ); + if ( !list_empty( p ) ) { - int v = atoi (p->string); - if (v == 0) + int v = atoi( object_str( list_front( p ) ) ); + if ( v == 0 ) globs.quitquick = 1; else globs.quitquick = 0; @@ -532,16 +553,9 @@ int main( int argc, char * * argv, char * * arg_environ ) PROFILE_ENTER( MAIN_MAKE ); LIST * targets = targets_to_update(); - if (targets) + if ( !list_empty( targets ) ) { - int targets_count = list_length( targets ); - const char * * targets2 = (const char * *) - BJAM_MALLOC( targets_count * sizeof( char * ) ); - int n = 0; - for ( ; targets; targets = list_next( targets ) ) - targets2[ n++ ] = targets->string; - status |= make( targets_count, targets2, anyhow ); - free( targets ); + status |= make( targets, anyhow ); } else { @@ -557,12 +571,28 @@ int main( int argc, char * * argv, char * * arg_environ ) if ( DEBUG_PROFILE ) profile_dump(); + +#ifdef OPT_HEADER_CACHE_EXT + hcache_done(); +#endif + + clear_targets_to_update(); + /* Widely scattered cleanup. */ - var_done(); file_done(); rules_done(); stamps_done(); - str_done(); + search_done(); + class_done(); + modules_done(); + regex_done(); + exec_done(); + pwd_done(); + path_done(); + function_done(); + list_done(); + constants_done(); + object_done(); /* Close cmdout. */ if ( globs.cmdout ) @@ -579,7 +609,7 @@ int main( int argc, char * * argv, char * * arg_environ ) #if defined(_WIN32) #include <windows.h> -char *executable_path(char *argv0) { +char *executable_path(const char *argv0) { char buf[1024]; DWORD ret = GetModuleFileName(NULL, buf, sizeof(buf)); if (ret == 0 || ret == sizeof(buf)) return NULL; @@ -587,7 +617,7 @@ char *executable_path(char *argv0) { } #elif defined(__APPLE__) /* Not tested */ #include <mach-o/dyld.h> -char *executable_path(char *argv0) { +char *executable_path(const char *argv0) { char buf[1024]; uint32_t size = sizeof(buf); int ret = _NSGetExecutablePath(buf, &size); @@ -597,12 +627,12 @@ char *executable_path(char *argv0) { #elif defined(sun) || defined(__sun) /* Not tested */ #include <stdlib.h> -char *executable_path(char *argv0) { +char *executable_path(const char *argv0) { return strdup(getexecname()); } #elif defined(__FreeBSD__) #include <sys/sysctl.h> -char *executable_path(char *argv0) { +char *executable_path(const char *argv0) { int mib[4]; mib[0] = CTL_KERN; mib[1] = KERN_PROC; @@ -616,16 +646,16 @@ char *executable_path(char *argv0) { } #elif defined(__linux__) #include <unistd.h> -char *executable_path(char *argv0) { +char *executable_path(const char *argv0) { char buf[1024]; ssize_t ret = readlink("/proc/self/exe", buf, sizeof(buf)); if (ret == 0 || ret == sizeof(buf)) return NULL; return strndup(buf, ret); } #else -char *executable_path(char *argv0) { +char *executable_path(const char *argv0) { /* If argv0 is absolute path, assume it's the right absolute path. */ - if (argv0[0] == "/") + if (argv0[0] == '/') return strdup(argv0); return NULL; } |