Skip to content

Commit

Permalink
fix build --release and --optimized (#850)
Browse files Browse the repository at this point in the history
Typo in the hash get; also made them options for the build script.
  • Loading branch information
vyzo authored Sep 15, 2023
1 parent fba4fc7 commit 0271dba
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
24 changes: 19 additions & 5 deletions src/std/build-script.ss
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,29 @@
(export defbuild-script)

(def (build-main args build-spec keys that-file)
(def srcdir (path-normalize (path-directory that-file)))
(def (build) (apply make build-spec srcdir: srcdir keys))
(def (clean) (apply make-clean build-spec srcdir: srcdir keys))
(def (parse-options opts)
(let lp ((rest opts) (options []))
(match rest
([] options)
(["--release" . rest]
(lp rest (cons* build-release: #t options)))
(["--optimized" . rest]
(lp rest (cons* build-optimized: #t options)))
(else
(error "Unexpected " rest)))))
(def srcdir
(path-normalize (path-directory that-file)))
(def (build options)
(apply make build-spec srcdir: srcdir (append options keys)))
(def (clean)
(apply make-clean build-spec srcdir: srcdir keys))

(match args
(["meta"] (write '("spec" "compile" "clean")) (newline))
(["spec"] (pretty-print build-spec))
(["compile"] (build))
(["compile" . options] (build (parse-options options)))
(["clean"] (clean))
([] (build))))
([] (build []))))

(defsyntax (defbuild-script stx)
(syntax-case stx ()
Expand Down
16 changes: 13 additions & 3 deletions src/tools/gxpkg.ss
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
((new)
(pkg-new .package .name .link))
((build)
(build-pkgs .pkg .?release .?optimized))
(build-pkgs .pkg .?build-release .?build-optimized))
((clean)
(clean-pkgs .pkg))
((link)
Expand Down Expand Up @@ -344,6 +344,16 @@
(delete-file dest))))

(def (pkg-build pkg (dependents? #t))
(def build-options
(let* ((options [])
(options (if (getenv "GERBIL_BUILD_RELEASE" #f)
(cons "--release" options)
options))
(options (if (getenv "GERBIL_BUILD_OPTIMIZED" #f)
(cons "--optimized" options)
options)))
options))

(cond
((equal? pkg "all")
(let* ((pkgs (pkg-list))
Expand All @@ -354,7 +364,7 @@
((equal? pkg ".")
(displayln "... build in current directory")
(let (build.ss (path-expand "build.ss" (current-directory)))
(run-process [build.ss "compile"]
(run-process [build.ss "compile" build-options ...]
stdout-redirection: #f)))
(else
(let* ((root (pkg-root-dir))
Expand All @@ -363,7 +373,7 @@
(error "Cannot build unknown package" pkg)))
(build.ss (pkg-build-script pkg)))
(displayln "... build " pkg)
(run-process [build.ss "compile"]
(run-process [build.ss "compile" build-options ...]
directory: path
coprocess: void
stdout-redirection: #f)
Expand Down

0 comments on commit 0271dba

Please sign in to comment.