Class: Tebako::RuntimeBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/tebako/runtime_builder.rb

Overview

Builds the reusable native runtime independently from application packaging.

Constant Summary collapse

".tebako-runtime-link-identity"

Instance Method Summary collapse

Constructor Details

#initialize(options_manager, scenario_manager, command_runner: nil, file_generator: nil, finalizer: nil, configure_command: nil, build_command: nil) ⇒ RuntimeBuilder

Returns a new instance of RuntimeBuilder.



24
25
26
27
28
29
30
31
32
33
# File 'lib/tebako/runtime_builder.rb', line 24

def initialize(options_manager, scenario_manager, command_runner: nil, file_generator: nil, finalizer: nil,
               configure_command: nil, build_command: nil)
  @opts = options_manager
  @scm = scenario_manager
  @command_runner = command_runner || ->(environment, command) { system(environment, command) }
  @file_generator = file_generator
  @finalizer = finalizer
  @configured_command = configure_command
  @configured_build_command = build_command
end

Instance Method Details

#buildObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/tebako/runtime_builder.rb', line 35

def build
  current = current_descriptor
  if current
    Tebako::BuildReporter.record(
      stage: "runtime_build",
      status: "reused",
      reason: "runtime identity and native inputs are unchanged",
      key: current.identity
    )
    return current
  end

  started_at = monotonic_time
  generate_files
  merged_env = ENV.to_h.merge(@scm.b_env)
  Tebako.packaging_error(103) unless @command_runner.call(merged_env, configure_command)
  Tebako.packaging_error(104) unless @command_runner.call(merged_env, build_command)
  finalize
  descriptor = write_descriptor
  write_link_identity(descriptor)
  Tebako::BuildReporter.record(
    stage: "runtime_build",
    status: "checked",
    reason: "CMake evaluated the runtime dependency graph",
    duration: monotonic_time - started_at,
    details: descriptor ? { "runtime_identity" => descriptor.identity } : nil
  )
  descriptor
end