Module: MilkTea::VendoredLibUV

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

Constant Summary collapse

Error =
VendoredCLibrary::Error
SOURCE_NAME =
"libuv"
CONFIGURE_ARGS =
%w[
  -DCMAKE_BUILD_TYPE=Release
  -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  -DBUILD_SHARED_LIBS=OFF
  -DBUILD_TESTING=OFF
].freeze

Class Method Summary collapse

Class Method Details

.archive_path(root: MilkTea.root) ⇒ Object



58
59
60
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 58

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

.build_root(root: MilkTea.root) ⇒ Object



50
51
52
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 50

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

.header_path(root: MilkTea.root) ⇒ Object



46
47
48
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 46

def header_path(root: MilkTea.root)
  include_root(root:).join("uv.h")
end

.include_flags(root: MilkTea.root) ⇒ Object



62
63
64
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 62

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

.include_root(root: MilkTea.root) ⇒ Object



42
43
44
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 42

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

.install_root(root: MilkTea.root) ⇒ Object



54
55
56
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 54

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

.library(root: MilkTea.root) ⇒ Object



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

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: "libuv",
    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: "libuv-static",
    cc_env_var: "LIBUV_CC",
  )
end


66
67
68
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 66

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

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



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

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

.source(root: MilkTea.root) ⇒ Object



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

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



38
39
40
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 38

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