Class: MilkTea::Run

Inherits:
Object
  • Object
show all
Defined in:
lib/milk_tea/tooling/run.rb

Defined Under Namespace

Classes: Result, WasmPreviewServer

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, output_path:, cc:, keep_c_path:, module_roots: nil, package_graph: nil, frontend: nil, profile: nil, platform: nil, bundle: false, archive: false, browser_opener: nil, preview_server_class: nil, preview_started: nil, argv: [], no_cache: false, kind: :executable, debug_guards: false) ⇒ Run

Returns a new instance of Run.



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/milk_tea/tooling/run.rb', line 217

def initialize(path, output_path:, cc:, keep_c_path:, module_roots: nil, package_graph: nil, frontend: nil, profile: nil, platform: nil, bundle: false, archive: false, browser_opener: nil, preview_server_class: nil, preview_started: nil, argv: [], no_cache: false, kind: :executable, debug_guards: false)
  @input_path = File.expand_path(path)
  @output_path = output_path ? File.expand_path(output_path) : nil
  @cc = cc
  @keep_c_path = keep_c_path ? File.expand_path(keep_c_path) : nil
  @module_roots = module_roots
  @project_root = resolve_project_root
  @package_graph = package_graph
  @frontend = frontend
  @profile = profile
  @platform = platform
  @bundle = bundle
  @archive = archive
  @browser_opener = browser_opener || method(:open_browser)
  @preview_server_class = preview_server_class || WasmPreviewServer
  @preview_started = preview_started
  @argv = argv
  @no_cache = no_cache
  @debug_guards = debug_guards
end

Class Method Details

.run(path, output_path: nil, cc: ENV.fetch("CC", "cc"), keep_c_path: nil, module_roots: nil, package_graph: nil, frontend: nil, profile: nil, platform: nil, bundle: false, archive: false, browser_opener: nil, preview_server_class: nil, preview_started: nil, argv: [], no_cache: false, kind: :executable, debug_guards: false) ⇒ Object



213
214
215
# File 'lib/milk_tea/tooling/run.rb', line 213

def self.run(path, output_path: nil, cc: ENV.fetch("CC", "cc"), keep_c_path: nil, module_roots: nil, package_graph: nil, frontend: nil, profile: nil, platform: nil, bundle: false, archive: false, browser_opener: nil, preview_server_class: nil, preview_started: nil, argv: [], no_cache: false, kind: :executable, debug_guards: false)
  new(path, output_path:, cc:, keep_c_path:, module_roots:, package_graph:, frontend:, profile:, platform:, bundle:, archive:, browser_opener:, preview_server_class:, preview_started:, argv:, no_cache:, kind:, debug_guards:).run
end

Instance Method Details

#runObject



238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/milk_tea/tooling/run.rb', line 238

def run
  if @output_path
    return run_binary(@output_path)
  end

  if wasm_target_requested?
    return run_binary(nil)
  end

  Dir.mktmpdir("milk-tea-run") do |dir|
    binary_path = File.join(dir, File.basename(@input_path, ".mt"))
    run_binary(binary_path)
  end
end