Class: RubyWasm::Toolchain

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_wasm/build/toolchain.rb

Direct Known Subclasses

Emscripten, WASISDK

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeToolchain

Returns a new instance of Toolchain.



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

def initialize
  @tools = {}
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/ruby_wasm/build/toolchain.rb', line 5

def name
  @name
end

Class Method Details

.check_executable(command) ⇒ Object



40
41
42
43
44
# File 'lib/ruby_wasm/build/toolchain.rb', line 40

def self.check_executable(command)
  tool = find_path(command)
  raise "missing executable: #{command}" unless tool
  tool
end

.find_path(command) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/ruby_wasm/build/toolchain.rb', line 30

def self.find_path(command)
  (ENV["PATH"] || "")
    .split(File::PATH_SEPARATOR)
    .each do |path_dir|
      bin_path = File.join(path_dir, command)
      return bin_path if File.executable?(bin_path)
    end
  nil
end

.get(target, build_dir = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/ruby_wasm/build/toolchain.rb', line 19

def self.get(target, build_dir = nil)
  case target
  when /^wasm32-unknown-wasi/
    return RubyWasm::WASISDK.new(build_dir: build_dir)
  when "wasm32-unknown-emscripten"
    return RubyWasm::Emscripten.new
  else
    raise "unknown target: #{target}"
  end
end

Instance Method Details

#check_envvar(name) ⇒ Object



15
16
17
# File 'lib/ruby_wasm/build/toolchain.rb', line 15

def check_envvar(name)
  raise "missing environment variable: #{name}" if ENV[name].nil?
end

#find_tool(name) ⇒ Object



11
12
13
# File 'lib/ruby_wasm/build/toolchain.rb', line 11

def find_tool(name)
  raise "not implemented"
end