Top Level Namespace

Includes:
Udb::Helpers::TemplateHelpers

Defined Under Namespace

Modules: Eqn, FFI, Idl, PrmGenerator, Tapioca, Udb, Z3 Classes: EqnParser, NonIsaSpecificationError, NonIsaSpecificationLoadError, NonIsaSpecificationValidationError, SubCommandBase

Constant Summary collapse

GITHUB_REPO =
"riscv/riscv-unified-db"

Instance Method Summary collapse

Instance Method Details

#download_with_redirects(url_str, limit: 10, hint: nil) ⇒ Object

Follow redirects (GitHub releases use a CDN redirect)



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'ext/udb_download/extconf.rb', line 46

def download_with_redirects(url_str, limit: 10, hint: nil)
  raise "Too many HTTP redirects" if limit.zero?

  uri = URI.parse(url_str)
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = (uri.scheme == "https")
  http.open_timeout = 30
  http.read_timeout = 120

  request = Net::HTTP::Get.new(uri.request_uri)
  request["User-Agent"] = "udb-gem/installer"

  response = http.request(request)

  case response
  when Net::HTTPSuccess
    response.body
  when Net::HTTPRedirection
    download_with_redirects(response["location"], limit: limit - 1, hint: hint)
  else
    msg = "Failed to download #{url_str}\nHTTP #{response.code} #{response.message}"
    msg += "\n#{hint}" if hint
    raise msg
  end
end

#find_executable(name) ⇒ Object

Check that required build tools are present



18
19
20
21
22
# File 'ext/udb_download/extconf.rb', line 18

def find_executable(name)
  ENV.fetch("PATH", "").split(File::PATH_SEPARATOR).any? do |dir|
    File.executable?(File.join(dir, name))
  end
end