Class: Bundler::Spinel::EngineInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/spinel/engine_installer.rb

Overview

Provisions the Spinel compiler itself, so onboarding a Spinel project doesn’t start with an out-of-band ‘git clone matz/spinel && make` (spinelgems#9). Fetches matz/spinel at a pinned revision, builds it (`make deps && make all` — C-only, no Rust), caches the result keyed by revision under `~/.cache/spinel/<rev>/`, and points a `current` symlink at it. `Engine` resolves that cache after `SPINEL_DIR` and before PATH, so a provisioned engine is found with zero further configuration.

Same recipe the survey path freezes per-rev and the Upsun build hook runs —promoted here to a first-class user command.

Constant Summary collapse

REPO =
"https://github.com/matz/spinel.git"
DEFAULT_REV =

Known-good default when no rev is given and no SPINEL_PIN file is present. Overridable by arg, a ./SPINEL_PIN file, or the SPINEL_REV env var.

"60070a6".freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rev: nil, out: $stdout) ⇒ EngineInstaller

Returns a new instance of EngineInstaller.



28
29
30
31
# File 'lib/bundler/spinel/engine_installer.rb', line 28

def initialize(rev: nil, out: $stdout)
  @rev = rev
  @out = out
end

Class Method Details

.cache_rootObject



22
23
24
# File 'lib/bundler/spinel/engine_installer.rb', line 22

def self.cache_root
  File.expand_path(ENV["SPINEL_CACHE"] || "~/.cache/spinel")
end

.current_dirObject



26
# File 'lib/bundler/spinel/engine_installer.rb', line 26

def self.current_dir = File.join(cache_root, "current")

Instance Method Details

#install(force: false) ⇒ Object

Returns the path to the provisioned ‘spinel` binary.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bundler/spinel/engine_installer.rb', line 34

def install(force: false)
  check_toolchain!
  rev = resolve_rev
  dir = File.join(self.class.cache_root, rev)
  bin = File.join(dir, "spinel")

  if File.executable?(bin) && !force
    @out.puts "engine #{rev} already provisioned"
  else
    fetch_and_build(rev, dir)
    bin = File.join(dir, "spinel")
    raise Error, "build finished but #{bin} is missing" unless File.executable?(bin)
  end

  link_current(dir)
  smoke!(bin)
  report(rev, dir, bin)
  bin
end