Skip to content

Build zlib as a dependency #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BUILD_SOURCES = [
},
]

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"
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"

BUILD_PROFILES = {
"minimal" => { debug: false, default_exts: "", user_exts: [] },
Expand Down Expand Up @@ -115,7 +115,7 @@ class BuildPlan

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

def check_deps
Expand Down Expand Up @@ -157,6 +157,7 @@ class BuildPlan
args << "--with-static-linked-ext"
args << %Q(--with-ext="#{default_exts}")
args << %Q(--with-libyaml-dir="#{deps_install_dir}/libyaml/usr/local")
args << %Q(--with-zlib-dir="#{deps_install_dir}/zlib")
args << %Q(--with-baseruby="#{baseruby_path}")

case target
Expand Down Expand Up @@ -216,6 +217,30 @@ namespace :deps do
sh "./configure #{configure_args.join(" ")}", chdir: build_dir
sh "make install DESTDIR=#{install_dir}/libyaml", chdir: build_dir
end

zlib_version = "1.2.12"
desc "build zlib #{zlib_version} for #{target}"
task "zlib-#{target}" do
next if Dir.exist?("#{install_dir}/zlib")

build_dir = File.join(Dir.pwd, "/build/deps/#{target}/zlib-#{zlib_version}")
mkdir_p File.dirname(build_dir)
rm_rf build_dir

sh "curl -L https://zlib.net/zlib-#{zlib_version}.tar.gz | tar xz", chdir: File.dirname(build_dir)

configure_args = []
case target
when "wasm32-unknown-wasi"
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))
when "wasm32-unknown-emscripten"
configure_args.concat(%W(CC=emcc RANLIB=emranlib AR=emar))
else
raise "unknown target: #{target}"
end
sh "#{configure_args.join(" ")} ./configure --prefix=#{install_dir}/zlib --static", chdir: build_dir
sh "make install", chdir: build_dir
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion builders/wasm32-unknown-emscripten/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM emscripten/emsdk:2.0.13

RUN set -eux; \
apt-get update; \
apt-get install ruby bison make autoconf git curl build-essential libyaml-dev -y; \
apt-get install ruby bison make autoconf git curl build-essential libyaml-dev zlib1g-dev -y; \
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -; \
apt-get install nodejs -y; \
apt-get clean; \
Expand Down
2 changes: 1 addition & 1 deletion builders/wasm32-unknown-wasi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ENV WASI_SDK_PATH="/opt/wasi-sdk"

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