Module: MilkTea::VendoredPCRE2

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

Constant Summary collapse

Error =
VendoredCLibrary::Error
SOURCE_NAME =
"pcre2"
CONFIGURE_ARGS =
%w[
  -DCMAKE_BUILD_TYPE=Release
  -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  -DBUILD_SHARED_LIBS=OFF
  -DPCRE2_BUILD_PCRE2_8=ON
  -DPCRE2_BUILD_PCRE2_16=OFF
  -DPCRE2_BUILD_PCRE2_32=OFF
  -DPCRE2_BUILD_PCRE2GREP=OFF
  -DPCRE2_BUILD_PCRE2TEST=OFF
  -DPCRE2_BUILD_TESTS=OFF
].freeze
%w[
  -lm
].freeze

Class Method Summary collapse

Class Method Details

.archive_path(root: MilkTea.root) ⇒ Object



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

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

.build_root(root: MilkTea.root) ⇒ Object



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

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

.header_path(root: MilkTea.root) ⇒ Object



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

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

.include_flags(root: MilkTea.root) ⇒ Object



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

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

.include_root(root: MilkTea.root) ⇒ Object



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

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

.install_root(root: MilkTea.root) ⇒ Object



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

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

.library(root: MilkTea.root) ⇒ Object



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

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: "pcre2",
    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: "PCRE2_CC",
  )
end


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

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

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



77
78
79
80
# File 'lib/milk_tea/bindings/vendored_pcre2.rb', line 77

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

.source(root: MilkTea.root) ⇒ Object



24
25
26
27
# File 'lib/milk_tea/bindings/vendored_pcre2.rb', line 24

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



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

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