Module: MilkTea::VendoredBox2D

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

Constant Summary collapse

Error =
VendoredCLibrary::Error
CONFIGURE_ARGS =
%w[
  -DCMAKE_BUILD_TYPE=Release
  -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  -DBUILD_SHARED_LIBS=OFF
  -DBOX2D_SAMPLES=OFF
  -DBOX2D_BENCHMARKS=OFF
  -DBOX2D_DOCS=OFF
  -DBOX2D_PROFILE=OFF
  -DBOX2D_VALIDATE=OFF
  -DBOX2D_UNIT_TESTS=OFF
].freeze
%w[
  -lm
].freeze

Class Method Summary collapse

Class Method Details

.archive_path(root: MilkTea.root) ⇒ Object



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

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

.build_root(root: MilkTea.root) ⇒ Object



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

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

.header_root(root: MilkTea.root) ⇒ Object



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

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

.include_flags(root: MilkTea.root) ⇒ Object



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

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

.include_root(root: MilkTea.root) ⇒ Object



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

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

.install_root(root: MilkTea.root) ⇒ Object



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

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

.library(root: MilkTea.root) ⇒ Object



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

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: "box2d",
    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,
    system_link_flags: SYSTEM_LINK_FLAGS,
    cc_env_var: "BOX2D_CC",
  )
end


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

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

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



75
76
77
# File 'lib/milk_tea/bindings/vendored_box2d.rb', line 75

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

.source_root(root: MilkTea.root) ⇒ Object



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

def source_root(root: MilkTea.root)
  MilkTea.writable_root_for(root).join("third_party/box2d-upstream")
end