Module: Udb::DepDownloader

Defined in:
lib/udb/dep_paths.rb

Overview

Shared HTTP download helper for binary dependencies (espresso, eqntott, must).

Constant Summary collapse

GITHUB_REPO =
"riscv/riscv-unified-db"

Class Method Summary collapse

Class Method Details

.bin_dir(name, version) ⇒ Object



27
28
29
30
# File 'lib/udb/dep_paths.rb', line 27

def bin_dir(name, version)
  xdg_cache = ENV.fetch("XDG_CACHE_HOME", File.join(Dir.home, ".cache"))
  File.join(xdg_cache, "udb", name, version, host_cpu)
end

.binary(name, version) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/udb/dep_paths.rb', line 32

def binary(name, version)
  path = File.join(bin_dir(name, version), name)
  unless File.exist?(path)
    begin
      download_binary(name, version, path)
    rescue => e
      raise "#{name} binary not found at #{path} and download failed: #{e.message}"
    end
  end
  path
end

.host_cpuObject



19
20
21
22
23
24
25
# File 'lib/udb/dep_paths.rb', line 19

def host_cpu
  case RbConfig::CONFIG["host_cpu"]
  when /arm64|aarch64/ then "arm64"
  when /x86_64|x64/    then "x64"
  else raise "Unsupported host cpu: #{RbConfig::CONFIG["host_cpu"]}"
  end
end