Updated to enumerate target files until error encountered, use 3.3 IDE.

This commit is contained in:
beard%netscape.com 1998-12-24 19:30:15 +00:00
parent 17b9100eae
commit 33851ca23f

View File

@ -27,8 +27,8 @@
(* Global Configuration Properties *)
property pShowReport : true
property pSourceTree : "Homeward:Work:Raptor:src:"
-- property pSourceTree : "Morbeus:Projects:Raptor:src:"
-- property pSourceTree : "Homeward:Work:Raptor:src:"
property pSourceTree : "Morbeus:Projects:Raptor:src:"
on swapDelimiters(newDelimiters)
set oldDelimiters to get AppleScript's text item delimiters
@ -53,7 +53,7 @@ on replace(aString, oldChar, newChar)
return newString
end replace
-- uses "sort" scripting addition to sort a list of strings.
(* uses "sort" scripting addition to sort a list of strings. *)
on sortList(aList)
if (aList ­ {}) then
return sort aList
@ -86,21 +86,37 @@ on readManifestFile(sourceTree, manifestFile)
return sortList(fileLines)
end readManifestFile
(* both of the following depend on ":" as the delimiter character. *)
on folderFromPath(filePath)
return ((filePath's text items 1 thru ((count of filePath's text items) - 1)) as string) & ":"
end folderFromPath
on fileFromPath(filePath)
return last text item of filePath
end fileFromPath
(* CW Pro IDE Interface Handlers. *)
on openProject(aProjectFile)
tell application "CodeWarrior IDE 3.2"
tell application "CodeWarrior IDE 3.3"
-- activate
open aProjectFile
end tell
end openProject
(* forces the named project file to be the front window. *)
on selectProject(aProjectFile)
set projectName to fileFromPath(aProjectFile as text)
tell application "CodeWarrior IDE 3.3"
if (name of window 1 is not projectName) then
select window projectName
end if
end tell
end selectProject
on closeProject(aProjectFile)
tell application "CodeWarrior IDE 3.2"
tell application "CodeWarrior IDE 3.3"
Close Project
end tell
end closeProject
@ -108,7 +124,7 @@ end closeProject
on getTargets()
set targetList to {}
set nameList to {}
tell application "CodeWarrior IDE 3.2"
tell application "CodeWarrior IDE 3.3"
set currentProject to project document 1
repeat with targetIndex from 1 to (count of targets of currentProject)
set currentTarget to (target targetIndex of currentProject)
@ -119,25 +135,43 @@ on getTargets()
end tell
end getTargets
(* uses "info for" scripting addition, to return the file type of a path. *)
on getFileType(aFilePath)
return file type of (info for alias aFilePath)
end getFileType
(* returns all "TEXT" files of the named target. *)
on getTargetFiles(targetKey)
set targetFiles to {}
tell application "CodeWarrior IDE 3.2"
tell application "CodeWarrior IDE 3.3"
set currentProject to project document 1
set currentTarget to (target targetKey of currentProject)
repeat with fileIndex from 1 to (count of target files of currentTarget)
set targetFile to (target file fileIndex of currentTarget)
-- only consider text files, since other platforms won't be managing binaries.
-- also, only consider if target file is directly linked.
if (type of targetFile is text file) and (linked of targetFile) then
set targetFiles to targetFiles & {Access Paths of targetFile}
end if
end repeat
try
-- workaround for CW IDE 3.X bug, loop until error encountered.
set fileIndex to 1
repeat until false
set targetFile to (target file fileIndex of currentTarget)
-- only consider text files, since other platforms won't be managing binaries.
-- also, only consider if target file is directly linked.
if (linked of targetFile) then
set targetFilePath to (Access Paths of targetFile)
tell me
if (getFileType(targetFilePath) = "TEXT") then
set targetFiles to targetFiles & {targetFilePath}
end if
end tell
end if
set fileIndex to (fileIndex + 1)
end repeat
on error msg
-- display dialog msg & " file count = " & fileIndex
end try
end tell
return sortList(targetFiles)
end getTargetFiles
on addTargetFile(targetFile, targetList)
tell application "CodeWarrior IDE 3.2"
tell application "CodeWarrior IDE 3.3"
add (project document 1) new target file with data {targetFile} to targets targetList
end tell
end addTargetFile
@ -147,14 +181,14 @@ global gCurrentTarget
on setCurrentTarget(currentTargetName)
if (gCurrentTarget ­ currentTargetName) then
set gCurrentTarget to currentTargetName
tell application "CodeWarrior IDE 3.2"
tell application "CodeWarrior IDE 3.3"
Set Current Target currentTargetName
end tell
end if
end setCurrentTarget
on removeTargetFile(targetFile)
tell application "CodeWarrior IDE 3.2"
tell application "CodeWarrior IDE 3.3"
Remove Files {targetFile}
end tell
end removeTargetFile
@ -178,13 +212,14 @@ end showList
global gProjectModified
on ModifyReadOnly(projectFile)
on ModifyReadOnly(aProjectFile)
if (not gProjectModified) then
set gProjectModified to true
-- so CodeWarrior will notice, must close the file before MROing it.
closeProject(projectFile)
mro projectFile
openProject(projectFile)
closeProject(aProjectFile)
mro aProjectFile
openProject(aProjectFile)
selectProject(aProjectFile)
end if
end ModifyReadOnly
@ -245,6 +280,7 @@ on ReconcileProject(sourceTree, projectPath, manifestoPath)
-- now, start processing the file items, ensuring that the project contains all items.
openProject(projectFile)
selectProject(projectFile)
set targetsList to getTargets()
set targetNames to names of targetsList
@ -309,7 +345,7 @@ on ReconcileProject(sourceTree, projectPath, manifestoPath)
-- activate_application(frontmostApplication)
-- commit the project changes, and optionally display a report.
tell application "CodeWarrior IDE 3.2"
tell application "CodeWarrior IDE 3.3"
-- leave project open for compilation phase?
Close Project
if pShowReport then
@ -331,6 +367,6 @@ on run
-- when run interactively,
-- ask user which project/MANIFEST files to use.
set projectPath to (choose file with prompt "Choose a CW Project file." of type {"MMPr"}) as text
set manifestPath to (choose file with prompt "Choose a MANIFEST file to process." of type {"TEXT"}) as text
set manifestPath to (choose file with prompt "Choose a TOC file to process." of type {"TEXT"}) as text
ReconcileProject(pSourceTree, projectPath, manifestPath)
end run