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



61
62
63
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 61

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

.build_root(root: MilkTea.root) ⇒ Object



53
54
55
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 53

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

.header_root(root: MilkTea.root) ⇒ Object



49
50
51
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 49

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

.include_flags(root: MilkTea.root) ⇒ Object



65
66
67
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 65

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

.include_root(root: MilkTea.root) ⇒ Object



45
46
47
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 45

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

.install_root(root: MilkTea.root) ⇒ Object



57
58
59
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 57

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

.library(root: MilkTea.root) ⇒ Object



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

def 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


69
70
71
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 69

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

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



73
74
75
76
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 73

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

.source(root: MilkTea.root) ⇒ Object



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

def 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



41
42
43
# File 'lib/milk_tea/bindings/vendored_sdl3.rb', line 41

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