Skip to content

Commit

Permalink
Merge pull request #330 from ruby/katei/tarball-build
Browse files Browse the repository at this point in the history
build: Support tarball source type
  • Loading branch information
kateinoigakukun authored Dec 3, 2023
2 parents 8532165 + 919fded commit c46b66a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 1 addition & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ BUILD_SOURCES = {
rev: "master",
patches: Dir["./patches/*.patch"].map { |p| File.expand_path(p) }
},
"3.2" => {
type: "github",
repo: "ruby/ruby",
rev: "v3_2_0"
}
"3.2" => { type: "tarball", url: "https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz" }
}

# Respect revisions specified in build_manifest.json, which is usually generated on GitHub Actions.
Expand Down
1 change: 1 addition & 0 deletions lib/ruby_wasm/build/product/crossruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def build(executor, remake: false, reconfigure: false)
install_dir = File.join(build_dir, "install")
if !File.exist?(install_dir) || remake || reconfigure
executor.system "make",
"-j#{executor.process_count}",
"install",
"DESTDIR=#{install_dir}",
chdir: build_dir
Expand Down
7 changes: 7 additions & 0 deletions lib/ruby_wasm/build/product/ruby_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def cache_key(digest)
case @params[:type]
when "github"
digest << @params[:rev]
when "tarball"
digest << @params[:url]
when "local"
digest << File.mtime(@params[:src]).to_i.to_s
else
Expand Down Expand Up @@ -58,6 +60,11 @@ def fetch(executor)
"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.cp_r @params[:src], src_dir
Expand Down
4 changes: 3 additions & 1 deletion tasks/ci.rake
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
def latest_build_sources
BUILD_SOURCES
.map do |name, src|
.filter_map do |name, src|
case src[:type]
when "github"
url = "repos/#{src[:repo]}/commits/#{src[:rev]}"
revision = JSON.parse(`gh api #{url}`)
[name, revision["sha"]]
when "tarball"
nil
else
raise "#{src[:type]} is not supported to pin source revision"
end
Expand Down

0 comments on commit c46b66a

Please sign in to comment.