Class: Everywhere::Builders::Desktop

Inherits:
Object
  • Object
show all
Defined in:
lib/everywhere/builders/desktop.rb

Overview

Resolves where cargo should run for the desktop shell, and stamps a per-app copy of it when the app declares native.desktop.

EVERY app gets its own staged copy of the shell under ~/.rubyeverywhere/desktop/; cargo never runs in the template. Cargo writes Cargo.lock into the package dir and every build swaps the app's icon into icons/icon.png, so compiling the template in place means writing into the installed gem — Errno::EACCES on a system-wide install, and one app's branding in the next app's build when two builds share it.

What the two paths differ in is the stamp and the target dir:

no native.desktop   the template verbatim, compiled against the SHARED
                  ~/.rubyeverywhere/shell-target. The source really is
                  identical for every such app, so one warm target dir
                  serves all of them.

native.desktop      the app's Rust stamped in, and its own target dir,
                  exactly like the iOS and Android work dirs. Costs one
                  cold Tauri compile (minutes) and a couple of GB,
                  which is why it is not the default.

The stamped list, and nothing else:

Cargo.toml                  the template's, with native.desktop.crates
                          substituted into the __EVERYWHERE_APP_CRATES__
                          marker
src/extensions/**           native/desktop/**/*.rs, plus a generated
                          mod.rs per directory

Everything else in the work dir is the frozen template, copied as-is. In particular src/main.rs, src/extension_host.rs and capabilities/ are never rewritten — see support/desktop/README.md.

Defined Under Namespace

Classes: Prepared

Constant Summary collapse

MODULE_FILE =

The generated module file, at every level of src/extensions. Reserved: an app shipping its own would be silently overwritten, so we refuse.

"mod.rs"
STAGE_MARKER =
".everywhere-template"
CRATES_MARKER =
"# __EVERYWHERE_APP_CRATES__"
SOURCE_DIR =

Where the app keeps its Rust, relative to the app root.

File.join("native", "desktop")

Instance Method Summary collapse

Constructor Details

#initialize(config:, root:, template_dir: nil) ⇒ Desktop

Returns a new instance of Desktop.



57
58
59
60
61
# File 'lib/everywhere/builders/desktop.rb', line 57

def initialize(config:, root:, template_dir: nil)
  @config = config
  @root = root
  @template_dir = template_dir
end

Instance Method Details

#prepare!Object

Returns where to run cargo and what to set CARGO_TARGET_DIR to. Callers (every dev, every build) don't need to care which path they got.



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/everywhere/builders/desktop.rb', line 65

def prepare!
  template = @template_dir || Paths.shell_dir!
  stamped = @config.native_desktop?
  preflight! if stamped

  src_tauri = stage(template)
  stamp!(src_tauri) if stamped
  Prepared.new(dir: src_tauri,
               target_dir: stamped ? Paths.desktop_target_dir(bundle_id) : Paths.cargo_target_dir,
               stamped: stamped)
end