Class: RubyWasm::ZlibProduct
- Inherits:
-
AutoconfProduct
- Object
- BuildProduct
- AutoconfProduct
- RubyWasm::ZlibProduct
- Defined in:
- lib/ruby_wasm/build/product/zlib.rb
Constant Summary collapse
- ZLIB_VERSION =
"1.3.1"
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #build(executor) ⇒ Object
- #configure_args ⇒ Object
- #destdir ⇒ Object
-
#initialize(build_dir, target, toolchain) ⇒ ZlibProduct
constructor
A new instance of ZlibProduct.
- #install_root ⇒ Object
- #name ⇒ Object
- #product_build_dir ⇒ Object
Methods inherited from AutoconfProduct
#system_triplet_args, #tools_args
Constructor Details
#initialize(build_dir, target, toolchain) ⇒ ZlibProduct
Returns a new instance of ZlibProduct.
9 10 11 12 13 |
# File 'lib/ruby_wasm/build/product/zlib.rb', line 9 def initialize(build_dir, target, toolchain) @build_dir = build_dir @target = target super(target, toolchain) end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
5 6 7 |
# File 'lib/ruby_wasm/build/product/zlib.rb', line 5 def target @target end |
Instance Method Details
#build(executor) ⇒ Object
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 |
# File 'lib/ruby_wasm/build/product/zlib.rb', line 37 def build(executor) return if Dir.exist?(install_root) executor.mkdir_p File.dirname(product_build_dir) executor.rm_rf product_build_dir executor.mkdir_p product_build_dir tarball_path = File.join(product_build_dir, "zlib-#{ZLIB_VERSION}.tar.gz") executor.system "curl", "-o", tarball_path, "-L", "https://github.com/madler/zlib/releases/download/v#{ZLIB_VERSION}/zlib-#{ZLIB_VERSION}.tar.gz" executor.system "tar", "xzf", tarball_path, "-C", product_build_dir, "--strip-components=1" configure_args = self.configure_args.dup configure_args << "CFLAGS=-fPIC" if target.pic? executor.system "env", *configure_args, "./configure", "--static", chdir: product_build_dir executor.system "make", "install", "DESTDIR=#{destdir}", chdir: product_build_dir end |
#configure_args ⇒ Object
31 32 33 34 35 |
# File 'lib/ruby_wasm/build/product/zlib.rb', line 31 def configure_args args = %w[CHOST=linux] args + tools_args end |
#destdir ⇒ Object
19 20 21 |
# File 'lib/ruby_wasm/build/product/zlib.rb', line 19 def destdir File.join(product_build_dir, "opt") end |
#install_root ⇒ Object
23 24 25 |
# File 'lib/ruby_wasm/build/product/zlib.rb', line 23 def install_root File.join(destdir, "usr", "local") end |
#name ⇒ Object
27 28 29 |
# File 'lib/ruby_wasm/build/product/zlib.rb', line 27 def name "zlib-#{ZLIB_VERSION}-#{target}" end |
#product_build_dir ⇒ Object
15 16 17 |
# File 'lib/ruby_wasm/build/product/zlib.rb', line 15 def product_build_dir File.join(@build_dir, target.to_s, "zlib-#{ZLIB_VERSION}") end |