home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-08 | 10.7 KB | 349 lines | [TEXT/ToyS] |
-
- -- Compiles and builds all the components of Thread Library using CodeWarrior. Before running,
- -- you need to set the strings returned by mpwhomeFolder, cwhomeFolder, and tlhomeFolder. You
- -- can also set gMakeProject to true to compile anything that needs compiling, and
- -- gRemoveBinaries to strip the binaries after compiling. Still waiting on a scriptable Find
- -- File and proper script compiler to make this script independent of application locations...
-
- -- Note: should use Finder's Find File to locate MPW, CW, and Thread Library,
- -- but can't since Find File isn't scriptable and ScriptEditor's AppleScript
- -- compiler won't accept application aliases in variables as targets of
- -- tell statements. This means you need to set the strings
- -- returned by compiler68k() and compilerPPC(). You also
- -- need to set the names of the applications in the tell
- -- statements to whatever version of CodeWarrior you now
- -- have (for instance, CW6 uses version number "1.2.2"
- -- in the application names).
-
- -- Globals
-
- global gMakeProject
- global gRemoveBinaries
-
- -- CodeWarrior
-
- on cwhomeFolder()
- return alias "Flicker:Development:Environments:CodeWarrior:"
- end cwhomeFolder
-
- on compiler68k()
- return ((cwhomeFolder() as string) & "Metrowerks C/C++ ƒ:MW C/C++ 68K 1.2.2")
- end compiler68k
-
- on compilerPPC()
- return ((cwhomeFolder() as string) & "Metrowerks C/C++ ƒ:MW C/C++ PPC 1.2.2")
- end compilerPPC
-
- -- MPW
-
- on mpwhomeFolder()
- return alias ((cwhomeFolder() as string) & "Fully Configured MPW")
- end mpwhomeFolder
-
- on mpwApplication()
- return application ((mpwhomeFolder() as string) & "MPW Shell")
- end mpwApplication
-
- -- Thread Library
-
- on tlhomeFolder()
- return alias "Flicker:WinterShell:Shared:Libraries:ThreadLibrary-1.0:"
- end tlhomeFolder
-
- on tlexecFolder()
- return alias ((tlhomeFolder() as string) & "Executables")
- end tlexecFolder
-
- on tllibFolder()
- return alias ((tlhomeFolder() as string) & "Libraries")
- end tllibFolder
-
- on libhomeFolder()
- return alias ((tlhomeFolder() as string) & "Source:Libraries")
- end libhomeFolder
-
- -- remove suffix from string
- on stripSuffix(s)
- set n to length of s
- set a to 1
- set b to n + 1
- repeat with i from 1 to n
- if character i of s = "." then
- set b to i
- end if
- end repeat
- set b to (b - 1)
- if b = 0 then
- return ""
- end if
- return characters a thru b of s as string
- end stripSuffix
-
- -- place quotation marks around string
- on stringQuote(s)
- return "\"" & s & "\""
- end stringQuote
-
- -- merge resource fork with destination's resource fork
- on mergeResources(src, dst)
- set src to ("∂\"" & src as string) & "∂\""
- set dst to stringQuote(dst as string)
- tell application "MPW Shell"
- DoScript ("echo \"include " & src & ";\" | rez -a -o " & dst)
- end tell
- end mergeResources
-
- -- copy data fork to destination
- on copyDataFork(src, dst)
- set src to stringQuote(src as string)
- set dst to stringQuote(dst as string)
- tell application "MPW Shell"
- DoScript ("duplicate -d -y " & src & " " & dst)
- end tell
- end copyDataFork
-
- -- copy resource fork to destination
- on copyResourceFork(src, dst)
- set src to stringQuote(src as string)
- set dst to stringQuote(dst as string)
- tell application "MPW Shell"
- DoScript ("duplicate -r -y " & src & " " & dst)
- end tell
- end copyResourceFork
-
- -- copy file to destination
- on copyFile(src, dst)
- set src to stringQuote(src as string)
- set dst to stringQuote(dst as string)
- tell application "MPW Shell"
- DoScript ("duplicate -y " & src & " " & dst)
- end tell
- end copyFile
-
- -- move file to destination
- on replaceFile(src, dst)
- tell application "Finder"
- move src to dst replacing conflicts
- end tell
- end replaceFile
-
- -- move file to destination
- on replaceFileIfExists(src, dst)
- set src to (src as string)
- tell application "Finder"
- if file src exists then
- move file src to dst replacing conflicts
- else if file ((dst as string) & src) exists then
- delete file ((dst as string) & src)
- end if
- end tell
- end replaceFileIfExists
-
- -- delete file
- on deleteFile(path)
- tell application "Finder"
- if file path exists then
- delete file path
- end if
- end tell
- end deleteFile
-
- -- bring a project up to date
- on makeProject(projectspec, compiler)
- tell application "Finder"
- open projectspec
- end tell
- with timeout of 60000 seconds
- if compiler = compiler68k() then
- tell application "MW C/C++ 68K 1.2.2"
- -- activate
- Make Project
- end tell
- else if compiler = compilerPPC() then
- tell application "MW C/C++ PPC 1.2.2"
- -- activate
- Make Project
- end tell
- else
- error "Unknown compiler."
- end if
- end timeout
- end makeProject
-
- -- bring a 68K project up to date
- on makeProject68K(Project)
- makeProject(Project, compiler68k())
- end makeProject68K
-
- -- bring a PPC project up to date
- on makeProjectPPC(Project)
- makeProject(Project, compilerPPC())
- end makeProjectPPC
-
- -- remove binaries from project
- on removeBinaries(projectspec, output, compiler)
- if gRemoveBinaries then
- tell application "Finder"
- open projectspec
- end tell
- with timeout of 60000 seconds
- if compiler = compiler68k() then
- -- remove binaries from project file
- tell application "MW C/C++ 68K 1.2.2"
- Remove Binaries
- end tell
- -- remove debug and symbol files
- deleteFile(stripSuffix(projectspec as string) & ".dbg")
- deleteFile(stripSuffix(projectspec as string) & ".SYM")
- else if compiler = compilerPPC() then
- -- remove binaries from project file
- tell application "MW C/C++ PPC 1.2.2"
- Remove Binaries
- end tell
- deleteFile(stripSuffix(projectspec as string) & ".xdbg")
- deleteFile(stripSuffix(projectspec as string) & ".xSYM")
- else
- error "Unknown compiler."
- end if
- end timeout
- -- remove output file
- deleteFile(output)
- end if
- end removeBinaries
-
- -- remove binaries from 68k project
- on removeBinaries68k(Project, output)
- removeBinaries(Project, output, compiler68k())
- end removeBinaries68k
-
- -- remove binaries from PPC project
- on removeBinariesPPC(Project, output)
- removeBinaries(Project, output, compilerPPC())
- end removeBinariesPPC
-
- -- make a fat application
- on makeProjectFat(project68k, output68k, projectPPC, outputPPC, outputFat, outputFolder)
- if gMakeProject then
- makeProject68K(project68k)
- makeProjectPPC(projectPPC)
- copyFile(outputPPC, outputFat)
- mergeResources(output68k, outputFat)
- replaceFile(alias output68k, outputFolder)
- replaceFile(alias outputPPC, outputFolder)
- end if
- removeBinaries68k(project68k, output68k)
- removeBinariesPPC(projectPPC, outputPPC)
- end makeProjectFat
-
- -- build project using specified compiler
- on makeProjectTarget(Project, output, destination, compiler)
- if gMakeProject then
- makeProject(Project, compiler)
- replaceFile(output as alias, destination as alias)
- replaceFileIfExists(((output as string) & ".SYM"), destination as alias)
- replaceFileIfExists(((output as string) & ".xSYM"), destination as alias)
- end if
- removeBinaries(Project, output, compiler)
- end makeProjectTarget
-
- -- build 68k project
- on makeProjectTarget68K(Project, output, destination)
- makeProjectTarget(Project, output, destination, compiler68k())
- end makeProjectTarget68K
-
- -- build PPC project
- on makeProjectTargetPPC(Project, output, destination)
- makeProjectTarget(Project, output, destination, compilerPPC())
- end makeProjectTargetPPC
-
- -- return name of output file of project
- on projectOutput(projectspec, compiler)
- tell application "Finder"
- open projectspec
- end tell
- if compiler = compiler68k() then
- tell application "MW C/C++ 68K 1.2.2"
- set output to (File Name of (Get Preferences Of {File Name}))
- end tell
- else if compiler = compilerPPC() then
- tell application "MW C/C++ PPC 1.2.2"
- set output to (File Name of (Get Preferences Of {File Name}))
- end tell
- else
- error "Unknown compiler."
- end if
- return output
- end projectOutput
-
- -- return name of output file of 68k project
- on projectOutput68k(Project)
- return projectOutput(Project, compiler68k())
- end projectOutput68k
-
- -- return name of output file of PPC project
- on projectOutputPPC(Project)
- return projectOutput(Project, compilerPPC())
- end projectOutputPPC
-
- on build68kLibraries()
- set project68k to alias ((libhomeFolder() as string) & "ThreadLibrary-68K.π")
- set output68k to ((libhomeFolder() as string) & projectOutput68k(project68k))
- makeProjectTarget68K(project68k, output68k, tllibFolder())
- set project68k to alias ((libhomeFolder() as string) & "ThreadLibrary-68K-Debug.π")
- set output68k to ((libhomeFolder() as string) & projectOutput68k(project68k))
- makeProjectTarget68K(project68k, output68k, tllibFolder())
- end build68kLibraries
-
- on buildPPCLibraries()
- set projectPPC to alias ((libhomeFolder() as string) & "ThreadLibrary-PPC.π")
- set outputPPC to ((libhomeFolder() as string) & projectOutputPPC(projectPPC))
- makeProjectTargetPPC(projectPPC, outputPPC, tllibFolder())
- set projectPPC to alias ((libhomeFolder() as string) & "ThreadLibrary-PPC-Debug.π")
- set outputPPC to ((libhomeFolder() as string) & projectOutputPPC(projectPPC))
- makeProjectTargetPPC(projectPPC, outputPPC, tllibFolder())
- end buildPPCLibraries
-
- on buildPPCSharedLibaries()
- set projectPPC to alias ((libhomeFolder() as string) & "ThreadLibrary-PPC.lib.π")
- set outputPPC to ((libhomeFolder() as string) & projectOutputPPC(projectPPC))
- makeProjectTargetPPC(projectPPC, outputPPC, tllibFolder())
- set projectPPC to alias ((libhomeFolder() as string) & "ThreadLibrary-PPC-Debug.lib.π")
- set outputPPC to ((libhomeFolder() as string) & projectOutputPPC(projectPPC))
- makeProjectTargetPPC(projectPPC, outputPPC, tllibFolder())
- end buildPPCSharedLibaries
-
- on buildTestApplication()
- set testhomeFolder to alias ((tlhomeFolder() as string) & "Source:Demos:ThreadsTest")
- set project68k to alias ((testhomeFolder as string) & "ThreadsTest-68K.π")
- set output68k to ((testhomeFolder as string) & projectOutput68k(project68k))
- set projectPPC to alias ((testhomeFolder as string) & "ThreadsTest-PPC.π")
- set outputPPC to ((testhomeFolder as string) & projectOutputPPC(projectPPC))
- set outputFat to ((tlexecFolder() as string) & "ThreadsTest-FAT")
- makeProjectFat(project68k, output68k, projectPPC, outputPPC, outputFat, tlexecFolder())
- end buildTestApplication
-
- on buildSpeedTestApplication()
- set timedhomeFolder to alias ((tlhomeFolder() as string) & "Source:Demos:ThreadsTimed")
- set project68k to alias ((timedhomeFolder as string) & "ThreadsTimed-68K.π")
- set output68k to ((timedhomeFolder as string) & projectOutput68k(project68k))
- set projectPPC to alias ((timedhomeFolder as string) & "ThreadsTimed-PPC.π")
- set outputPPC to ((timedhomeFolder as string) & projectOutputPPC(projectPPC))
- set outputFat to ((tlexecFolder() as string) & "ThreadsTimed-FAT")
- makeProjectFat(project68k, output68k, projectPPC, outputPPC, outputFat, tlexecFolder())
- end buildSpeedTestApplication
-
- on run
-
- -- set globals
- set gMakeProject to true
- set gRemoveBinaries to true
-
- -- build everything
- build68kLibraries()
- buildPPCLibraries()
- buildPPCSharedLibaries()
- buildTestApplication()
- buildSpeedTestApplication()
-
- end run
-