@@ -85,6 +85,10 @@ class BuildPlan
85
85
"#{ @base_dir } /build/ext-build/#{ name } "
86
86
end
87
87
88
+ def deps_install_dir
89
+ "#{ @base_dir } /build/deps/#{ @params [ :target ] } /opt"
90
+ end
91
+
88
92
def dest_dir
89
93
"#{ @base_dir } /rubies/#{ name } "
90
94
end
@@ -93,6 +97,11 @@ class BuildPlan
93
97
"#{ ext_build_dir } /extinit.o"
94
98
end
95
99
100
+ def dep_tasks
101
+ return [ ] if @params [ :profile ] == "minimal"
102
+ [ "deps:libyaml-#{ @params [ :target ] } " ]
103
+ end
104
+
96
105
def check_deps
97
106
target = @params [ :target ]
98
107
profile = BUILD_PROFILES [ @params [ :profile ] ]
@@ -125,6 +134,7 @@ class BuildPlan
125
134
args = [ "--host" , target , "--build" , build_triple ]
126
135
args << "--with-static-linked-ext"
127
136
args << %Q(--with-ext="#{ default_exts } ")
137
+ args << %Q(--with-libyaml-dir="#{ deps_install_dir } /libyaml/usr/local")
128
138
129
139
case target
130
140
when "wasm32-unknown-wasi"
@@ -149,6 +159,38 @@ class BuildPlan
149
159
end
150
160
end
151
161
162
+ namespace :deps do
163
+ [ "wasm32-unknown-wasi" , "wasm32-unknown-emscripten" ] . each do |target |
164
+ install_dir = File . join ( Dir . pwd , "/build/deps/#{ target } /opt" )
165
+ libyaml_version = "0.2.5"
166
+ desc "build libyaml #{ libyaml_version } for #{ target } "
167
+ task "libyaml-#{ target } " do
168
+ next if Dir . exist? ( "#{ install_dir } /libyaml" )
169
+
170
+ build_dir = File . join ( Dir . pwd , "/build/deps/#{ target } /yaml-#{ libyaml_version } " )
171
+ mkdir_p File . dirname ( build_dir )
172
+ rm_rf build_dir
173
+ sh "curl -L https://github.com/yaml/libyaml/releases/download/#{ libyaml_version } /yaml-#{ libyaml_version } .tar.gz | tar xz" , chdir : File . dirname ( build_dir )
174
+
175
+ # obtain the latest config.guess and config.sub for Emscripten and WASI triple support
176
+ sh "curl -o #{ build_dir } /config/config.guess 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD'"
177
+ sh "curl -o #{ build_dir } /config/config.sub 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD'"
178
+
179
+ configure_args = [ ]
180
+ case target
181
+ when "wasm32-unknown-wasi"
182
+ configure_args . concat ( %W( --host wasm32-wasi CC=#{ ENV [ "WASI_SDK_PATH" ] } /bin/clang RANLIB=#{ ENV [ "WASI_SDK_PATH" ] } /bin/llvm-ranlib LD=#{ ENV [ "WASI_SDK_PATH" ] } /bin/clang AR=#{ ENV [ "WASI_SDK_PATH" ] } /bin/llvm-ar ) )
183
+ when "wasm32-unknown-emscripten"
184
+ configure_args . concat ( %W( --host wasm32-emscripten CC=emcc RANLIB=emranlib LD=emcc AR=emar ) )
185
+ else
186
+ raise "unknown target: #{ target } "
187
+ end
188
+ sh "./configure #{ configure_args . join ( " " ) } " , chdir : build_dir
189
+ sh "make install DESTDIR=#{ install_dir } /libyaml" , chdir : build_dir
190
+ end
191
+ end
192
+ end
193
+
152
194
namespace :build do
153
195
154
196
base_dir = Dir . pwd
@@ -174,7 +216,7 @@ namespace :build do
174
216
directory build . dest_dir
175
217
directory build . build_dir
176
218
177
- task "#{ build . name } -configure" , [ :reconfigure ] => [ build . build_dir , source . src_dir , source . configure_file ] do |t , args |
219
+ task "#{ build . name } -configure" , [ :reconfigure ] => [ build . build_dir , source . src_dir , source . configure_file ] + build . dep_tasks do |t , args |
178
220
args . with_defaults ( :reconfigure => false )
179
221
build . check_deps
180
222
0 commit comments