Class: RubyWasm::Toolchain

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

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

#nameString (readonly)

Returns the value of attribute name.

Returns:

  • (String)


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

def name
  @name
end

Class Method Details

.check_executable(command) ⇒ String

Parameters:

  • command (String)

Returns:

  • (String)


45
46
47
48
49
# File 'lib/ruby_wasm/build/toolchain.rb', line 45

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

.find_path(command) ⇒ String?

Parameters:

  • command (String)

Returns:

  • (String, nil)


35
36
37
38
39
40
41
42
43
# File 'lib/ruby_wasm/build/toolchain.rb', line 35

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, options, build_dir = nil) ⇒ Toolchain

Parameters:

  • target (Target)
  • config (Hash[untyped, untyped])
  • build_dir (String, nil) (defaults to: nil)

Returns:



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

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

Instance Method Details

#arString

Returns:

  • (String)


251
# File 'sig/ruby_wasm/build.rbs', line 251

def ar: -> String

#ccString

Returns:

  • (String)


247
# File 'sig/ruby_wasm/build.rbs', line 247

def cc: -> String

#check_envvar(name) ⇒ void

This method returns an undefined value.

Parameters:

  • 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

#cxxString

Returns:

  • (String)


248
# File 'sig/ruby_wasm/build.rbs', line 248

def cxx: -> String

#find_tool(name) ⇒ String

Parameters:

  • name (Symbol)

Returns:

  • (String)


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

def find_tool(name)
  raise "not implemented"
end

#installvoid

This method returns an undefined value.

Parameters:



253
# File 'sig/ruby_wasm/build.rbs', line 253

def install: (_CommandExecutor executor) -> void

#ldString

Returns:

  • (String)


250
# File 'sig/ruby_wasm/build.rbs', line 250

def ld: -> String

#ranlibString

Returns:

  • (String)


249
# File 'sig/ruby_wasm/build.rbs', line 249

def ranlib: -> String