1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960
|
-- C apps --
--
-- Properties
--
property pUsingCPlusPlus : false
property pProjectFileExtension : ".mcp"
-- Whether to recreate existing project files.
property pAlwaysCreateProjects : false
-- Which targets to build.
-- All of the targets are populated all the time. These affect what is compiled & built.
property pCreateCarbonTargets : true
property pCreateMachOTargets : true
property pCreateWinTargets : true
property pCreateDebugTargets : true
property pCreateOptimizedTargets : true
property pCreateProfiledTargets : false
property pCreateBlastTargets : false
-- Whether to compile anything.
property pShouldBuild : true
property pMakeStationeryScript : "makeStat.met"
property pStationeryName : "ApplicationStationery"
property pDirsToCreate : {
{relPath:"", name:"build"},
{relPath:"build", name:pStationeryName}}
global gProjectData
on SimpleProjectData(projName, features)
if (count characters of projName) > 18 then
set projName to characters 1 through 18 of projName as string
end if
tell application "CodeWarrior IDE"
if features does not contain "C" and features does not contain "C++" then
--error "Project " & projName & "'s default language (a feature) must be C or C++."
copy "C" to end of features
end if
set myFeatures to features
return {name:projName, features:myFeatures, rsrcs:{"ncbilogo.r", "Info.plc"}, settings:
{Prefix File:"", ppcProject:{}}, projLibs:
{"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbimmdb", "ncbitool"}, fileData:
{{projPath:"demo:", fileList:{projName}}}}
end tell
end SimpleProjectData
on AddSimpleProject(projName, features)
AddProject(SimpleProjectData(projName, features))
end AddSimpleProject
on AddProject(projData)
copy projData to end of gProjectData
end AddProject
on SetProjectData()
tell application "CodeWarrior IDE"
-- Sequin
set myName to "Sequin"
set myFeatures to {"sockets"}
set mySettings to
{Prefix File:"", creator:"SEQN", ppcProject:{Preferred Heap Size:32000, Min Heap Size:6000}}
set myRsrcs to {"sequin.r", "InfoSequin.plc"}
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "ncbicdr", "vibrant", "ncbidesk",
"ncbimmdb", "ncbitool", "netcli", "netentr", "ncbibls3", "ncbimla",
"ncbitxc2", "ncbiid1", "vibnet"}
set myFiles to
{{projPath:"cdromlib:", fileList:{"accentr", "accutils"}},
{projPath:"sequin:", fileList:{"sequin1", "sequin2", "sequin3", "sequin4", "sequin5",
"sequin6", "sequin7", "sequin8", "sequin9", "sequin10", "sequinx"}}}
set sequinData to
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:
myLibs, fileData:myFiles}
-- Entrez
set myName to "Entrez"
set myFeatures to {"sockets"}
set mySettings to {Prefix File:"", creator:"ENTZ", ppcProject:{}}
set myRsrcs to {"entrez.r", "Info.plc"}
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "ncbicdr", "vibrant", "ncbidesk", "ncbimmdb",
"ncbitool", "netcli", "netentr", "ncbibls3", "ncbiid1", "vibnet"}
set myFiles to
{{projPath:"cdromlib:", fileList:{"accentr", "accutils"}},
{projPath:"demo:", fileList:{"entrez"}}}
set entrezData to
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:
myLibs, fileData:myFiles}
-- Entrez2
set myName to "Entrez2"
set myFeatures to {"sockets"}
set mySettings to {Prefix File:"", creator:"ENTZ", ppcProject:{}}
set myRsrcs to {"entrez.r", "Info.plc"}
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "ncbimmdb", "ncbitool", "vibrant", "ncbidesk"}
set myFiles to
{{projPath:"demo:", fileList:{"entrez2"}}}
set entrez2Data to
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:
myLibs, fileData:myFiles}
-- BlastCL3
set myName to "blastcl3"
set myFeatures to {"sockets"}
set mySettings to {Prefix File:"blastcl3.pfx", ppcProject:{}}
set myRsrcs to {"ncbilogo.r", "Info.plc"}
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "netcli", "ncbibls3"}
set myFiles to
{{projPath:"demo:", fileList:{"blastall"}}}
set blastcl3Data to
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:
myLibs, fileData:myFiles}
-- Bl2seq
set myName to "bl2seq"
set myFeatures to {"sockets"}
set mySettings to {Prefix File:"", ppcProject:{}}
set myRsrcs to {"ncbilogo.r", "Info.plc"}
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "netcli", "ncbibls3", "ncbiid1"}
set myFiles to
{{projPath:"demo:", fileList:{"bl2seq"}}}
set bl2seqData to
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:
myLibs, fileData:myFiles}
-- Impala
set impalaData to my SimpleProjectData("impala", {})
set item 1 of fileList of item 1 of fileData of impalaData to "profiles"
-- Spidey
set myName to "spidey"
set myFeatures to {"sockets"}
set mySettings to {Prefix File:"", ppcProject:{}}
set myRsrcs to {"ncbilogo.r", "Info.plc"}
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "netcli", "ncbiid1"}
set myFiles to
{{projPath:"demo:", fileList:{"spideymain"}}}
set spideyData to
{name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs:
myLibs, fileData:myFiles}
end tell
AddProject(sequinData)
AddProject(entrez2Data)
AddSimpleProject("tbl2asn", {})
AddSimpleProject("asn2gb", {"sockets"})
AddProject(spideyData)
-- AddProject(entrezData)
if pCreateBlastTargets then
AddSimpleProject("formatdb", {})
AddSimpleProject("fastacmd", {})
AddProject(bl2seqData)
AddSimpleProject("blastall", {})
AddSimpleProject("blastpgp", {})
AddProject(blastcl3Data)
AddSimpleProject("megablast", {})
AddSimpleProject("blastclust", {})
AddSimpleProject("rpsblast", {})
AddSimpleProject("seedtop", {})
AddSimpleProject("copymat", {})
AddSimpleProject("makemat", {})
AddProject(impalaData)
end if
end SetProjectData
--
-- Global variables
--
global gStartupDisk
global gHomeDir
global gMWroot
global gMWCWfolder
global gDistribRoot
global gAccessRoot
global gProjectsDir
global gSourceDir
global gIncludeDir
global gLibsDir
global gRsrcsDir
global gMakeDir
global gStationeryDir
on GetFileNames(relPath)
set theFiles to list folder (gSourceDir & relPath) without invisibles
set theFiles to EndsWith(theFiles, ".c") -- Assume C projects not C++
return theFiles
end GetFileNames
on EndsWith(aList, suffix)
set newList to {}
repeat with f in aList
if (f ends with suffix) then
set newList to newList & (f as string)
end if
end repeat
return newList
end EndsWith
on ResolveAlias(pathname)
tell application "Finder"
--if the last character of pathname is ":" then error "Don't use a trailing colon with ResolveAlias."
if exists folder pathname then return pathname & ":"
if exists alias file pathname then return the original item of alias file pathname as string
error "The folder (or alias) '" & pathname & "' doesn't exist."
end tell
end ResolveAlias
on IsOSX()
tell application "Finder"
set vers to the version as text
if second character of vers is equal to "." then
set vers to "0" & vers
end if
return vers > 10 or vers = 10
end tell
end IsOSX
on stripVolName(macPath)
set saveTID to get text item delimiters of AppleScript
set text item delimiters of AppleScript to ":"
set strippedPath to (rest of text items of macPath) as string
set text item delimiters of AppleScript to saveTID
return strippedPath
end stripVolName
on HomeDir()
tell application "Finder"
if my IsOSX() then
return the home as string
-- return my stripVolName(home as string)
else
return gStartupDisk
end if
end tell
end HomeDir
on ModuleRoot()
if pUsingCPlusPlus then
set subFolder to "cxx"
else
set subFolder to "ncbi"
end if
set modRoot to ""
try
set modRoot to ResolveAlias(gMWroot & subFolder)
on error
try
set modRoot to ResolveAlias(gHomeDir & subFolder)
end try
end try
return modRoot
end ModuleRoot
on AccessRoot()
if my IsOSX() then
-- strip off the volume name at the front.
return my stripVolName(gDistribRoot)
else
return gDistribRoot
end if
end AccessRoot
on MWRootDir()
set mwRoot to ""
set mwLocations to {gStartupDisk, gStartupDisk & "Applications:", gStartupDisk & "Applications (Mac OS 9):",
gStartupDisk & "AppsLocal:", gHomeDir, gHomeDir & "Applications:", gHomeDir & "Applications (Mac OS 9):",
gHomeDir & "AppsLocal:"}
repeat with mwVersion from 8 to 9
set dirName to "Metrowerks CodeWarrior " & mwVersion & ".0"
repeat with mwLoc in mwLocations
try
set mwRoot to ResolveAlias(mwLoc & dirName)
return mwRoot
end try
end repeat
end repeat
error "Can't find the Metrowerks CodeWarrior folder."
end MWRootDir
on GetMyPath()
set myPath to path to me as string
if myPath contains "Script Editor" then
-- Oops! running under script editor. 'me' is Script Editor not this script.
-- use the location this script is supposed to be in.
if pUsingCPlusPlus then
return gDistribRoot & "compilers:mac_prj"
else
return gDistribRoot & "make:"
end if
else
tell application "Finder"
return container of myPath
end tell
end if
end GetMyPath
on SetGlobals()
tell application "Finder"
set gProjectData to {}
set gStartupDisk to startup disk as string
set gHomeDir to my HomeDir()
set gMWroot to my MWRootDir()
set gMWCWfolder to gMWroot & "Metrowerks CodeWarrior:"
set gDistribRoot to my ModuleRoot()
set gAccessRoot to my AccessRoot()
set gIncludeDir to gDistribRoot & "include:"
if pUsingCPlusPlus then
set gSourceDir to gDistribRoot & "src:"
set gLibsDir to gDistribRoot & "compilers:mac_prj:lib:"
set gProjectsDir to gDistribRoot & "compilers:mac_prj:bin:"
set gRsrcsDir to gDistribRoot & "compilers:mac_prj:"
else
set gSourceDir to gDistribRoot
set gLibsDir to gDistribRoot & "lib:"
set gProjectsDir to gDistribRoot & "build:"
set gRsrcsDir to gDistribRoot & "link:macmet:"
end if
set gStationeryDir to gProjectsDir & pStationeryName & ":"
set gMakeDir to my GetMyPath()
end tell
end SetGlobals
on SetUserPaths()
tell application "CodeWarrior IDE"
set pathsToAdd to {}
-- Put the ncbi root, recursively at the end of the user paths.
-- we did not do this in makeStationery because we did not want to drag over there the mess
-- of the distinction between file paths names (which include volume name)
-- and access paths (which do not).
copy {name:gAccessRoot, recursive:true, origin:absolute} to end of pathsToAdd
Set Preferences of panel "Access Paths" to {User Paths:pathsToAdd}
end tell
end SetUserPaths
on SetSysPaths()
-- This was all done in the Stationery project.
end SetSysPaths
on SetupTarget(proj, targetIndex)
tell application "CodeWarrior IDE"
set targetName to name of target targetIndex of project document 1
if targetName contains "Carbon" then
set targetAPI to "Carbon"
else if targetName contains "Mach-O" then
if not my IsOSX() then return -- do not try to populate Mach-O targets on pre-OS X systems.
set targetAPI to "Mach-O"
else if targetName contains "Win32" then
set targetAPI to "Win32"
end if
if targetName contains "Debug" then
set targetDebug to true
if pCreateProfiledTargets then
set targetProfile to true
else
set targetProfile to false
end if
else -- if targeName contains "Final" then
set targetDebug to false
set targetProfile to false
end if
-- NOTE: no Profile targets. if pCreateProfiledTargets, we make the debug targets also profile-able.
set the current target of project document 1 to target targetIndex of project document 1
-- initialize variables
set projRsrcs to {}
set projFeatures to {}
set sysPaths to {}
-- Grab the fields of our project record and store them in local variables.
set projName to proj's name
set projSettings to proj's settings
try
set projFeatures to proj's features
end try
try
set sysPaths to proj's sysPaths
end try
try
set projRsrcs to proj's rsrcs
end try
set projLibs to proj's projLibs
set projFileData to proj's fileData
-- Figure out what our output file and input libraries will be named.
set fileNameSuffix to ""
if targetAPI is "Carbon" then
set fileNameSuffix to "_C"
else if targetAPI is "Mach-O" then
set fileNameSuffix to "_M"
else if targetAPI is "Win32" then
set fileNameSuffix to "_W"
end if
-- Debug or not.
if not targetDebug then
set fileNameSuffix to fileNameSuffix & "_O" -- for Optimized.
else
set fileNameSuffix to fileNameSuffix & "_D"
end if
-- non debug targets get different output names.
if not targetDebug then
if targetAPI is "Mach-O" then
set targetFilename to projName & "OSX" -- Mach adds OSX on the end.
else
set targetFilename to projName -- Carbon & Windows have same name as project.
end if
else
set targetFilename to projName & fileNameSuffix
end if
-- make sure Mach bundles have .app on the end.
if targetAPI is "Mach-O" then
set targetFilename to targetFilename & ".app"
else if targetAPI is "Win32" then
-- and Windows executables have .exe
set targetFilename to targetFilename & ".exe"
end if
-- Get Preference Panel names.
if targetAPI is "Mach-O" then
set targetPanelName to "PPC Mac OS X Project"
set codeGenPanelName to "PPC CodeGen Mach-O"
else if targetAPI is "Win32" then
set targetPanelName to "x86 Project"
set codeGenPanelName to "x86 CodeGen"
else
set targetPanelName to "PPC Project"
set codeGenPanelName to "PPC CodeGen"
end if
-- Set the name of the output file (the application)
Set Preferences of panel targetPanelName to {File Name:targetFilename}
-- If specified, set the File Creator.
try
set creatorName to creator of projSettings
Set Preferences of panel targetPanelName to {File Creator:creatorName}
end try
-- If we have any per-project override settings, set them.
-- ignore errors since ppcProject might not be appropriate for all targets.
try
if (count ppcProject of projSettings) > 0 then
Set Preferences of panel targetPanelName to ppcProject of projSettings
end if
end try
my SetUserPaths()
-- my SetSysPaths() -- done in the stationery project.
-- Add per-project system paths.
set pathsToAdd to {}
repeat with i in sysPaths
copy {name:i, recursive:false, origin:absolute} to end of pathsToAdd
end repeat
if (count pathsToAdd) > 0 then
Set Preferences of panel "Access Paths" to {System Paths:pathsToAdd}
-- Set the appropriate prefix file.
set prefixFile to Prefix File of projSettings
if targetAPI is "Win32" and projFeatures contains "winprefix" then
set prefixFile to "Win32Headers.pch"
else
if prefixFile is "" then
set prefixFile to "CarbonPrefix.h"
else
set prefixFile to "Carbon-" & prefixFile
end if
end if
if prefixFile is not "" then
Set Preferences of panel "C/C++ Compiler" to {Prefix File:prefixFile}
end if
-- Are we assuming a .c or a .cpp extension?
if projFeatures contains "C++" then
set fileExtension to pCPlusPlusExtension
else
set fileExtension to ".c"
end if
end tell
-- Add source files.
repeat with group in projFileData
set projPath to projPath of group
set fileList to group's fileList
set filesToAdd to {}
repeat with i in fileList
if i does not contain "." then set i to i & fileExtension
try -- ignore it if the file doesn't exist.
-- NOTE: if the following line is within a tell "Codewarrior" block then
-- the following Add Files command will fail.
copy alias (gSourceDir & projPath & i) to end of filesToAdd
end try
end repeat
tell application "CodeWarrior IDE"
Add Files filesToAdd
-- Take out source files that do not belong.
--set fileNotList to group's fileNotList
--Remove Files fileNotList
end tell
end repeat
tell application "CodeWarrior IDE"
-- take care of debugging and profiling settings
if targetDebug then
set the debug of every target file of target targetIndex
of project document 1 to true
end if
if targetAPI is "Carbon" then
if targetProfile then
(* ===== Panel PPC Processor ===== *)
Set Preferences of panel codeGenPanelName to
{Use Profiler:true}
else
(* ===== Panel PPC Processor ===== *)
Set Preferences of panel codeGenPanelName to
{Use Profiler:false}
end if
(*
else if targetAPI is "Mach-O"
In the following lines we should see Mach-O Profiling instead of property B617
But a hyphen is illegal in a name in Applescript (MW's fault). When compiling, the
property B617 will get replaced with Mach-O Profiling, which is okay.
But if the script gets changed and recompiled this will give an error.
So ... replace 'Mach-O Profiling' below with 'property B617' (minus the quotes).
You can copy and paste from this comment.
Or comment all of this out and forget Mach-O profiling till MW fixes this.
-- *)
if targetProfile then
(* ===== Panel PPC Processor ===== *)
Set Preferences of panel codeGenPanelName to
{property B617:metrowerks}
else
(* ===== Panel PPC Processor ===== *)
Set Preferences of panel codeGenPanelName to
{property B617:off}
end if
*)
end if
-- Add user libraries.
set filesToAdd to {}
if projFeatures contains "sockets" and targetAPI is "Carbon" then
if projLibs does not contain "mitsock" then
copy "mitsock" to beginning of projLibs
end if
end if
repeat with i in projLibs
copy gLibsDir & i & fileNameSuffix & ".lib" to end of filesToAdd
end repeat
-- No profiling library for MW on Mach-O yet.
if targetProfile and targetAPI is "Carbon" then
copy gMWCWfolder & "MacOS Support:Profiler:Profiler PPC:Profiler Carbon.Lib" to end of filesToAdd
end if
try
Add Files filesToAdd
end try
-- Add resources.
set filesToAdd to {}
if targetAPI is not "Win32" then
repeat with i in projRsrcs
if targetAPI is "Carbon" then
if i ends with ".plc" then
copy gRsrcsDir & "Carbon-" & i to end of filesToAdd
else
copy gRsrcsDir & i to end of filesToAdd
end if
else
-- Mach-O does not need the .r files, only the .plc files.
if i does not end with ".r" then
copy gRsrcsDir & i to end of filesToAdd
end if
end if
end repeat
Add Files filesToAdd
end if
Reset File Paths
end tell
end SetupTarget
on CreateFolders()
tell application "Finder"
repeat with i in pDirsToCreate
set pth to relPath of i
if pth is not "" then set pth to pth & ":"
-- display dialog "Folder? " & (gDistribRoot & pth & i's name) buttons {"OK"} default button 1
if not (exists folder (gDistribRoot & pth & i's name)) then
-- display dialog "make Folder: " & i's name & " at: " & (gDistribRoot & pth) buttons {"OK"} default button 1
make new folder at folder (gDistribRoot & pth) with properties {name:i's name}
end if
end repeat
end tell
end CreateFolders
on CreateProject(proj)
tell application "CodeWarrior IDE"
-- This statement doesn't work, because AppleScript is broken.
if proj is {} then return
try
get proj's name
on error
return
end try
set projFilename to proj's name & pProjectFileExtension
set projPathname to gProjectsDir & projFilename
if pAlwaysCreateProjects or not (exists file projPathname of application "Finder") then
try
close (the first project document whose name is projFilename)
end try
set stationeryName to (gStationeryDir & pStationeryName & pProjectFileExtension)
(* display dialog "creating project: " & projPathname & return & "from: " & stationeryName
buttons {"OK"} default button 1
*)
Create Project {projPathname} from stationery alias stationeryName
if the name of window 1 is "Project Messages" then
close first window -- "close window 1" becomes "Close Window 1" (different event)
end if
-- display dialog "created project: " & projPathname buttons {"OK"} default button 1
repeat with i from 1 to (count targets of project document 1)
my SetupTarget(proj, i)
end repeat
set the current target of project document 1 to target 1 of project document 1
Close Project
end if
end tell
end CreateProject
on CreateAllProjects()
repeat with proj in gProjectData
CreateProject(proj)
end repeat
end CreateAllProjects
global gTargets2Build
-- get names of files in thePath that start with "Build"
on GetMakeFileNames(thePath)
set theFiles to list folder (thePath) without invisibles
set newList to {}
repeat with f in theFiles
if (f begins with "Build") then
set newList to newList & (f as string)
end if
end repeat
return newList
end GetMakeFileNames
on AddtoList(aList, anItem)
if (aList does not contain anItem) then
copy anItem to end of aList
end if
end AddtoList
on FindTargets2Build()
set gTargets to {}
if pCreateCarbonTargets then
set gTargets to gTargets & "Carbon"
end if
if pCreateMachOTargets then
set gTargets to gTargets & "Mach-O"
end if
if pCreateWinTargets then
set gTargets to gTargets & "Win32"
end if
set gBuildTypes to {}
if pCreateDebugTargets or pCreateProfileTargets then
set gBuildTypes to gBuildTypes & "Debug"
end if
if pCreateOptimizedTargets then
set gBuildTypes to gBuildTypes & "Final"
end if
-- set gTargets to {"Carbon", "Mach-O"}
-- set gBuildTypes to {"Final", "Debug", "Profile"}
set makeFiles to my GetMakeFileNames(gMakeDir)
if (count items of makeFiles) is 0 then
set makeFiles to gTargets -- if nothing, make everything.
end if
set gTargets2Build to {}
repeat with f in makeFiles
set thisTarget to ""
set targetSet to false
repeat with t in gTargets
if f contains t then
set thisTarget to contents of t
set targetSet to true
exit repeat
end if
end repeat
set typeSet to false
repeat with t in gBuildTypes
if f contains t then
set thisTarget to thisTarget & " " & t
set typeSet to true
exit repeat
end if
end repeat
if targetSet and typeSet then
my AddtoList(gTargets2Build, thisTarget)
else if (targetSet or typeSet) then
if not typeSet then
repeat with t in {"Final", "Debug"}
AddtoList(gTargets2Build, (thisTarget & " " & t))
end repeat
end if
if not targetSet then
repeat with t in gTargets
AddtoList(gTargets2Build, (t & thisTarget))
end repeat
end if
end if
end repeat
end FindTargets2Build
on OkaytoBuild(targetName)
repeat with t in gTargets2Build
if (targetName contains t) then
return true
end if
end repeat
return false
end OkaytoBuild
on BuildProject(projName)
tell application "CodeWarrior IDE"
open (gProjectsDir & projName & pProjectFileExtension)
if the name of window 1 is "Project Messages" then
close first window -- "close window 1" becomes "Close Window 1" (different event)
end if
repeat with i from 1 to (count targets of project document 1)
-- do we want to build this target?
if my OkaytoBuild(name of target i of project document 1) then
set the current target of project document 1 to target i of project document 1
Make Project
-- If there were compiler warnings, then a compiler window will be in front.
-- For whatever reason, this causes the next "set the current target..." to fail.
-- So check for the window and close it.
if the name of window 1 is "Errors & Warnings" then
close first window -- "close window 1" becomes "Close Window 1" (different event)
end if
end if
end repeat
set the current target of project document 1 to target 1 of project document 1
Close Project
end tell
end BuildProject
on BuildAllProjects()
FindTargets2Build()
repeat with proj in gProjectData
try
set projName to proj's name
on error
set projName to ""
end try
-- This statement doesn't work, because AppleScript is broken.
if proj is not {} then
if projName is not "" then
BuildProject(projName)
end if
end if
end repeat
end BuildAllProjects
on GuaranteeStationery()
tell application "Finder"
-- get rid of any old copy.
try
delete file (gStationeryDir & pStationeryName & pProjectFileExtension)
end try
-- copy it.
my DuplicateFile(file (gRsrcsDir & pStationeryName & pProjectFileExtension), folder gStationeryDir)
-- make sure there is nothing else in the folder.
my CleanupFolder(gStationeryDir, pStationeryName & pProjectFileExtension)
end tell
end GuaranteeStationery
on DuplicateFile(fileToCopy, destFolder)
tell application "Finder"
try
duplicate fileToCopy to destFolder
on error msg number errnum
if errnum is -43 then
(* if the file was just newly created (e.g. a clean install or cvs update)
the finder gets this error trying to copy a file from it.
Opening its folder with the finder fixes this.
We do this in a try block so we aren't always flashing the window open
for this somewhat rare occurrence.
*)
open (container of fileToCopy)
close first Finder window
duplicate fileToCopy to destFolder
else
error msg number errnum
end if
end try
end tell
end DuplicateFile
-- Delete everything in the folder 'thePath' except the saveFile.
on CleanupFolder(thePath, saveFile)
repeat with f in list folder (thePath) with invisibles
if (f as string is not saveFile) then
try
tell application "Finder" to delete folder (thePath & f)
end try
try
tell application "Finder" to delete file (thePath & f)
end try
end if
end repeat
end CleanupFolder
on CleanupFiles(thePath)
-- get rid of all the files and folders starting with xxxx in thePath
repeat with f in list folder (thePath) without invisibles
if ((f as string) begins with "xxxx") then
try
tell application "Finder" to delete folder (thePath & f)
end try
try
tell application "Finder" to delete file (thePath & f)
end try
end if
end repeat
-- delete the stationery folder.
try
tell application "Finder" to delete folder gStationeryDir
end try
end CleanupFiles
on SignalCompletion()
beep
end SignalCompletion
with timeout of 60000 seconds
SetGlobals()
SetProjectData()
CreateFolders()
tell application "CodeWarrior IDE" to activate
GuaranteeStationery()
CreateAllProjects()
if pShouldBuild then
BuildAllProjects()
end if
CleanupFiles(gProjectsDir)
SignalCompletion()
end timeout
|