Skip to content

Commit 21500ac

Browse files
add rake format task and apply it
1 parent a49e2a7 commit 21500ac

File tree

6 files changed

+60
-19
lines changed

6 files changed

+60
-19
lines changed

Gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
group :development do
6+
gem "syntax_tree", "~> 3.5"
7+
end

Gemfile.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
prettier_print (0.1.0)
5+
syntax_tree (3.5.0)
6+
prettier_print
7+
8+
PLATFORMS
9+
x86_64-linux
10+
11+
DEPENDENCIES
12+
syntax_tree (~> 3.5)
13+
14+
BUNDLED WITH
15+
2.4.0.dev

lib/ruby_wasm/build_system/product/baseruby.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def name
2424
end
2525

2626
def define_task
27-
2827
directory product_build_dir
2928

3029
desc "build baseruby #{@channel}"

lib/ruby_wasm/build_system/product/crossruby.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ def define_task(crossruby)
5454
sh make_cmd
5555
# A ext can provide link args by link.filelist. It contains only built archive file by default.
5656
unless File.exist?(linklist(crossruby))
57-
File.write(
58-
linklist(crossruby),
59-
Dir.glob("#{objdir}/*.a").join("\n")
60-
)
57+
File.write(linklist(crossruby), Dir.glob("#{objdir}/*.a").join("\n"))
6158
end
6259
end
6360
end
@@ -207,9 +204,7 @@ def configure_args(build_triple, toolchain)
207204
raise "unknown target: #{target}"
208205
end
209206

210-
(user_exts || []).each do |lib|
211-
xldflags << "@#{lib.linklist(self)}"
212-
end
207+
(user_exts || []).each { |lib| xldflags << "@#{lib.linklist(self)}" }
213208
xldflags << extinit_obj
214209

215210
xcflags = []

lib/ruby_wasm/rake_task.rb

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,47 @@
22
require_relative "./build_system"
33

44
class RubyWasm::BuildTask < ::Rake::TaskLib
5-
6-
def initialize(name, target:, src:, extensions: [], toolchain: nil, build_dir: nil, rubies_dir: nil, **options, &task_block)
5+
def initialize(
6+
name,
7+
target:,
8+
src:,
9+
extensions: [],
10+
toolchain: nil,
11+
build_dir: nil,
12+
rubies_dir: nil,
13+
**options,
14+
&task_block
15+
)
716
build_dir ||= File.join(Dir.pwd, "build")
817
rubies_dir ||= File.join(Dir.pwd, "rubies")
918
toolchain ||= RubyWasm::Toolchain.get target
1019

11-
libyaml = add_product RubyWasm::LibYAMLProduct.new(build_dir, target, toolchain)
20+
libyaml =
21+
add_product RubyWasm::LibYAMLProduct.new(build_dir, target, toolchain)
1222
zlib = add_product RubyWasm::ZlibProduct.new(build_dir, target, toolchain)
1323

1424
source = add_product RubyWasm::BuildSource.new(src, build_dir)
1525
baseruby = add_product RubyWasm::BaseRubyProduct.new(build_dir, source)
1626

17-
build_params = RubyWasm::BuildParams.new(
18-
options.merge(
19-
name: name, src: source, target: target, user_exts: extensions
27+
build_params =
28+
RubyWasm::BuildParams.new(
29+
options.merge(
30+
name: name,
31+
src: source,
32+
target: target,
33+
user_exts: extensions
34+
)
2035
)
21-
)
2236

23-
product = RubyWasm::CrossRubyProduct.new(build_params, build_dir, rubies_dir, baseruby, source, toolchain)
37+
product =
38+
RubyWasm::CrossRubyProduct.new(
39+
build_params,
40+
build_dir,
41+
rubies_dir,
42+
baseruby,
43+
source,
44+
toolchain
45+
)
2446
product.with_libyaml libyaml
2547
product.with_zlib zlib
2648
product.define_task
@@ -30,9 +52,7 @@ def initialize(name, target:, src:, extensions: [], toolchain: nil, build_dir: n
3052

3153
def add_product(product)
3254
@@products ||= {}
33-
if @@products[product.name]
34-
return @@products[product.name]
35-
end
55+
return @@products[product.name] if @@products[product.name]
3656
@@products[product.name] = product
3757
product.define_task
3858
product

tasks/format.rake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
begin
2+
require "syntax_tree/rake_tasks"
3+
SyntaxTree::Rake::WriteTask.new(:format)
4+
rescue LoadError
5+
end

0 commit comments

Comments
 (0)