Class: RubyWasm::Toolchain
- Inherits:
-
Object
- Object
- RubyWasm::Toolchain
- Defined in:
- lib/ruby_wasm/build/toolchain.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
- .check_executable(command) ⇒ Object
- .find_path(command) ⇒ Object
- .get(target, build_dir = nil) ⇒ Object
Instance Method Summary collapse
- #check_envvar(name) ⇒ Object
- #find_tool(name) ⇒ Object
-
#initialize ⇒ Toolchain
constructor
A new instance of Toolchain.
Constructor Details
#initialize ⇒ Toolchain
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
#name ⇒ Object (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 |