Class: Fresco::CLI::Release

Inherits:
Object
  • Object
show all
Defined in:
lib/fresco/cli/release.rb

Constant Summary collapse

LIBPQ_ROOTS =

On macOS, libpq’s headers ship in Homebrew’s keg-only ‘libpq` formula (or Postgres.app), so they’re not in cc’s default include path. Auto-detect a few known locations and prepend them to CPATH / LIBRARY_PATH so Spinel’s compile of the postgres.c shim finds libpq-fe.h / -lpq without the user having to remember the export dance. SQLite builds are unaffected — cc ignores include/lib paths that nothing references.

[
  "/opt/homebrew/opt/libpq",
  "/usr/local/opt/libpq",
  "/Applications/Postgres.app/Contents/Versions/latest",
].freeze

Instance Method Summary collapse

Instance Method Details

#run(argv = []) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fresco/cli/release.rb', line 20

def run(argv = [])
  # Regenerate generated/* first so the binary picks up any
  # routes/views/actions that changed since the last dev cycle.
  require "fresco/cli/build"
  Fresco::CLI::Build.new.run

  export_libpq_env!

  spinel = find_spinel_binary
  unless spinel
    abort <<~MSG
      [release] no spinel binary found. Tried: ./spinel, vendor/spinel/bin/spinel, $PATH.
      Build Spinel from https://github.com/.../spinel and place the binary at
      ./spinel, vendor/spinel/bin/spinel, or on your PATH.
    MSG
  end

  FileUtils.mkdir_p("build")
  unless system(spinel, "app.rb", "-o", "build/app")
    abort "[release] spinel failed; see output above"
  end

  size = File.size("build/app")
  puts "built build/app (#{size} bytes)"
  0
end