b'\tMake our stationery project from scratch that will '
b'\tbe used to make all other libraries. This allows us to get all of these common '
b'\tsettings out of the makeall script.'
0
- create library or application stationery?
b'property pCreateLibrary : false'
b'property pProjectFileExtension : ".mcp"'
b'property pTargetList : {"Carbon Debug", "Carbon Final", "Mach-O Debug", "Mach-O Final"}'
b'(* ====== Stand alone. When run by itself, make the appropriate stationery. ====== *)'
b'set my pCreateLibrary to true'
b'CreateStationeryProject(gStationeryName, gRsrcsDir, gMWCWfolder)'
b'set my pCreateLibrary to false'
b'CreateStationeryProject(gStationeryName, gRsrcsDir, gMWCWfolder)'
b'on CreateStationeryProject(projName, projDir, cwDir)'
b'\t-- make sure the Metrowerks folder spec is global.'
b'\tif gMWCWfolder is not cwDir then'
b'\t\tset gMWCWfolder to cwDir'
b'\tset projFilename to projName & pProjectFileExtension'
b'\tset projPathname to projDir & projFilename'
b'\ttell application "CodeWarrior IDE"'
b'\t\t\tclose (the first project document whose name is projFilename)'
b'\t\t-- display dialog "creating project: " & projPathname buttons {"OK"} default button 1'
b'\t\tCreate Project {projPathname}'
b'\t\trepeat with t in pTargetList'
b'\t\t\tmy SetupTarget(t, projName)'
b'\t\tif my IsOSX() and not pCreateLibrary then'
b'\t\t\tdisplay dialog "To finish add the following files into " & projFilename & "\'s Mach-O targets:" & return & \xc2'
b'\t\t\t\t" /System/Library/Frameworks/Carbon.framework" & return & \xc2'
b'\t\t\t\t" /System/Library/Frameworks/System.framework" & return & \xc2'
b'\t\t\t\t" /usr/lib/crt1.o" & return & return & \xc2'
b'\t\t\t\t"Sorry, but Codewarrior\'s Applescript won\'t do these." buttons {"OK"} default button 1'
b'\tCleanupFolder(projDir, projName)'
b'end CreateStationeryProject'
1
- Delete files and folders created during this process we do not need.
2
- particularly the project's Data directory and output files and directories.
b'on CleanupFolder(thePath, projName)'
b'\trepeat with f in list folder (thePath) without invisibles'
b'\t\tif ((f as string) begins with "xxxx_" or (f as string) is projName & " Data") then'
b'\t\t\t\ttell application "Finder" to delete folder (thePath & f)'
b'\t\t\t\ttell application "Finder" to delete file (thePath & f)'
b'on SetupTarget(targetName, projName)'
b'\ttell application "CodeWarrior IDE"'
b'\t\t-- display dialog "Setup target: " & targetName & return & "project: " & projName'
b'\t\t-- Figure out what our output file will be (tentatively) named.'
b'\t\tset targetFilename to "xxxx" -- The real target\'s output name will get set later.'
b'\t\tset targetAPI to ""'
b'\t\tset debugFlag to ""'
b'\t\t-- Linker & Output type.'
b'\t\tif targetName contains "Carbon" then'
b'\t\t\tset targetFilename to targetFilename & "_C"'
b'\t\t\tset targetAPI to "Carbon"'
b'\t\telse if targetName contains "Mach-O" and my IsOSX() then'
b'\t\t\tset targetFilename to targetFilename & "_M"'
b'\t\t\tset targetAPI to "Mach-O"'
b'\t\t\t-- I do not know what kind of target you are talking about.'
b"\t\t\t-- or we are on a OS 9 machine and I don't know what Mach-O is."
b'\t\t\t-- ignore this argument.'
b'\t\tif targetName contains "Final" or targetName contains "Release" then'
b'\t\t\tset debugFlag to "Final"'
b'\t\t\tset targetFilename to targetFilename & "_O" -- for Optimized.'
b'\t\t\t-- Assume Debug if nothing else.'
b'\t\t\tset debugFlag to "Debug"'
b'\t\t\tset targetFilename to targetFilename & "_D"'
b'\t\tif pCreateLibrary then'
b'\t\t\tset targetFilename to targetFilename & ".lib"'
b'\t\t\tset targetName to "Library " & targetName'
b'\t\t\tset targetFilename to targetFilename & ".app"'
b'\t\t\tset targetName to "Application " & targetName'
b'\t\t-- Make the new target, and set the current target to be it.'
b'\t\tif (count targets of project document 1) is 1 and \xc2'
b'\t\t\t(name of target 1 of project document 1) is projName then'
b'\t\t\t-- brand new project comes with one default target, same name as the project.'
b'\t\t\t-- rename that one.'
b'\t\t\tset (name of target 1 of project document 1) to targetName'
b'\t\t\tset the current target of project document 1 to the target 1 of project document 1'
b'\t\t\t-- make all the subsequent targets.'
b'\t\t\tmake new target at project document 1 with properties {name:targetName}'
b'\t\t\tset the current target of project document 1 to the result'
b'\t\t-- set all the preference panels'
b'\t\t-- display dialog " API: " & targetAPI & return & " filename: " & targetFilename & return & debugFlag'
b'\t\tmy SetPreferences(targetAPI, targetFilename, debugFlag is "Debug")'
3
----- All Preference Panel settings in here. -----
b'on SetPreferences(targetAPI, targetFilename, shouldDebug)'
b'\tset weAreMach to (targetAPI is "Mach-O")'
b'\ttell application "CodeWarrior IDE"'
b'\t\t\tset linkerName to "MacOS X PPC Linker"'
b'\t\t\tset targetPanelName to "PPC Mac OS X Project"'
b'\t\t\tset codeGenPanelName to "PPC CodeGen Mach-O"'
b'\t\t\tset linkerPanelName to "PPC Mac OS X Linker"'
b'\t\t\tset linkerName to "MacOS PPC Linker"'
b'\t\t\tset targetPanelName to "PPC Project"'
b'\t\t\tset codeGenPanelName to "PPC CodeGen"'
b'\t\t\tset linkerPanelName to "PPC Linker"'
b'\t\t(* ===== Section "Target" ===== *)'
b'\t\tSet Preferences of panel "Target Settings" to {Linker:linkerName}'
b'\t\t-- Panel "PPC or Mac OS X Target"'
b'\t\tif pCreateLibrary then'
b'\t\t\tSet Preferences of panel targetPanelName to {Project Type:library, File Name:targetFilename}'
b'\t\t\tif weAreMach then'
b'\t\t\t\tSet Preferences of panel targetPanelName to \xc2'
b'\t\t\t\t\t{Project Type:application package, File Name:targetFilename, File Creator:"NCBI", File Type:"APPL"}'
b'\t\t\t\tSet Preferences of panel targetPanelName to \xc2'
b'\t\t\t\t\t{Project Type:standard application, File Name:targetFilename, File Creator:"NCBI", File Type:"APPL", SIZE Flags:22720, Preferred Heap Size:8000, Min Heap Size:5000, Stack Size:64} \xc2'
b'\t\t\t\t-- the following only needed on pre-OS X systems when we turn on the Output Flags post-linker, '
b'\t\t\t\t-- but it is harmless in other cases.'
b'\t\t\t\tSet Preferences of panel "Output Flags" to {Has Bundle:true}'
b'\t\t(* ===== Section "Language Settings" ===== *)'
b'\t\t-- Panel "C/C++ Language"'
b'\t\tSet Preferences of panel "C/C++ Compiler" to \xc2'
b'\t\t\t{Activate CPlusPlus:false \xc2'
b'\t\t\t\t, ARM Conformance:false \xc2'
b'\t\t\t\t, Exception Handling:true \xc2'
b'\t\t\t\t, RTTI:true \xc2'
b'\t\t\t\t, Pool Strings:true \xc2'
b'\t\t\t\t, Dont Reuse Strings:false \xc2'
b'\t\t\t\t, Require Function Prototypes:true \xc2'
b'\t\t\t\t, Enable bool Support:true \xc2'
b'\t\t\t\t, Enable wchar_t:true \xc2'
b'\t\t\t\t, C99:false \xc2'
b'\t\t\t\t, ANSI Strict:false \xc2'
b'\t\t\t\t, ANSI Keywords Only:false \xc2'
b'\t\t\t\t, Expand Trigraph Sequences:false \xc2'
b'\t\t\t\t, MPW Newlines:false \xc2'
b'\t\t\t\t, MPW Pointer Type Rules:false \xc2'
b'\t\t\t\t, Enums Always Ints:false \xc2'
b'\t\t\t\t, Prefix File:""}'
b'\t\t-- Panel "C/C++ Warnings"'
b'\t\tSet Preferences of panel "C/C++ Warnings" to \xc2'
b'\t\t\t{Treat Warnings As Errors:false \xc2'
b'\t\t\t\t, Illegal Pragmas:true \xc2'
b'\t\t\t\t, Empty Declarations:true \xc2'
b'\t\t\t\t, Possible Errors:true \xc2'
b'\t\t\t\t, Unused Variables:true \xc2'
b'\t\t\t\t, Unused Arguments:false \xc2'
b'\t\t\t\t, Extra Commas:true \xc2'
b'\t\t\t\t, Extended Error Checking:true \xc2'
b'\t\t\t\t, Hidden Virtual Functions:true \xc2'
b'\t\t\t\t, Implicit Arithmetic Conversions:false \xc2'
b'\t\t\t\t, NonInlined Functions:false \xc2'
b'\t\t\t\t, Inconsistent Class Struct:true}'
b'\t\t(* ===== Section "Code Generation" ===== *)'
b'\t\t-- Panel "PPC CodeGen Mach-O"'
b'\t\tSet Preferences of panel codeGenPanelName to \xc2'
b'\t\t\t{Struct Alignment:Align_PPC \xc2'
b'\t\t\t\t, Make Strings ReadOnly:true \xc2'
b'\t\t\t\t, Use FMADD Instructions:false \xc2'
b'\t\t\t\t, Schedule:false \xc2'
b'\t\t\t\t, Peephole Optimizer:true}'
b'\t\tif not weAreMach then'
b'\t\t\t-- preferences that are only on non-Mach targets.'
b'\t\t\tSet Preferences of panel codeGenPanelName to \xc2'
b'\t\t\t\t{Store Data in TOC:true \xc2'
b'\t\t\t\t\t, Traceback Tables:TB_Inline}'
b'\t\t(* ===== Section "Debugger" ===== *)'
b'\t\tif shouldDebug then'
b'\t\t\t(* ==== Debug settings ==== *)'
b'\t\t\t(* ===== Panel PPC Global Optimizer ===== *)'
b'\t\t\tSet Preferences of panel "PPC Global Optimizer" to \xc2'
b'\t\t\t\t{Optimize For:code_Speed, Level:0}'
b'\t\t\t(* ===== Panel PPC Linker ===== *)'
b'\t\t\tSet Preferences of panel linkerPanelName to \xc2'
b'\t\t\t\t{Generate SYM File:true \xc2'
b'\t\t\t\t\t, Full Path In SYM:true \xc2'
b'\t\t\t\t\t, Generate Link Map:false \xc2'
b'\t\t\t\t\t, Link Mode:fast}'
b'\t\t\t(* ===== Panel C/C++ Language ===== *)'
b'\t\t\tSet Preferences of panel "C/C++ Compiler" to \xc2'
b'\t\t\t\t{Inlining:inline_none, AutoInlining:false}'
b'\t\t\t(* ==== optimized/release settings ==== *)'
b'\t\t\t(* ===== Panel PPC Global Optimizer ===== *)'
b'\t\t\tSet Preferences of panel "PPC Global Optimizer" to \xc2'
b'\t\t\t\t{Optimize For:code_Speed, Level:4}'
b'\t\t\t(* ===== Panel PPC Linker ===== *)'
b'\t\t\tSet Preferences of panel linkerPanelName to \xc2'
b'\t\t\t\t{Generate SYM File:false \xc2'
b'\t\t\t\t\t, Generate Link Map:false \xc2'
b'\t\t\t\t\t, Link Mode:fast}'
b'\t\t\t(* ===== Panel C/C++ Language ===== *)'
b'\t\t\tSet Preferences of panel "C/C++ Compiler" to \xc2'
b'\t\t\t\t{Inlining:inline_smart, AutoInlining:true}'
b'\t\t-- Panel "Debugger Settings"'
b'\t\tSet Preferences of panel "Debugger Target" to \xc2'
b'\t\t\t{Log System Messages:false}'
b'\t\t(* ===== Panel Access Paths ===== *)'
b'\t\t-- when building projects add the other paths at the end of User Paths.'
b"\t\t-- since 'Always Full Search' is true they will get searched before the default System Paths."
b'\t\t-- But MachO needs to move the /usr/.. directories to User Paths.'
b'\t\tSet Preferences of panel "Access Paths" to {Always Full Search:true, Convert Paths:true, Require Framework Includes:false}'
b'\t\tmy SetPaths(weAreMach)'
b'\t\t-- add libraries to this target'
b'\t\tif not pCreateLibrary then'
b'\t\t\tif not weAreMach then'
b'\t\t\t\tif shouldDebug then'
b'\t\t\t\t\tset libsToAdd to {gMWCWfolder & "MacOS Support:Libraries:Runtime:Libs:MSL_All_Carbon_D.lib"}'
b'\t\t\t\t\tset libsToAdd to {gMWCWfolder & "MacOS Support:Libraries:Runtime:Libs:MSL_All_Carbon.lib"}'
b'\t\t\t\tcopy (gMWCWfolder & "MacOS Support:Universal:Libraries:StubLibraries:CarbonLib") to end of libsToAdd'
b'\t\t\t\tif shouldDebug then'
b'\t\t\t\t\tset libsToAdd to {gMWCWfolder & "MacOS X Support:Libraries:Runtime:Libs:MSL_All_Mach-O_D.lib"}'
b'\t\t\t\t\tset libsToAdd to {gMWCWfolder & "MacOS X Support:Libraries:Runtime:Libs:MSL_All_Mach-O.lib"}'
b'\t\t\t\tcopy (gMWCWfolder & "MSL:MSL_C:MSL_MacOS:Src:console_OS_X.c") to end of libsToAdd'
b'\t\t\t\tcopy ("/usr/lib/crt1.o") to end of libsToAdd'
b'\t\t\t\tcopy "abc:System:Library:Frameworks:Carbon.framework" to end of libsToAdd'
b'\t\t\t\tcopy "abc:System:Library:Frameworks:System.framework" to end of libsToAdd'
b'\t\t\tAdd Files libsToAdd'
b'on SetPaths(weAreMach)'
b'\ttell application "CodeWarrior IDE"'
b'\t\t(* ===== Panel Access Paths ===== *)'
b'\t\t-- This removes the compiler default folders because otherwise setting the paths only adds on to the end. Never deletes anything.'
b'\t\tSet Preferences of panel "Access Paths" to {User Paths:{}, System Paths:{}}'
b'\t\t-- set up User Paths'
b'\t\tset userPaths to {{name:":", format:MacOS Path, origin:project relative, recursive:true}}'
b'\t\t\tcopy {name:":usr:include:", format:MacOS Path, origin:root relative, root:"OS X Volume", recursive:false} \xc2'
b'\t\t\t\tto end of userPaths'
b'\t\t\tif not pCreateLibrary then'
b'\t\t\t\tcopy {name:":usr:lib:", format:MacOS Path, origin:root relative, root:"OS X Volume", recursive:false} \xc2'
b'\t\t\t\t\tto end of userPaths'
b'\t\t-- set up System Paths'
b'\t\t\tset sysPaths to {\xc2'
b'\t\t\t\t{name:":MSL:MSL_C:", format:MacOS Path, origin:shell relative, recursive:true}, \xc2'
b'\t\t\t\t{name:":MacOS Support:", format:MacOS Path, origin:shell relative, recursive:true}, \xc2'
b'\t\t\t\t{name:":MacOS X Support:", format:MacOS Path, origin:shell relative, recursive:true}}'
b'\t\t\tset sysPaths to {\xc2'
b'\t\t\t\t{name:":MSL:", format:MacOS Path, origin:shell relative, recursive:true}, \xc2'
b'\t\t\t\t{name:":MacOS Support:", format:MacOS Path, origin:shell relative, recursive:true}}'
b'\t\t-- put everything back.'
b'\t\tSet Preferences of panel "Access Paths" to {User Paths:userPaths, System Paths:sysPaths}'
b'on stripVolName(macPath)'
b'\tset saveTID to get text item delimiters of AppleScript'
b'\tset text item delimiters of AppleScript to ":"'
b'\tset strippedPath to (rest of text items of macPath) as string'
b'\tset text item delimiters of AppleScript to saveTID'
b'\ttell application "Finder"'
b'\t\tset vers to the version as text'
b'\t\tif second character of vers is equal to "." then'
b'\t\t\tset vers to "0" & vers'
b'\t\treturn vers > 10 or vers = 10'
4
- the following will build the stationery project in the lib directory.
5
- CreateStationeryProject(gStationeryName, gDistribRoot & gBuildDir & ":" & gStationeryName & ":", gMWCWfolder)
6
- the following are needed to run this script by itself,
7
- they are not needed when it is called by another script.
b'global gStationeryName'
b'on ResolveAlias(pathname)'
b'\ttell application "Finder"'
b'\t\tif exists folder pathname then return pathname & ":"'
b'\t\tif exists alias file pathname then return the original item of alias file pathname as string'
b'\t\terror "The folder (or alias) \'" & pathname & "\' doesn\'t exist."'
b'\ttell application "Finder"'
b'\t\tif my IsOSX() then'
b'\t\t\treturn the home as string'
b'\t\t\treturn gStartupDisk'
b'\t\tset modRoot to ResolveAlias(gMWroot & "ncbi")'
b'\t\t\tset modRoot to ResolveAlias(gHomeDir & "ncbi")'
b'\tset mwLocations to {gStartupDisk, gStartupDisk & "Applications:", gStartupDisk & "Applications (Mac OS 9):", \xc2'
b'\t\tgHomeDir, gHomeDir & "Applications:", gHomeDir & "Applications (Mac OS 9):"}'
b'\trepeat with mwVersion from 8 to 9'
b'\t\tset dirName to "Metrowerks CodeWarrior " & mwVersion & ".0"'
b'\t\trepeat with mwLoc in mwLocations'
b'\t\t\t\tset mwRoot to ResolveAlias(mwLoc & dirName)'
b'\terror "Can\'t find the Metrowerks CodeWarrior folder."'
b'\ttell application "Finder"'
b'\t\tset gStartupDisk to startup disk as string'
b'\t\tset gHomeDir to my HomeDir()'
b'\t\tset gMWroot to my MWRootDir()'
b'\t\tset gMWCWfolder to gMWroot & "Metrowerks CodeWarrior:"'
b'\t\tset gDistribRoot to my ModuleRoot()'
b'\t\tset gRsrcsDir to gDistribRoot & "link:macmet:"'
b'\t\tif pCreateLibrary then'
b'\t\t\tset gStationeryName to "LibraryStationery"'
b'\t\t\tset gBuildDir to "lib"'
b'\t\t\tset gStationeryName to "ApplicationStationery"'
b'\t\t\tset gBuildDir to "build"'
b'\t\tset gDirsToCreate to {\xc2'
b'\t\t\t{relPath:"", name:gBuildDir}, \xc2'
b'\t\t\t{relPath:gBuildDir, name:gStationeryName}}'
b'\ttell application "Finder"'
b'\t\trepeat with i in gDirsToCreate'
b'\t\t\tset pth to relPath of i'
b'\t\t\tif pth is not "" then set pth to pth & ":"'
b"\t\t\tif not (exists folder (gDistribRoot & pth & i's name)) then"
b"\t\t\t\tmake new folder at folder (gDistribRoot & pth) with properties {name:i's name}"
b'\\ No newline at end of file'