Module: MilkTea::VendoredSDL3

Defined in:
lib/milk_tea/bindings/vendored_sdl3.rb

Constant Summary collapse

Error =
VendoredCLibrary::Error
SOURCE_NAME =
"sdl3"
CONFIGURE_ARGS =
%w[
  -DCMAKE_BUILD_TYPE=Release
  -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  -DSDL_SHARED=OFF
  -DSDL_STATIC=ON
  -DSDL_TEST_LIBRARY=OFF
  -DSDL_TESTS=OFF
  -DSDL_EXAMPLES=OFF
].freeze

Class Method Summary collapse

Class Method Details

.archive_path(root: MilkTea.root) ⇒ Object



59
60
61
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 59

def self.archive_path(root: MilkTea.root)
  install_root(root:).join("lib/libSDL3.a")
end

.build_root(root: MilkTea.root) ⇒ Object



51
52
53
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 51

def self.build_root(root: MilkTea.root)
  MilkTea.writable_root_for(root).join("tmp/vendored-sdl3")
end

.header_root(root: MilkTea.root) ⇒ Object



47
48
49
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 47

def self.header_root(root: MilkTea.root)
  include_root(root:).join("SDL3")
end

.include_flags(root: MilkTea.root) ⇒ Object



63
64
65
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 63

def self.include_flags(root: MilkTea.root)
  library(root:).include_flags
end

.include_root(root: MilkTea.root) ⇒ Object



43
44
45
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 43

def self.include_root(root: MilkTea.root)
  source_root(root:).join("include")
end

.install_root(root: MilkTea.root) ⇒ Object



55
56
57
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 55

def self.install_root(root: MilkTea.root)
  MilkTea.writable_root_for(root).join("tmp/vendored-sdl3-prefix")
end

.library(root: MilkTea.root) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 23

def self.library(root: MilkTea.root)
  resolved_root = Pathname.new(File.expand_path(root.to_s))
  @libraries ||= {}
  @libraries[resolved_root.to_s] ||= VendoredCLibrary::CMake.new(
    name: "sdl3",
    source_root: source_root(root: resolved_root),
    build_root: build_root(root: resolved_root),
    install_root: install_root(root: resolved_root),
    archive_path: archive_path(root: resolved_root),
    include_roots: [include_root(root: resolved_root)],
    configure_args: CONFIGURE_ARGS,
    pkg_config_name: "sdl3",
    cc_env_var: "SDL3_CC",
  )
end


67
68
69
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 67

def self.link_flags(root: MilkTea.root)
  library(root:).link_flags
end

.prepare!(root: MilkTea.root, **kwargs) ⇒ Object



71
72
73
74
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 71

def self.prepare!(root: MilkTea.root, **kwargs)
  source(root:).bootstrap!
  library(root:).prepare!(**kwargs)
end

.source(root: MilkTea.root) ⇒ Object



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

def self.source(root: MilkTea.root)
  UpstreamSources.default_sources(root:).find { |entry| entry.name == SOURCE_NAME } ||
    raise(Error, "missing upstream source definition for #{SOURCE_NAME}")
end

.source_root(root: MilkTea.root) ⇒ Object



39
40
41
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 39

def self.source_root(root: MilkTea.root)
  source(root:).checkout_root
end