Class: Thermite::Config

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

Instance Method Summary collapse

Instance Method Details

#cargo_target_path(profile, *path_components) ⇒ Object

Due to the lack of cross-compilation support, thermite assumes the resulting binary is placed in target/<profile>, however it’s actually in target/<target_arch>/<profile>



18
19
20
21
# File 'lib/thermite_patch.rb', line 18

def cargo_target_path(profile, *path_components)
  target_base = ENV.fetch('CARGO_TARGET_DIR', File.join(rust_toplevel_dir, 'target'))
  File.join(target_base, ENV.fetch('CARGO_BUILD_TARGET', ''), profile, *path_components)
end

#dynamic_linker_flagsObject



23
24
25
26
27
28
29
30
31
# File 'lib/thermite_patch.rb', line 23

def dynamic_linker_flags
  @dynamic_linker_flags ||= begin
    default_flags = RbConfig::CONFIG['DLDFLAGS'].strip
    if target_os == 'darwin' && !default_flags.include?('-Wl,-undefined,dynamic_lookup')
      default_flags += ' -Wl,-undefined,dynamic_lookup'
    end
    default_flags
  end
end

#target_archObject

Thermite doesn’t support cross-compilation so it always assumes the binary is being built for the current architecture. It only really affects the name of the tarball.



7
8
9
# File 'lib/thermite_patch.rb', line 7

def target_arch
  @target_arch ||= ENV.fetch('TARGET_ARCH', RbConfig::CONFIG['target_cpu'])
end

#target_osObject

Use the same target for all darwin versions



12
13
14
# File 'lib/thermite_patch.rb', line 12

def target_os
  @target_os ||= RbConfig::CONFIG['target_os'].sub(/darwin\d+/, 'darwin')
end