home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lrcs30.zip / examples.zip / LARCBLD1.BAT < prev    next >
DOS Batch File  |  1994-05-15  |  17KB  |  405 lines

  1. @ECHO OFF
  2. REM ============================================================================
  3. REM 
  4. REM LARC-S "LARC Examples"
  5. REM LARC-D "Example Windows-based Release Build File"
  6. REM LARC-V "100"
  7. REM
  8. REM Revision history:
  9. REM kbg 05/14/94 100 - Created.
  10. REM
  11. REM Some general notes about this file follows.
  12. REM
  13. REM This batch file is started by LARC and LARC passes the following parameters:
  14. REM 
  15. REM     %1 = Argument 1 contains the 8 character release identifier that you
  16. REM         entered when you started building the release.
  17. REM
  18. REM     %2 = Argument 2 contains the release build type that you selected:
  19. REM
  20. REM        "*" = full system build requested.
  21. REM        "T" = test build requested.
  22. REM        "1" thru "5" = individual test build requested.
  23. REM
  24. REM     %3 = Argument 3 contains the two character hard drive name (i.e., "C:").
  25. REM
  26. REM     %4 = Argument 4 contains source file directory name (i.e., "C:\LARCEMP").
  27. REM
  28. REM     %5 = Argument 5 contains release directory name (i.e., "C:\LARCREL").
  29. REM
  30. REM     %6 = Argument 6 contains current system date formatted as mm-dd-yy.
  31. REM
  32. REM     %7 = Argument 7 contains current system time formatted as hh:mm:ss.
  33. REM
  34. REM     %8 = Argument 8 contains the three character source library number.
  35. REM         This number can be used with LARC utility programs such as
  36. REM         GETLARC to extract file information from LARC libraries.
  37. REM
  38. REM     %9 = Argument 9 contains the same release identifier that is passed in
  39. REM         argument 1, but this one has certain characters (such as "V",
  40. REM         and "." removed.  This argument provides the release identifier in
  41. REM          a format that can be used to create file names.
  42. REM
  43. REM LARC allows you complete freedom over how your product is built.  Since
  44. REM LARC executes this standard DOS command batch file, you can use any
  45. REM combination of system commands to build the release.  The only requirement
  46. REM made by LARC is that you must create the file named BUILDFIN.CTL if you
  47. REM believe the build completed successfully.
  48. REM
  49. REM Normally, ECHO OFF is set to keep things like REM lines from being
  50. REM scrolled up the screen.  Then ECHO commands are used to display progress
  51. REM messages.  In addition, piping information to a "build progress" file
  52. REM allows you to retain a record of the build for later inspection.  This
  53. REM example pipes information to a file named MAKE.OUT.
  54. REM
  55. REM Not all development tools support piping, so some information may not get
  56. REM saved.  You will need test your tools to determine if useful information
  57. REM is saved if piping is used.
  58. REM
  59. REM Notice also that you should test DOS ERRORLEVEL after issuing commands
  60. REM whenever possible.  The "GOTO ERRxx" statements allow the build command file
  61. REM to terminate whenever an error is detected.  The error can then be resolved
  62. REM and the build restarted.  Not all tools (especially older ones) set
  63. REM ERRORLEVEL.  If your tool does not set ERRORLEVEL, you will need to use
  64. REM other methods to ensure that the command completed successfully.  For
  65. REM example, if your compiler only creates the object file if no errors are
  66. REM encountered, then you should perform an "IF EXIST" test on the OBJ file.
  67. REM ============================================================================
  68.  
  69.  
  70.  
  71.  
  72. REM ============================================================================
  73. REM The following set of ECHO commands demonstrates the idea of displaying
  74. REM information to the screen and piping the same information to the build
  75. REM progress file MAKE.OUT.  Notice that the first pipe command uses the ">"
  76. REM character which causes the file to be created.  Since LARC always clears
  77. REM the release directory, you could always use the ">>" characters because the
  78. REM file will be created if it does not exist.
  79. REM ============================================================================
  80. ECHO.
  81. ECHO LARC Examples %1 [%2]
  82. ECHO.
  83. ECHO Build created %6 at %7
  84. ECHO.
  85.  
  86. ECHO.>MAKE.OUT
  87. ECHO>>MAKE.OUT LARC Examples %1 [%2]
  88. ECHO.>>MAKE.OUT
  89. ECHO>>MAKE.OUT Build created %6 at %7
  90. ECHO.>>MAKE.OUT
  91.  
  92.  
  93.  
  94.  
  95. REM ============================================================================
  96. REM The next series of SET commands are used to set the environment needed
  97. REM by your development tools in order to build your product.  Ken's Environment
  98. REM Verification utility program is used to make sure that the SET command
  99. REM actually worked.
  100. REM
  101. REM Depending on the number of environment setting you need to make, you may
  102. REM need to increase your space size.  Do this by using the "/E:xxxx" parameter
  103. REM on the SHELL statement in your CONFIG.SYS file.  For example, using:
  104. REM
  105. REM    SHELL=C:\DOS\COMMAND.COM /P /E:2048
  106. REM
  107. REM will assign 2,048 bytes for the environment space.
  108. REM
  109. REM Once other consideration is that you may have to include dummy SET
  110. REM statements in your AUTOEXEC.BAT file in order to reserve room for them in
  111. REM the initial environment region.
  112. REM
  113. REM The following lines set the environment variables so that the Microsoft
  114. REM Visual C/C++ 1.5 compiler can be used.
  115. REM ============================================================================
  116.  
  117. SET PATH=
  118. SET PATH=C:\MSVC\BIN;C:\SDK\BIN;C:\DOS;C:\WINDOWS;C:\LARC3;
  119. KVERENV PATH=C:\MSVC\BIN;C:\SDK\BIN;C:\DOS;C:\WINDOWS;C:\LARC3;
  120. IF ERRORLEVEL 1 GOTO ERR00
  121.  
  122. SET LIB=
  123. SET LIB=C:\MSVC\LIB;C:\SDK\LIB;
  124. KVERENV LIB=C:\MSVC\LIB;C:\SDK\LIB;
  125. IF ERRORLEVEL 1 GOTO ERR00
  126.  
  127. SET INCLUDE=
  128. SET INCLUDE=C:\MSVC\INCLUDE;C:\SDK\INCLUDE;C:\LARCSRC\EXAMPLES
  129. KVERENV INCLUDE=C:\MSVC\INCLUDE;C:\SDK\INCLUDE;C:\LARCSRC\EXAMPLES
  130. IF ERRORLEVEL 1 GOTO ERR00
  131.  
  132. SET TMP=
  133. SET TMP=C:\MSVC
  134. KVERENV TMP=C:\MSVC
  135. IF ERRORLEVEL 1 GOTO ERR00
  136.  
  137.  
  138.  
  139.  
  140. REM ============================================================================
  141. REM It's a good idea to pipe the current environment setting into the MAKE.OUT
  142. REM file.  The environment settings may come in handy either in investigating
  143. REM any build problems, or for support when your system finally becomes one of
  144. REM those dreaded "legacy systems".  Notice that the settings are displayed and
  145. REM piped to the MAKE.OUT file.
  146. REM ============================================================================
  147. SET
  148. SET >>MAKE.OUT
  149.  
  150.  
  151.  
  152.  
  153. REM ============================================================================
  154. REM This example builds a Windows-based program using the Microsoft Visual C/C++
  155. REM version 1.5 compiler.  To keep things simple, the source files that we will
  156. REM compile will be copied from the LARC source library into the release
  157. REM library, NMAKE will be executed, then the sources will be removed from the
  158. REM directory when the build completes.  While it may be possible to compile
  159. REM straight from the source library, some compilers, like MSVC, put the object
  160. REM files they create in the directory specified when with the source file name.
  161. REM So, copying the sources into the release directory keeps the source library 
  162. REM free of files that are not controlled by LARC.
  163. REM 
  164. REM Also, since you are likely to copy and check the files out of LARC into a
  165. REM single local working directory, using this method allows you use a single
  166. REM make file for your development work and for the LARC builds.
  167. REM
  168. REM Here you issue the commands necessary to copy the file from the LARC source
  169. REM library.  You do not need to specify a destination directory because LARC
  170. REM has already established the default to be the release directory.
  171. REM
  172. REM If you keep your sources in compressed libraries, you will need to issue
  173. REM the PKUNZIP command instead of the DOS copy command.  If the example
  174. REM sources were in a compressed library, you would use:
  175. REM    
  176. REM    PKUNZIP C:\LARCEMP\LARCEMP.ZIP
  177. REM    IF ERRORLEVEL 1 GOTO ERR03
  178. REM
  179. REM If you really want to control things, you can copy each file individual,
  180. REM then issue an "IF EXISTS" statement to ensure that it was successfully
  181. REM copied.  However, this isn't really necessary because the compiler and linker
  182. REM should complain if a file was missed.
  183. REM ============================================================================
  184. COPY %4\*.* *.* > NUL:
  185.  
  186.  
  187.  
  188.  
  189. REM ============================================================================
  190. REM Next a special C/C++ include file is created that contains some of the build
  191. REM information provided by LARC.  "szVersion" contains the release identifier
  192. REM that you entered which LARC passes in as the first argument to this build
  193. REM command file.  "szBuildType" contains the type of build that you requested
  194. REM which LARC passes in as the second argument to this build command file.
  195. REM ============================================================================
  196.  
  197. ECHO>RELEASE.H //
  198. ECHO>>RELEASE.H // LARC Example %1
  199. ECHO>>RELEASE.H // Release Version Include File
  200. ECHO>>RELEASE.H //
  201. ECHO>>RELEASE.H     char    *szVersion = "%1";         // Current Version
  202. ECHO>>RELEASE.H     char    *szBuildType = "%2";       // Build Type
  203.  
  204.  
  205.  
  206.  
  207. REM ============================================================================
  208. REM Now the actual build commands will be issued.
  209. REM
  210. REM This example uses the NMAKE utility provided with the Microsoft Visual 
  211. REM C/C++ 1.5 to make the program.
  212. REM ============================================================================
  213.  
  214. NMAKE -S -f LHELLO.MAK >>MAKE.OUT
  215. IF ERRORLEVEL 1 GOTO ERR04
  216.  
  217.  
  218.  
  219.  
  220. REM ============================================================================
  221. REM Because NMAKE doesn't always return specific failure codes, we'll check for
  222. REM the existence of the LHELLO.EXE.  For this to work, you will need to set
  223. REM your compiler so that object modules are not created if errors are
  224. REM encountered.  Likewise, set you linker so that executables are not produced
  225. REM if errors are encountered.
  226. REM ============================================================================
  227. IF NOT EXIST LHELLO.EXE GOTO ERR05
  228.  
  229.  
  230.  
  231.  
  232. REM ============================================================================
  233. REM You might want to compress and save your *.MAP and *.OBJ files.  They might
  234. REM come in handy in the future if a user encounters a problem that requires
  235. REM you to do some low-level tracing.  Depending on the environment for which
  236. REM you are developing, you may also want to save other files, such as debug
  237. REM information files.
  238. REM ============================================================================
  239. PKZIP BLDSTUFF.ZIP *.MAP *.OBJ
  240. IF ERRORLEVEL 1 GOTO ERR06
  241.  
  242.  
  243.  
  244. REM ============================================================================
  245. REM Now get ride of any temporary build files that were created.  This step
  246. REM is useful keeping you disk space usage to a minimum.  Notice that we delete
  247. REM the copy of all of the files that were copied from the source library
  248. REM because we don't need them on the system twice!
  249. REM
  250. REM If you are building more than one program and you keep your sources in
  251. REM separate libraries, you might consider creating a CLEANUP.BAT file that
  252. REM you can CALL after each build.
  253. REM ============================================================================
  254. IF EXIST *.ASM DEL *.ASM >NUL
  255. IF EXIST *.BAT DEL *.BAT >NUL
  256. IF EXIST *.BMP DEL *.BMP >NUL
  257. IF EXIST *.C   DEL *.C   >NUL
  258. IF EXIST *.CUR DEL *.CUR >NUL
  259. IF EXIST *.CUT DEL *.CUT >NUL
  260. IF EXIST *.CV  DEL *.CV  >NUL
  261. IF EXIST *.DAT DEL *.DAT >NUL
  262. IF EXIST *.DEF DEL *.DEF >NUL
  263. IF EXIST *.DLG DEL *.DLG >NUL
  264. IF EXIST *.FNC DEL *.FNC >NUL
  265. IF EXIST *.H   DEL *.H   >NUL
  266. IF EXIST *.HH  DEL *.HH  >NUL
  267. IF EXIST *.ICO DEL *.ICO >NUL
  268. IF EXIST *.LNK DEL *.LNK >NUL
  269. IF EXIST *.MAK DEL *.MAK >NUL
  270. IF EXIST *.MAP DEL *.MAP >NUL
  271. IF EXIST *.NCV DEL *.NCV >NUL
  272. IF EXIST *.OBJ DEL *.OBJ >NUL
  273. IF EXIST *.P   DEL *.P   >NUL
  274. IF EXIST *.PDB DEL *.PDB >NUL
  275. IF EXIST *.RES DEL *.RES >NUL
  276. IF EXIST *.RC  DEL *.RC  >NUL
  277.  
  278.  
  279.  
  280.  
  281. REM ============================================================================
  282. REM The second argument (%2) is tested.  If this is not a final ("*") build,
  283. REM then you might want to create a test build backup.  You define the tool and
  284. REM directory used for this backup.
  285. REM
  286. REM Note that final releases are always archived because LARC will automatically
  287. REM execute the LARCARC.BAT command file if the build completes successfully.
  288. REM ============================================================================
  289.  
  290. IF %2 == * GOTO SKIP-BACKUP
  291.  
  292. MD C:\LARCBACK > NUL:
  293.  
  294. ECHO.
  295. ECHO Creating backup ZIP file...
  296. ECHO>>MAKE.OUT Creating backup ZIP file...
  297. PKZIP -ES -P -R -U C:\LARCBACK\%9.ZIP C:\LARCSRC\*.*
  298.  
  299. :SKIP-BACKUP
  300.  
  301.  
  302.  
  303.  
  304. REM ============================================================================
  305. REM It's a good idea to pipe the contents of this directory, plus any other
  306. REM backup directories you created in the previous step, into the MAKE.OUT file.
  307. REM Again, this listing might come in handy as you are initially creating and
  308. REM debugging the build files.
  309. REM ============================================================================
  310.  
  311. ECHO>>MAKE.OUT ==================== LISTING OF BACKUP DIRECTORY FILES ====================
  312. DIR C:\LARCBACK\*.* >>MAKE.OUT
  313.  
  314. ECHO>>MAKE.OUT ==================== LIST OF RELEASE DIRECTORY FILES ====================
  315. DIR *.* >>MAKE.OUT
  316.  
  317.  
  318.  
  319.  
  320. REM ============================================================================
  321. REM If we made it here, then the build completed sucessfully.  LARC expects
  322. REM the BUILDFIN.CTL file to be created only if the build completes with no
  323. REM (detectable) errors.  LARC also expects the BUILDFIN.CTL file to contain
  324. REM the date, time, build type and release identifier.  You use the arguments
  325. REM provided by LARC to create the file, then jump past the error labels to
  326. REM the end of the file (i.e. "GOTO DONE").
  327. REM ============================================================================
  328. ECHO.>>MAKE.OUT
  329. ECHO>>MAKE.OUT ==================== BUILD COMPLETED ====================
  330. ECHO %6%7%2%1 >BUILDFIN.CTL
  331.  
  332. GOTO DONE
  333.  
  334.  
  335.  
  336.  
  337. REM ============================================================================
  338. REM Here is the start of the error message labels that you "GOTO" whenever a
  339. REM build error is detected.  Make sure that you do not create the BUILDFIN.CTL
  340. REM file if you jump to one of these error message labels.  If the BUILDFIN.CTL
  341. REM file is NOT created, then LARC will not record the release identifier, and
  342. REM will can resolve the problem and rebuild the release.
  343. REM
  344. REM You can be as elaborate with error messages as you like, but it is highly
  345. REM recommended that you pipe them into a build progress (MAKE.OUT) file.
  346. REM ============================================================================
  347. :ERR00
  348. ECHO.>>MAKE.OUT
  349. ECHO>>MAKE.OUT *** Error: Failed to properly set environment string
  350. GOTO TERMINATE
  351.  
  352. :ERR01
  353. ECHO.>>MAKE.OUT
  354. ECHO>>MAKE.OUT *** Error: Source file missing
  355. GOTO TERMINATE
  356.  
  357. :ERR02
  358. ECHO.>>MAKE.OUT
  359. ECHO>>MAKE.OUT *** Error: LINK failed
  360. GOTO TERMINATE
  361.  
  362. :ERR03
  363. ECHO.>>MAKE.OUT
  364. ECHO>>MAKE.OUT *** Error: Failed to unzip the source library
  365. GOTO TERMINATE
  366.  
  367. :ERR04
  368. ECHO.>>MAKE.OUT
  369. ECHO>>MAKE.OUT *** Error: NMAKE failed
  370. GOTO TERMINATE
  371.  
  372. :ERR05
  373. ECHO.>>MAKE.OUT
  374. ECHO>>MAKE.OUT *** Error: One (or more) components failed to build
  375. GOTO TERMINATE
  376.  
  377. :ERR06
  378. ECHO.>>MAKE.OUT
  379. ECHO>>MAKE.OUT *** Error: File zip failed
  380. GOTO TERMINATE
  381.  
  382. :TERMINATE
  383. ECHO.>>MAKE.OUT
  384. ECHO>>MAKE.OUT ******************************************************
  385. ECHO>>MAKE.OUT ******************** BUILD FAILED ********************
  386. ECHO>>MAKE.OUT ******************************************************
  387.  
  388.  
  389.  
  390.  
  391. REM ============================================================================
  392. REM Finally, we make it to the end of the build file.  Notice that the second
  393. REM argument (the build type) is tested.  If this was a final build, then the
  394. REM MAKE.OUT file will be printed.  It is recommended that the printed MAKE.OUT
  395. REM files be stored along with the full build archives.
  396. REM
  397. REM If this was a test build, them the MAKE.OUT file will not be printed.  It is
  398. REM assumed that many more test builds will be produced and it is not really
  399. REM necessary to waste printer paper on test build results.  The MAKE.OUT file
  400. REM can be always be inspected or manually printed if a test build error is
  401. REM encountered.
  402. REM ============================================================================
  403. :DONE
  404. IF %2 == * PRINT MAKE.OUT
  405.