Class: MilkTea::VendoredSteamworks::Library

Inherits:
MilkTea::VendoredCLibrary::Base show all
Defined in:
lib/milk_tea/bindings/vendored_steamworks.rb

Instance Attribute Summary collapse

Attributes inherited from MilkTea::VendoredCLibrary::Base

#include_roots, #name, #source_root

Instance Method Summary collapse

Methods inherited from MilkTea::VendoredCLibrary::Base

#build_flags, #include_flags

Constructor Details

#initialize(root: MilkTea.root) ⇒ Library

Returns a new instance of Library.



20
21
22
23
24
# File 'lib/milk_tea/bindings/vendored_steamworks.rb', line 20

def initialize(root: MilkTea.root)
  @root = Pathname.new(File.expand_path(root.to_s))
  @build_root = MilkTea.writable_root_for(root).join("tmp/vendored-steamworks")
  super(name: "steamworks", source_root: MilkTea.writable_root_for(root).join("third_party/steamworks-sdk-upstream"))
end

Instance Attribute Details

#build_rootObject (readonly)

Returns the value of attribute build_root.



18
19
20
# File 'lib/milk_tea/bindings/vendored_steamworks.rb', line 18

def build_root
  @build_root
end

#rootObject (readonly)

Returns the value of attribute root.



18
19
20
# File 'lib/milk_tea/bindings/vendored_steamworks.rb', line 18

def root
  @root
end

Instance Method Details



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/milk_tea/bindings/vendored_steamworks.rb', line 26

def link_flags(platform: nil)
  resolved_platform = platform || host_platform

  case resolved_platform
  when :windows
    copied_import_library = build_root.join(MilkTea::Steamworks::IMPORT_LIBRARY_BASENAME_BY_PLATFORM.fetch(resolved_platform))
    return [copied_import_library.to_s] if File.file?(copied_import_library)

    ["-L#{build_root}"]
  else
    ["-L#{build_root}"]
  end
end

#prepare!(env: ENV, cc: ENV.fetch("CC", "cc"), platform: nil) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/milk_tea/bindings/vendored_steamworks.rb', line 40

def prepare!(env: ENV, cc: ENV.fetch("CC", "cc"), platform: nil)
  _resolved_cc = resolved_cc(env, cc)
  FileUtils.mkdir_p(build_root)

  resolved_platform = platform || host_platform
  import_library = MilkTea::Steamworks.import_library_path(root:, env:, platform: resolved_platform, bootstrap: true)
  runtime_library = MilkTea::Steamworks.runtime_library_path(root:, env:, platform: resolved_platform, bootstrap: true)

  copy_if_present(import_library)
  copy_if_present(runtime_library)
rescue Errno::ENOENT => e
  raise tool_not_found(e)
end