jolt build: default output under target/{debug,release}, resolved against the project
Build output landed in the CLI's cwd (the jolt repo, since bin/joltc cd's there), not the project — so a bare -o path or the default binary appeared in the wrong place. Resolve output against JOLT_PWD, and default it cargo- style under the project's target/: target/release for release/--opt, target/debug for --dev, named after the project dir. The <name>.build scratch dir sits beside the binary, so it lands under the same target dir. -o is honored — absolute as-is, relative against the project.
This commit is contained in:
parent
d9d55fd533
commit
56d5707bfe
2 changed files with 24 additions and 5 deletions
|
|
@ -74,10 +74,15 @@ project inherits its dependencies' `:jolt/native`.
|
||||||
|
|
||||||
## Standalone binaries
|
## Standalone binaries
|
||||||
|
|
||||||
`joltc build -m NS -o OUT` compiles the app and every library into one
|
`joltc build -m NS` compiles the app and every library into one executable (the
|
||||||
executable (the runtime + compiler are baked in). It loads the resolved
|
runtime + compiler are baked in). It loads the resolved `:jolt/native` libs at
|
||||||
`:jolt/native` libs at startup, so an FFI app — sockets, SQLite — runs with no
|
startup, so an FFI app — sockets, SQLite — runs with no jolt or Chez on the path.
|
||||||
jolt or Chez on the path.
|
|
||||||
|
Output goes under the project's `target/`, cargo-style: `target/release/<project>`
|
||||||
|
by default and with `--opt`, `target/debug/<project>` with `--dev` (the
|
||||||
|
`<name>.build` scratch dir sits beside it). `-o PATH` overrides — absolute as-is,
|
||||||
|
relative against the project dir. Paths resolve against the project (`JOLT_PWD`),
|
||||||
|
not the CLI's cwd, since `bin/joltc` runs from the jolt repo.
|
||||||
|
|
||||||
`:jolt/build {:embed ["resources" …]}` bakes those directories' files into the
|
`:jolt/build {:embed ["resources" …]}` bakes those directories' files into the
|
||||||
binary; `io/resource` serves them from the image with no files on disk. Resources
|
binary; `io/resource` serves them from the image with no files on disk. Resources
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,21 @@
|
||||||
:else "release")]
|
:else "release")]
|
||||||
(when (nil? entry)
|
(when (nil? entry)
|
||||||
(throw (ex-info "build needs an entry: -m NS" {})))
|
(throw (ex-info "build needs an entry: -m NS" {})))
|
||||||
(let [out (or (:out opts) (first (str/split entry #"\.")))
|
;; Output paths resolve against the project dir (JOLT_PWD), not the CLI's
|
||||||
|
;; cwd — bin/joltc cd's to the jolt repo, so a bare relative path would land
|
||||||
|
;; there. Default output is cargo-style under target/: --dev -> target/debug,
|
||||||
|
;; release/--opt -> target/release, the binary named after the project dir
|
||||||
|
;; (falling back to the entry's first segment). The <name>.build scratch dir
|
||||||
|
;; the driver creates sits next to it, so it lands under the same target dir.
|
||||||
|
;; An explicit -o is honored: absolute as-is, relative against the project.
|
||||||
|
(let [pdir (project-dir)
|
||||||
|
proj (let [seg (last (str/split pdir #"/"))]
|
||||||
|
(if (or (str/blank? seg) (= "." seg)) (first (str/split entry #"\.")) seg))
|
||||||
|
out (let [o (:out opts)]
|
||||||
|
(cond
|
||||||
|
(nil? o) (str pdir "/target/" (if (= mode "dev") "debug" "release") "/" proj)
|
||||||
|
(str/starts-with? o "/") o
|
||||||
|
:else (str pdir "/" o)))
|
||||||
natives (encode-natives (:natives resolved))]
|
natives (encode-natives (:natives resolved))]
|
||||||
;; embed-dirs (absolute) are walked + baked into the binary by the driver;
|
;; embed-dirs (absolute) are walked + baked into the binary by the driver;
|
||||||
;; project-paths (relative) become runtime io/resource roots (ship-alongside).
|
;; project-paths (relative) become runtime io/resource roots (ship-alongside).
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue