Skip to content

Commit fcccef4

Browse files
Merge pull request #22 from skryukov/zlib
Build zlib as a dependency
2 parents 2641ace + 2e5f22e commit fcccef4

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

Rakefile

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ BUILD_SOURCES = [
1111
},
1212
]
1313

14-
FULL_EXTS = "bigdecimal,cgi/escape,continuation,coverage,date,dbm,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,gdbm,json,json/generator,json/parser,nkf,objspace,pathname,psych,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor"
14+
FULL_EXTS = "bigdecimal,cgi/escape,continuation,coverage,date,dbm,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,gdbm,json,json/generator,json/parser,nkf,objspace,pathname,psych,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor,zlib"
1515

1616
BUILD_PROFILES = {
1717
"minimal" => { debug: false, default_exts: "", user_exts: [] },
@@ -115,7 +115,7 @@ class BuildPlan
115115

116116
def dep_tasks
117117
return [baseruby_name] if @params[:profile] == "minimal"
118-
[baseruby_name, "deps:libyaml-#{@params[:target]}"]
118+
[baseruby_name, "deps:libyaml-#{@params[:target]}", "deps:zlib-#{@params[:target]}"]
119119
end
120120

121121
def check_deps
@@ -157,6 +157,7 @@ class BuildPlan
157157
args << "--with-static-linked-ext"
158158
args << %Q(--with-ext="#{default_exts}")
159159
args << %Q(--with-libyaml-dir="#{deps_install_dir}/libyaml/usr/local")
160+
args << %Q(--with-zlib-dir="#{deps_install_dir}/zlib")
160161
args << %Q(--with-baseruby="#{baseruby_path}")
161162

162163
case target
@@ -216,6 +217,30 @@ namespace :deps do
216217
sh "./configure #{configure_args.join(" ")}", chdir: build_dir
217218
sh "make install DESTDIR=#{install_dir}/libyaml", chdir: build_dir
218219
end
220+
221+
zlib_version = "1.2.12"
222+
desc "build zlib #{zlib_version} for #{target}"
223+
task "zlib-#{target}" do
224+
next if Dir.exist?("#{install_dir}/zlib")
225+
226+
build_dir = File.join(Dir.pwd, "/build/deps/#{target}/zlib-#{zlib_version}")
227+
mkdir_p File.dirname(build_dir)
228+
rm_rf build_dir
229+
230+
sh "curl -L https://zlib.net/zlib-#{zlib_version}.tar.gz | tar xz", chdir: File.dirname(build_dir)
231+
232+
configure_args = []
233+
case target
234+
when "wasm32-unknown-wasi"
235+
configure_args.concat(%W(CC=#{ENV["WASI_SDK_PATH"]}/bin/clang RANLIB=#{ENV["WASI_SDK_PATH"]}/bin/llvm-ranlib AR=#{ENV["WASI_SDK_PATH"]}/bin/llvm-ar))
236+
when "wasm32-unknown-emscripten"
237+
configure_args.concat(%W(CC=emcc RANLIB=emranlib AR=emar))
238+
else
239+
raise "unknown target: #{target}"
240+
end
241+
sh "#{configure_args.join(" ")} ./configure --prefix=#{install_dir}/zlib --static", chdir: build_dir
242+
sh "make install", chdir: build_dir
243+
end
219244
end
220245
end
221246

builders/wasm32-unknown-emscripten/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM emscripten/emsdk:2.0.13
22

33
RUN set -eux; \
44
apt-get update; \
5-
apt-get install ruby bison make autoconf git curl build-essential libyaml-dev -y; \
5+
apt-get install ruby bison make autoconf git curl build-essential libyaml-dev zlib1g-dev -y; \
66
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -; \
77
apt-get install nodejs -y; \
88
apt-get clean; \

builders/wasm32-unknown-wasi/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ENV WASI_SDK_PATH="/opt/wasi-sdk"
1717

1818
RUN set -eux; \
1919
apt-get update; \
20-
apt-get install ruby bison make autoconf git curl build-essential libyaml-dev -y; \
20+
apt-get install ruby bison make autoconf git curl build-essential libyaml-dev zlib1g-dev -y; \
2121
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -; \
2222
apt-get install nodejs -y; \
2323
apt-get clean; \

0 commit comments

Comments
 (0)