Class: Vcdeps::Installed

Inherits:
Object
  • Object
show all
Defined in:
lib/vcdeps/installed.rb

Overview

An immutable snapshot of one completed out-of-tree install. All paths are absolute Strings with backslash separators (display-normalized like Vcvars::Locator#win). Runtime DLLs are enumerated from the authoritative vcpkg\info*.list files — NEVER guessed from port names (R§8.2) — and the debug/ tree is never exposed (R§8.4).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:, triplet:, manifest_dir:, key:, tool:, prefix: nil) ⇒ Installed

tool is nil for a --with-vcdeps-dir bypass install. prefix: overrides the computed <triplet> (the bypass passes the prefix dir directly).



17
18
19
20
21
22
23
24
# File 'lib/vcdeps/installed.rb', line 17

def initialize(root:, triplet:, manifest_dir:, key:, tool:, prefix: nil)
  @root = win(root)
  @triplet = triplet
  @manifest_dir = win(manifest_dir)
  @key = key
  @tool = tool
  @prefix_override = prefix ? win(prefix) : nil
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



13
14
15
# File 'lib/vcdeps/installed.rb', line 13

def key
  @key
end

#manifest_dirObject (readonly)

Returns the value of attribute manifest_dir.



13
14
15
# File 'lib/vcdeps/installed.rb', line 13

def manifest_dir
  @manifest_dir
end

#rootObject (readonly)

Returns the value of attribute root.



13
14
15
# File 'lib/vcdeps/installed.rb', line 13

def root
  @root
end

#toolObject (readonly)

Returns the value of attribute tool.



13
14
15
# File 'lib/vcdeps/installed.rb', line 13

def tool
  @tool
end

#tripletObject (readonly)

Returns the value of attribute triplet.



13
14
15
# File 'lib/vcdeps/installed.rb', line 13

def triplet
  @triplet
end

Instance Method Details

#bin_dirObject



42
43
44
# File 'lib/vcdeps/installed.rb', line 42

def bin_dir
  File.join(prefix, "bin").tr("/", "\\")
end

Hash{ "zlib" => "\share\zlib\copyright", ... } for EXISTING files.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/vcdeps/installed.rb', line 84

def copyright_files
  result = {}
  ports.each do |port|
    cand = File.join(prefix, "share", port.name, "copyright")
    result[port.name] = win(cand) if File.exist?(cand)
  end
  # Bypass mode has no ports; scan share\*\copyright directly.
  if bypass?
    share = File.join(prefix, "share").tr("\\", "/")
    Dir[File.join(share, "*", "copyright")].each do |cp|
      name = File.basename(File.dirname(cp))
      result[name] ||= win(cp)
    end
  end
  result
end

#dllsObject

Array absolute paths of RELEASE runtime DLLs. Normal mode: read every info-list file, take entries ending in .dll that are NOT under a debug/ directory, resolve to absolute backslash paths. Bypass mode (no tool): glob bin*.dll.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/vcdeps/installed.rb', line 66

def dlls
  if bypass?
    Dir[File.join(bin_dir.tr("\\", "/"), "*.dll")].sort.map { |p| win(p) }
  else
    out = []
    list_files.each do |list|
      read_list_entries(list).each do |entry|
        next unless entry =~ /\.dll\z/i
        next if entry =~ %r{(?:\A|/)debug/}i

        out << win(File.join(@root, entry))
      end
    end
    out.uniq.sort
  end
end

#include_dirObject



33
34
35
# File 'lib/vcdeps/installed.rb', line 33

def include_dir
  File.join(prefix, "include").tr("/", "\\")
end

#info_dirObject

The vcpkg metadata dir holding info*.list (and status).



52
53
54
# File 'lib/vcdeps/installed.rb', line 52

def info_dir
  File.join(@root, "vcpkg", "info").tr("/", "\\")
end

#lib_dirObject

The RELEASE lib dir — never debug\lib (R§8.4).



38
39
40
# File 'lib/vcdeps/installed.rb', line 38

def lib_dir
  File.join(prefix, "lib").tr("/", "\\")
end

#pkgconfig_dirObject

Accessor only; vcdeps never runs pkg-config (§5.14).



47
48
49
# File 'lib/vcdeps/installed.rb', line 47

def pkgconfig_dir
  File.join(prefix, "lib", "pkgconfig").tr("/", "\\")
end

#portsObject

Array parsed from \vcpkg\info<name>__.list filenames. In bypass mode (no tool) there is no info tree, so this is [].



58
59
60
# File 'lib/vcdeps/installed.rb', line 58

def ports
  list_files.filter_map { |path| parse_port(File.basename(path, ".list")) }
end

#prefixObject

<triplet> (or the bypass prefix override).



27
28
29
30
31
# File 'lib/vcdeps/installed.rb', line 27

def prefix
  return @prefix_override if @prefix_override

  File.join(@root, @triplet).tr("/", "\\")
end