Class: RubyWasm::BuildSource
- Inherits:
-
BuildProduct
- Object
- BuildProduct
- RubyWasm::BuildSource
- Defined in:
- lib/ruby_wasm/build/product/ruby_source.rb
Instance Method Summary collapse
- #build(executor) ⇒ Object
- #cache_key(digest) ⇒ Object
- #configure_file ⇒ Object
- #fetch(executor) ⇒ Object
-
#initialize(params, build_dir) ⇒ BuildSource
constructor
A new instance of BuildSource.
- #name ⇒ Object
- #src_dir ⇒ Object
Constructor Details
#initialize(params, build_dir) ⇒ BuildSource
Returns a new instance of BuildSource.
5 6 7 8 |
# File 'lib/ruby_wasm/build/product/ruby_source.rb', line 5 def initialize(params, build_dir) @params = params @build_dir = build_dir end |
Instance Method Details
#build(executor) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/ruby_wasm/build/product/ruby_source.rb', line 87 def build(executor) fetch(executor) unless File.exist?(src_dir) unless File.exist?(configure_file) executor.system "ruby", "tool/downloader.rb", "-d", "tool", "-e", "gnu", "config.guess", "config.sub", chdir: src_dir executor.system "./autogen.sh", chdir: src_dir end end |
#cache_key(digest) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ruby_wasm/build/product/ruby_source.rb', line 14 def cache_key(digest) digest << @params[:type] case @params[:type] when "github" digest << @params[:rev] when "tarball" digest << @params[:url] when "local" digest << File.mtime(@params[:path]).to_i.to_s else raise "unknown source type: #{@params[:type]}" end end |
#configure_file ⇒ Object
32 33 34 |
# File 'lib/ruby_wasm/build/product/ruby_source.rb', line 32 def configure_file File.join(src_dir, "configure") end |
#fetch(executor) ⇒ Object
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 |
# File 'lib/ruby_wasm/build/product/ruby_source.rb', line 36 def fetch(executor) case @params[:type] when "github" repo_url = "https://github.com/#{@params[:repo]}.git" executor.mkdir_p src_dir executor.system "git", "init", chdir: src_dir executor.system "git", "remote", "add", "origin", repo_url, chdir: src_dir executor.system( "git", "fetch", "--depth", "1", "origin", "#{@params[:rev]}:origin/#{@params[:rev]}", chdir: src_dir ) executor.system( "git", "checkout", "origin/#{@params[:rev]}", chdir: src_dir ) when "tarball" executor.mkdir_p src_dir tarball_path = File.join(File.dirname(src_dir), File.basename(src_dir) + ".tar.gz") executor.system("curl", "-L", "-o", tarball_path, @params[:url]) executor.system( "tar", "xf", tarball_path, "-C", src_dir, "--strip-components=1" ) when "local" executor.mkdir_p File.dirname(src_dir) executor.ln_s File.(@params[:path]), src_dir else raise "unknown source type: #{@params[:type]}" end (@params[:patches] || []).each do |patch_path| executor.system "patch", "-p1", "-i", patch_path, chdir: src_dir end end |
#name ⇒ Object
10 11 12 |
# File 'lib/ruby_wasm/build/product/ruby_source.rb', line 10 def name @params[:name] end |
#src_dir ⇒ Object
28 29 30 |
# File 'lib/ruby_wasm/build/product/ruby_source.rb', line 28 def src_dir File.join(@build_dir, "checkouts", @params[:name]) end |