void delete_module( module_t * m ) { /* Clear out all the rules. */ if ( m->rules ) { hashenumerate( m->rules, delete_rule_, (void *)0 ); hashdone( m->rules ); m->rules = 0; } if ( m->native_rules ) { hashenumerate( m->native_rules, delete_native_rule, (void *)0 ); hashdone( m->native_rules ); m->native_rules = 0; } if ( m->variables ) { var_hash_swap( &m->variables ); var_done(); var_hash_swap( &m->variables ); m->variables = 0; } if ( m->imported_modules ) { hashenumerate( m->imported_modules, delete_imported_modules, (void *)0 ); hashdone( m->imported_modules ); m->imported_modules = 0; } }
int main( int argc, char **argv, char **arg_environ ) { int n, num_targets; const char *s; struct option optv[N_OPTS]; char* targets[N_TARGETS]; const char *all = "all"; int anyhow = 0; int status; # ifdef OS_MAC InitGraf(&qd.thePort); # endif argc--, argv++; if( ( num_targets = getoptions( argc, argv, "d:j:f:gs:t:ano:qv", optv, targets ) ) < 0 ) { printf( "\nusage: jam [ options ] targets...\n\n" ); printf( "-a Build all targets, even if they are current.\n" ); printf( "-dx Display (a)actions (c)causes (d)dependencies\n" ); printf( " (m)make tree (x)commands (0-9) debug levels.\n" ); printf( "-fx Read x instead of Jambase.\n" ); printf( "-g Build from newest sources first.\n" ); printf( "-jx Run up to x shell commands concurrently.\n" ); printf( "-n Don't actually execute the updating actions.\n" ); printf( "-ox Write the updating actions to file x.\n" ); printf( "-q Quit quickly as soon as a target fails.\n" ); printf( "-sx=y Set variable x=y, overriding environment.\n" ); printf( "-tx Rebuild x, even if it is up-to-date.\n" ); printf( "-v Print the version of jam and exit.\n\n" ); exit( EXITBAD ); } /* Version info. */ if( ( s = getoptval( optv, 'v', 0 ) ) ) { printf( "FT-Jam %s. %s. ", VERSION, OSMINOR ); printf( "(C) 1993-2003 Christopher Seiwald, see www.freetype.org/jam/\n" ); return EXITOK; } /* Pick up interesting options */ if( ( s = getoptval( optv, 'n', 0 ) ) ) globs.noexec++, DEBUG_MAKE = DEBUG_MAKEQ = DEBUG_EXEC = 1; if( ( s = getoptval( optv, 'q', 0 ) ) ) globs.quitquick = 1; if( ( s = getoptval( optv, 'a', 0 ) ) ) anyhow++; if( ( s = getoptval( optv, 'j', 0 ) ) ) globs.jobs = atoi( s ); if( ( s = getoptval( optv, 'g', 0 ) ) ) globs.newestfirst = 1; /* Turn on/off debugging */ for( n = 0; (s = getoptval( optv, 'd', n )) != 0; n++ ) { int i = atoi( s ); /* First -d, turn off defaults. */ if( !n ) DEBUG_MAKE = DEBUG_MAKEQ = DEBUG_EXEC = 0; /* n turns on levels 1-n */ /* +n turns on level n */ /* c turns on named display c */ if( i < 0 || i >= DEBUG_MAX ) { printf( "Invalid debug level '%s'.\n", s ); } else if( *s == '+' ) { globs.debug[i] = 1; } else if( i ) while( i ) { globs.debug[i--] = 1; } else while( *s ) switch( *s++ ) { case 'a': DEBUG_MAKE = DEBUG_MAKEQ = 1; break; case 'c': DEBUG_CAUSES = 1; break; case 'd': DEBUG_DEPENDS = 1; break; case 'm': DEBUG_MAKEPROG = 1; break; case 'x': DEBUG_EXEC = 1; break; case '0': break; default: printf( "Invalid debug flag '%c'.\n", s[-1] ); } } /* Set JAMDATE first */ { char buf[ 128 ]; time_t clock; time( &clock ); strcpy( buf, ctime( &clock ) ); /* Trim newline from date */ if( strlen( buf ) == 25 ) buf[ 24 ] = 0; var_set( "JAMDATE", list_new( L0, buf, 0 ), VAR_SET ); } /* And JAMUNAME */ # ifdef unix { struct utsname u; if( uname( &u ) >= 0 ) { LIST *l = L0; l = list_new( l, u.machine, 0 ); l = list_new( l, u.version, 0 ); l = list_new( l, u.release, 0 ); l = list_new( l, u.nodename, 0 ); l = list_new( l, u.sysname, 0 ); var_set( "JAMUNAME", l, VAR_SET ); } } # endif /* unix */ /* * Jam defined variables OS, OSPLAT */ var_defines( othersyms ); /* load up environment variables */ var_defines( (const char **)use_environ ); /* Load up variables set on command line. */ for( n = 0; (s = getoptval( optv, 's', n )) != 0; n++ ) { const char *symv[2]; symv[0] = s; symv[1] = 0; var_defines( symv ); } /* Initialize built-in rules */ load_builtins(); /* Parse ruleset */ for( n = 0; (s = getoptval( optv, 'f', n )) != 0; n++ ) parse_file( s ); if( !n ) parse_file( "+" ); status = yyanyerrors(); /* Manually touch -t targets */ for( n = 0; (s = getoptval( optv, 't', n )) != 0; n++ ) touchtarget( s ); /* If an output file is specified, set globs.cmdout to that */ if( (s = getoptval( optv, 'o', 0 )) != 0 ) { if( !( globs.cmdout = fopen( s, "w" ) ) ) { printf( "Failed to write to '%s'\n", s ); exit( EXITBAD ); } globs.noexec++; } /* Add JAMCMDARGS */ { LIST* l = L0; for ( n = 0; n < num_targets; n++ ) l = list_new( l, targets[n], 0 ); var_set( "JAMCMDARGS", l, VAR_SET ); } /* Now make target */ if( !num_targets ) status |= make( 1, &all, anyhow ); else status |= make( num_targets, (const char**)targets, anyhow ); /* Widely scattered cleanup */ var_done(); donerules(); donestamps(); donestr(); /* close cmdout */ if( globs.cmdout ) fclose( globs.cmdout ); return status ? EXITBAD : EXITOK; }
int main( int argc, char * * argv, char * * arg_environ ) { int n; char * s; struct option optv[N_OPTS]; char const * all = "all"; int status; int arg_c = argc; char * * arg_v = argv; char const * progname = argv[0]; saved_argv0 = argv[0]; BJAM_MEM_INIT(); # ifdef OS_MAC InitGraf(&qd.thePort); # endif --argc; ++argv; if ( getoptions( argc, argv, "-:l:d:j:p:f:gs:t:ano:qv", optv ) < 0 ) { printf( "\nusage: %s [ options ] targets...\n\n", progname ); printf( "-a Build all targets, even if they are current.\n" ); printf( "-dx Set the debug level to x (0-9).\n" ); printf( "-fx Read x instead of Jambase.\n" ); /* printf( "-g Build from newest sources first.\n" ); */ printf( "-jx Run up to x shell commands concurrently.\n" ); printf( "-lx Limit actions to x number of seconds after which they are stopped.\n" ); printf( "-n Don't actually execute the updating actions.\n" ); printf( "-ox Write the updating actions to file x.\n" ); printf( "-px x=0, pipes action stdout and stderr merged into action output.\n" ); printf( "-q Quit quickly as soon as a target fails.\n" ); printf( "-sx=y Set variable x=y, overriding environment.\n" ); printf( "-tx Rebuild x, even if it is up-to-date.\n" ); printf( "-v Print the version of jam and exit.\n" ); printf( "--x Option is ignored.\n\n" ); exit( EXITBAD ); } /* Version info. */ if ( ( s = getoptval( optv, 'v', 0 ) ) ) { printf( "Boost.Jam " ); printf( "Version %s. %s.\n", VERSION, OSMINOR ); printf( " Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. \n" ); printf( " Copyright 2001 David Turner.\n" ); printf( " Copyright 2001-2004 David Abrahams.\n" ); printf( " Copyright 2002-2008 Rene Rivera.\n" ); printf( " Copyright 2003-2008 Vladimir Prus.\n" ); return EXITOK; } /* Pick up interesting options. */ if ( ( s = getoptval( optv, 'n', 0 ) ) ) globs.noexec++, globs.debug[2] = 1; if ( ( s = getoptval( optv, 'p', 0 ) ) ) { /* Undocumented -p3 (acts like both -p1 -p2) means separate pipe action * stdout and stderr. */ globs.pipe_action = atoi( s ); if ( ( 3 < globs.pipe_action ) || ( globs.pipe_action < 0 ) ) { printf( "Invalid pipe descriptor '%d', valid values are -p[0..3].\n", globs.pipe_action ); exit( EXITBAD ); } } if ( ( s = getoptval( optv, 'q', 0 ) ) ) globs.quitquick = 1; if ( ( s = getoptval( optv, 'a', 0 ) ) ) anyhow++; if ( ( s = getoptval( optv, 'j', 0 ) ) ) { globs.jobs = atoi( s ); if (globs.jobs == 0) { printf("Invalid value for the '-j' option.\n"); exit(EXITBAD); } } if ( ( s = getoptval( optv, 'g', 0 ) ) ) globs.newestfirst = 1; if ( ( s = getoptval( optv, 'l', 0 ) ) ) globs.timeout = atoi( s ); /* Turn on/off debugging */ for ( n = 0; ( s = getoptval( optv, 'd', n ) ); ++n ) { int i; /* First -d, turn off defaults. */ if ( !n ) for ( i = 0; i < DEBUG_MAX; ++i ) globs.debug[i] = 0; i = atoi( s ); if ( ( i < 0 ) || ( i >= DEBUG_MAX ) ) { printf( "Invalid debug level '%s'.\n", s ); continue; } /* n turns on levels 1-n. */ /* +n turns on level n. */ if ( *s == '+' ) globs.debug[i] = 1; else while ( i ) globs.debug[i--] = 1; } { PROFILE_ENTER( MAIN ); #ifdef HAVE_PYTHON { PROFILE_ENTER( MAIN_PYTHON ); Py_Initialize(); { static PyMethodDef BjamMethods[] = { {"call", bjam_call, METH_VARARGS, "Call the specified bjam rule."}, {"import_rule", bjam_import_rule, METH_VARARGS, "Imports Python callable to bjam."}, {"define_action", bjam_define_action, METH_VARARGS, "Defines a command line action."}, {"variable", bjam_variable, METH_VARARGS, "Obtains a variable from bjam's global module."}, {"backtrace", bjam_backtrace, METH_VARARGS, "Returns bjam backtrace from the last call into Python."}, {"caller", bjam_caller, METH_VARARGS, "Returns the module from which the last call into Python is made."}, {NULL, NULL, 0, NULL} }; Py_InitModule( "bjam", BjamMethods ); } PROFILE_EXIT( MAIN_PYTHON ); } #endif #ifndef NDEBUG run_unit_tests(); #endif #if YYDEBUG != 0 if ( DEBUG_PARSE ) yydebug = 1; #endif /* Set JAMDATE. */ var_set( "JAMDATE", list_new( L0, 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 ); /* Set JAMUNAME. */ #ifdef unix { struct utsname u; 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 ); } } #endif /* unix */ /* Load up environment variables. */ /* First into the global module, with splitting, for backward * compatibility. */ var_defines( use_environ, 1 ); /* Then into .ENVIRON, without splitting. */ enter_module( bindmodule(".ENVIRON") ); var_defines( use_environ, 0 ); exit_module( bindmodule(".ENVIRON") ); /* * 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 ); /* Load up variables set on command line. */ for ( n = 0; ( s = getoptval( optv, 's', n ) ); ++n ) { 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") ); } /* 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 ); /* Initialize built-in rules. */ load_builtins(); /* Add the targets in the command line to the update list. */ for ( n = 1; n < arg_c; ++n ) { if ( arg_v[ n ][ 0 ] == '-' ) { char * f = "-:l:d:j:f:gs:t:ano:qv"; for ( ; *f; ++f ) if ( *f == arg_v[ n ][ 1 ] ) break; if ( ( f[ 1 ] == ':' ) && ( arg_v[ n ][ 2 ] == '\0' ) ) ++n; } else { mark_target_for_updating( arg_v[ n ] ); } } if (!targets_to_update()) mark_target_for_updating("all"); /* Parse ruleset. */ { FRAME frame[ 1 ]; frame_init( frame ); for ( n = 0; ( s = getoptval( optv, 'f', n ) ); ++n ) parse_file( s, frame ); if ( !n ) parse_file( "+", frame ); } status = yyanyerrors(); /* Manually touch -t targets. */ for ( n = 0; ( s = getoptval( optv, 't', n ) ); ++n ) touch_target( s ); /* If an output file is specified, set globs.cmdout to that. */ if ( ( s = getoptval( optv, 'o', 0 ) ) ) { if ( !( globs.cmdout = fopen( s, "w" ) ) ) { printf( "Failed to write to '%s'\n", s ); exit( EXITBAD ); } ++globs.noexec; } /* The build system may set the PARALLELISM variable to override -j options. */ { LIST *p = L0; p = var_get ("PARALLELISM"); if (p) { int j = atoi (p->string); if (j == -1) { printf( "Invalid value of PARALLELISM: %s\n", p->string); } else { globs.jobs = j; } } } /* KEEP_GOING overrides -q option. */ { LIST *p = L0; p = var_get ("KEEP_GOING"); if (p) { int v = atoi (p->string); if (v == 0) globs.quitquick = 1; else globs.quitquick = 0; } } /* Now make target. */ { PROFILE_ENTER( MAIN_MAKE ); LIST * targets = targets_to_update(); if (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 ); } else { status = last_update_now_status; } PROFILE_EXIT( MAIN_MAKE ); } PROFILE_EXIT( MAIN ); } if ( DEBUG_PROFILE ) profile_dump(); /* Widely scattered cleanup. */ var_done(); file_done(); rules_done(); stamps_done(); str_done(); /* Close cmdout. */ if ( globs.cmdout ) fclose( globs.cmdout ); #ifdef HAVE_PYTHON Py_Finalize(); #endif BJAM_MEM_CLOSE(); return status ? EXITBAD : EXITOK; }
int main( int argc, char **argv, char **arg_environ ) { int n; char *s; struct option optv[N_OPTS]; const char *all = "all"; int anyhow = 0; int status; int arg_c = argc; char ** arg_v = argv; # ifdef OS_MAC InitGraf(&qd.thePort); # endif argc--, argv++; if( ( n = getoptions( argc, argv, "-:d:j:f:gs:t:ano:qv", optv ) ) < 0 ) { printf( "\nusage: jam [ options ] targets...\n\n" ); printf( "-a Build all targets, even if they are current.\n" ); printf( "-dx Set the debug level to x (0-9).\n" ); printf( "-fx Read x instead of Jambase.\n" ); /* printf( "-g Build from newest sources first.\n" ); */ printf( "-jx Run up to x shell commands concurrently.\n" ); printf( "-n Don't actually execute the updating actions.\n" ); printf( "-ox Write the updating actions to file x.\n" ); printf( "-q Quit quickly as soon as a target fails.\n" ); printf( "-sx=y Set variable x=y, overriding environment.\n" ); printf( "-tx Rebuild x, even if it is up-to-date.\n" ); printf( "-v Print the version of jam and exit.\n" ); printf( "--x Option is ignored.\n\n" ); exit( EXITBAD ); } argc -= n, argv += n; /* Version info. */ if( ( s = getoptval( optv, 'v', 0 ) ) ) { printf( "Boost.Jam " ); printf( "Version %s. %s.\n", VERSION, OSMINOR ); printf( " Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. \n" ); printf( " Copyright 2001 David Turner.\n" ); printf( " Copyright 2001-2004 David Abrahams.\n" ); printf( " Copyright 2002-2004 Rene Rivera.\n" ); return EXITOK; } /* Pick up interesting options */ if( ( s = getoptval( optv, 'n', 0 ) ) ) globs.noexec++, globs.debug[2] = 1; if( ( s = getoptval( optv, 'q', 0 ) ) ) globs.quitquick = 1; if( ( s = getoptval( optv, 'a', 0 ) ) ) anyhow++; if( ( s = getoptval( optv, 'j', 0 ) ) ) globs.jobs = atoi( s ); if( ( s = getoptval( optv, 'g', 0 ) ) ) globs.newestfirst = 1; /* Turn on/off debugging */ for( n = 0; s = getoptval( optv, 'd', n ); n++ ) { int i; /* First -d, turn off defaults. */ if( !n ) for( i = 0; i < DEBUG_MAX; i++ ) globs.debug[i] = 0; i = atoi( s ); if( i < 0 || i >= DEBUG_MAX ) { printf( "Invalid debug level '%s'.\n", s ); continue; } /* n turns on levels 1-n */ /* +n turns on level n */ if( *s == '+' ) globs.debug[i] = 1; else while( i ) globs.debug[i--] = 1; } #ifndef NDEBUG run_unit_tests(); #endif #if YYDEBUG != 0 if ( DEBUG_PARSE ) yydebug = 1; #endif /* Set JAMDATE first */ { char *date; time_t clock; time( &clock ); date = newstr( ctime( &clock ) ); /* Trim newline from date */ if( strlen( date ) == 25 ) date[ 24 ] = 0; var_set( "JAMDATE", list_new( L0, newstr( date ) ), VAR_SET ); } { /* Pleace don't change the following line. The 'bump_version.py' script expect a specific format of it. */ char *major_version = "03", *minor_version = "01", *changenum = "10"; var_set( "JAM_VERSION", list_new( list_new( list_new( L0, newstr( major_version ) ), newstr( minor_version ) ), newstr( changenum ) ), VAR_SET ); } /* And JAMUNAME */ # ifdef unix { struct utsname u; 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 ); } } # endif /* unix */ /* load up environment variables */ var_defines( use_environ ); /* * Jam defined variables OS, OSPLAT * We load them after environment, so that * setting OS in environment does not * change Jam notion of the current platform. */ var_defines( othersyms ); /* Load up variables set on command line. */ for( n = 0; s = getoptval( optv, 's', n ); n++ ) { char *symv[2]; symv[0] = s; symv[1] = 0; var_defines( symv ); } /* 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 ); } /* Initialize built-in rules */ load_builtins(); /* Add the targets in the command line to update list */ for ( n = 0; n < argc; ++n ) { mark_target_for_updating(argv[n]); } /* Parse ruleset */ { FRAME frame[1]; frame_init( frame ); for( n = 0; s = getoptval( optv, 'f', n ); n++ ) parse_file( s, frame ); if( !n ) parse_file( "+", frame ); } status = yyanyerrors(); /* Manually touch -t targets */ for( n = 0; s = getoptval( optv, 't', n ); n++ ) touchtarget( s ); /* If an output file is specified, set globs.cmdout to that */ if( s = getoptval( optv, 'o', 0 ) ) { if( !( globs.cmdout = fopen( s, "w" ) ) ) { printf( "Failed to write to '%s'\n", s ); exit( EXITBAD ); } globs.noexec++; } /* Now make target */ { LIST* targets = targets_to_update(); if ( !targets ) { status |= make( 1, &all, anyhow ); } else { int targets_count = list_length(targets); const char **targets2 = (const char **)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); } } if ( DEBUG_PROFILE ) profile_dump(); /* Widely scattered cleanup */ var_done(); donerules(); donestamps(); donestr(); /* close cmdout */ if( globs.cmdout ) fclose( globs.cmdout ); return status ? EXITBAD : EXITOK; }
int main( int argc, char **argv, char **arg_environ ) { int n; char *s; struct option optv[N_OPTS]; const char *all = "all"; int anyhow = 0; int status; int arg_c = argc; char ** arg_v = argv; const char *progname = argv[0]; # ifdef OS_MAC InitGraf(&qd.thePort); # endif argc--, argv++; if( getoptions( argc, argv, "-:l:d:j:f:gs:t:ano:qv", optv ) < 0 ) { printf( "\nusage: %s [ options ] targets...\n\n", progname ); printf( "-a Build all targets, even if they are current.\n" ); printf( "-dx Set the debug level to x (0-9).\n" ); printf( "-fx Read x instead of Jambase.\n" ); /* printf( "-g Build from newest sources first.\n" ); */ printf( "-jx Run up to x shell commands concurrently.\n" ); printf( "-lx Limit actions to x number of seconds after which they are stopped.\n" ); printf( "-n Don't actually execute the updating actions.\n" ); printf( "-ox Write the updating actions to file x.\n" ); printf( "-q Quit quickly as soon as a target fails.\n" ); printf( "-sx=y Set variable x=y, overriding environment.\n" ); printf( "-tx Rebuild x, even if it is up-to-date.\n" ); printf( "-v Print the version of jam and exit.\n" ); printf( "--x Option is ignored.\n\n" ); exit( EXITBAD ); } /* Version info. */ if( ( s = getoptval( optv, 'v', 0 ) ) ) { printf( "Boost.Jam " ); printf( "Version %s. %s.\n", VERSION, OSMINOR ); printf( " Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. \n" ); printf( " Copyright 2001 David Turner.\n" ); printf( " Copyright 2001-2004 David Abrahams.\n" ); printf( " Copyright 2002-2005 Rene Rivera.\n" ); printf( " Copyright 2003-2005 Vladimir Prus.\n" ); return EXITOK; } /* Pick up interesting options */ if( ( s = getoptval( optv, 'n', 0 ) ) ) globs.noexec++, globs.debug[2] = 1; if( ( s = getoptval( optv, 'q', 0 ) ) ) globs.quitquick = 1; if( ( s = getoptval( optv, 'a', 0 ) ) ) anyhow++; if( ( s = getoptval( optv, 'j', 0 ) ) ) globs.jobs = atoi( s ); if( ( s = getoptval( optv, 'g', 0 ) ) ) globs.newestfirst = 1; if( ( s = getoptval( optv, 'l', 0 ) ) ) globs.timeout = atoi( s ); /* Turn on/off debugging */ for( n = 0; s = getoptval( optv, 'd', n ); n++ ) { int i; /* First -d, turn off defaults. */ if( !n ) for( i = 0; i < DEBUG_MAX; i++ ) globs.debug[i] = 0; i = atoi( s ); if( i < 0 || i >= DEBUG_MAX ) { printf( "Invalid debug level '%s'.\n", s ); continue; } /* n turns on levels 1-n */ /* +n turns on level n */ if( *s == '+' ) globs.debug[i] = 1; else while( i ) globs.debug[i--] = 1; } { PROFILE_ENTER(MAIN); #ifdef HAVE_PYTHON { PROFILE_ENTER(MAIN_PYTHON); Py_Initialize(); { static PyMethodDef BjamMethods[] = { {"call", bjam_call, METH_VARARGS, "Call the specified bjam rule."}, {"import_rule", bjam_import_rule, METH_VARARGS, "Imports Python callable to bjam."}, {NULL, NULL, 0, NULL} }; Py_InitModule("bjam", BjamMethods); } PROFILE_EXIT(MAIN_PYTHON); } #endif #ifndef NDEBUG run_unit_tests(); #endif #if YYDEBUG != 0 if ( DEBUG_PARSE ) yydebug = 1; #endif /* Set JAMDATE first */ { char *date; time_t clock; time( &clock ); date = newstr( ctime( &clock ) ); /* Trim newline from date */ if( strlen( date ) == 25 ) date[ 24 ] = 0; var_set( "JAMDATE", list_new( L0, newstr( date ) ), VAR_SET ); } 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 ); /* And JAMUNAME */ # ifdef unix { struct utsname u; 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 ); } } # endif /* unix */ /* load up environment variables */ /* first into global module, with splitting, for backward compatibility */ var_defines( use_environ, 1 ); /* then into .ENVIRON, without splitting */ enter_module( bindmodule(".ENVIRON") ); var_defines( use_environ, 0 ); exit_module( bindmodule(".ENVIRON") ); /* * Jam defined variables OS, OSPLAT * We load them after environment, so that * setting OS in environment does not * change Jam notion of the current platform. */ var_defines( othersyms, 1 ); /* Load up variables set on command line. */ for( n = 0; s = getoptval( optv, 's', n ); n++ ) { char *symv[2]; symv[0] = s; symv[1] = 0; var_defines( symv, 1 ); } /* 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 ); } /* Initialize built-in rules */ load_builtins(); /* Add the targets in the command line to update list */ for ( n = 1; n < arg_c; ++n ) { if ( arg_v[n][0] == '-' ) { char *f = "-:l:d:j:f:gs:t:ano:qv"; for( ; *f; f++ ) if( *f == arg_v[n][1] ) break; if ( f[1] == ':' && arg_v[n][2] == '\0' ) { ++n; } } else { mark_target_for_updating(arg_v[n]); } } /* Parse ruleset */ { FRAME frame[1]; frame_init( frame ); for( n = 0; s = getoptval( optv, 'f', n ); n++ ) parse_file( s, frame ); if( !n ) parse_file( "+", frame ); } status = yyanyerrors(); /* Manually touch -t targets */ for( n = 0; s = getoptval( optv, 't', n ); n++ ) touchtarget( s ); /* If an output file is specified, set globs.cmdout to that */ if( s = getoptval( optv, 'o', 0 ) ) { if( !( globs.cmdout = fopen( s, "w" ) ) ) { printf( "Failed to write to '%s'\n", s ); exit( EXITBAD ); } globs.noexec++; } /* Now make target */ { PROFILE_ENTER(MAIN_MAKE); LIST* targets = targets_to_update(); if ( !targets ) { status |= make( 1, &all, anyhow ); } else { int targets_count = list_length(targets); const char **targets2 = (const char **)malloc(targets_count * sizeof(char *)); int n = 0; if ( DEBUG_PROFILE ) profile_memory( targets_count * sizeof(char *) ); for ( ; targets; targets = list_next(targets) ) { targets2[n++] = targets->string; } status |= make( targets_count, targets2, anyhow ); free(targets); } PROFILE_EXIT(MAIN_MAKE); } PROFILE_EXIT(MAIN); } if ( DEBUG_PROFILE ) profile_dump(); /* Widely scattered cleanup */ var_done(); file_done(); donerules(); donestamps(); donestr(); /* close cmdout */ if( globs.cmdout ) fclose( globs.cmdout ); #ifdef HAVE_PYTHON Py_Finalize(); #endif return status ? EXITBAD : EXITOK; }