Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1081 lines
26 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. --*/
  3. //+---------------------------------------------------------------------------
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1994
  7. //
  8. // File: build.h
  9. //
  10. // Contents: Main Include file for build.exe
  11. //
  12. // History: 16-May-89 SteveWo Created
  13. // 26-Jul-94 LyleC Cleanup/Add Support for Pass0
  14. //
  15. //----------------------------------------------------------------------------
  16. #include <assert.h>
  17. #include <process.h>
  18. #include <stdio.h>
  19. #include <stddef.h>
  20. #include <stdlib.h>
  21. #include <stdarg.h>
  22. #include <limits.h>
  23. #include <malloc.h>
  24. #include <errno.h>
  25. #include <ctype.h>
  26. #include <signal.h>
  27. #include <string.h>
  28. #include <time.h>
  29. #include <io.h>
  30. #include <conio.h>
  31. #include <sys\types.h>
  32. #include <sys\stat.h>
  33. #define INC_OLE2
  34. #include <windows.h>
  35. #define UINT DWORD
  36. #define HDIR HANDLE
  37. VOID
  38. ClearLine(VOID);
  39. //
  40. // Types and Constant Definitions
  41. //
  42. #if DBG
  43. #define DEBUG_1 (fDebug & 1)
  44. #else
  45. #define DEBUG_1 FALSE
  46. #endif
  47. BOOL fDebug;
  48. #define DEBUG_2 (fDebug & 3)
  49. #define DEBUG_4 (fDebug & 4)
  50. //
  51. // Target specific dirs file name.
  52. //
  53. extern LPSTR pszTargetDirs;
  54. #define MAX_TARGET_MACHINES 3
  55. typedef struct _TARGET_MACHINE_INFO {
  56. UCHAR SourceSubDirMask; // TMIDIR_I386
  57. LPSTR Description; // "i386"
  58. LPSTR Switch; // "-386"
  59. LPSTR Switch2; // "-x86"
  60. LPSTR MakeVariable; // "386=1"
  61. LPSTR SourceVariable; // "i386_SOURCES"
  62. LPSTR ObjectVariable; // "386_OBJECTS"
  63. LPSTR AssociateDirectory; // "i386"
  64. LPSTR SourceDirectory; // "i386"
  65. LPSTR TargetDirs; // "i386dirs"
  66. LPSTR ObjectDirectory[2]; // "i386" -- initialize only first entry
  67. ULONG DirIncludeMask; // Platform/Group/etc.
  68. LPSTR ObjectMacro; // don't initialize
  69. } TARGET_MACHINE_INFO, *PTARGET_MACHINE_INFO;
  70. #define DIR_INCLUDE_NONE 0x00000000
  71. #define DIR_INCLUDE_X86 0x00000001
  72. // 0x00000002
  73. #define DIR_INCLUDE_IA64 0x00000004
  74. // 0x00000008
  75. #define DIR_INCLUDE_WIN32 0x00000010
  76. #define DIR_INCLUDE_WIN64 0x00000020
  77. #define DIR_INCLUDE_RISC 0x00000040
  78. #define DIR_INCLUDE_AMD64 0x00000080
  79. #define DIR_INCLUDE_ALL 0xffffffff
  80. // It's possible to have SOURCES= entries of the following forms:
  81. // entry SourceSubDirMask
  82. // ----- ----------------
  83. // foo.c 0
  84. // i386\foo.c 1
  85. // amd64\foo.c 2
  86. // ia64\foo.c 4
  87. // ..\foo.c 80
  88. // ..\i386\foo.c 81
  89. // ..\amd64\foo.c 82
  90. // ..\ia64\foo.c 84
  91. #define TMIDIR_I386 0x0001
  92. #define TMIDIR_AMD64 0x0002
  93. #define TMIDIR_IA64 0x0004
  94. #define TMIDIR_PARENT 0x0080 // or'd in with above bits
  95. #define SIG_DIRREC 0x44644464 // "DdDd"
  96. #ifdef SIG_DIRREC
  97. #define SIG_FILEREC 0x46664666 // "FfFf"
  98. #define SIG_INCLUDEREC 0x49694969 // "IiIi"
  99. #define SIG_SOURCEREC 0x53735373 // "SsSs"
  100. #define SigCheck(s) s
  101. #else
  102. #define SigCheck(s)
  103. #endif
  104. #define AssertDir(pdr) \
  105. SigCheck(assert((pdr) != NULL && (pdr)->Sig == SIG_DIRREC))
  106. #define AssertOptionalDir(pdr) \
  107. SigCheck(assert((pdr) == NULL || (pdr)->Sig == SIG_DIRREC))
  108. #define AssertFile(pfr) \
  109. SigCheck(assert((pfr) != NULL && (pfr)->Sig == SIG_FILEREC))
  110. #define AssertOptionalFile(pfr) \
  111. SigCheck(assert((pfr) == NULL || (pfr)->Sig == SIG_FILEREC))
  112. #define AssertInclude(pir) \
  113. SigCheck(assert((pir) != NULL && (pir)->Sig == SIG_INCLUDEREC))
  114. #define AssertOptionalInclude(pir) \
  115. SigCheck(assert((pir) == NULL || (pir)->Sig == SIG_INCLUDEREC))
  116. #define AssertSource(psr) \
  117. SigCheck(assert((psr) != NULL && (psr)->Sig == SIG_SOURCEREC))
  118. #define AssertOptionalSource(psr) \
  119. SigCheck(assert((psr) == NULL || (psr)->Sig == SIG_SOURCEREC))
  120. //
  121. // Information about source directories is stored an in-memory database.
  122. // The information is saved on disk by writing the contents of the database
  123. // to "build.dat". It is reloaded from disk for subsequent invocations,
  124. // and re-written only when it has been updated.
  125. //
  126. typedef struct _INCLUDEREC {
  127. SigCheck(ULONG Sig;)
  128. struct _INCLUDEREC *Next; // static list describes original arcs
  129. struct _INCLUDEREC *NextTree; // dynamic list -- cycles are collapsed
  130. struct _FILEREC *pfrCycleRoot;
  131. struct _FILEREC *pfrInclude;
  132. USHORT Version;
  133. USHORT IncFlags;
  134. char Name[1];
  135. } INCLUDEREC, *PINCLUDEREC;
  136. #define INCLUDEDB_LOCAL 0x0001 // include "foo.h"
  137. #define INCLUDEDB_POST_HDRSTOP 0x0002 // appears after #pragma hdrstop
  138. #define INCLUDEDB_MISSING 0x0400 // include file was once missing
  139. #define INCLUDEDB_GLOBAL 0x0800 // include file is in global directory
  140. #define INCLUDEDB_SNAPPED 0x1000 // include file snapped
  141. #define INCLUDEDB_CYCLEALLOC 0x2000 // allocated to flatten cycle
  142. #define INCLUDEDB_CYCLEROOT 0x4000 // moved to root file to flatten cycle
  143. #define INCLUDEDB_CYCLEORPHAN 0x8000 // orphaned to flatten cycle
  144. // Flags preserved when loading build.dat:
  145. #define INCLUDEDB_DBPRESERVE (INCLUDEDB_LOCAL | INCLUDEDB_POST_HDRSTOP)
  146. #define IsCleanTree(pir) \
  147. ((pir)->NextTree == NULL && \
  148. ((pir)->IncFlags & \
  149. (INCLUDEDB_CYCLEALLOC | INCLUDEDB_CYCLEROOT | INCLUDEDB_CYCLEORPHAN)) == 0)
  150. #if DBG
  151. VOID AssertCleanTree(INCLUDEREC *pir, OPTIONAL struct _FILEREC *pfr);
  152. #else
  153. #define AssertCleanTree(pir, pfr) assert(IsCleanTree(pir))
  154. #endif
  155. //
  156. // Make file description structure definition.
  157. //
  158. typedef struct _FILEDESC {
  159. LPSTR pszPattern; // pattern to match file name
  160. LPSTR pszCommentToEOL; // comment-to-eol string
  161. BOOL fNeedFileRec; // TRUE => file needs a file record
  162. ULONG FileFlags; // flags to be set in file record
  163. ULONG DirFlags; // flags to be set in directory record
  164. } FILEDESC;
  165. extern FILEDESC FileDesc[];
  166. typedef struct _FILEREC {
  167. SigCheck(ULONG Sig;)
  168. struct _FILEREC *Next;
  169. struct _DIRREC *Dir;
  170. INCLUDEREC *IncludeFiles; // static list describes original arcs
  171. INCLUDEREC *IncludeFilesTree; // dynamic list -- cycles are collapsed
  172. struct _FILEREC *NewestDependency;
  173. LPSTR pszCommentToEOL; // comment-to-eol string in source
  174. ULONG DateTime;
  175. ULONG DateTimeTree; // Newest DateTime for included tree
  176. ULONG TotalSourceLines; // line count in all included files
  177. ULONG FileFlags;
  178. ULONG SourceLines;
  179. USHORT Attr;
  180. USHORT SubDirIndex;
  181. USHORT Version;
  182. USHORT GlobalSequence; // Sequence number for dynamic include tree
  183. USHORT LocalSequence; // Sequence number for dynamic include tree
  184. USHORT idScan; // id used for detecting multiple inclusion
  185. USHORT CheckSum; // Name checksum
  186. UCHAR fDependActive;
  187. char Name[1];
  188. } FILEREC, *PFILEREC;
  189. #define MAKE_DATE_TIME( date, time ) \
  190. ((ULONG)(((USHORT)(time)) | ((ULONG)((USHORT)(date))) << 16))
  191. #define FILEDB_SOURCE 0x00000001
  192. #define FILEDB_DIR 0x00000002
  193. #define FILEDB_HEADER 0x00000004
  194. #define FILEDB_ASM 0x00000008
  195. #define FILEDB_MASM 0x00000010
  196. #define FILEDB_RC 0x00000020
  197. #define FILEDB_C 0x00000040
  198. #define FILEDB_MIDL 0x00000080
  199. #define FILEDB_ASN 0x00000100
  200. #define FILEDB_JAVA 0x00000200
  201. #define FILEDB_MOF 0x00000400
  202. #define FILEDB_CSHARP 0x00000800
  203. #define FILEDB_SCANNED 0x00001000
  204. #define FILEDB_OBJECTS_LIST 0x00002000
  205. #define FILEDB_FILE_MISSING 0x00004000
  206. #define FILEDB_MKTYPLIB 0x00008000
  207. #define FILEDB_MULTIPLEPASS 0x00010000
  208. #define FILEDB_PASS0 0x00020000
  209. #define FILEDB_SOURCEREC_EXISTS 0x00040000
  210. // Flags preserved when loading build.dat:
  211. #define FILEDB_DBPRESERVE (FILEDB_SOURCE | \
  212. FILEDB_DIR | \
  213. FILEDB_HEADER | \
  214. FILEDB_ASM | \
  215. FILEDB_MASM | \
  216. FILEDB_RC | \
  217. FILEDB_C | \
  218. FILEDB_MIDL | \
  219. FILEDB_ASN | \
  220. FILEDB_JAVA | \
  221. FILEDB_MOF | \
  222. FILEDB_CSHARP | \
  223. FILEDB_MKTYPLIB | \
  224. FILEDB_MULTIPLEPASS | \
  225. FILEDB_PASS0)
  226. typedef struct _SOURCEREC {
  227. SigCheck(ULONG Sig;)
  228. struct _SOURCEREC *psrNext;
  229. FILEREC *pfrSource;
  230. UCHAR SourceSubDirMask;
  231. UCHAR SrcFlags;
  232. } SOURCEREC;
  233. #define SOURCEDB_SOURCES_LIST 0x01
  234. #define SOURCEDB_FILE_MISSING 0x02
  235. #define SOURCEDB_PCH 0x04
  236. #define SOURCEDB_OUT_OF_DATE 0x08
  237. #define SOURCEDB_COMPILE_NEEDED 0x10
  238. typedef struct _DIRSUP {
  239. LPSTR TestType;
  240. LPSTR LocalIncludePath;
  241. LPSTR PchIncludeDir;
  242. LPSTR PchInclude;
  243. LPSTR PchTargetDir;
  244. LPSTR PchTarget;
  245. LPSTR PassZeroHdrDir;
  246. LPSTR PassZeroSrcDir1;
  247. LPSTR PassZeroSrcDir2;
  248. LPSTR ConditionalIncludes;
  249. ULONG DateTimeSources;
  250. ULONG IdlType;
  251. ULONG fNoTarget;
  252. LPSTR SourcesVariables[MAX_TARGET_MACHINES + 1];
  253. SOURCEREC *psrSourcesList[MAX_TARGET_MACHINES + 1];
  254. } DIRSUP;
  255. typedef struct _DIRREC {
  256. SigCheck(ULONG Sig;)
  257. struct _DIRREC *Next;
  258. DIRSUP *pds; // Used to preserve info from pass zero
  259. PFILEREC Files;
  260. LPSTR TargetPath;
  261. LPSTR TargetPathLib;
  262. LPSTR TargetName;
  263. LPSTR TargetExt;
  264. LPSTR KernelTest;
  265. LPSTR UserAppls;
  266. LPSTR UserTests;
  267. LPSTR NTTargetFile0;
  268. LPSTR Pch;
  269. LPSTR PchObj;
  270. LONG SourceLinesToCompile;
  271. LONG PassZeroLines;
  272. ULONG DirFlags;
  273. ULONG RecurseLevel;
  274. USHORT FindCount;
  275. USHORT CountSubDirs;
  276. SHORT CountOfFilesToCompile;
  277. SHORT CountOfPassZeroFiles;
  278. USHORT CheckSum; // Name checksum
  279. char Name[1];
  280. } DIRREC, *PDIRREC;
  281. #define DIRDB_SOURCES 0x00000001
  282. #define DIRDB_DIRS 0x00000002
  283. #define DIRDB_MAKEFILE 0x00000004
  284. #define DIRDB_MAKEFIL0 0x00000008
  285. #define DIRDB_TARGETFILE0 0x00000010
  286. #define DIRDB_TARGETFILES 0x00000020
  287. #define DIRDB_RESOURCE 0x00000040
  288. #define DIRDB_PASS0 0x00000080
  289. #define DIRDB_SOURCES_SET 0x00000100
  290. #define DIRDB_CHICAGO_INCLUDES 0x00000800
  291. #define DIRDB_NEW 0x00001000
  292. #define DIRDB_SCANNED 0x00002000
  293. #define DIRDB_SHOWN 0x00004000
  294. #define DIRDB_GLOBAL_INCLUDES 0x00008000
  295. #define DIRDB_SYNCHRONIZE_BLOCK 0x00010000
  296. #define DIRDB_SYNCHRONIZE_DRAIN 0x00020000
  297. #define DIRDB_COMPILENEEDED 0x00040000
  298. #define DIRDB_COMPILEERRORS 0x00080000
  299. #define DIRDB_SOURCESREAD 0x00100000
  300. #define DIRDB_DLLTARGET 0x00200000
  301. #define DIRDB_LINKNEEDED 0x00400000
  302. #define DIRDB_FORCELINK 0x00800000
  303. #define DIRDB_PASS0NEEDED 0x01000000
  304. #define DIRDB_MAKEFIL1 0x02000000
  305. #define DIRDB_CHECKED_ALT_DIR 0x04000000
  306. // Flags preserved when loading build.dat:
  307. #define DIRDB_DBPRESERVE 0
  308. typedef struct _TARGET {
  309. FILEREC *pfrCompiland;
  310. DIRREC *pdrBuild;
  311. LPSTR pszSourceDirectory;
  312. LPSTR ConditionalIncludes;
  313. ULONG DateTime;
  314. ULONG DirFlags;
  315. char Name[1];
  316. } TARGET, *PTARGET;
  317. #define BUILD_VERSION 0x0403
  318. #define DBMASTER_NAME "build.dat"
  319. #define DB_MAX_PATH_LENGTH 256
  320. // If you change or add any values to this enum,
  321. // also fix MemTab in buildutl.c:
  322. typedef enum _MemType {
  323. MT_TOTALS = 0,
  324. MT_UNKNOWN,
  325. MT_CHILDDATA,
  326. MT_CMDSTRING,
  327. MT_DIRDB,
  328. MT_DIRSUP,
  329. MT_DIRPATH,
  330. MT_DIRSTRING,
  331. MT_EVENTHANDLES,
  332. MT_FILEDB,
  333. MT_FILEREADBUF,
  334. MT_FRBSTRING,
  335. MT_INCLUDEDB,
  336. MT_IOBUFFER,
  337. MT_MACRO,
  338. MT_SOURCEDB,
  339. MT_TARGET,
  340. MT_THREADFILTER,
  341. MT_THREADHANDLES,
  342. MT_THREADSTATE,
  343. MT_INVALID = 255,
  344. } MemType;
  345. struct _THREADSTATE;
  346. typedef BOOL (*FILTERPROC)(struct _THREADSTATE *ThreadState, LPSTR p);
  347. typedef struct _THREADSTATE {
  348. USHORT cRowTotal;
  349. USHORT cColTotal;
  350. BOOL IsStdErrTty;
  351. FILE *ChildOutput;
  352. UINT ChildState;
  353. UINT ChildFlags;
  354. LPSTR ChildTarget;
  355. UINT LinesToIgnore;
  356. FILTERPROC FilterProc;
  357. ULONG ThreadIndex;
  358. CHAR UndefinedId[ DB_MAX_PATH_LENGTH ];
  359. CHAR ChildCurrentDirectory[ DB_MAX_PATH_LENGTH ];
  360. CHAR ChildCurrentFile[ DB_MAX_PATH_LENGTH ];
  361. DIRREC *CompileDirDB;
  362. } THREADSTATE, *PTHREADSTATE;
  363. //
  364. // Global Data (uninit will always be FALSE)
  365. //
  366. BOOL fUsage; // Set when usage message is to be displayed
  367. BOOL fStatus; // Set by -s and -S options
  368. BOOL fStatusTree; // Set by -S option
  369. BOOL fShowTree; // Set by -t and -T options
  370. BOOL fShowTreeIncludes; // Set by -T option
  371. BOOL fClean; // Set by -c option
  372. BOOL fCleanLibs; // Set by -C option
  373. BOOL fCleanRestart; // Set by -r option
  374. BOOL fRestartClean; // Set if -c and -r were both given
  375. BOOL fRestartCleanLibs; // Set if -C and -r were both given
  376. BOOL fPause; // Set by -p option
  377. BOOL fParallel; // Set on a multiprocessor machine or by -M
  378. BOOL fPrintElapsed; // Set by -P option
  379. BOOL fQuery; // Set by -q option
  380. BOOL fStopAfterPassZero; // Set by -0 option
  381. BOOL fQuicky; // Set by -z and -Z options
  382. BOOL fQuickZero; // Set by -3
  383. BOOL fSemiQuicky; // Set by -Z option
  384. BOOL fShowOutOfDateFiles; // Set by -o option
  385. BOOL fSyncLink; // Set by -a option
  386. BOOL fForce; // Set by -f option
  387. BOOL fEnableVersionCheck; // Set by -v option
  388. BOOL fSilent; // Set by -i option
  389. BOOL fKeep; // Set by -k option
  390. BOOL fCompileOnly; // Set by -L option
  391. BOOL fLinkOnly; // Set by -l option
  392. BOOL fErrorLog; // Set by -e option
  393. BOOL fGenerateObjectsDotMacOnly; // Set by -O option
  394. BOOL fShowWarningsOnScreen; // Set by -w option
  395. BOOL fNoisyScan; // Set by -y option
  396. BOOL fFullErrors; // Set by -b option
  397. BOOL fWhyBuild; // Set by -why option
  398. BOOL fChicagoProduct; // Set if CHICAGO_PRODUCT is set in environment
  399. BOOL fLineCleared; // Current line on screen clear?
  400. BOOL fPassZero; // Indicates we've found pass zero dirs
  401. BOOL fFirstScan; // Indicates this is the first scan
  402. BOOL fAlwaysPrintFullPath; // Set by -F option
  403. BOOL fTargetDirs; // Set by -g option
  404. BOOL fAlwaysKeepLogfile; // Set by -E option
  405. BOOL fShowUnusedDirs; // Set by -u option
  406. BOOL fCheckIncludePaths; // Set by -# option
  407. BOOL fNoThreadIndex; // Set by -I option
  408. BOOL fMTScriptSync; // Set when communicating with the MTScript engine
  409. #define MAX_INCLUDE_PATTERNS 32
  410. LPSTR AcceptableIncludePatternList[ MAX_INCLUDE_PATTERNS + 1 ];
  411. LPSTR UnacceptableIncludePatternList[ MAX_INCLUDE_PATTERNS + 1 ];
  412. LPSTR MakeProgram;
  413. char MakeParameters[ 512 ];
  414. LPSTR MakeParametersTail;
  415. char MakeTargets[ 256 ];
  416. char RestartDir[ 256 ];
  417. char NtRoot[ 256 ];
  418. char DbMasterName[ 256 ];
  419. extern const char szNewLine[];
  420. char *pszSdkLibDest;
  421. char *pszDdkLibDest;
  422. char *pszPublicInternalPath;
  423. char *pszIncOak;
  424. char *pszIncDdk;
  425. char *pszIncWdm;
  426. char *pszIncSdk;
  427. char *pszIncMfc;
  428. char *pszIncCrt;
  429. char *pszIncPri;
  430. char *pszIncOs2;
  431. char *pszIncPosix;
  432. char *pszIncChicago;
  433. char *szBuildTag;
  434. char *pszObjDir;
  435. char *pszObjDirSlash;
  436. char *pszObjDirSlashStar;
  437. BOOL fCheckedBuild;
  438. ULONG iObjectDir;
  439. extern ULONG NumberProcesses;
  440. CRITICAL_SECTION TTYCriticalSection;
  441. CHAR const *cmdexe;
  442. LONG TotalFilesToCompile;
  443. LONG TotalFilesCompiled;
  444. LONG TotalLinesToCompile;
  445. LONG TotalLinesCompiled;
  446. ULONG ElapsedCompileTime;
  447. DIRREC *CurrentCompileDirDB;
  448. // Fixed length arrays...
  449. UINT CountTargetMachines;
  450. TARGET_MACHINE_INFO *TargetMachines[MAX_TARGET_MACHINES];
  451. TARGET_MACHINE_INFO *PossibleTargetMachines[MAX_TARGET_MACHINES];
  452. TARGET_MACHINE_INFO i386TargetMachine;
  453. TARGET_MACHINE_INFO ia64TargetMachine;
  454. TARGET_MACHINE_INFO Amd64TargetMachine;
  455. UINT TargetToPossibleTarget[MAX_TARGET_MACHINES];
  456. #define MAX_OPTIONAL_DIRECTORIES 256
  457. UINT CountOptionalDirs;
  458. LPSTR OptionalDirs[MAX_OPTIONAL_DIRECTORIES];
  459. BOOLEAN OptionalDirsUsed[MAX_OPTIONAL_DIRECTORIES];
  460. BOOL BuildAllOptionalDirs;
  461. #define MAX_EXCLUDE_DIRECTORIES MAX_OPTIONAL_DIRECTORIES
  462. UINT CountExcludeDirs;
  463. LPSTR ExcludeDirs[MAX_EXCLUDE_DIRECTORIES];
  464. BOOLEAN ExcludeDirsUsed[MAX_OPTIONAL_DIRECTORIES];
  465. #define MAX_EXCLUDE_INCS 128
  466. UINT CountExcludeIncs;
  467. LPSTR ExcludeIncs[MAX_EXCLUDE_INCS];
  468. #define MAX_INCLUDE_DIRECTORIES 128
  469. UINT CountIncludeDirs;
  470. UINT CountSystemIncludeDirs;
  471. DIRREC *IncludeDirs[MAX_INCLUDE_DIRECTORIES];
  472. #define MAX_BUILD_DIRECTORIES 8192
  473. UINT CountPassZeroDirs;
  474. DIRREC *PassZeroDirs[MAX_BUILD_DIRECTORIES];
  475. UINT CountCompileDirs;
  476. DIRREC *CompileDirs[MAX_BUILD_DIRECTORIES];
  477. UINT CountLinkDirs;
  478. DIRREC *LinkDirs[MAX_BUILD_DIRECTORIES];
  479. UINT CountShowDirs;
  480. DIRREC *ShowDirs[MAX_BUILD_DIRECTORIES];
  481. DIRREC *AllDirs;
  482. CHAR CurrentDirectory[DB_MAX_PATH_LENGTH];
  483. BOOL AllDirsInitialized;
  484. BOOL AllDirsModified;
  485. USHORT GlobalSequence;
  486. USHORT LocalSequence;
  487. BOOLEAN fConsoleInitialized;
  488. DWORD NewConsoleMode;
  489. LPSTR BuildDefault;
  490. LPSTR BuildParameters;
  491. LPSTR SystemIncludeEnv;
  492. LPSTR LocalIncludeEnv;
  493. LPSTR BigBuf;
  494. UINT BigBufSize;
  495. UINT RecurseLevel;
  496. FILE *LogFile;
  497. FILE *WrnFile;
  498. FILE *ErrFile;
  499. FILE *IPGScriptFile;
  500. FILE *IncFile;
  501. EXTERN_C UINT NumberCompileWarnings;
  502. EXTERN_C UINT NumberCompileErrors;
  503. EXTERN_C UINT NumberCompiles;
  504. EXTERN_C UINT NumberLibraries;
  505. EXTERN_C UINT NumberLibraryWarnings;
  506. EXTERN_C UINT NumberLibraryErrors;
  507. EXTERN_C UINT NumberLinks;
  508. EXTERN_C UINT NumberLinkWarnings;
  509. EXTERN_C UINT NumberLinkErrors;
  510. EXTERN_C UINT NumberBinplaces;
  511. EXTERN_C UINT NumberBinplaceWarnings;
  512. EXTERN_C UINT NumberBinplaceErrors;
  513. char szAsterisks[];
  514. ULONG BuildStartTime;
  515. VOID ReportDirsUsage(VOID);
  516. VOID SetObjDir(BOOL fAlternate);
  517. //
  518. // Stuff defined in buildscr.cpp
  519. //
  520. typedef enum _PROC_EVENTS
  521. {
  522. PE_PASS0_COMPLETE = WM_USER,
  523. PE_PASS1_COMPLETE,
  524. PE_PASS2_COMPLETE,
  525. PE_EXIT
  526. } PROC_EVENTS;
  527. EXTERN_C HANDLE g_hMTThread;
  528. EXTERN_C HANDLE g_hMTEvent;
  529. EXTERN_C DWORD g_dwMTThreadId;
  530. EXTERN_C DWORD WINAPI MTScriptThread(LPVOID pv);
  531. EXTERN_C void WaitForResume(BOOL fPause, PROC_EVENTS pe);
  532. EXTERN_C void ExitMTScriptThread();
  533. //
  534. // Data Base functions defined in builddb.c
  535. //
  536. PDIRREC
  537. LoadDirDB(LPSTR DirName);
  538. #if DBG
  539. VOID
  540. PrintAllDirs(VOID);
  541. #endif
  542. VOID
  543. PrintSourceDBList(SOURCEREC *psr, int i);
  544. VOID
  545. PrintFileDB(FILE *pf, FILEREC *pfr, int DetailLevel);
  546. VOID
  547. PrintDirDB(DIRREC *pdr, int DetailLevel);
  548. FILEREC *
  549. FindSourceFileDB(DIRREC *pdr, LPSTR pszRelPath, DIRREC **ppdr);
  550. DIRREC *
  551. FindSourceDirDB(
  552. LPSTR pszDir, // directory
  553. LPSTR pszRelPath, // relative path
  554. BOOL fTruncateFileName); // TRUE: drop last component of path
  555. SOURCEREC *
  556. FindSourceDB(
  557. SOURCEREC *psr,
  558. FILEREC *pfr);
  559. SOURCEREC *
  560. InsertSourceDB(
  561. SOURCEREC **ppsrNext,
  562. FILEREC *pfr,
  563. UCHAR SubDirMask,
  564. UCHAR SrcFlags);
  565. VOID
  566. FreeSourceDB(SOURCEREC **ppsr);
  567. VOID
  568. UnsnapIncludeFiles(FILEREC *pfr, BOOL fUnsnapGlobal);
  569. VOID
  570. UnsnapAllDirectories(VOID);
  571. VOID
  572. FreeAllDirs(VOID);
  573. PFILEREC
  574. LookupFileDB(
  575. PDIRREC DirDB,
  576. LPSTR FileName);
  577. PFILEREC
  578. InsertFileDB(
  579. PDIRREC DirDB,
  580. LPSTR FileName,
  581. ULONG DateTime,
  582. USHORT Attr,
  583. ULONG FileFlags);
  584. VOID
  585. DeleteUnscannedFiles(PDIRREC DirDB);
  586. PINCLUDEREC
  587. InsertIncludeDB(
  588. PFILEREC FileDB,
  589. LPSTR IncludeFileName,
  590. USHORT IncFlags);
  591. VOID
  592. LinkToCycleRoot(INCLUDEREC *pir, FILEREC *pfrRoot);
  593. VOID
  594. RemoveFromCycleRoot(INCLUDEREC *pir, FILEREC *pfrRoot);
  595. VOID
  596. MergeIncludeFiles(FILEREC *pfr, INCLUDEREC *pirList, FILEREC *pfrRoot);
  597. VOID
  598. MarkIncludeFileRecords(PFILEREC FileDB);
  599. VOID
  600. DeleteIncludeFileRecords(PFILEREC FileDB);
  601. PFILEREC
  602. FindIncludeFileDB(
  603. FILEREC *pfrSource,
  604. FILEREC *pfrCompiland,
  605. DIRREC *pdrBuild,
  606. LPSTR pszSourceDirectory,
  607. INCLUDEREC *IncludeDB);
  608. BOOL
  609. SaveMasterDB(VOID);
  610. void
  611. LoadMasterDB(VOID);
  612. PDIRREC
  613. LoadMasterDirDB(LPSTR s);
  614. PFILEREC
  615. LoadMasterFileDB(LPSTR s);
  616. PINCLUDEREC
  617. LoadMasterIncludeDB(LPSTR s);
  618. //
  619. // Scanning functions defined in buildscn.c
  620. //
  621. VOID
  622. AddIncludeDir(DIRREC *pdr, UINT *pui);
  623. VOID
  624. AddShowDir(DIRREC *pdr);
  625. VOID
  626. ScanGlobalIncludeDirectory(LPSTR path);
  627. VOID
  628. ScanIncludeEnv(LPSTR IncludeEnv);
  629. PDIRREC
  630. ScanDirectory(LPSTR DirName);
  631. BOOL
  632. ScanFile(PFILEREC FileDB);
  633. //
  634. // Functions defined in buildmak.c
  635. //
  636. VOID
  637. ScanSourceDirectories(LPSTR DirName);
  638. VOID
  639. CompilePassZeroDirectories(VOID);
  640. VOID
  641. CompileSourceDirectories(VOID);
  642. VOID
  643. LinkSourceDirectories(VOID);
  644. VOID
  645. FreeDirSupData(DIRSUP *pds);
  646. VOID
  647. FreeDirData(DIRREC *pdr);
  648. BOOL
  649. CheckDependencies(
  650. PTARGET Target,
  651. FILEREC *FileDB,
  652. BOOL CheckDate,
  653. FILEREC **ppFileDBRoot);
  654. BOOL
  655. CreateBuildDirectory(LPSTR Name);
  656. VOID
  657. CreatedBuildFile(LPSTR DirName, LPSTR FileName);
  658. VOID
  659. GenerateObjectsDotMac(DIRREC *DirDB, DIRSUP *pds, ULONG DateTimeSources);
  660. VOID
  661. ExpandObjAsterisk(
  662. LPSTR pbuf,
  663. LPSTR pszpath,
  664. LPSTR *ppszObjectDirectory);
  665. //
  666. // Build -# functions defined in buildinc.c
  667. //
  668. LPCTSTR
  669. FindCountedSequenceInString(
  670. IN LPCTSTR String,
  671. IN LPCTSTR Sequence,
  672. IN DWORD Length);
  673. BOOL
  674. DoesInstanceMatchPattern(
  675. IN LPCTSTR Instance,
  676. IN LPCTSTR Pattern);
  677. LPSTR
  678. CombinePaths(
  679. IN LPCSTR ParentPath,
  680. IN LPCSTR ChildPath,
  681. OUT LPSTR TargetPath);
  682. VOID
  683. CreateRelativePath(
  684. IN LPCSTR SourceAbsName,
  685. IN LPCSTR TargetAbsName,
  686. OUT LPSTR RelativePath);
  687. BOOL
  688. ShouldWarnInclude(
  689. IN LPCSTR CompilandFullName,
  690. IN LPCSTR IncludeeFullName);
  691. VOID
  692. CheckIncludeForWarning(
  693. IN LPCSTR CompilandDir,
  694. IN LPCSTR CompilandName,
  695. IN LPCSTR IncluderDir,
  696. IN LPCSTR IncluderName,
  697. IN LPCSTR IncludeeDir,
  698. IN LPCSTR IncludeeName);
  699. //
  700. // Utility functions defined in buildutl.c
  701. //
  702. VOID
  703. AllocMem(UINT cb, VOID **ppv, MemType mt);
  704. VOID
  705. FreeMem(VOID **ppv, MemType mt);
  706. VOID
  707. ReportMemoryUsage(VOID);
  708. BOOL
  709. MyOpenFile(
  710. LPSTR DirName,
  711. LPSTR FileName,
  712. LPSTR Access,
  713. FILE **Stream,
  714. BOOL fBufferedIO);
  715. BOOL
  716. OpenFilePush(
  717. LPSTR pszdir,
  718. LPSTR pszfile,
  719. LPSTR pszCommentToEOL,
  720. FILE **ppf
  721. );
  722. BOOL
  723. SetupReadFile(LPSTR pszdir, LPSTR pszfile, LPSTR pszCommentToEOL,
  724. FILE **ppf);
  725. ULONG
  726. CloseReadFile(UINT *pcline);
  727. LPSTR
  728. ReadLine(FILE *pf);
  729. UINT
  730. ProbeFile(
  731. LPSTR DirName,
  732. LPSTR FileName);
  733. BOOL
  734. EnsureDirectoriesExist(
  735. LPSTR DirName);
  736. ULONG
  737. DateTimeFile(
  738. LPSTR DirName,
  739. LPSTR FileName);
  740. ULONG
  741. DateTimeFile2(
  742. LPSTR DirName,
  743. LPSTR FileName);
  744. ULONG (*pDateTimeFile)(LPSTR, LPSTR);
  745. BOOL (WINAPI * pGetFileAttributesExA)(LPCSTR, GET_FILEEX_INFO_LEVELS, LPVOID);
  746. BOOL
  747. DeleteSingleFile(
  748. LPSTR DirName,
  749. LPSTR FileName,
  750. BOOL QuietFlag);
  751. BOOL
  752. DeleteMultipleFiles(
  753. LPSTR DirName,
  754. LPSTR FilePattern);
  755. BOOL
  756. CloseOrDeleteFile(
  757. FILE **Stream,
  758. LPSTR DirName,
  759. LPSTR FileName,
  760. ULONG SizeThreshold);
  761. LPSTR
  762. PushCurrentDirectory(LPSTR NewCurrentDirectory);
  763. VOID
  764. PopCurrentDirectory(LPSTR OldCurrentDirectory);
  765. UINT
  766. ExecuteProgram(
  767. LPSTR ProgramName,
  768. LPSTR CommandLine,
  769. LPSTR MoreCommandLine,
  770. BOOL MustBeSynchronous);
  771. VOID
  772. WaitForParallelThreads(VOID);
  773. BOOL
  774. CanonicalizePathName(
  775. LPSTR SourcePath,
  776. UINT Action,
  777. LPSTR FullPath);
  778. #define CANONICALIZE_ONLY 0
  779. #define CANONICALIZE_FILE 1
  780. #define CANONICALIZE_DIR 2
  781. LPSTR
  782. FormatPathName(
  783. LPSTR DirName,
  784. LPSTR FileName);
  785. #if DBG
  786. VOID
  787. AssertPathString(LPSTR pszPath);
  788. #else
  789. #define AssertPathString(p)
  790. #endif
  791. LPSTR
  792. AppendString(
  793. LPSTR Destination,
  794. LPSTR Source,
  795. BOOL PrefixWithSpace);
  796. LPSTR CopyString(LPSTR Destination, LPSTR Source, BOOL fPath);
  797. VOID MakeString(LPSTR *Destination, LPSTR Source, BOOL fPath, MemType mt);
  798. VOID MakeExpandedString(LPSTR *Destination, LPSTR Source);
  799. VOID FreeString(LPSTR *Source, MemType mt);
  800. LPSTR FormatNumber(ULONG Number);
  801. LPSTR FormatTime(ULONG Seconds);
  802. BOOL AToX(LPSTR *pp, ULONG *pul);
  803. BOOL AToD(LPSTR *pp, ULONG *pul);
  804. EXTERN_C VOID __cdecl LogMsg(const char *pszfmt, ...);
  805. EXTERN_C VOID __cdecl BuildMsg(const char *pszfmt, ...);
  806. VOID __cdecl BuildMsgRaw(const char *pszfmt, ...);
  807. VOID __cdecl BuildError(const char *pszfmt, ...);
  808. EXTERN_C VOID __cdecl BuildErrorRaw(const char *pszfmt, ...);
  809. //
  810. // Functions in buildsrc.c
  811. //
  812. VOID
  813. StartElapsedTime(VOID);
  814. VOID
  815. PrintElapsedTime(VOID);
  816. BOOL
  817. ReadDirsFile(DIRREC *DirDB);
  818. VOID
  819. ProcessLinkTargets(PDIRREC DirDB, LPSTR CurrentDirectory);
  820. BOOL
  821. SplitToken(LPSTR pbuf, char chsep, LPSTR *ppstr);
  822. BOOL
  823. MakeMacroString(LPSTR *pp, LPSTR p);
  824. VOID
  825. SaveMacro(LPSTR pszName, LPSTR pszValue);
  826. VOID
  827. FormatLinkTarget(
  828. LPSTR path,
  829. LPSTR *ObjectDirectory,
  830. LPSTR TargetPath,
  831. LPSTR TargetName,
  832. LPSTR TargetExt);
  833. BOOL
  834. ReadSourcesFile(DIRREC *DirDB, DIRSUP *pds, ULONG *pDateTimeSources);
  835. VOID
  836. PostProcessSources(DIRREC *pdr, DIRSUP *pds);
  837. VOID
  838. PrintDirSupData(DIRSUP *pds);
  839. //+---------------------------------------------------------------------------
  840. //
  841. // Function: IsFullPath
  842. //
  843. //----------------------------------------------------------------------------
  844. __inline BOOL
  845. IsFullPath(char *pszfile)
  846. {
  847. return(pszfile[0] == '\\' || (isalpha(pszfile[0]) && pszfile[1] == ':'));
  848. }