6
property pRootFolderName : "ncbi" -- name of the toolkit directory
7
property pRootFolderPath : "" -- full path of the parent of the toolkit directory. Optional
9
property pProjectFileExt : ".mcp"
11
property pSaveContinueOnErrors : false
12
-- true if we want to save compilation errors in a file and continue.
13
-- false if we want to stop on an error.
15
-- Whether to recreate existing project files.
16
property pAlwaysCreateProjects : false
17
-- Which targets to build.
18
-- All of the targets are populated all the time. These affect what is compiled & built.
19
property pCreateMachOTargets : true
20
property pCreateCarbonTargets : false
21
property pCreateWinTargets : false
23
property pCreateOptimizedTargets : true
24
property pCreateDebugTargets : false
25
property pCreateProfiledTargets : false
27
-- Whether to have the projects use CVS or not.
28
property pProjectsCVSEnabled : true
30
property pCreateBlastTargets : false
32
-- Whether to compile anything.
33
property pShouldBuild : true
35
property pStationeryName : "ApplicationStationery"
37
-- the handler GetTargetSpecs should change if these do.
38
property pTargetKeyWords : "Mach-O Carbon Win32 Debug Final Profile"
43
on SimpleProjectData(projName, features)
45
if (count characters of projName) > 25 then
46
set projName to characters 1 through 25 of projName as string
49
if features does not contain "C" and features does not contain "C++" then
50
--error "Project " & projName & "'s default language (a feature) must be C or C++."
51
copy "C" to end of features
53
set myFeatures to features
54
return {name:projName, features:myFeatures, rsrcs:{"ncbilogo.r", "Info.plc"}, settings:�
55
{prefixFile:"", ppcProject:{}}, projLibs:�
56
{"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbimmdb", "ncbitool"}, fileData:�
57
{{projPath:"demo:", fileList:{projName & ".c"}}}}
61
on AddProject(projData)
62
copy projData to end of gProjectData
65
on AddSimpleProject(projName, features)
66
AddProject(SimpleProjectData(projName, features))
70
tell application "CodeWarrior IDE"
73
set myName to "Sequin"
74
set myFeatures to {"sockets"}
76
{prefixFile:"", creator:"SEQN", ppcProject:{Preferred Heap Size:32000, Min Heap Size:6000}} �
78
set myRsrcs to {"sequin.r", "InfoSequin.plc"}
79
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "ncbicdr", "vibrant", "ncbidesk", �
80
"ncbimmdb", "ncbitool", "netcli", "netentr", "ncbibls3", "ncbimla", �
81
"ncbitxc2", "ncbiid1", "ncbispell", "vibnet", "ncbiblast", "ncbiblastapi"}
83
{{projPath:"cdromlib:", fileList:{"accentr.c", "accutils.c"}}, �
84
{projPath:"sequin:", fileList:{"sequin1.c", "sequin2.c", "sequin3.c", "sequin4.c", "sequin5.c", �
85
"sequin6.c", "sequin7.c", "sequin8.c", "sequin9.c", "sequin10.c", "sequinx.c"}}}
87
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:�
88
myLibs, fileData:myFiles}
91
set myName to "Entrez"
92
set myFeatures to {"sockets"}
93
set mySettings to {prefixFile:"", creator:"ENTZ", ppcProject:{}}
94
set myRsrcs to {"entrez.r", "Info.plc"}
95
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "ncbicdr", "vibrant", "ncbidesk", "ncbimmdb", �
96
"ncbitool", "netcli", "netentr", "ncbibls3", "ncbiid1", "vibnet"}
98
{{projPath:"cdromlib:", fileList:{"accentr.c", "accutils.c"}}, �
99
{projPath:"demo:", fileList:{"entrez.c"}}}
101
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:�
102
myLibs, fileData:myFiles}
105
set myName to "Entrez2"
106
set myFeatures to {"sockets"}
107
set mySettings to {prefixFile:"", creator:"ENTZ", ppcProject:{}}
108
set myRsrcs to {"entrez.r", "Info.plc"}
109
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "ncbimmdb", "ncbitool", "vibrant", "ncbidesk", �
110
"ncbiblast", "ncbiblastapi"}
112
{{projPath:"demo:", fileList:{"entrez2.c"}}}
114
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:�
115
myLibs, fileData:myFiles}
118
set myName to "blastcl3"
119
set myFeatures to {"sockets"}
120
set mySettings to {prefixFile:"blastcl3.pfx", ppcProject:{}}
121
set myRsrcs to {"ncbilogo.r", "Info.plc"}
122
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "netcli", "ncbibls3"}
124
{{projPath:"demo:", fileList:{"blastall.c"}}}
125
set blastcl3Data to �
126
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:�
127
myLibs, fileData:myFiles}
130
set myName to "bl2seq"
131
set myFeatures to {"sockets"}
132
set mySettings to {prefixFile:"", ppcProject:{}}
133
set myRsrcs to {"ncbilogo.r", "Info.plc"}
134
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "netcli", "ncbibls3", "ncbiid1"}
136
{{projPath:"demo:", fileList:{"bl2seq.c"}}}
138
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:�
139
myLibs, fileData:myFiles}
142
set myName to "megablast"
143
set myFeatures to {"sockets"}
144
set mySettings to {prefixFile:"", ppcProject:{}}
145
set myRsrcs to {"ncbilogo.r", "Info.plc"}
146
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "ncbiblast", "ncbiblastapi"}
148
{{projPath:"demo:", fileList:{"megablast.c"}}}
149
set megablastData to �
150
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:�
151
myLibs, fileData:myFiles}
154
set myName to "copymat"
155
set myFeatures to {"sockets"}
156
set mySettings to {prefixFile:"", ppcProject:{}}
157
set myRsrcs to {"ncbilogo.r", "Info.plc"}
158
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "ncbiblast", "ncbiblastapi"}
160
{{projPath:"demo:", fileList:{"copymat.c"}}}
162
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:�
163
myLibs, fileData:myFiles}
166
set impalaData to my SimpleProjectData("impala", {})
167
set item 1 of fileList of item 1 of fileData of impalaData to "profiles.c"
170
set myName to "asn2fsa"
171
set myFeatures to {"sockets"}
172
set mySettings to {prefixFile:"", ppcProject:{}}
173
set myRsrcs to {"ncbilogo.r", "Info.plc"}
174
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "netcli", "ncbiid1"}
176
{{projPath:"demo:", fileList:{"asn2fsa.c"}}}
178
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:�
179
myLibs, fileData:myFiles}
182
set myName to "asn2all"
183
set myFeatures to {"sockets"}
184
set mySettings to {prefixFile:"", ppcProject:{}}
185
set myRsrcs to {"ncbilogo.r", "Info.plc"}
186
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "netcli", "ncbiid1"}
188
{{projPath:"demo:", fileList:{"asn2all.c"}}}
190
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:�
191
myLibs, fileData:myFiles}
194
set myName to "spidey"
195
set myFeatures to {"sockets"}
196
set mySettings to {prefixFile:"", ppcProject:{}}
197
set myRsrcs to {"ncbilogo.r", "Info.plc"}
198
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "netcli", "ncbiid1", �
199
"ncbiblast", "ncbiblastapi"}
201
{{projPath:"demo:", fileList:{"spideymain.c"}}}
203
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:�
204
myLibs, fileData:myFiles}
209
AddProject(sequinData)
210
AddProject(entrez2Data)
211
AddSimpleProject("tbl2asn", {"sockets"})
212
AddSimpleProject("asn2gb", {"sockets"})
213
AddProject(asn2fsaData)
214
AddProject(asn2allData)
215
AddProject(spideyData)
217
-- AddProject(entrezData)
219
if pCreateBlastTargets then
220
AddSimpleProject("formatdb", {})
221
AddSimpleProject("fastacmd", {})
223
AddProject(bl2seqData)
225
AddSimpleProject("blastall", {})
226
AddSimpleProject("blastpgp", {})
228
AddProject(blastcl3Data)
229
AddProject(megablastData)
230
AddSimpleProject("blastclust", {})
231
AddSimpleProject("rpsblast", {})
232
AddSimpleProject("seedtop", {})
233
AddProject(copymatData)
234
AddSimpleProject("makemat", {})
236
AddProject(impalaData)
257
global gStationeryDir
259
on GetFileNames(relPath)
260
set theFiles to list folder (gSourceDir & relPath) without invisibles
261
set theFiles to EndsWith(theFiles, ".c") -- Assume C projects not C++
266
on EndsWith(aList, suffix)
268
repeat with f in aList
269
if (f ends with suffix) then
270
set newList to newList & (f as string)
279
CreateFolder(gIncludeDir)
280
tell application "Finder"
282
set corelibFolder to folder (gDistribRoot & "corelib")
284
my UpdateRenameHeader("ncbilcl.met", corelibFolder, "ncbilcl.h", "")
289
on ResolveAlias(pathname)
290
tell application "Finder"
291
if exists folder pathname then
292
-- if pathname does not end with ":" then set pathname to pathname & ":"
293
return folder pathname as string
295
if exists alias file pathname then return the original item of alias file pathname as string
301
tell application "Finder"
303
set vers to the version as text
305
if second character of vers is equal to "." then
306
set vers to "0" & vers
309
return vers > 10 or vers = 10
314
on stripVolName(macPath)
315
set saveTID to get text item delimiters of AppleScript
316
set text item delimiters of AppleScript to ":"
317
set strippedPath to (rest of text items of macPath) as string
318
set text item delimiters of AppleScript to saveTID
323
tell application "Finder"
325
return the home as string
335
set modRoot to ResolveAlias(pRootFolderPath & pRootFolderName)
337
if modRoot is "" then
338
set modRoot to ResolveAlias(gHomeDir & pRootFolderName)
344
set myPath to path to me as string
345
if myPath contains "Script Editor" or �
346
myPath contains "osascript" or �
347
myPath contains "Smile.app" then
348
-- Oops! running under script editor. 'me' is Script Editor not this script.
349
-- use the location this script is supposed to be in.
350
return gDistribRoot & "make:"
352
tell application "Finder"
353
return container of myPath as string
359
tell application "Finder"
361
set gProjectData to {}
363
set gStartupDisk to startup disk as string
364
set gHomeDir to my HomeDir()
365
set gDistribRoot to my ModuleRoot()
367
set gIncludeDir to gDistribRoot & "include:"
368
set gSourceDir to gDistribRoot
369
set gLibsDir to gDistribRoot & "lib:"
370
set gProjectsDir to gDistribRoot & "build:"
371
set gRsrcsDir to gDistribRoot & "link:macmet:"
372
set gStationeryDir to gProjectsDir & pStationeryName & ":"
373
set gMakeDir to my GetMyPath()
378
on HeaderExists(header, headerDir)
379
tell application "Finder"
380
if headerDir is "" then set headerDir to folder gIncludeDir
381
return exists file header of headerDir
385
on IsOlderThan(fileA, fileB)
386
tell application "Finder"
387
return (the modification date of fileA < the modification date of fileB)
391
on UpdateRenameHeader(canonicalName, canonicalDir, dotHName, dotHDir)
392
tell application "Finder"
394
set needRename to (dotHName is not "")
395
if not needRename then set dotHName to canonicalName
396
if dotHDir is "" then set dotHDir to folder gIncludeDir
398
-- This file is only present if the script was interrupted.
399
if needRename and my HeaderExists(canonicalName, dotHDir) then
400
delete file canonicalName of dotHDir
403
-- The native config file.
404
-- If it's missing, assume this is a prepared distribution and the header is already up-to-date.
405
if not my HeaderExists(canonicalName, canonicalDir) then return
406
set canonicalFile to file canonicalName of canonicalDir
409
if my HeaderExists(dotHName, dotHDir) then
410
set dotHFile to file dotHName of dotHDir
411
if my IsOlderThan(dotHFile, canonicalFile) then
414
set needCopy to false
419
duplicate canonicalFile to dotHDir
420
if needRename then set name of file canonicalName of dotHDir to dotHName
424
end UpdateRenameHeader
427
on AppendAccessPath(aPath, isRecursive, isUserPath)
428
tell application "CodeWarrior IDE"
429
if (aPath does not end with ":") then set aPath to aPath & ":"
431
set aPath to POSIX path of aPath
432
set pathsToAdd to {{name:aPath, recursive:isRecursive, origin:absolute, format:Unix Path}}
434
Set Preferences of panel "Access Paths" to {User Paths:pathsToAdd}
436
Set Preferences of panel "Access Paths" to {System Paths:pathsToAdd}
442
on AppendPrefixFile(filename)
443
tell application "CodeWarrior IDE"
445
Set Preferences of panel "C/C++ Compiler" to {Prefix File:prefixFile}
448
set oldtext to Get Preferences of {Prefix Text} from panel "C/C++ Preprocessor"
449
set oldtext to (Prefix Text of oldtext)
450
set prefixFileInclude to (oldtext & return & "#include \"" & filename & "\"")
451
Set Preferences of panel "C/C++ Preprocessor" to {Prefix Text:prefixFileInclude}
457
on SetupTarget(proj, targetIndex)
458
tell application "CodeWarrior IDE"
460
set targetName to name of target targetIndex of project document 1
461
if targetName contains "Carbon" then
462
set targetAPI to "Carbon"
463
else if targetName contains "Mach-O" then
464
if not my IsOSX() then return -- do not try to populate Mach-O targets on pre-OS X systems.
465
set targetAPI to "Mach-O"
466
else if targetName contains "Win32" then
467
set targetAPI to "Win32"
470
if targetName contains "Debug" then
471
set targetDebug to true
472
set targetProfile to false
473
else if targetName contains "Profile" then
474
set targetDebug to false
475
set targetProfile to true
476
else -- if targeName contains "Final" then
477
set targetDebug to false
478
set targetProfile to false
481
-- NOTE: no Profile targets. if pCreateProfiledTargets, we make the debug targets also profile-able.
483
set the current target of project document 1 to target targetIndex of project document 1
485
-- initialize variables
487
set projFeatures to {}
490
-- Grab the fields of our project record and store them in local variables.
491
set projName to proj's name
492
set projSettings to proj's settings
494
set projFeatures to proj's features
497
set sysPaths to proj's sysPaths
500
set projRsrcs to proj's rsrcs
502
set projLibs to proj's projLibs
503
set projFileData to proj's fileData
505
-- Figure out what our output file and input libraries will be named.
506
set fileNameSuffix to ""
508
if targetAPI is "Carbon" then
509
set fileNameSuffix to "_C"
510
else if targetAPI is "Mach-O" then
511
set fileNameSuffix to "_M"
512
else if targetAPI is "Win32" then
513
set fileNameSuffix to "_W"
518
set fileNameSuffix to fileNameSuffix & "_D"
519
else if targetProfile then
520
set fileNameSuffix to fileNameSuffix & "_P"
522
set fileNameSuffix to fileNameSuffix & "_O" -- for Optimized.
525
-- non debug targets get different output names.
526
if not targetDebug and not targetProfile then
527
if targetAPI is "Mach-O" then
528
set targetFilename to projName & "OSX" -- Mach adds OSX on the end.
529
else if targetAPI is "Carbon" then
530
set targetFilename to projName & "OS9" -- Carbon adds OS9 on the end.
532
set targetFilename to projName -- Windows have same name as project.
535
set targetFilename to projName & fileNameSuffix
538
-- make sure Mach bundles have .app on the end.
539
if targetAPI is "Mach-O" then
540
set targetFilename to targetFilename & ".app"
541
else if targetAPI is "Win32" then
542
-- and Windows executables have .exe
543
set targetFilename to targetFilename & ".exe"
546
-- Get Preference Panel names.
547
if targetAPI is "Mach-O" then
548
set targetPanelName to "PPC Mac OS X Project"
549
set codeGenPanelName to "PPC CodeGen Mach-O"
550
else if targetAPI is "Win32" then
551
set targetPanelName to "x86 Project"
552
set codeGenPanelName to "x86 CodeGen"
554
set targetPanelName to "PPC Project"
555
set codeGenPanelName to "PPC CodeGen"
558
-- Set the name of the output file (the application)
559
Set Preferences of panel targetPanelName to {File Name:targetFilename}
561
-- If specified, set the File Creator.
563
set creatorName to creator of projSettings
564
Set Preferences of panel targetPanelName to {File Creator:creatorName}
567
-- If we have any per-project override settings, set them.
568
if (count ppcProject of projSettings) > 0 then
570
Set Preferences of panel targetPanelName to ppcProject of projSettings
575
if targetAPI is "Mach-O" then
576
my AppendAccessPath(gDistribRoot, true, false) -- end of system paths.
578
my AppendAccessPath(gDistribRoot, true, true) -- end of user paths.
581
-- Add per-project system paths.
583
repeat with i in sysPaths
584
copy {name:i, recursive:false, origin:absolute} to end of pathsToAdd
586
if (count pathsToAdd) > 0 then �
587
Set Preferences of panel "Access Paths" to {System Paths:pathsToAdd}
589
-- Set the appropriate prefix file.
590
set prefixFile to prefixFile of projSettings
591
if targetAPI is "Win32" and projFeatures contains "winprefix" then
592
set prefixFile to "Win32Headers.pch"
594
if prefixFile is "" then
595
set prefixFile to "CarbonPrefix.h"
597
set prefixFile to "Carbon-" & prefixFile
600
if prefixFile is not "" then
601
my AppendPrefixFile(prefixFile)
607
repeat with group in projFileData
608
set projPath to projPath of group
609
set fileList to group's fileList
612
repeat with i in fileList
613
--try -- ignore it if the file doesn't exist.
615
-- NOTE: if the following line is within a tell "Codewarrior" block then
616
-- the following Add Files command will fail.
617
copy alias (gSourceDir & projPath & i) to end of filesToAdd
621
tell application "CodeWarrior IDE"
624
-- Take out source files that do not belong.
625
--set fileNotList to group's fileNotList
626
--Remove Files fileNotList
630
tell application "CodeWarrior IDE"
632
-- take care of debugging and profiling settings
633
if targetDebug or targetProfile then
634
set the debug of every target file of target targetIndex �
635
of project document 1 to true
639
if targetAPI is "Carbon" then
640
if targetProfile then
641
(* ===== Panel PPC Processor ===== *)
642
Set Preferences of panel codeGenPanelName to �
645
(* ===== Panel PPC Processor ===== *)
646
Set Preferences of panel codeGenPanelName to �
651
-- Add user libraries.
653
if projFeatures contains "sockets" and targetAPI is "Carbon" then
654
if projLibs does not contain "mitsock" then
655
copy "mitsock" to beginning of projLibs
658
repeat with i in projLibs
659
if exists file (gLibsDir & i & fileNameSuffix & ".lib") of application "Finder" then
660
copy gLibsDir & i & fileNameSuffix & ".lib" to end of filesToAdd
670
if targetAPI is not "Win32" then
671
repeat with i in projRsrcs
672
if targetAPI is "Carbon" then
673
if i ends with ".plc" then
674
copy gRsrcsDir & "Carbon-" & i to end of filesToAdd
676
copy gRsrcsDir & i to end of filesToAdd
679
-- Mach-O does not need the .r files, only the .plc files.
680
if i does not end with ".r" then
681
copy gRsrcsDir & i to end of filesToAdd
694
tell application "CodeWarrior IDE"
696
if (i > (count of targets of project document 1)) then
699
-- get references to all the targets files
700
set atarget to get target i of project document 1
701
set trefs to (target files of atarget whose linked is true)
704
if ((count of trefs) � 0) then
705
repeat with tf in trefs
706
-- get locations of the targets files (as file objects)
707
tell application "CodeWarrior IDE"
708
set f to (location of tf)
710
tell application "Finder"
711
-- convert the file's to strings (colon style paths)
713
copy f as string to end of tfiles
714
on error errmsg number errnum
715
-- file in target but does not exist.
716
if errnum � -2753 then -- variable not defined.
717
error errmsg number errnum
726
on UpdateTarget(proj, targetIndex)
728
tell application "CodeWarrior IDE"
730
set targetName to name of target targetIndex of project document 1
731
if targetName contains "Carbon" then
732
set targetAPI to "Carbon"
733
else if targetName contains "Mach-O" then
734
if not my IsOSX() then return -- do not try to populate Mach-O targets on pre-OS X systems.
735
set targetAPI to "Mach-O"
736
else if targetName contains "Win32" then
737
set targetAPI to "Win32"
740
-- Grab the fields of our project record and store them in local variables.
741
set projName to proj's name
743
set targetName to name of target targetIndex of project document 1
745
set the current target of project document 1 to target targetIndex of project document 1
747
-- initialize variables
748
set projFeatures to {}
750
-- Grab the fields of our project record and store them in local variables.
752
set projFeatures to proj's features
754
set projFileData to proj's fileData
758
-- Update source files
759
set targetFileList to my GetTargetFiles(targetIndex)
760
repeat with group in projFileData
761
set projPath to projPath of group -- projPath is relative.
763
set fileList to group's fileList
767
repeat with i in fileList
768
set fileFullPath to gSourceDir & projPath & i
769
set found to targetFileList contains fileFullPath
771
try -- ignore it if the file doesn't exist.
773
-- NOTE: if the following line is within a tell "Codewarrior" block then
774
-- the following Add Files command will fail.
776
copy alias (fileFullPath) to end of filesToAdd
781
tell application "CodeWarrior IDE"
782
if ((count of filesToAdd) is not 0) then
784
set targetFileList to my GetTargetFiles(targetIndex)
787
-- Take out source files that do not belong.
788
--set fileNotList to group's fileNotList
789
--Remove Files fileNotList
795
on CreateFolder(folderPath)
796
set text item delimiters of AppleScript to ":"
797
-- strip off disk name.
798
tell application "Finder"
800
if (exists disk (first text item of folderPath)) then
801
set pathSoFar to first text item of folderPath
802
set folderPath to (rest of text items of folderPath) as string
804
repeat with f in (text items of folderPath)
805
set longerPath to pathSoFar & ":" & f
806
if not (exists folder (longerPath)) then
807
make new folder at folder (pathSoFar) with properties {name:f}
809
set pathSoFar to longerPath
812
set text item delimiters of AppleScript to ""
815
on GetStationeryName(proj)
816
set stationeryDir to gProjectsDir & pStationeryName & ":"
817
set stationeryName to pStationeryName & pProjectFileExt
819
CreateFolder(stationeryDir)
820
tell application "Finder"
821
-- does the Library Stationery already exist?
822
if not (exists file (stationeryDir & stationeryName)) then
824
duplicate file (stationeryName) of folder gRsrcsDir to folder stationeryDir
827
return (stationeryDir & stationeryName)
828
end GetStationeryName
830
on CreateProject(proj)
831
tell application "CodeWarrior IDE"
838
set projFilename to proj's name & pProjectFileExt
839
set projPathname to gProjectsDir & projFilename
840
if pAlwaysCreateProjects or not (exists file projPathname of application "Finder") then
843
close (the first project document whose name is projFilename)
846
set stationeryName to my GetStationeryName(proj)
848
Create Project projPathname from stationery alias stationeryName
849
if the name of window 1 is "Project Messages" then
850
close first window -- "close window 1" becomes "Close Window 1" (different event)
853
repeat with i from 1 to (count targets of project document 1)
854
my SetupTarget(proj, i)
857
-- project already exists. Make sure it has all right files.
859
if the name of window 1 is "Project Messages" then
860
close first window -- "close window 1" becomes "Close Window 1" (different event)
862
repeat with i from 1 to (count targets of project document 1)
863
my UpdateTarget(proj, i)
866
if pProjectsCVSEnabled then
868
Set Preferences of panel "VCS Setup" to {VCS Active:true, Connection Method:"mwCVS"}
871
set the current target of project document 1 to target 1 of project document 1
877
on CreateAllProjects()
878
CreateFolder(gProjectsDir)
879
CleanupFiles(gProjectsDir)
881
repeat with proj in gProjectData
885
end CreateAllProjects
888
a target spec is a string of words "MSL Debug", all of which appear on our list of keywords.
889
Convert a Build file name to a target spec by filtering out non-keywords.
890
Each Build file creates another target spec.
891
A project target must match one of the target specs to compile.
892
To match, a target's name must contain each of the words in the target spec.
893
An empty target spec matches everything.
894
An empty list of target specs (no Build files) matches nothing,
895
But if there are no Build files we make target specs based on
896
the script parameters.
900
set theFiles to (list folder gMakeDir without invisibles)
901
set targetSpecs to {}
902
repeat with f in theFiles
903
if (f begins with "Build ") then
904
set targetSpecs to targetSpecs & MakeTargetSpec(f)
907
-- no Build files? match what the script parameters say to match.
908
-- NOTE: This is dependent on pTargetKeyWords and the target names in the stationery.
909
if (count items of targetSpecs) is 0 then
911
if pCreateDebugTargets then
912
if pCreateMachOTargets then copy ("Mach-O Debug") to end of targetSpecs
913
if pCreateCarbonTargets then copy ("Carbon Debug") to end of targetSpecs
914
if pCreateWinTargets then copy ("Win32 Debug") to end of targetSpecs
916
if pCreateProfiledTargets then
917
if pCreateMachOTargets then copy ("Mach-O Profile") to end of targetSpecs
918
if pCreateCarbonTargets then copy ("Carbon Profile") to end of targetSpecs
919
if pCreateWinTargets then copy ("Win32 Profile") to end of targetSpecs
921
if pCreateOptimizedTargets then
922
if pCreateMachOTargets then copy ("Mach-O Final") to end of targetSpecs
923
if pCreateCarbonTargets then copy ("Carbon Final") to end of targetSpecs
924
if pCreateWinTargets then copy ("Win32 Final") to end of targetSpecs
932
repeat with w in (words of f)
933
if pTargetKeyWords contains w then
934
set tspec to tspec & w & " "
940
on OkaytoBuild(targetName, targetSpecs)
941
--This target name must match at least one of the target specs.
942
repeat with ts in targetSpecs
943
if MatchSpec2Target(ts, targetName) then return true
948
on MatchSpec2Target(targSpec, targName)
949
-- the targetname must contain all of the words in the target spec.
950
repeat with w in (words of targSpec)
951
if w is not in targName then return false
956
on BuildProject(projName, targetSpecs)
957
tell application "CodeWarrior IDE"
958
open (gProjectsDir & projName & pProjectFileExt)
959
if the name of window 1 is "Project Messages" then
960
close first window -- "close window 1" becomes "Close Window 1" (different event)
962
repeat with i from 1 to (count targets of project document 1)
963
-- do we want to build this target?
964
set thisTarget to name of target i of project document 1
965
if my OkaytoBuild(thisTarget, targetSpecs) then
967
set the current target of project document 1 to target i of project document 1
968
if pSaveContinueOnErrors then
971
on error errmsg number errnum
973
set errFileName to (gProjectsDir & projName & "-" & i & ".errs")
974
Save Error Window As (file errFileName)
977
error errmsg number errnum
980
else -- stop on any error.
983
-- If there were compiler warnings, then a compiler window will be in front.
984
-- For whatever reason, this causes the next "set the current target..." to fail.
985
-- So check for the window and close it.
986
if the name of window 1 is "Errors & Warnings" then
987
close first window -- "close window 1" becomes "Close Window 1" (different event)
991
set the current target of project document 1 to target 1 of project document 1
996
on BuildAllProjects()
997
set targetSpecs to GetTargetSpecs()
998
repeat with proj in gProjectData
1000
set projName to proj's name
1004
if projName is not "" then
1005
BuildProject(projName, targetSpecs)
1009
end BuildAllProjects
1011
-- Delete everything in the folder 'thePath' except the saveFile.
1012
on CleanupFolder(thePath, saveFile)
1013
repeat with f in list folder (thePath) with invisibles
1014
if (f as string is not saveFile) then
1016
tell application "Finder" to delete folder (thePath & f)
1019
tell application "Finder" to delete file (thePath & f)
1025
on CleanupFiles(thePath)
1026
-- get rid of all the files and folders starting with xxxx in thePath
1027
repeat with f in list folder (thePath) without invisibles
1028
if ((f as string) begins with "xxxx") then
1030
tell application "Finder" to delete folder (thePath & f)
1033
tell application "Finder" to delete file (thePath & f)
1037
-- delete the stationery folder.
1039
tell application "Finder" to delete folder (thePath & pStationeryName)
1043
on SignalCompletion()
1045
end SignalCompletion
1047
with timeout of 60000 seconds
1053
tell application "CodeWarrior IDE" to activate
1057
if pShouldBuild then
1061
CleanupFiles(gProjectsDir)