|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/make/makeLibs.met |
source navigation diff markup identifier search freetext search file search |
1 -- C libs --
2
3 --
4 -- Properties
5 --
6 property pRootFolderName : "ncbi" -- name of the toolkit directory
7 property pRootFolderPath : "" -- full path of the parent of the toolkit directory. Optional
8
9 property pProjectFileExt : ".mcp"
10
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.
14
15 -- Whether to recreate existing project files.
16 property pAlwaysCreateProjects : false
17
18 -- Which targets to build.
19 -- All of the targets are populated all the time. These affect what is compiled & built.
20 property pCreateMachOTargets : true
21 property pCreateCarbonTargets : false
22 property pCreateWinTargets : false
23
24 property pCreateOptimizedTargets : true
25 property pCreateDebugTargets : false
26 property pCreateProfiledTargets : false
27
28 -- Whether to have the projects use CVS or not.
29 property pProjectsCVSEnabled : true
30
31 -- Whether to compile anything.
32 property pShouldBuild : true
33
34 property pStationeryName : "LibraryStationery"
35
36 -- the handler GetTargetSpecs should change if these do.
37 property pTargetKeyWords : "Mach-O Carbon Win32 Debug Final Profile"
38
39
40 global gStartupDisk
41 global gHomeDir
42 global gDistribRoot
43 global gProjectsDir
44 global gSourceDir
45 global gIncludeDir
46 global gRsrcsDir
47 global gMakeDir
48
49 global gProjectData
50
51 on ProjectData(projName, features, aFileData)
52
53 if (count characters of projName) > 25 then
54 set projName to characters 1 through 25 of projName as string
55 end if
56
57 if features does not contain "C" and features does not contain "C++" then
58 copy "C" to end of features
59 end if
60 set myFeatures to features
61
62 return {name:projName, features:myFeatures, rsrcs:{}, settings:Â
63 {prefixFile:"", ppcProject:{}}, projLibs:{}, sysPaths:{}, fileData:Â
64 aFileData}
65
66 end ProjectData
67
68 on AddProject(projData)
69 copy projData to end of gProjectData
70 end AddProject
71
72 on AddSimpleProject(projName, features, section)
73 AddProject(ProjectData(projName, features, {mkFileData(section)}))
74 end AddSimpleProject
75
76 on AddSimpleProjectListFiles(projName, features, section, fileList)
77 AddProject(ProjectData(projName, features, {mkFileDataListFiles(section, fileList)}))
78 end AddSimpleProjectListFiles
79
80 on AddSimpleProjectExceptFiles(projName, features, section, fileNotList)
81 AddProject(ProjectData(projName, features, {mkFileDataExceptFiles(section, fileNotList)}))
82 end AddSimpleProjectExceptFiles
83
84 on mkFileData(section)
85 if (section does not end with ":") then set section to section & ":"
86 return {projPath:section, fileList:GetFileNames(section), fileNotList:{}}
87 end mkFileData
88
89 on mkFileDataListFiles(section, fileList)
90 if (section does not end with ":") then set section to section & ":"
91 set newFileList to {}
92 repeat with i in fileList
93 if i does not contain "." then set i to i & ".c"
94 copy (contents of i) to end of newFileList
95 end repeat
96 return {projPath:section, fileList:newFileList, fileNotList:{}}
97 end mkFileDataListFiles
98
99 on mkFileDataExceptFiles(section, fileNotList)
100 if (section does not end with ":") then set section to section & ":"
101 set theFileList to GetFileNames(section)
102 set theRealFileList to {}
103 repeat with f in theFileList
104 if fileNotList does not contain f then
105 copy f to the end of theRealFileList
106 end if
107 end repeat
108 return {projPath:section, fileList:theRealFileList, fileNotList:fileNotList}
109 end mkFileDataExceptFiles
110
111 on DataPlusPrefixFile(dataRec, prefix)
112 tell application "CodeWarrior IDE"
113
114 set the prefixFile of dataRec's settings to prefix
115 return dataRec
116
117 end tell
118 end DataPlusPrefixFile
119
120 on GetFileNames(relPath)
121 set theFiles to list folder (gSourceDir & relPath) without invisibles
122 set theFiles to EndsWith(theFiles, ".c") -- Assume C projects not C++
123
124 return theFiles
125 end GetFileNames
126
127 on EndsWith(aList, suffix)
128 set newList to {}
129 repeat with f in aList
130 if (f ends with suffix) then
131 copy (f as string) to end of newList
132 end if
133 end repeat
134 return newList
135 end EndsWith
136
137 on SetProjectData()
138
139 -- Only needed for Carbon
140 AddSimpleProject("mitsock", {}, "connect:mitsock")
141
142 AddProject(ProjectData("ncbi", {"winprefix"}, {Â
143 mkFileDataExceptFiles("corelib:", {"drwnflpt.c", "drwnfspc.c", "drwnmfls.c", "ncbiargs.c", "ncbimain.c"}), Â
144 mkFileData("corelib:morefile:"), Â
145 mkFileDataListFiles("connect:", {"urlquery"}), Â
146 mkFileData("ctools:"), Â
147 mkFileDataListFiles("util:tables:", {"raw_scoremat"}), Â
148 mkFileDataExceptFiles("asnlib:", {"asncode.c", "asntool.c"})}))
149
150 AddProject(ProjectData("ncbiobj", {}, {Â
151 mkFileDataExceptFiles("object:", {"objmime.c"}), Â
152 mkFileDataExceptFiles("access:", {"strucapi.c"}), Â
153 mkFileData("api:"), Â
154 mkFileData("util:creaders:"), Â
155 mkFileDataExceptFiles("ddv:", {"ddvmain.c"})}))
156
157 AddSimpleProject("vibrant", {"winprefix"}, "vibrant")
158
159 AddSimpleProjectExceptFiles("ncbicdr", {}, "cdromlib", {"acccn3ds.c", "accentr.c", "accmmdbs.c", "accutils.c"})
160
161 AddSimpleProjectExceptFiles("ncbidesk", {}, "desktop", {"sdisplay.c"})
162
163 AddSimpleProject("ddvlib", {}, "ddv")
164
165 AddProject(DataPlusPrefixFile(ProjectData("ncbimmdb", {}, {Â
166 mkFileDataListFiles("biostruc:", {Â
167 "corematx", "dvncode", "objmmdb1", "objmmdb2", "objmmdb3", "mmdbapi", Â
168 "mmdbapi1", "mmdbapi2", "mmdbapi3", "mmdbapi4", "mmdbentr", "vastsubs", Â
169 "prunebsc"}), Â
170 mkFileDataListFiles("object:", {Â
171 "objmime"}), Â
172 mkFileDataListFiles("access:", {Â
173 "strucapi"}), Â
174 mkFileDataListFiles("biostruc:cn3d:", {Â
175 "objcn3d"}), Â
176 mkFileDataListFiles("biostruc:cdd:", {Â
177 "objcdd", "cddutil", "cddposutil", Â
178 "thrdalgs", "thrdatd", "thrdbwfi", "thrdcpal", Â
179 "thrdcpll", "thrdcprl", "thrdcxei", "thrddgri", "thrdrsmp", Â
180 "thrdsal0", "thrdsalr", "thrdsalu", "thrdsgoi", "thrdslo0", Â
181 "thrdslor", "thrdslou", "thrdspci", "thrdspea", "thrdspel", Â
182 "thrdspni", "thrdttb0", "thrdttbi", "thrdzsc"})}), "gif.pfx"))
183
184 AddSimpleProject("ncbiNacc", {}, "cdromlib")
185
186 AddSimpleProject("vibnet", {}, "network:vibnet")
187
188 AddSimpleProject("ncbitool", {}, "tools")
189
190 AddSimpleProject("netentr", {}, "network:entrez:client")
191
192 AddSimpleProjectExceptFiles("ncbibls3", {}, "network:blast3:client", {"blastcl3.c"})
193
194 AddSimpleProjectExceptFiles("ncbiid1", {}, "network:id1arch", {"idfetch.c"})
195
196 -- AddSimpleProject("ncbiid2", {}, "network:id2arch")
197
198 AddSimpleProjectExceptFiles("ncbimla", {}, "network:medarch:client", {"sybmed.c"})
199
200 AddProject(DataPlusPrefixFile(ProjectData("ncbitxc2", {}, {Â
201 mkFileDataExceptFiles("network:taxon1:taxon2:", {"txcproc.c"}), Â
202 mkFileDataExceptFiles("network:taxon1:common:", {"checkid.c"})}), "tax2.pfx"))
203
204 AddSimpleProjectListFiles("ncbiconn", {"winprefix"}, "connect", Â
205 {"ncbi_buffer", "ncbi_socket", "ncbi_core", "ncbi_core_c", "ncbi_types", "ncbi_util", Â
206 "ncbi_priv", "ncbi_ansi_ext", "ncbi_connection", "ncbi_connector", "ncbi_connutil", Â
207 "ncbi_file_connector", "ncbi_host_info.c", "ncbi_http_connector", Â
208 "ncbi_memory_connector", "ncbi_server_info", "ncbi_service", Â
209 "ncbi_service_connector", "ncbi_dispd", "ncbi_lb", "ncbi_local", "ncbi_lbsmd_stub", Â
210 "ncbi_socket_connector", "ncbi_ftp_connector", "ncbi_sendmail"})
211
212 AddSimpleProjectExceptFiles("netcli", {}, "network:nsclilib", {"ni_encr.c", "ni_list.c", "ni_lib.c", "ni_disp.c", "ni_encr.c"})
213
214
215 AddSimpleProject("ncbispell", {}, "network:spell:client")
216
217 AddSimpleProject("ncbiblast", {}, "algo:blast:core")
218
219 AddSimpleProject("ncbiblastapi", {}, "algo:blast:api")
220
221 AddSimpleProject("blastcompadj", {}, "algo:blast:composition_adjustment")
222
223 end SetProjectData
224
225 --
226 -- Set Global variables
227 --
228
229 on IsOSX()
230 tell application "Finder"
231 set vers to the version as text
232 if second character of vers is equal to "." then
233 set vers to "0" & vers
234 end if
235 return vers > 10 or vers = 10
236 end tell
237 end IsOSX
238
239 on ResolveAlias(pathname)
240 tell application "Finder"
241 if exists folder pathname then
242 -- if pathname does not end with ":" then set pathname to pathname & ":"
243 return folder pathname as string
244 end if
245 if exists alias file pathname then return the original item of alias file pathname as string
246 end tell
247 return ""
248 end ResolveAlias
249
250 on stripVolName(macPath)
251 set saveTID to get text item delimiters of AppleScript
252 set text item delimiters of AppleScript to ":"
253 set strippedPath to (rest of text items of macPath) as string
254 set text item delimiters of AppleScript to saveTID
255 return strippedPath
256 end stripVolName
257
258 on HomeDir()
259 tell application "Finder"
260 if my IsOSX() then
261 return the home as string
262 else
263 return gStartupDisk
264 end if
265 end tell
266 end HomeDir
267
268 on ModuleRoot()
269 set modRoot to ""
270 try
271 set modRoot to ResolveAlias(pRootFolderPath & pRootFolderName)
272 end try
273 if modRoot is "" then
274 set modRoot to ResolveAlias(gHomeDir & pRootFolderName)
275 end if
276 return modRoot
277 end ModuleRoot
278
279 on GetMyPath()
280 set myPath to path to me as string
281 if myPath contains "Script Editor" or Â
282 myPath contains "osascript" or Â
283 myPath contains "Smile.app" then
284 -- Oops! running under script editor. 'me' is Script Editor not this script.
285 -- use the location this script is supposed to be in.
286 return gDistribRoot & "make:"
287 else
288 tell application "Finder"
289 return container of myPath as string
290 end tell
291 end if
292 end GetMyPath
293
294 on SetGlobals()
295 tell application "Finder"
296
297 set gProjectData to {}
298
299 set gStartupDisk to startup disk as string
300 set gHomeDir to my HomeDir()
301 set gDistribRoot to my ModuleRoot()
302
303 set gIncludeDir to gDistribRoot & "include:"
304 set gSourceDir to gDistribRoot
305 set gProjectsDir to gDistribRoot & "lib:"
306 set gRsrcsDir to gDistribRoot & "link:macmet:"
307 set gMakeDir to my GetMyPath()
308
309 end tell
310 end SetGlobals
311
312 on HeaderExists(header, headerDir)
313 tell application "Finder"
314 if headerDir is "" then set headerDir to folder gIncludeDir
315 return exists file header of headerDir
316 end tell
317 end HeaderExists
318
319 on IsOlderThan(fileA, fileB)
320 tell application "Finder"
321 return (the modification date of fileA < the modification date of fileB)
322 end tell
323 end IsOlderThan
324
325 on UpdateRenameHeader(canonicalName, canonicalDir, dotHName, dotHDir)
326 tell application "Finder"
327
328 set needRename to (dotHName is not "")
329 if not needRename then set dotHName to canonicalName
330 if dotHDir is "" then set dotHDir to folder gIncludeDir
331
332 -- This file is only present if the script was interrupted.
333 if needRename and my HeaderExists(canonicalName, dotHDir) then
334 delete file canonicalName of dotHDir
335 end if
336
337 -- The native config file.
338 -- If it's missing, assume this is a prepared distribution and the header is already up-to-date.
339 if not my HeaderExists(canonicalName, canonicalDir) then return
340 set canonicalFile to file canonicalName of canonicalDir
341
342 set needCopy to true
343 if my HeaderExists(dotHName, dotHDir) then
344 set dotHFile to file dotHName of dotHDir
345 if my IsOlderThan(dotHFile, canonicalFile) then
346 delete dotHFile
347 else
348 set needCopy to false
349 end if
350 end if
351 if needCopy then
352 duplicate canonicalFile to dotHDir
353 if needRename then set name of file canonicalName of dotHDir to dotHName
354 end if
355 end tell
356 end UpdateRenameHeader
357
358 on CopyHeaders()
359 CreateFolder(gIncludeDir)
360 tell application "Finder"
361 set corelibFolder to folder (gDistribRoot & "corelib")
362 my UpdateRenameHeader("ncbilcl.met", corelibFolder, "ncbilcl.h", "")
363 end tell
364 end CopyHeaders
365
366
367 on AppendAccessPath(aPath, isRecursive, isUserPath)
368 tell application "CodeWarrior IDE"
369 if (aPath does not end with ":") then set aPath to aPath & ":"
370
371 set aPath to POSIX path of aPath
372 set pathsToAdd to {{name:aPath, recursive:isRecursive, origin:absolute, format:Unix Path}}
373 if isUserPath then
374 Set Preferences of panel "Access Paths" to {User Paths:pathsToAdd}
375 else
376 Set Preferences of panel "Access Paths" to {System Paths:pathsToAdd}
377 end if
378 end tell
379 end AppendAccessPath
380
381
382 on AppendPrefixFile(filename)
383 tell application "CodeWarrior IDE"
384 try -- CW ver. 8
385 Set Preferences of panel "C/C++ Compiler" to {Prefix File:prefixFile}
386 end try
387 try -- CW ver. 9
388 set oldtext to Get Preferences of {Prefix Text} from panel "C/C++ Preprocessor"
389 set oldtext to (Prefix Text of oldtext)
390 set prefixFileInclude to (oldtext & return & "#include \"" & filename & "\"")
391 Set Preferences of panel "C/C++ Preprocessor" to {Prefix Text:prefixFileInclude}
392 end try
393 end tell
394 end AppendPrefixFile
395
396
397 on SetupTarget(proj, targetIndex)
398 tell application "CodeWarrior IDE"
399
400 set targetName to name of target targetIndex of project document 1
401 if targetName contains "Carbon" then
402 set targetAPI to "Carbon"
403 else if targetName contains "Mach-O" then
404 if not my IsOSX() then return -- do not try to populate Mach-O targets on pre-OS X systems.
405 set targetAPI to "Mach-O"
406 else if targetName contains "Win32" then
407 set targetAPI to "Win32"
408 end if
409
410 if targetName contains "Debug" then
411 set targetDebug to true
412 set targetProfile to false
413 else if targetName contains "Profile" then
414 set targetDebug to false
415 set targetProfile to true
416 else -- if targeName contains "Final" then
417 set targetDebug to false
418 set targetProfile to false
419 end if
420
421 -- NOTE: no Profile targets. if pCreateProfiledTargets, we make the debug targets also profile-able.
422
423 set the current target of project document 1 to target targetIndex of project document 1
424
425 -- initialize variables
426 set projRsrcs to {}
427 set projFeatures to {}
428 set sysPaths to {}
429
430 -- Grab the fields of our project record and store them in local variables.
431 set projName to proj's name
432 set projSettings to proj's settings
433 try
434 set projFeatures to proj's features
435 end try
436 try
437 set sysPaths to proj's sysPaths
438 end try
439 try
440 set projRsrcs to proj's rsrcs
441 end try
442 set projLibs to proj's projLibs
443 set projFileData to proj's fileData
444
445 -- mitsock library isn't needed (and won't compile) as Mach-O
446 if projName is "mitsock" and targetAPI is not "Carbon" then
447 return
448 end if
449
450 -- Figure out what our output file and input libraries will be named.
451 set targetFilename to projName
452
453 if targetAPI is "Carbon" then
454 set targetFilename to targetFilename & "_C"
455 else if targetAPI is "Mach-O" then
456 set targetFilename to targetFilename & "_M"
457 else if targetAPI is "Win32" then
458 set targetFilename to targetFilename & "_W"
459 end if
460
461 -- Debug or not.
462 if targetDebug then
463 set targetFilename to targetFilename & "_D"
464 else if targetProfile then
465 set targetFilename to targetFilename & "_P"
466 else
467 set targetFilename to targetFilename & "_O" -- for Optimized.
468 end if
469
470 set targetFilename to targetFilename & ".lib"
471
472 -- Get Preference Panel names.
473 if targetAPI is "Mach-O" then
474 set targetPanelName to "PPC Mac OS X Project"
475 set codeGenPanelName to "PPC CodeGen Mach-O"
476 else if targetAPI is "Win32" then
477 set targetPanelName to "x86 Project"
478 set codeGenPanelName to "x86 CodeGen"
479 else
480 set targetPanelName to "PPC Project"
481 set codeGenPanelName to "PPC CodeGen"
482 end if
483
484 -- Set the name of the output file (the application)
485 Set Preferences of panel targetPanelName to {File Name:targetFilename}
486
487 -- If we have any per-project override settings, set them.
488 if (count ppcProject of projSettings) > 0 then
489 Set Preferences of panel targetPanelName to ppcProject of projSettings
490 end if
491
492
493 if targetAPI is "Mach-O" then
494 my AppendAccessPath(gDistribRoot, true, false) -- end of system paths.
495 else
496 my AppendAccessPath(gDistribRoot, true, true) -- end of user paths.
497 end if
498
499 -- Add per-project system paths.
500 set pathsToAdd to {}
501 repeat with i in sysPaths
502 copy {name:i, recursive:false, origin:absolute} to end of pathsToAdd
503 end repeat
504 if (count pathsToAdd) > 0 then Â
505 Set Preferences of panel "Access Paths" to {System Paths:pathsToAdd}
506
507 -- Set the appropriate prefix file.
508 set prefixFile to prefixFile of projSettings
509 if targetAPI is "Win32" and projFeatures contains "winprefix" then
510 my AppendPrefixFile("Win32Headers.pch")
511 else
512 if prefixFile is "" then
513 set prefixFile to "CarbonPrefix.h"
514 else
515 set prefixFile to "Carbon-" & prefixFile
516 end if
517 my AppendPrefixFile(prefixFile)
518 my AppendPrefixFile("MW-BSD-limits-fix.h")
519 end if
520 end tell
521
522 -- Add source files.
523 repeat with group in projFileData
524 set projPath to projPath of group
525 set fileList to group's fileList
526
527 set filesToAdd to {}
528 repeat with i in fileList
529 try -- ignore it if the file doesn't exist.
530
531 -- NOTE: if the following line is within a tell "Codewarrior" block then
532 -- the following Add Files command will fail.
533 copy alias (gSourceDir & projPath & i) to end of filesToAdd
534 end try
535 end repeat
536
537 tell application "CodeWarrior IDE"
538 Add Files filesToAdd
539
540 -- Take out source files that do not belong.
541 --set fileNotList to group's fileNotList
542 --Remove Files fileNotList
543 end tell
544 end repeat
545
546 tell application "CodeWarrior IDE"
547
548 -- take care of debugging and profiling settings
549 if targetDebug or targetProfile then
550 set the debug of every target file of target targetIndex Â
551 of project document 1 to true
552 end if
553
554
555 if targetAPI is "Carbon" then
556 if targetProfile then
557 (* ===== Panel PPC Processor ===== *)
558 Set Preferences of panel codeGenPanelName to Â
559 {Use Profiler:true}
560 else
561 (* ===== Panel PPC Processor ===== *)
562 Set Preferences of panel codeGenPanelName to Â
563 {Use Profiler:false}
564 end if
565 end if
566
567
568 -- Add resources.
569 set filesToAdd to {}
570 if targetAPI is not "Win32" then
571 repeat with i in projRsrcs
572 copy gRsrcsDir & i to end of filesToAdd
573 end repeat
574
575 Add Files filesToAdd
576 end if
577
578 end tell
579 end SetupTarget
580
581
582 on GetTargetFiles(i)
583 tell application "CodeWarrior IDE"
584 -- get the target
585 if (i > (count of targets of project document 1)) then
586 return {}
587 end if
588 -- get references to all the targets files
589 set atarget to get target i of project document 1
590 set trefs to (target files of atarget whose linked is true)
591 end tell
592 set tfiles to {}
593 if ((count of trefs) 0) then
594 repeat with tf in trefs
595 -- get locations of the targets files (as file objects)
596 tell application "CodeWarrior IDE"
597 set f to (location of tf)
598 end tell
599 tell application "Finder"
600 -- convert the file's to strings (colon style paths)
601 try
602 copy f as string to end of tfiles
603 on error errmsg number errnum
604 -- file in target but does not exist.
605 if errnum -2753 then -- variable not defined.
606 error errmsg number errnum
607 end if
608 end try
609 end tell
610 end repeat
611 end if
612 return tfiles
613 end GetTargetFiles
614
615 on UpdateTarget(proj, targetIndex)
616
617 tell application "CodeWarrior IDE"
618
619 set targetName to name of target targetIndex of project document 1
620 if targetName contains "Carbon" then
621 set targetAPI to "Carbon"
622 else if targetName contains "Mach-O" then
623 if not my IsOSX() then return -- do not try to populate Mach-O targets on pre-OS X systems.
624 set targetAPI to "Mach-O"
625 else if targetName contains "Win32" then
626 set targetAPI to "Win32"
627 end if
628
629 -- Grab the fields of our project record and store them in local variables.
630 set projName to proj's name
631
632 -- mitsock library isn't needed (and won't compile) except under Carbon.
633 if projName is "mitsock" and targetAPI is not "Carbon" then
634 return
635 end if
636
637 set targetName to name of target targetIndex of project document 1
638
639 set the current target of project document 1 to target targetIndex of project document 1
640
641 -- initialize variables
642 set projFeatures to {}
643
644 -- Grab the fields of our project record and store them in local variables.
645 try
646 set projFeatures to proj's features
647 end try
648 set projFileData to proj's fileData
649
650 end tell
651
652 -- Update source files
653 set targetFileList to my GetTargetFiles(targetIndex)
654 repeat with group in projFileData
655 set projPath to projPath of group -- projPath is relative.
656
657 set fileList to group's fileList
658
659 set filesToAdd to {}
660
661 repeat with i in fileList
662 set fileFullPath to gSourceDir & projPath & i
663 set found to targetFileList contains fileFullPath
664 if (not found) then
665 try -- ignore it if the file doesn't exist.
666
667 -- NOTE: if the following line is within a tell "Codewarrior" block then
668 -- the following Add Files command will fail.
669
670 copy alias (fileFullPath) to end of filesToAdd
671 end try
672 end if
673 end repeat
674
675 tell application "CodeWarrior IDE"
676 if ((count of filesToAdd) is not 0) then
677 Add Files filesToAdd
678 set targetFileList to my GetTargetFiles(targetIndex)
679 end if
680
681 -- Take out source files that do not belong.
682 --set fileNotList to group's fileNotList
683 --Remove Files fileNotList
684 end tell
685 end repeat
686
687 end UpdateTarget
688
689 on CreateFolder(folderPath)
690 set text item delimiters of AppleScript to ":"
691 -- strip off disk name.
692 tell application "Finder"
693 set pathSoFar to ""
694 if (exists disk (first text item of folderPath)) then
695 set pathSoFar to first text item of folderPath
696 set folderPath to (rest of text items of folderPath) as string
697 end if
698 repeat with f in (text items of folderPath)
699 set longerPath to pathSoFar & ":" & f
700 if not (exists folder (longerPath)) then
701 make new folder at folder (pathSoFar) with properties {name:f}
702 end if
703 set pathSoFar to longerPath
704 end repeat
705 end tell
706 set text item delimiters of AppleScript to ""
707 end CreateFolder
708
709 on GetStationeryName(proj)
710 set stationeryDir to gProjectsDir & pStationeryName & ":"
711 set stationeryName to pStationeryName & pProjectFileExt
712 try
713 tell application "Finder" to delete folder stationeryDir
714 end try
715
716 CreateFolder(stationeryDir)
717 tell application "Finder"
718 -- does the Library Stationery already exist?
719 if not (exists file (stationeryDir & stationeryName)) then
720 -- copy it.
721 duplicate file (stationeryName) of folder gRsrcsDir to folder stationeryDir
722 end if
723 end tell
724 return (stationeryDir & stationeryName)
725 end GetStationeryName
726
727 on CreateProject(proj)
728 tell application "CodeWarrior IDE"
729 try
730 get proj's name
731 on error
732 return
733 end try
734
735 set projFilename to proj's name & pProjectFileExt
736 set projPathname to gProjectsDir & projFilename
737 if pAlwaysCreateProjects or not (exists file projPathname of application "Finder") then
738
739 try
740 close (the first project document whose name is projFilename)
741 end try
742
743 set stationeryName to my GetStationeryName(proj)
744
745 Create Project projPathname from stationery alias stationeryName
746 if the name of window 1 is "Project Messages" then
747 close first window -- "close window 1" becomes "Close Window 1" (different event)
748 end if
749
750 repeat with i from 1 to (count targets of project document 1)
751 my SetupTarget(proj, i)
752 end repeat
753 else
754 -- project already exists. Make sure it has all right files.
755 open (projPathname)
756 if the name of window 1 is "Project Messages" then
757 close first window -- "close window 1" becomes "Close Window 1" (different event)
758 end if
759 repeat with i from 1 to (count targets of project document 1)
760 my UpdateTarget(proj, i)
761 end repeat
762 end if
763 if pProjectsCVSEnabled then
764 --try
765 Set Preferences of panel "VCS Setup" to {VCS Active:true, Connection Method:"mwCVS"}
766 --end try
767 end if
768 set the current target of project document 1 to target 1 of project document 1
769 Close Project
770
771 end tell
772 end CreateProject
773
774 on CreateAllProjects()
775 CreateFolder(gProjectsDir)
776 CleanupFiles(gProjectsDir)
777
778 repeat with proj in gProjectData
779 CreateProject(proj)
780 end repeat
781
782 end CreateAllProjects
783
784 (*
785 a target spec is a string of words "MSL Debug", all of which appear on our list of keywords.
786 Convert a Build file name to a target spec by filtering out non-keywords.
787 Each Build file creates another target spec.
788 A project target must match one of the target specs to compile.
789 To match, a target's name must contain each of the words in the target spec.
790 An empty target spec matches everything.
791 An empty list of target specs (no Build files) matches nothing,
792 But if there are no Build files we make target specs based on
793 the script parameters.
794 *)
795
796 on GetTargetSpecs()
797 set theFiles to (list folder gMakeDir without invisibles)
798 set targetSpecs to {}
799 repeat with f in theFiles
800 if (f begins with "Build ") then
801 set targetSpecs to targetSpecs & MakeTargetSpec(f)
802 end if
803 end repeat
804 -- no Build files? match what the script parameters say to match.
805 -- NOTE: This is dependent on pTargetKeyWords and the target names in the stationery.
806 if (count items of targetSpecs) is 0 then
807 set debugspec to ""
808 if pCreateDebugTargets then
809 if pCreateMachOTargets then copy ("Mach-O Debug") to end of targetSpecs
810 if pCreateCarbonTargets then copy ("Carbon Debug") to end of targetSpecs
811 if pCreateWinTargets then copy ("Win32 Debug") to end of targetSpecs
812 end if
813 if pCreateProfiledTargets then
814 if pCreateMachOTargets then copy ("Mach-O Profile") to end of targetSpecs
815 if pCreateCarbonTargets then copy ("Carbon Profile") to end of targetSpecs
816 if pCreateWinTargets then copy ("Win32 Profile") to end of targetSpecs
817 end if
818 if pCreateOptimizedTargets then
819 if pCreateMachOTargets then copy ("Mach-O Final") to end of targetSpecs
820 if pCreateCarbonTargets then copy ("Carbon Final") to end of targetSpecs
821 if pCreateWinTargets then copy ("Win32 Final") to end of targetSpecs
822 end if
823 end if
824 return targetSpecs
825 end GetTargetSpecs
826
827 on MakeTargetSpec(f)
828 set tspec to ""
829 repeat with w in (words of f)
830 if pTargetKeyWords contains w then
831 set tspec to tspec & w & " "
832 end if
833 end repeat
834 return tspec
835 end MakeTargetSpec
836
837 on OkaytoBuild(targetName, targetSpecs)
838 --This target name must match at least one of the target specs.
839 repeat with ts in targetSpecs
840 if MatchSpec2Target(ts, targetName) then return true
841 end repeat
842 return false
843 end OkaytoBuild
844
845 on MatchSpec2Target(targSpec, targName)
846 -- the targetname must contain all of the words in the target spec.
847 repeat with w in (words of targSpec)
848 if w is not in targName then return false
849 end repeat
850 return true
851 end MatchSpec2Target
852
853 on BuildProject(projName, targetSpecs)
854 tell application "CodeWarrior IDE"
855 open (gProjectsDir & projName & pProjectFileExt)
856 if the name of window 1 is "Project Messages" then
857 close first window -- "close window 1" becomes "Close Window 1" (different event)
858 end if
859 repeat with i from 1 to (count targets of project document 1)
860 -- do we want to build this target?
861 set thisTarget to name of target i of project document 1
862 if my OkaytoBuild(thisTarget, targetSpecs) then
863
864 set the current target of project document 1 to target i of project document 1
865 if pSaveContinueOnErrors then
866 try
867 Make Project
868 on error errmsg number errnum
869 if (errnum = 5) then
870 set errFileName to (gProjectsDir & projName & "-" & i & ".errs")
871 Save Error Window As (file errFileName)
872 close first window
873 else
874 error errmsg number errnum
875 end if
876 end try
877 else -- stop on any error.
878 Make Project
879 end if
880 -- If there were compiler warnings, then a compiler window will be in front.
881 -- For whatever reason, this causes the next "set the current target..." to fail.
882 -- So check for the window and close it.
883 if the name of window 1 is "Errors & Warnings" then
884 close first window -- "close window 1" becomes "Close Window 1" (different event)
885 end if
886 end if
887 end repeat
888 set the current target of project document 1 to target 1 of project document 1
889 Close Project
890 end tell
891 end BuildProject
892
893 on BuildAllProjects()
894 set targetSpecs to GetTargetSpecs()
895 repeat with proj in gProjectData
896 try
897 set projName to proj's name
898 on error
899 set projName to ""
900 end try
901 if projName is not "" then
902 BuildProject(projName, targetSpecs)
903 end if
904 end repeat
905
906 end BuildAllProjects
907
908 on CleanupFiles(thePath)
909 -- get rid of all the files and folders starting with xxxx in thePath
910 repeat with f in list folder (thePath) without invisibles
911 if ((f as string) begins with "xxxx") then
912 try
913 tell application "Finder" to delete folder (thePath & f)
914 end try
915 try
916 tell application "Finder" to delete file (thePath & f)
917 end try
918 end if
919 end repeat
920 -- delete the stationery folder.
921 try
922 tell application "Finder" to delete folder (thePath & pStationeryName)
923 end try
924 end CleanupFiles
925
926 on SignalCompletion()
927 beep
928 end SignalCompletion
929
930 with timeout of 60000 seconds
931
932 SetGlobals()
933 SetProjectData()
934 CopyHeaders()
935
936 tell application "CodeWarrior IDE" to activate
937
938 CreateAllProjects()
939
940 if pShouldBuild then
941 BuildAllProjects()
942 end if
943
944 CleanupFiles(gProjectsDir)
945
946 SignalCompletion()
947
948 end timeout
949
|
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |