| 16 | | set modelSrcDir to my modelSrcDirPath(full path of modelIt) |
|---|
| 17 | | set targetList to my everyTargetWithBuildFilePath(_project, full path of modelIt) |
|---|
| 18 | | |
|---|
| 19 | | -- Create the .xcdatamodel related source group if necessary. |
|---|
| 20 | | if not (exists (every item reference of group of modelIt whose full path is modelSrcDir)) then |
|---|
| 21 | | tell group of modelIt |
|---|
| 22 | | make new group with properties {full path:modelSrcDir, name:text 1 thru -13 of ((name of modelIt) as string)} |
|---|
| 23 | | end tell |
|---|
| 24 | | end if |
|---|
| 25 | | set modelSrcGroup to item 1 of (every item reference of group of modelIt whose full path is modelSrcDir) |
|---|
| 26 | | tell modelSrcGroup to delete every item reference -- clear it out for population in case we didn't just create it |
|---|
| 27 | | |
|---|
| 28 | | -- Meat. |
|---|
| 29 | | do shell script "/usr/bin/mogenerator --model '" & full path of modelIt & "' --output-dir '" & modelSrcDir & "'" |
|---|
| 30 | | |
|---|
| 31 | | -- Build a list of resulting source files. |
|---|
| 32 | | tell application "System Events" |
|---|
| 33 | | set humanFileList to (every file of (POSIX file modelSrcDir as alias) whose (name ends with ".m" or name ends with ".mm") and name does not start with "_") |
|---|
| 34 | | set machineFileList to (every file of (POSIX file modelSrcDir as alias) whose (name ends with ".m" or name ends with ".mm") and name starts with "_") |
|---|
| 35 | | set fileList to humanFileList & machineFileList |
|---|
| 36 | | set pathList to {} |
|---|
| 37 | | repeat with fileItem in fileList |
|---|
| 38 | | set pathList to pathList & POSIX path of fileItem |
|---|
| 39 | | end repeat |
|---|
| 40 | | end tell |
|---|
| 41 | | |
|---|
| 42 | | -- Add the source files to the model's source group and the model's targets. |
|---|
| 43 | | repeat with pathIt in pathList |
|---|
| 44 | | tell modelSrcGroup |
|---|
| 45 | | set modelSrcFileRef to make new file reference with properties {full path:pathIt, name:name of (info for POSIX file pathIt)} |
|---|
| 46 | | repeat with targetIndex from 1 to (count of targetList) |
|---|
| 47 | | set targetIt to item targetIndex of targetList |
|---|
| 48 | | add modelSrcFileRef to targetIt |
|---|
| | 16 | if comments of modelIt contains "xmod" then |
|---|
| | 17 | set modelSrcDir to my modelSrcDirPath(full path of modelIt) |
|---|
| | 18 | set targetList to my everyTargetWithBuildFilePath(_project, full path of modelIt) |
|---|
| | 19 | |
|---|
| | 20 | -- Create the .xcdatamodel related source group if necessary. |
|---|
| | 21 | if not (exists (every item reference of group of modelIt whose full path is modelSrcDir)) then |
|---|
| | 22 | tell group of modelIt |
|---|
| | 23 | make new group with properties {full path:modelSrcDir, name:text 1 thru -13 of ((name of modelIt) as string)} |
|---|
| | 24 | end tell |
|---|
| | 25 | end if |
|---|
| | 26 | set modelSrcGroup to item 1 of (every item reference of group of modelIt whose full path is modelSrcDir) |
|---|
| | 27 | tell modelSrcGroup to delete every item reference -- clear it out for population in case we didn't just create it |
|---|
| | 28 | |
|---|
| | 29 | -- Meat. |
|---|
| | 30 | do shell script "/usr/bin/mogenerator --model '" & full path of modelIt & "' --output-dir '" & modelSrcDir & "'" |
|---|
| | 31 | |
|---|
| | 32 | -- Build a list of resulting source files. |
|---|
| | 33 | tell application "System Events" |
|---|
| | 34 | set humanFileList to (every file of (POSIX file modelSrcDir as alias) whose (name ends with ".m" or name ends with ".mm") and name does not start with "_") |
|---|
| | 35 | set machineFileList to (every file of (POSIX file modelSrcDir as alias) whose (name ends with ".m" or name ends with ".mm") and name starts with "_") |
|---|
| | 36 | set fileList to humanFileList & machineFileList |
|---|
| | 37 | set pathList to {} |
|---|
| | 38 | repeat with fileItem in fileList |
|---|
| | 39 | set pathList to pathList & POSIX path of fileItem |
|---|