forked from carsonmcdonald/ios-ruby-embedded
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
152 lines (116 loc) · 4.9 KB
/
Rakefile
File metadata and controls
152 lines (116 loc) · 4.9 KB
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
XCODEROOT = %x[xcode-select -print-path].strip
SIMSDKPATH = Dir["#{XCODEROOT}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator*.sdk/"].sort.last
IOSSDKPATH = Dir["#{XCODEROOT}/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/"].sort.last
task :verify_sysroot => [SIMSDKPATH, IOSSDKPATH]
file "ios_build_config.rb" do
open('ios_build_config.rb', 'w') do |config_file|
config_file.puts <<__EOF__
MRuby::Build.new do |conf|
toolchain :clang
conf.gembox 'default'
end
SIM_SYSROOT="#{SIMSDKPATH}"
DEVICE_SYSROOT="#{IOSSDKPATH}"
MRuby::CrossBuild.new('ios-simulator') do |conf|
conf.bins = []
conf.gembox 'default'
conf.cc do |cc|
cc.command = 'xcrun'
cc.flags = %W(-sdk iphoneos clang -miphoneos-version-min=5.0 -arch i386 -isysroot \#{SIM_SYSROOT} -g -O3 -Wall -Werror-implicit-function-declaration)
end
conf.linker do |linker|
linker.command = 'xcrun'
linker.flags = %W(-sdk iphoneos clang -miphoneos-version-min=5.0 -arch i386 -isysroot \#{SIM_SYSROOT})
end
end
MRuby::CrossBuild.new('ios-armv7') do |conf|
conf.bins = []
conf.gembox 'default'
conf.cc do |cc|
cc.command = 'xcrun'
cc.flags = %W(-sdk iphoneos clang -arch armv7 -isysroot \#{DEVICE_SYSROOT} -g -O3 -Wall -Werror-implicit-function-declaration)
end
conf.linker do |linker|
linker.command = 'xcrun'
linker.flags = %W(-sdk iphoneos clang -arch armv7 -isysroot \#{DEVICE_SYSROOT})
end
end
MRuby::CrossBuild.new('ios-armv7s') do |conf|
conf.bins = []
conf.gembox 'default'
conf.cc do |cc|
cc.command = 'xcrun'
cc.flags = %W(-sdk iphoneos clang -arch armv7s -isysroot \#{DEVICE_SYSROOT} -g -O3 -Wall -Werror-implicit-function-declaration)
end
conf.linker do |linker|
linker.command = 'xcrun'
linker.flags = %W(-sdk iphoneos clang -arch armv7s -isysroot \#{DEVICE_SYSROOT})
end
end
MRuby::CrossBuild.new('ios-arm64') do |conf|
conf.bins = []
conf.gembox 'default'
conf.cc do |cc|
cc.command = 'xcrun'
cc.flags = %W(-sdk iphoneos clang -arch arm64 -isysroot \#{DEVICE_SYSROOT} -g -O3 -Wall -Werror-implicit-function-declaration)
end
conf.linker do |linker|
linker.command = 'xcrun'
linker.flags = %W(-sdk iphoneos clang -arch arm64 -isysroot \#{DEVICE_SYSROOT})
end
end
__EOF__
end
end
directory "MRuby.framework/Versions"
directory "MRuby.framework/Versions/1.0.0/"
directory "MRuby.framework/Versions/1.0.0/Headers"
directory "MRuby.framework/Versions/1.0.0/Resources"
task "MRuby.framework/Versions/1.0.0/" => "MRuby.framework/Versions" do
Dir.chdir("MRuby.framework/Versions/") do
File.symlink("1.0.0", "Current")
end
Dir.chdir("MRuby.framework/") do
File.symlink("Versions/Current/Headers", "Headers")
File.symlink("Versions/Current/MRuby", "MRuby")
File.symlink("Versions/Current/Resources", "Resources")
end
end
task :build_mruby => "ios_build_config.rb" do
Dir.chdir("mruby") do
ENV['MRUBY_CONFIG'] = "../ios_build_config.rb"
sh "rake"
end
end
directory "bin"
file "bin/mirb" => [:build_mruby, "bin"] do
FileUtils.cp "mruby/build/host/bin/mirb", "bin/mirb"
end
file "bin/mrbc" => [:build_mruby, "bin"] do
FileUtils.cp "mruby/build/host/bin/mrbc", "bin/mrbc"
end
file "bin/mruby" => [:build_mruby, "bin"] do
FileUtils.cp "mruby/build/host/bin/mruby", "bin/mruby"
end
file "MRuby.framework/Versions/Current/MRuby" => [:build_mruby, "MRuby.framework/Versions/1.0.0/"] do
sh "#{IOSSDKPATH}/../../usr/bin/lipo -arch i386 mruby/build/ios-simulator/lib/libmruby.a -arch arm64 mruby/build/ios-arm64/lib/libmruby.a -arch armv7 mruby/build/ios-armv7/lib/libmruby.a -arch armv7s mruby/build/ios-armv7s/lib/libmruby.a -create -output MRuby.framework/Versions/Current/MRuby"
end
task :mruby_headers => [:build_mruby, "MRuby.framework/Versions/1.0.0/Headers"] do
FileUtils.cp_r "mruby/include/.", "MRuby.framework/Versions/Current/Headers/"
sh "sed -i '' 's/mruby\\.h/..\\/mruby\\.h/g' MRuby.framework/Versions/Current/Headers/mruby/*"
sh "sed -i '' 's/mruby\\/khash\\.h/..\\/mruby\\/khash\\.h/g' MRuby.framework/Versions/Current/Headers/mruby/*"
sh "sed -i '' 's/mruby\\/irep\\.h/..\\/mruby\\/irep\\.h/g' MRuby.framework/Versions/Current/Headers/mruby/proc.h"
sh "sed -i '' 's/mruby\\/irep\\.h/..\\/mruby\\/irep\\.h/g' MRuby.framework/Versions/Current/Headers/mruby/dump.h"
sh "sed -i '' 's/mruby\\/object\\.h/..\\/mruby\\/object\\.h/g' MRuby.framework/Versions/Current/Headers/mruby/value.h"
sh "sed -i '' 's/mruby\\/compile\\.h/..\\/mruby\\/compile\\.h/g' MRuby.framework/Versions/Current/Headers/mruby/irep.h"
end
task :all => [:verify_sysroot, "bin/mirb", "bin/mrbc", "bin/mruby", "MRuby.framework/Versions/Current/MRuby", :mruby_headers]
task :default => :all
task :clean => "ios_build_config.rb" do
Dir.chdir("mruby") do
ENV['MRUBY_CONFIG'] = "../ios_build_config.rb"
sh "rake clean"
end
FileUtils.rm_f ["ios_build_config.rb", "bin/mirb", "bin/mrbc", "bin/mruby"]
FileUtils.rm_rf "MRuby.framework"
end