Class: RubyWasm::BuildTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/ruby_wasm/rake_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, target:, src:, toolchain: nil, build_dir: nil, rubies_dir: nil, **options) {|@build| ... } ⇒ BuildTask

Returns a new instance of BuildTask.

Yields:

  • (@build)


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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ruby_wasm/rake_task.rb', line 9

def initialize(
  name,
  target:,
  src:,
  toolchain: nil,
  build_dir: nil,
  rubies_dir: nil,
  **options,
  &block
)
  target = Target.new(target)
  @build =
    RubyWasm::Build.new(
      name,
      target: target,
      src: src,
      toolchain: toolchain,
      build_dir: build_dir || File.join(Dir.pwd, "build"),
      rubies_dir: rubies_dir || File.join(Dir.pwd, "rubies"),
      **options,
      &block
    )
  yield @build if block_given?
  @crossruby = @build.crossruby
  # Rake.verbose can be Object.new by default, so compare with true explicitly.
  executor = RubyWasm::BuildExecutor.new(verbose: Rake.verbose == true)

  desc "Cross-build Ruby for #{@target}"
  task name do
    next if File.exist? @crossruby.artifact
    @crossruby.build(executor)
  end
  namespace name do
    task :remake do
      @crossruby.build(executor, remake: true)
    end
    task :reconfigure do
      @crossruby.build(executor, reconfigure: true)
    end
    task :clean do
      @crossruby.clean(executor)
    end
  end
end

Instance Attribute Details

#nameObject

Name of the task.



7
8
9
# File 'lib/ruby_wasm/rake_task.rb', line 7

def name
  @name
end

Instance Method Details

#hexdigestObject



54
55
56
57
58
59
# File 'lib/ruby_wasm/rake_task.rb', line 54

def hexdigest
  require "digest"
  digest = Digest::SHA256.new
  @build.cache_key(digest)
  digest.hexdigest
end