Skip to content

Commit c46b66a

Browse files
Merge pull request #330 from ruby/katei/tarball-build
build: Support tarball source type
2 parents 8532165 + 919fded commit c46b66a

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

Rakefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ BUILD_SOURCES = {
1515
rev: "master",
1616
patches: Dir["./patches/*.patch"].map { |p| File.expand_path(p) }
1717
},
18-
"3.2" => {
19-
type: "github",
20-
repo: "ruby/ruby",
21-
rev: "v3_2_0"
22-
}
18+
"3.2" => { type: "tarball", url: "https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz" }
2319
}
2420

2521
# Respect revisions specified in build_manifest.json, which is usually generated on GitHub Actions.

lib/ruby_wasm/build/product/crossruby.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def build(executor, remake: false, reconfigure: false)
178178
install_dir = File.join(build_dir, "install")
179179
if !File.exist?(install_dir) || remake || reconfigure
180180
executor.system "make",
181+
"-j#{executor.process_count}",
181182
"install",
182183
"DESTDIR=#{install_dir}",
183184
chdir: build_dir

lib/ruby_wasm/build/product/ruby_source.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def cache_key(digest)
1616
case @params[:type]
1717
when "github"
1818
digest << @params[:rev]
19+
when "tarball"
20+
digest << @params[:url]
1921
when "local"
2022
digest << File.mtime(@params[:src]).to_i.to_s
2123
else
@@ -58,6 +60,11 @@ def fetch(executor)
5860
"origin/#{@params[:rev]}",
5961
chdir: src_dir
6062
)
63+
when "tarball"
64+
executor.mkdir_p src_dir
65+
tarball_path = File.join(File.dirname(src_dir), File.basename(src_dir) + ".tar.gz")
66+
executor.system("curl", "-L", "-o", tarball_path, @params[:url])
67+
executor.system("tar", "xf", tarball_path, "-C", src_dir, "--strip-components=1")
6168
when "local"
6269
executor.mkdir_p File.dirname(src_dir)
6370
executor.cp_r @params[:src], src_dir

tasks/ci.rake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
def latest_build_sources
22
BUILD_SOURCES
3-
.map do |name, src|
3+
.filter_map do |name, src|
44
case src[:type]
55
when "github"
66
url = "repos/#{src[:repo]}/commits/#{src[:rev]}"
77
revision = JSON.parse(`gh api #{url}`)
88
[name, revision["sha"]]
9+
when "tarball"
10+
nil
911
else
1012
raise "#{src[:type]} is not supported to pin source revision"
1113
end

0 commit comments

Comments
 (0)