Class: Tebako::RubyBuilder

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

Overview

Tebako packaging support (ruby builder)

Constant Summary collapse

".tebako-link-manifest"

Instance Method Summary collapse

Constructor Details

#initialize(ruby_ver, src_dir) ⇒ RubyBuilder

Returns a new instance of RubyBuilder.



44
45
46
47
48
# File 'lib/tebako/ruby_builder.rb', line 44

def initialize(ruby_ver, src_dir)
  @ruby_ver = ruby_ver
  @src_dir = src_dir
  @ncores = ScenarioManagerBase.new.ncores
end

Instance Method Details

#make_target(*args) ⇒ Object

Ruby's parallel build can race on ext/extinit.o: the ruby link step can start before extinit.o is (re)built after configure-ext.mk is regenerated, giving "clang: error: no such file or directory: 'ext/extinit.o'". A second, serial pass is mostly cached and builds the raced target deterministically, so retry once serially.



54
55
56
57
58
# File 'lib/tebako/ruby_builder.rb', line 54

def make_target(*args)
  BuildHelpers.run_with_capture(["make", *args, "-j#{@ncores}"])
rescue Tebako::Error
  BuildHelpers.run_with_capture(["make", *args])
end

#target_build(output_type) ⇒ Object

Final build of tebako package



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/tebako/ruby_builder.rb', line 70

def target_build(output_type)
  puts "   ... building tebako #{output_type}"
  Dir.chdir(@src_dir) do
    if native_link_current?
      puts "   ... native link inputs are unchanged; reusing Ruby executable"
      next
    end

    make_target
    record_native_link
  end
end

Relink only the final macOS executable, placing the application envelope in a Mach-O section so the complete one-file bundle can be code signed.



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/tebako/ruby_builder.rb', line 85

def target_link_with_application(output, application)
  puts "   ... linking signed-container-ready macOS bundle"
  target = File.expand_path(output)
  build_name = ".tebako-bundle-#{Process.pid}-#{SecureRandom.hex(6)}"
  build_target = File.join(@src_dir, build_name)
  prepare_link_target(target)
  run_application_link(build_name, application)
  publish_application_link(output, target, build_target)
ensure
  FileUtils.rm_f(build_target) if build_target
end

#toolchain_buildObject

Final build of tebako package



61
62
63
64
65
66
67
# File 'lib/tebako/ruby_builder.rb', line 61

def toolchain_build
  puts "   ... building toolchain Ruby"
  Dir.chdir(@src_dir) do
    make_target
    make_target("install")
  end
end