/* * /+\ * +\ Copyright 1993, 2000 Christopher Seiwald. * \+/ * * This file is part of jam. * * License is hereby granted to use this software and distribute it * freely, as long as this copyright notice is retained and modifications * are clearly marked. * * ALL WARRANTIES ARE HEREBY DISCLAIMED. */ /* * jam.c - make redux * * See Jam.html and Jamlang.html for usage information. * * These comments document the code. * * The top half of the code is structured such: * * jam * / | \ * +---+ | \ * / | \ * jamgram option \ * / | \ \ * / | \ \ * / | \ | * scan | compile make * | | / \ / | \ * | | / \ / | \ * | | / \ / | \ * jambase parse rules search make1 * | | \ * | | \ * | | \ * timestamp command execute * * * The support routines are called by all of the above, but themselves * are layered thus: * * variable|expand * / | | | * / | | | * / | | | * lists | | filesys * \ | | * \ | | * \ | | * newstr | * \ | * \ | * \ | * hash * * Roughly, the modules are: * * 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 * fileunix.c - manipulate file names and scan directories on UNIX * filevms.c - manipulate file names and scan directories on VMS * hash.c - simple in-memory hashing routines * headers.c - handle #includes in source files * jambase.c - compilable copy of Jambase * jamgram.y - jam grammar * 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 * option.c - command line option processing * parse.c - make and destroy parse trees as driven by the parser * regexp.c - Henry Spencer's regexp * rules.c - access to RULEs, TARGETs, and ACTIONs * scan.c - the jam yacc scanner * search.c - find a target along $(SEARCH) or $(LOCATE) * timestamp.c - get the timestamp of a file or archive member * variable.c - handle jam multi-element variables * * 05/04/94 (seiwald) - async multiprocess (-j) support * 02/08/95 (seiwald) - -n implies -d2. * 02/22/95 (seiwald) - -v for version info. * 09/11/00 (seiwald) - PATCHLEVEL folded into VERSION. */ #include "Option.hpp" #include "PatchLevel.hpp" /* These get various function declarations. */ #include "Compile.hpp" #include "Make.hpp" #include "Scan.hpp" #include "String.hpp" #include "Timestamp.hpp" #include "Variable.hpp" /* Macintosh is "special" */ #ifdef OS_MAC #include <QuickDraw.h> #endif /* And UNIX for this */ #ifdef unix #include <sys/utsname.h> #endif struct globs globs = { 0, /* noexec */ 1, /* jobs */ # ifdef OS_MAC { 0, 0 }, /* debug - suppress tracing output */ # else { 0, 1 }, /* debug ... */ # endif 0 /* output commands, not run them */ } ; /* Symbols to be defined as true for use in Jambase */ static char *othersyms[] = { OSMAJOR, OSMINOR, OSPLAT, JAMVERSYM, 0 } ; /* Known for sure: * mac needs arg_enviro * OS2 needs extern environ */ # ifdef OS_MAC # define use_environ arg_environ # ifdef MPW QDGlobals qd; # endif # endif # ifndef use_environ # define use_environ environ # if !defined( __WATCOM__ ) && !defined( OS_OS2 ) && !defined( OS_NT ) extern char **environ; # endif # endif using Jam::List; using Jam::Parse; using Jam::String; 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; # ifdef OS_MAC InitGraf(&qd.thePort); # endif argc--, argv++; if( ( n = getoptions( argc, argv, "d:j:f:s:t:ano:v", 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( "-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( "-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 ); } argc -= n, argv += n; /* Version info. */ if( ( s = getoptval( optv, 'v', 0 ) ) ) { printf( "Jam/MR " ); printf( "Version %s. ", VERSION ); printf( "Copyright 1993, 2000 Christopher Seiwald. " ); printf( "%s.\n", OSMINOR ); return EXITOK; } /* Pick up interesting options */ if( ( s = getoptval( optv, 'n', 0 ) ) ) globs.noexec++, globs.debug[2] = 1; if( ( s = getoptval( optv, 'a', 0 ) ) ) anyhow++; if( ( s = getoptval( optv, 'j', 0 ) ) ) globs.jobs = 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; } /* Set JAMDATE first */ { char *date; time_t clock; time( &clock ); date = String::newstr( ctime( &clock ) ); /* Trim newline from date */ if( strlen( date ) == 25 ) date[ 24 ] = 0; var_set( "JAMDATE", List::list_new( NULL, String::newstr( date ) ), 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 */ /* * Jam defined variables OS, OSPLAT */ var_defines( othersyms ); /* load up environment variables */ var_defines( use_environ ); /* 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 ); } /* Initialize builtins */ compile_builtins(); /* Parse ruleset */ for( n = 0; s = getoptval( optv, 'f', n ); n++ ) { Parse::parse_file( s ); } if( !n ) { Parse::parse_file( "+" ); } 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 */ if( !argc ) status |= make( 1, &all, anyhow ); else status |= make( argc, (const char**)argv, anyhow ); /* Widely scattered cleanup */ var_done(); donerules(); donestamps(); String::donestr(); /* close cmdout */ if( globs.cmdout ) fclose( globs.cmdout ); return status ? EXITBAD : EXITOK; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#12 | 1162 | bob_summerwill | Converted LIST into a List class, with all static methods. | ||
#11 | 1156 | bob_summerwill | Converted Parse into a class. | ||
#10 | 1153 | bob_summerwill | NewStr has been renamed as String. | ||
#9 | 1146 | bob_summerwill | Moved the NewStr global functions into a static class Jam::String. | ||
#8 | 1138 | bob_summerwill | Removed all extern "C" wrappers, so the program now has C++ linkage throughout, ready for refactoring. | ||
#7 | 1132 | bob_summerwill | All of the non-generated, non-platform-specific files are now mixed-case C++ source files. | ||
#6 | 1131 | bob_summerwill | More .C to .CPP conversions. | ||
#5 | 1130 | bob_summerwill | More .C to .CPP conversions. | ||
#4 | 1129 | bob_summerwill | Some const-correctness fixes. | ||
#3 | 1127 | bob_summerwill | More file renaming. | ||
#2 | 1126 | bob_summerwill | #include dependencies between headers are now modelled explicitly, with #includes as required in header files, rather than it being a client-code responsibility. | ||
#1 | 1124 | bob_summerwill | More .c to .cpp conversions. | ||
//guest/bob_summerwill/jam/src/jam.c | |||||
#3 | 1120 | bob_summerwill | A fair-size chunk of char* const-correctness modifications. | ||
#2 | 1117 | bob_summerwill |
Converted Compile and Expand files to C++. Some minor function prototype tweaks. |
||
#1 | 1106 | bob_summerwill | Integrated Jam from "public" to "guest/bob_summerwill". | ||
//guest/perforce_software/jam/src/jam.c | |||||
#7 | 486 | Perforce staff |
Jam 2.3. See RELNOTES for a list of changes from 2.2.x. Just about every source file was touched when jam got ANSI-fied. |
||
#6 | 213 | Perforce staff | Peter Glasscock's MPW port. | ||
#5 | 212 | Perforce staff |
An interpretative integration of Peter Glasscock's -o file support. This is handled in the make1() routine, rather than in all the exec*.c files. -o x writes the actions to file x rather than actually running them. Implies -n (but not -d2). |
||
#4 | 76 | Laura Wingerd |
Integrate command-block-too-long fix, plus minor doc updates. Jam/MR release level is now 2.2.5. (change 72, change 73, change 74, change 75) |
||
#3 | 5 | Perforce maintenance | Jam/MR 2.2.4 (HDRPATTERN, JAMUNAME, JAMSHELL, plus misc tweaks) | ||
#2 | 3 | Perforce maintenance | Jam/MR 2.2.1 (fix for NT handle leak) | ||
#1 | 2 | laura | Add Jam/MR 2.2 source |