![]() |
The Machine Perception Toolbox |
|
#include "jam.h"
#include "option.h"
#include "patchlevel.h"
#include "lists.h"
#include "parse.h"
#include "variable.h"
#include "compile.h"
#include "builtins.h"
#include "rules.h"
#include "newstr.h"
#include "scan.h"
#include "timestamp.h"
#include "make.h"
#include "strings.h"
#include "expand.h"
Include dependency graph for jam.c:
Go to the source code of this file.
Defines | |
#define | use_environ environ |
Functions | |
int | main (int argc, char **argv, char **arg_environ) |
void | run_unit_tests () |
Variables | |
char ** | environ |
globs | globs |
char * | othersyms [] = { OSMAJOR, OSMINOR, OSPLAT, JAMVERSYM, 0 } |
|
Definition at line 179 of file jam.c. Referenced by main(). |
|
Definition at line 201 of file jam.c. References globs::cmdout, globs::debug, donerules(), donestamps(), donestr(), EXITBAD, fclose(), FRAME, frame_init(), getoptions(), getoptval(), globs, i, globs::jobs, L0, LIST, list_length(), list_new(), list_next, load_builtins(), make(), mark_target_for_updating(), n, N_OPTS, globs::newestfirst, newstr(), globs::noexec, OSMINOR, othersyms, parse_file(), profile_dump(), globs::quitquick, run_unit_tests(), s, _list::string, targets_to_update(), touchtarget(), use_environ, VAR_APPEND, var_defines(), var_done(), VAR_SET, var_set(), VERSION, and yyanyerrors(). 00202 { 00203 int n; 00204 char *s; 00205 struct option optv[N_OPTS]; 00206 const char *all = "all"; 00207 int anyhow = 0; 00208 int status; 00209 int arg_c = argc; 00210 char ** arg_v = argv; 00211 00212 # ifdef OS_MAC 00213 InitGraf(&qd.thePort); 00214 # endif 00215 00216 argc--, argv++; 00217 00218 if( ( n = getoptions( argc, argv, "-:d:j:f:gs:t:ano:qv", optv ) ) < 0 ) 00219 { 00220 printf( "\nusage: jam [ options ] targets...\n\n" ); 00221 00222 printf( "-a Build all targets, even if they are current.\n" ); 00223 printf( "-dx Set the debug level to x (0-9).\n" ); 00224 printf( "-fx Read x instead of Jambase.\n" ); 00225 /* printf( "-g Build from newest sources first.\n" ); */ 00226 printf( "-jx Run up to x shell commands concurrently.\n" ); 00227 printf( "-n Don't actually execute the updating actions.\n" ); 00228 printf( "-ox Write the updating actions to file x.\n" ); 00229 printf( "-q Quit quickly as soon as a target fails.\n" ); 00230 printf( "-sx=y Set variable x=y, overriding environment.\n" ); 00231 printf( "-tx Rebuild x, even if it is up-to-date.\n" ); 00232 printf( "-v Print the version of jam and exit.\n" ); 00233 printf( "--x Option is ignored.\n\n" ); 00234 00235 exit( EXITBAD ); 00236 } 00237 00238 argc -= n, argv += n; 00239 00240 /* Version info. */ 00241 00242 if( ( s = getoptval( optv, 'v', 0 ) ) ) 00243 { 00244 printf( "Boost.Jam " ); 00245 printf( "Version %s. %s.\n", VERSION, OSMINOR ); 00246 printf( " Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. \n" ); 00247 printf( " Copyright 2001 David Turner.\n" ); 00248 printf( " Copyright 2001-2002 David Abrahams.\n" ); 00249 00250 return EXITOK; 00251 } 00252 00253 /* Pick up interesting options */ 00254 00255 if( ( s = getoptval( optv, 'n', 0 ) ) ) 00256 globs.noexec++, globs.debug[2] = 1; 00257 00258 if( ( s = getoptval( optv, 'q', 0 ) ) ) 00259 globs.quitquick = 1; 00260 if( ( s = getoptval( optv, 'a', 0 ) ) ) 00261 anyhow++; 00262 00263 if( ( s = getoptval( optv, 'j', 0 ) ) ) 00264 globs.jobs = atoi( s ); 00265 00266 if( ( s = getoptval( optv, 'g', 0 ) ) ) 00267 globs.newestfirst = 1; 00268 00269 /* Turn on/off debugging */ 00270 00271 for( n = 0; s = getoptval( optv, 'd', n ); n++ ) 00272 { 00273 int i; 00274 00275 /* First -d, turn off defaults. */ 00276 00277 if( !n ) 00278 for( i = 0; i < DEBUG_MAX; i++ ) 00279 globs.debug[i] = 0; 00280 00281 i = atoi( s ); 00282 00283 if( i < 0 || i >= DEBUG_MAX ) 00284 { 00285 printf( "Invalid debug level '%s'.\n", s ); 00286 continue; 00287 } 00288 00289 /* n turns on levels 1-n */ 00290 /* +n turns on level n */ 00291 00292 if( *s == '+' ) 00293 globs.debug[i] = 1; 00294 else while( i ) 00295 globs.debug[i--] = 1; 00296 } 00297 00298 #ifndef NDEBUG 00299 run_unit_tests(); 00300 #endif 00301 #if YYDEBUG != 0 00302 if ( DEBUG_PARSE ) 00303 yydebug = 1; 00304 #endif 00305 00306 /* Set JAMDATE first */ 00307 00308 { 00309 char *date; 00310 time_t clock; 00311 time( &clock ); 00312 date = newstr( ctime( &clock ) ); 00313 00314 /* Trim newline from date */ 00315 00316 if( strlen( date ) == 25 ) 00317 date[ 24 ] = 0; 00318 00319 var_set( "JAMDATE", list_new( L0, newstr( date ) ), VAR_SET ); 00320 } 00321 00322 var_set( "JAM_VERSION", 00323 list_new( list_new( list_new( L0, newstr( "03" ) ), newstr( "01" ) ), 00324 newstr( "08" ) ), 00325 VAR_SET ); 00326 00327 /* And JAMUNAME */ 00328 # ifdef unix 00329 { 00330 struct utsname u; 00331 00332 if( uname( &u ) >= 0 ) 00333 { 00334 var_set( "JAMUNAME", 00335 list_new( 00336 list_new( 00337 list_new( 00338 list_new( 00339 list_new( L0, 00340 newstr( u.sysname ) ), 00341 newstr( u.nodename ) ), 00342 newstr( u.release ) ), 00343 newstr( u.version ) ), 00344 newstr( u.machine ) ), VAR_SET ); 00345 } 00346 } 00347 # endif /* unix */ 00348 00349 /* 00350 * Jam defined variables OS, OSPLAT 00351 */ 00352 00353 var_defines( othersyms ); 00354 00355 /* load up environment variables */ 00356 00357 var_defines( use_environ ); 00358 00359 /* Load up variables set on command line. */ 00360 00361 for( n = 0; s = getoptval( optv, 's', n ); n++ ) 00362 { 00363 char *symv[2]; 00364 symv[0] = s; 00365 symv[1] = 0; 00366 var_defines( symv ); 00367 } 00368 00369 /* Set the ARGV to reflect the complete list of arguments of invocation. */ 00370 00371 for ( n = 0; n < arg_c; ++n ) 00372 { 00373 var_set( "ARGV", list_new( L0, newstr( arg_v[n] ) ), VAR_APPEND ); 00374 } 00375 00376 /* Initialize built-in rules */ 00377 00378 load_builtins(); 00379 00380 /* Add the targets in the command line to update list */ 00381 00382 for ( n = 0; n < argc; ++n ) 00383 { 00384 mark_target_for_updating(argv[n]); 00385 } 00386 00387 /* Parse ruleset */ 00388 00389 { 00390 FRAME frame[1]; 00391 frame_init( frame ); 00392 for( n = 0; s = getoptval( optv, 'f', n ); n++ ) 00393 parse_file( s, frame ); 00394 00395 if( !n ) 00396 parse_file( "+", frame ); 00397 } 00398 00399 status = yyanyerrors(); 00400 00401 /* Manually touch -t targets */ 00402 00403 for( n = 0; s = getoptval( optv, 't', n ); n++ ) 00404 touchtarget( s ); 00405 00406 /* If an output file is specified, set globs.cmdout to that */ 00407 00408 if( s = getoptval( optv, 'o', 0 ) ) 00409 { 00410 if( !( globs.cmdout = fopen( s, "w" ) ) ) 00411 { 00412 printf( "Failed to write to '%s'\n", s ); 00413 exit( EXITBAD ); 00414 } 00415 globs.noexec++; 00416 } 00417 00418 /* Now make target */ 00419 00420 { 00421 LIST* targets = targets_to_update(); 00422 if ( !targets ) 00423 { 00424 status |= make( 1, &all, anyhow ); 00425 } 00426 else 00427 { 00428 int targets_count = list_length(targets); 00429 const char **targets2 = (const char **)malloc(targets_count * sizeof(char *)); 00430 int n = 0; 00431 for ( ; targets; targets = list_next(targets) ) 00432 { 00433 targets2[n++] = targets->string; 00434 } 00435 status |= make( targets_count, targets2, anyhow ); 00436 free(targets); 00437 } 00438 } 00439 00440 00441 if ( DEBUG_PROFILE ) 00442 profile_dump(); 00443 00444 /* Widely scattered cleanup */ 00445 00446 var_done(); 00447 donerules(); 00448 donestamps(); 00449 donestr(); 00450 00451 /* close cmdout */ 00452 00453 if( globs.cmdout ) 00454 fclose( globs.cmdout ); 00455 00456 return status ? EXITBAD : EXITOK; 00457 }
|
Here is the call graph for this function:
|
Definition at line 190 of file jam.c. References string_unit_test(), and var_expand_unit_test(). Referenced by main(). 00191 { 00192 # if defined( USE_EXECNT ) 00193 extern void execnt_unit_test(); 00194 execnt_unit_test(); 00195 # endif 00196 string_unit_test(); 00197 var_expand_unit_test(); 00198 }
|
Here is the call graph for this function:
|
|
|
Initial value: { 0, 1, 0, 0, { 0, 1 }, 0 } Definition at line 139 of file jam.c. Referenced by main(). |
|
Definition at line 154 of file jam.c. Referenced by main(). |