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



56
57
58
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 56

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

.build_root(root: MilkTea.root) ⇒ Object



48
49
50
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 48

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

.header_path(root: MilkTea.root) ⇒ Object



44
45
46
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 44

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

.include_flags(root: MilkTea.root) ⇒ Object



60
61
62
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 60

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

.include_root(root: MilkTea.root) ⇒ Object



40
41
42
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 40

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

.install_root(root: MilkTea.root) ⇒ Object



52
53
54
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 52

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

.library(root: MilkTea.root) ⇒ Object



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

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: "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


64
65
66
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 64

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

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



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

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

.source(root: MilkTea.root) ⇒ Object



15
16
17
18
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 15

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



36
37
38
# File 'lib/milk_tea/bindings/vendored_libuv.rb', line 36

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