home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pwrgu2.zip / POWERGU2.EXE / GUIBUILD.CMD next >
OS/2 REXX Batch file  |  1995-07-21  |  9KB  |  254 lines

  1. /*---------------------------------------------------------*/
  2. /* UIBUILD                                                 */
  3. /*                                                         */
  4. /* A Mom and Pop exec to generate and cleanup the examples */
  5. /* for Power GUI Programming by Law, Leong, Love, Olson,   */
  6. /* and Tsuji. This exec must exist in the root samples     */
  7. /* directory.                                              */
  8. /*                                                         */
  9. /* Invocation:                                             */
  10. /*  guibuild <logFileName> ( <Options>                     */
  11. /*                                                         */
  12. /*   logFileName - The redirection file for commands       */
  13. /*   Options                                               */
  14. /*       none     - All program make files are run.        */
  15. /*       CLEAN    - All .OBJ .RES .HLP .I files deleted.   */
  16. /*       CLEANALL - .EXE and CLEAN files deleted.          */
  17. /*       RUNALL   - All executable programs are run.       */
  18. /*                                                         */
  19. /* Examples:                                               */
  20. /* 1) To build all programs and have output put into the   */
  21. /*    default log file, GUIBUILD.LOG, in the directory you */
  22. /*    start the exec:                                      */
  23. /*                                                         */
  24. /*       guibuild                                          */
  25. /*                                                         */
  26. /* 2) To erase all OBJs, RESs, HLPs, and INFs, but keep    */
  27. /*    the EXEs.                                            */
  28. /*                                                         */
  29. /*       guibuild (clean                                   */
  30. /*                                                         */
  31. /*                                                         */
  32. /*---------------------------------------------------------*/
  33. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  34. call SysLoadFuncs
  35.  
  36.  
  37. /* Save the program name.*/
  38. parse upper source . . uibuildName  .
  39.  
  40. /* Save the options */
  41. parse upper arg outFile '(' optionsUpper
  42.  
  43. /* Setup to restore the environment */
  44. n = setlocal()
  45.  
  46. /* Save the root directory */
  47. currentLocation = directory()
  48. startLocation = currentLocation
  49.  
  50. /* Determine the options specified  */
  51. /* Note: clean leaves the EXE/DLL, cleanAll removes the EXE/DLL as well */
  52. /*       If clean specified we don't do the make */
  53. clean       = pos("CLEAN", optionsUpper)
  54. cleanAll    = pos("CLEANALL", optionsUpper)
  55. cleanToShip = pos("CLEANTOSHIP", optionsUpper)
  56. runAll      = pos("RUNALL", optionsUpper)
  57. run         = pos("RUN", optionsUpper)
  58.  
  59. /* Establish the chapter names */
  60. chapters. = 0
  61. chapters.1  = "Getting Started"
  62. chapters.2  = "Object-Oriented User Interface Fundamentals"
  63. chapters.3  = "Tour of the User Interface Library"
  64. chapters.4  = "Windows, Handlers, and Events"
  65. chapters.5  = "Frame Window Basics"
  66. chapters.6  = "Menus and Keyboard Accelerators"
  67. chapters.7  = "Controls"
  68. chapters.8  = "Static Controls"
  69. chapters.9  = "Edit Controls"
  70. chapters.10 = "Button Controls"
  71. chapters.11 = "List Controls"
  72. chapters.12 = "Slider"
  73. chapters.13 = "Container"
  74. chapters.14 = "Notebook"
  75. chapters.15 = "Canvases"
  76. chapters.16 = "Reusable Handlers"
  77. chapters.17 = "Advanced Frame Window Topics"
  78. chapters.18 = "Custom Controls and Handlers"
  79. chapters.19 = "Applications and Threads"
  80. chapters.20 = "Direct Manipulation"
  81. chapters.21 = "Dynamic Data Exchange"
  82. chapters.22 = "Using Help"
  83. chapters.23 = "Using OS/2 Resources"
  84. chapters.24 = "Storing Data in a Profile"
  85. chapters.25 = "Data Types"
  86. chapters.26 = "Error Handling and Reporting"
  87. chapters.27 = "Problem Determination"
  88. chapters.28 = "Packaging and Performance Tuning"
  89.  
  90. makeErrorList. = ''
  91. makeErrorList.0 = 0
  92.  
  93.  
  94. /* Make sure we have a path to the log file since */
  95. /* we execute commands in multiple directories.   */
  96. /* If you don't specify the directory, it goes to */
  97. /* the current directory.                         */
  98. if outFile = "" then
  99.   outFile = currentLocation||"\guibuild.log"
  100. else do
  101.   if pos('\', outFile) = 0 then
  102.      outFile = currentLocation||"\"||outFile
  103. end
  104.  
  105. /* Determine the root samples directory and proceed   */
  106. /* there to start the work,                           */
  107. lastBackSlash = lastpos('\', uibuildName)
  108. uibuildPath = substr(uibuildName, 1, lastBackSlash-1)
  109. currentLocation = directory(uiBuildPath)
  110.  
  111. /* Name the file containing the list of samples.  */
  112. /* This file is installed in the samples root and */
  113. /* we assume it stays there.                      */
  114. sampleListFile = uibuildPath||'\powergui.lst'
  115. sampleList. = ''
  116.  
  117. '@echo Output written to file ' translate(outFile) '> CON'
  118. '@echo -------------------------------------------------------------> CON'
  119. /* Reset the output log */
  120. '@echo Started on' date() 'at' time() '> ' outFile
  121.  
  122.  
  123.  
  124. purgeList = ''
  125. purgeDesc = ''
  126. purge = 0
  127. if clean > 0 then do
  128.   purgeList = '*.RES *.OBJ *.I *.PCH'
  129.   purgeDesc = 'Purging generated files (except EXE/DLL)'
  130.   purge = 1
  131. end
  132.  
  133. if cleanAll > 0 then do
  134.   purgeList = purgeList '*.EXE *.DLL'
  135.   purgeDesc = 'Purging generated files (including EXE/DLL)'
  136. end
  137.  
  138. if cleanToShip > 0 then do
  139.   purgeList = purgeList '*ERR *.LAS *.RAM *.BAK *.ZIP *.TRC'
  140.   purgeDesc = 'Purging files '
  141. end
  142.  
  143.  
  144.  
  145.  
  146. lastChapter=0
  147. chapter=0
  148. if stream(sampleListFile,'C','QUERY EXIST')<>'' then
  149.  do
  150.    /* If only run (and not runAll is specified, we change the */
  151.    /* tag so that we only find the files with the tag--the    */
  152.    /* tag can be just the directory and then we will run      */
  153.    /* all programs in the directory                           */
  154.    if runAll = 0 & run > 0 then do
  155.       fileTag = " garbage xx"
  156.       tagFound = pos("RUN=", optionsUpper)
  157.       if tagFound > 0 then do
  158.          optionsRemaining = substr(optionsUpper, tagFound+4,)
  159.          fileTag = word(optionsRemaining, 1)
  160.       end
  161.    end  /* Do */
  162.    else
  163.       fileTag = ' x '
  164.  
  165.    /* Get a list of all files with the tag (either all programs */
  166.    /* or programs matching a tag).                              */
  167.    call SysFileSearch fileTag, sampleListFile, sampleList
  168.    if sampleList.0 >  0 then
  169.       do sample=1 TO sampleList.0
  170.         lastChapter = chapter
  171.         parse var sampleList.sample with ' x ' sampleNumber chapter location description
  172.         sampleNumber = strip(sampleNumber)
  173.         chapter = strip(chapter)
  174.         location = strip(location)
  175.         description = strip(description)
  176.  
  177.  
  178.         /* Change to the directory */
  179.         newLocation = directory(location)
  180.  
  181.         /* Clean files if requested */
  182.         if purge > 0 then do
  183.           '@echo' purgeDesc 'in directory:' location '> CON'
  184.  
  185.           /* Remove tempinc files and directory */
  186.           curMask = newLocation||'\tempinc\*.*'
  187.           rc = SysFileTree(curMask, 'file', 'FO', '***-*')
  188.           if file.0 > 0 then do
  189.             do maskj=1 to file.0
  190.                rc = SysFileDelete(file.maskj)
  191.                if rc <> 0 then
  192.                  '@ECHO Could not delete file' file.maskj '>>' outFile
  193.             end
  194.             rc = SysRmDir(newLocation||'\tempinc')
  195.             if rc <> 0 then
  196.               '@ECHO Could not remove directory' newLocation||'tempinc' '>>' outFile
  197.  
  198.           end
  199.  
  200.           fileMasks = purgeList
  201.           do maski=1 to words(fileMasks)
  202.             curMask = word(fileMasks,maski)
  203.             rc = SysFileTree(curMask, 'file', 'FO', '***-*')
  204.             do maskj=1 to file.0
  205.                rc = SysFileDelete(file.maskj)
  206.                if rc <> 0 then
  207.                  '@ECHO Could not delete file' file.maskj '>>' outFile
  208.             end
  209.           end
  210.           /* Need to clean up tempinc still */
  211.         end
  212.         else if run > 0 then do
  213.            /* Build the program string and run the program */
  214.            exeLocation = lastpos('\', location) + 1
  215.            exeName = substr(location, exeLocation)
  216.            exeName
  217.         end
  218.         else do
  219.           if chapter <> lastChapter then
  220.              '@ECHO Building Samples in Chapter' chapter '-' chapters.chapter '> CON'
  221.           '@ECHO ' format(sampleNumber,3)||') "'||description||'" > CON'
  222.           '@ECHO --------------------------------------------------------- >>' outFile
  223.           '@ECHO Running NMAKE in' translate(newLocation) '>>' outFile
  224.           '@nmake >> ' outFile ' 2>>&1'
  225.            if rc <> 0 then do
  226.              makeErrorList.0 = makeErrorList.0 + 1
  227.              makeErrorCount = makeErrorList.0
  228.              makeErrorList.makeErrorCount = description '(' newLocation ')'
  229.              '@ECHO           >>>>>>>>>>>>>>>>>>>>>>> Build failed  > CON'
  230.            end
  231.         end
  232.         newLocation = directory(uibuildPath)
  233.       end
  234.  end
  235. else
  236.    say "Could not find the sample list file -" sampleListFile
  237.  
  238.  
  239. /* Reset the output log */
  240. '@echo -------------------------------------------------------------> CON'
  241. '@echo Output written to file ' translate(outFile) '> CON'
  242. if makeErrorList.0 > 0 then do
  243.   '@echo The following examples failed to build correctly:'  '> CON'
  244.    do error=1 to makeErrorList.0
  245.     '@echo   ' makeErrorList.error  '> CON'
  246.    end
  247. end
  248.  
  249. '@echo Completed on' date() 'at' time() '>>' outFile
  250.  
  251. n = endlocal()
  252.  
  253. exit 0
  254.