home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / Getting Started / MPW Development / MPW Additions / Scripts / somc
Encoding:
Text File  |  1995-10-27  |  5.4 KB  |  250 lines  |  [TEXT/MPS ]

  1. Set Echo 0
  2.  
  3. #
  4. #
  5. #    File:         sc or somc (sc operates case sensitive)
  6. #    Function:    Drive the som compiler program like sc for SOM
  7. #
  8. #
  9.  
  10.  
  11. If {#} == 0
  12.     Begin
  13.         Echo "# Usage: {0} " '∂'
  14.         Echo "#             [ -D define ] [ -e emitter1,emitter2 ] [ -I folder ] [ -keeptm ] " '∂'
  15.         Echo "#             [ -m modifier ] [ -o outfolder ] [ -other" '"option"' "] " '∂'
  16.         Echo "#             [ -p ] [ -r ] [ -v ] [ -w ] [ -x ] " '∂'
  17.         Echo "#             file(s).idl" 
  18.     End > Dev:StdErr
  19.     Exit 1
  20. End
  21.  
  22. If "{0}" =~ /(≈:)«0,1»sc/
  23.     Set    CaseSensitive    1        # emulate unix - case counts
  24. Else
  25.     Set CaseSensitive    0       # allow either case
  26. End
  27.  
  28.  
  29. Unset    MyIncludes
  30. Unset    MyDefines
  31. Unset    MyFiles
  32. Unset    MyEmitters
  33. Unset    MyOptions
  34. Unset    OutDir
  35. Unset    EmitCtm
  36. Unset    EmitXtm
  37. Unset    Verbose
  38. Unset    PPOnly
  39. Unset    KeepTM
  40.  
  41. Loop
  42.     Break If {#} == 0
  43.     
  44.     # Echo "{1}"
  45.     
  46.     If "{1}" =~ /-p/
  47.         Set MyDefines "{MyDefines} -D __PRIVATE__"
  48.     Else If "{1}" =~ /-v/
  49.         Set Verbose 1
  50.         Set MyOptions "{MyOptions} -v"
  51.     Else If "{1}" =~ /-x/
  52.         Set PPOnly 1
  53.     Else If "{1}" =~ /-r/
  54.         Set MyOptions "{MyOptions} -r"
  55.     Else If "{1}" =~ /-w/
  56.         Set MyOptions "{MyOptions} -w"
  57.     Else If "{1}" =~ /-keeptm/
  58.         Set KeepTM 1
  59.     Else If "{1}" =~ /-D(≈)®1/
  60.         # Preprocessor define specification
  61.         If "{®1}" == ""
  62.             Shift
  63.         Else
  64.             Set 1 "{®1}"
  65.         End
  66.         Set MyDefines "{MyDefines} -D '{1}'"
  67.     Else If "{1}" =~ /-I(≈)®1/
  68.         # Include folder specification
  69.         If "{®1}" == ""
  70.             Shift
  71.         Else
  72.             Set 1 "{®1}"
  73.         End
  74.         Set MyIncludes "{MyIncludes} -I '{1}'"
  75.     Else If "{1}" =~ /-m(≈)®1/
  76.         # Modifier options
  77.         If "{®1}" == ""
  78.             Shift
  79.         Else
  80.             Set 1 "{®1}"
  81.         End
  82.         Set MyOptions "{MyOptions} -m'{1}'"
  83.     Else If "{1}" =~ /-other(≈)®1/
  84.         # Modifier options
  85.         If "{®1}" == ""
  86.             Shift
  87.         Else
  88.             Set 1 "{®1}"
  89.         End
  90.         Set MyOptions "{MyOptions} {1}"
  91.     Else If "{1}" =~ /-[od](≈)®1/    # -o for scom, -d for sc
  92.         # Output folder specification
  93.         If "{OutDir}" != ""
  94.             Echo "### {0} - OutFolder option already specified" > Dev:StdErr
  95.             Exit 1
  96.         End
  97.         If "{®1}" == ""
  98.             Shift
  99.         Else
  100.             Set 1 "{®1}"
  101.         End
  102.         Set OutDir "{1}"    # quoted whenever used
  103.     Else If "{1}" =~ /-[se](≈)®1/
  104.         # Emitter specification parameter
  105.         If "{®1}" == ""
  106.             Shift
  107.         Else
  108.             Set 1 "{®1}"
  109.         End
  110.         Loop
  111.             Break If "{1}" !~ /([¬;,]*)®1≈/
  112.             If {EmitCtm} == 0
  113.                 If "{®1}" =~ /c/
  114.                     # insert the ctm emitter if calling the c emitter
  115.                     Set MyEmitters "{MyEmitters} -e emitctm.dll"
  116.                     Set EmitCtm 1
  117.                 End
  118.             End
  119.             If {EmitXtm} == 0
  120.                 If "{®1}" =~ /xc/
  121.                     # insert the xtm emitter if calling the xc emitter
  122.                     Set MyEmitters "{MyEmitters} -e emitxtm.dll"
  123.                     Set EmitXtm 1
  124.                 End
  125.             End
  126.             Set MyEmitters "{MyEmitters} -e emit'{®1}'.dll"
  127.             Break If "{1}" !~ /[¬;,]*[;,](≈)®1/
  128.             Set 1 "{®1}"
  129.         End
  130.     Else If "{1}" !~ /-≈/
  131.         # Source file parameter
  132.         Set MyFiles "{MyFiles} '{1}'"
  133.     Else
  134.         Begin
  135.             Echo "### {0} - Option {1} unknown."
  136.             Echo "# Use -other" '"-xyz"' "to pass unknown options through."
  137.             Echo "# For example, {0} -other" '"-S ddd"' " ..."
  138.         End > Dev:StdErr
  139.         Exit 1
  140.     End
  141.     
  142.     Shift
  143. End    # for each input parameter
  144.  
  145.  
  146. If "{MyFiles}" == ""
  147.         Echo "### {0} - no source files supplied" > Dev:StdErr
  148.         Exit 1
  149. End
  150.  
  151. If "{MyEmitters}" == ""
  152.         Echo "### {0} - no emitters specified" > Dev:StdErr
  153.         Exit 1
  154. End
  155.  
  156.  
  157. # insure that OutDir ends with a : because it is concatenated to a filename
  158. If "{OutDir}" != ""
  159.     If "{OutDir}" !~ /≈:/
  160.         Set OutDir "{OutDir}:"
  161.     End
  162. End
  163.  
  164.  
  165. Set Temp "{TempFolder}sc.temp.idl.e"
  166.  
  167.  
  168. Unset CIncludes        # because we use C to preprocess idl files.
  169. Unset theFile theEmitter Output OldExit
  170. Unset IPCStatus __somIncludes __somExpandedIncs
  171.  
  172. #    expand SOMIncludes
  173. if "{SOMIncludes}" != ""
  174.     set __somIncludes "{SOMIncludes}"
  175.     loop
  176.         break if "{__somIncludes}" !~ /(≈)®1,(≈)®2/
  177.         set __somIncludes "{®1}"
  178.         set __somExpandedIncs "-I `quote "{®2}"` {__somExpandedIncs}"
  179.     end
  180.     set MyIncludes "{MyIncludes} -I `quote "{__somIncludes}"` {__somExpandedIncs}"
  181. end
  182.  
  183. For theFile in {MyFiles}
  184.  
  185.     If {Verbose}
  186.         Quote CParser -pp -a -ext off -nocomments "{theFile}" {MyDefines} {SOMDefines} {MyIncludes} -ppout "{Temp}"
  187.     End
  188.     CParser -pp -a -ext off -nocomments "{theFile}" {MyDefines} {SOMDefines} {MyIncludes} -ppout "{Temp}"
  189.  
  190.     # If OutDir is empty then we send result files to the current folder,
  191.     # no matter what dir the source file came from.
  192.  
  193.     If "{theFile}" =~ /(≈:)«0,1»(≈)®1.(≈)/ ## /(≈):(≈)®1.(≈)/ || /(≈)®1.(≈)/
  194.         Set Output "{OutDir}{®1}"
  195.     Else If "{theFile}" =~ /(≈):(≈)®1/
  196.         Set Output "{OutDir}{®1}"
  197.     Else
  198.         Set Output "{OutDir}{theFile}"
  199.     End
  200.     
  201.     # Ensure that the compiler generates bindings for the Macintosh
  202.     Set MyOptions "{MyOptions} -mmom"
  203.     
  204.     If {Verbose}
  205.         Quote somipc {MyOptions} {MyEmitters} {SOMOptions} -o "{Output}" "{Temp}"
  206.     End
  207.     If {PPOnly}
  208.         Echo "### SOM compiler not invoked (option -x set)."
  209.         Exit "-1"
  210.     End
  211.  
  212.     Delete -y -i stderr        # powerpc IT & FT
  213.       Set OldExit {Exit}
  214.       Set Exit 0
  215.     somipc {MyOptions} {MyEmitters} {SOMOptions} -o "{Output}" "{Temp}"
  216.       Set IPCStatus {Status}
  217.       Set Exit {OldExit}
  218.  
  219.     If "`Exists stderr`"
  220.         Catenate stderr        # powerpc IT & FT
  221.         Delete -y -i stderr    # powerpc IT & FT
  222.     End
  223.     If {IPCStatus}
  224.         Echo "### Exiting due to errors in SOM compile phase."
  225.         Exit "{IPCStatus}"
  226.     End
  227.     
  228.     If {KeepTM}
  229.     Else
  230.         If {EmitCtm}
  231.             If {Verbose}
  232.                 Quote Delete -y -i "{Output}.ctm"
  233.             End
  234.             Delete -y -i "{Output}.ctm"
  235.         End
  236.         If {EmitXtm}
  237.             If {Verbose}
  238.                 Quote Delete -y -i "{Output}.xtm"
  239.             End
  240.             Delete -y -i "{Output}.xtm"
  241.         End
  242.     End
  243. End    # for each idl file
  244.  
  245.  
  246. If {Verbose}
  247.     Quote Delete -y -i "{Temp}"
  248. End
  249. Delete -y -i "{Temp}"
  250.