-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
38 lines (31 loc) · 1.08 KB
/
Rakefile
File metadata and controls
38 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "opal/rspec/rake_task"
require 'erb'
RSpec::Core::RakeTask.new(:spec)
Opal::RSpec::RakeTask.new("spec-opal") do |server, task|
require 'opal/onigmo'
end
task :generate => ['opal/onigmo/constants.rb', 'opal/onigmo/onigmo-wasm.wasm'] do
end
def render_template(template, output, vars)
tmpl = File.read(template)
erb = ERB.new(tmpl, 0, "<>")
File.open(output, "w") do |f|
f.puts erb.result_with_hash(vars)
end
end
file 'opal/onigmo/constants.rb' => ['opal/onigmo/constants.rb.erb', 'Onigmo/onigmo.h'] do |task|
render_template(
File.expand_path(task.prerequisites.first, __dir__),
task.name,
{onigmo_h: File.read('Onigmo/onigmo.h')}
)
end
file 'opal/onigmo/onigmo-wasm.wasm' => ['Onigmo/build-wasm.sh'] do |task|
if File.exist? __dir__+"/../../wasi-sdk-11.0/share/wasi-sysroot/"
env = "BUILD=wasi WASI_PATH=#{__dir__}/../../wasi-sdk-11.0/share/wasi-sysroot/"
end
sh "cd Onigmo; #{env} sh ./build-wasm.sh; mv onigmo.wasm ../opal/onigmo/onigmo-wasm.wasm"
end
task :default => [:spec, "spec-opal"]