-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmogend.rb
executable file
·60 lines (47 loc) · 1.83 KB
/
mogend.rb
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
#!/usr/bin/env ruby -w
# This is a script designed to be called from a Build Rule in XCode like so
# ruby "${SRCROOT}/xcode_build_scripts/mogend.rb" arc NTManagedObject
# with the Process set to Data model versioned files (for momd models)
# and 'Using' set to 'Custom script'
# In the 'output files' section you should add
# $(DERIVED_FILES_DIR)/$(INPUT_FILE_BASE).momd
#
# Arguments
# 0: a string containing 'arc' or 'noarc' indicating where the generated
# models should be ARC compliant or not.
# 1: an optional name of a custom NSManagedObject base class eg NTManagedObject
puts "Running mogend.rb"
# Arguments
# 0: name of custom managed object base class
# 1: any value will trigger ARC output
baseClassOption = ""
arcOption = ""
ARGV.each_with_index do |arg, i|
baseClassOption = "--base-class #{arg}" if i == 0
arcOption = "--template-var arc=true" if i == 1 && arg = "arc"
end
# Get the current datamodel version - relies on PlistBuddy being installed
# Maybe we should document how to install this if missing?
# Could use CFPropertyList gem here
curVer=`/usr/libexec/PlistBuddy "#{ENV['INPUT_FILE_PATH']}/.xccurrentversion" -c 'print _XCCurrentVersionName'`
curVer.rstrip!.lstrip!
puts " Current model is #{ENV['INPUT_FILE_PATH']}/#{curVer}"
cmd = "/usr/local/bin/mogenerator --model \"#{ENV['INPUT_FILE_PATH']}/#{curVer}\" --output-dir \"#{ENV['INPUT_FILE_DIR']}/Models/\" #{baseClassOption} #{arcOption}"
#puts cmd
puts `#{cmd}`
if $? == 0
puts "mogenerator successful"
else
puts "mogenerator failed"
exit 1
end
cmd = "\"#{ENV['DEVELOPER_BIN_DIR']}/momc\" -XD_MOMC_TARGET_VERSION=10.6 \"#{ENV['INPUT_FILE_PATH']}\" \"#{ENV['TARGET_BUILD_DIR']}/#{ENV['EXECUTABLE_FOLDER_PATH']}/#{ENV['INPUT_FILE_BASE']}.momd\""
#puts cmd
puts = `#{cmd}`
if $? == 0
puts "momc successful"
else
puts "momc failed"
exit 1
end
exit 0