raco setup: add -M
/--compile-any
Add `-M`/`--compile-any` to `raco setup`, `raco pkg install`, etc., to build machine-independent bytecode, which is useful in the process of building distributions.
This commit is contained in:
parent
0bc010d972
commit
9441f7075f
|
@ -243,6 +243,12 @@ cross-compilation mode is used and that any foreign libraries needed
|
|||
for build time can be found, but many cross-compilation scenarios work
|
||||
without `-C`.
|
||||
|
||||
Specify `SETUP_MACHINE_FLAGS=...` to set flags for `raco setup` and
|
||||
`raco pkg install` that control the target machine of compiled
|
||||
bytecode. For example `SETUP_MACHINE_FLAGS=-M` causes the generated
|
||||
bytecode to be machine-independent, which is mainly useful when the
|
||||
generated installation will be used as a template for other platforms.
|
||||
|
||||
Installing Packages
|
||||
-------------------
|
||||
|
||||
|
|
17
Makefile
17
Makefile
|
@ -52,16 +52,19 @@ in-place:
|
|||
cpus-in-place:
|
||||
$(MAKE) -j $(CPUS) plain-in-place JOB_OPTIONS="-j $(CPUS)" PKGS="$(PKGS)"
|
||||
|
||||
# For -M, etc., to pick the target machine for compilation:
|
||||
SETUP_MACHINE_FLAGS =
|
||||
|
||||
# Explicitly propagate variables for non-GNU `make's:
|
||||
LIBSETUP = -N raco -l- raco setup
|
||||
|
||||
# Update before install to avoid needless work on the initial build,
|
||||
# and use `--no-setup` plus an explicit `raco setup` for the same reason.
|
||||
UPDATE_PKGS_ARGS = --all --auto --no-setup --scope installation
|
||||
INSTALL_PKGS_ARGS = $(JOB_OPTIONS) --no-setup --pkgs \
|
||||
UPDATE_PKGS_ARGS = --all --auto --no-setup --scope installation $(SETUP_MACHINE_FLAGS)
|
||||
INSTALL_PKGS_ARGS = $(JOB_OPTIONS) $(SETUP_MACHINE_FLAGS) --no-setup --pkgs \
|
||||
--skip-installed --scope installation --deps search-auto \
|
||||
$(REQUIRED_PKGS) $(PKGS)
|
||||
ALL_PLT_SETUP_OPTIONS = $(JOB_OPTIONS) $(PLT_SETUP_OPTIONS)
|
||||
ALL_PLT_SETUP_OPTIONS = $(JOB_OPTIONS) $(PLT_SETUP_OPTIONS) $(SETUP_MACHINE_FLAGS)
|
||||
|
||||
plain-in-place:
|
||||
$(MAKE) plain-minimal-in-place
|
||||
|
@ -174,7 +177,8 @@ MORE_CONFIGURE_ARGS =
|
|||
|
||||
SELF_UP =
|
||||
SELF_FLAGS_qq = SELF_RACKET_FLAGS="-G `cd $(SELF_UP)../../../build/config; pwd`"
|
||||
INSTALL_SETUP_ARGS = $(SELF_FLAGS_qq) PLT_SETUP_OPTIONS="$(JOB_OPTIONS) $(PLT_SETUP_OPTIONS)"
|
||||
PLT_SETUP_OPTIONS_qq = PLT_SETUP_OPTIONS="$(JOB_OPTIONS) $(PLT_SETUP_OPTIONS) $(SETUP_MACHINE_FLAGS)"
|
||||
INSTALL_SETUP_ARGS = $(SELF_FLAGS_qq) $(PLT_SETUP_OPTIONS_qq)
|
||||
|
||||
BASE_INSTALL_TARGET = plain-base-install
|
||||
|
||||
|
@ -545,8 +549,7 @@ WIN32_RACKET = $(WIN32_PLAIN_RACKET) $(USER_CONFIG)
|
|||
WIN32_RACO = $(WIN32_PLAIN_RACKET) $(USER_CONFIG) -N raco -l- raco
|
||||
X_AUTO_OPTIONS = --skip-installed --deps search-auto --pkgs $(JOB_OPTIONS)
|
||||
USER_AUTO_OPTIONS = --scope user $(X_AUTO_OPTIONS)
|
||||
LOCAL_USER_AUTO = --catalog build/local/catalog $(USER_AUTO_OPTIONS)
|
||||
SOURCE_USER_AUTO_q = --catalog build/catalog-copy $(USER_AUTO_OPTIONS)
|
||||
SOURCE_USER_AUTO_q = --catalog build/catalog-copy $(USER_AUTO_OPTIONS) $(SETUP_MACHINE_FLAGS)
|
||||
REMOTE_USER_AUTO = --catalog $(SVR_CAT) $(USER_AUTO_OPTIONS)
|
||||
REMOTE_INST_AUTO = --catalog $(SVR_CAT) --scope installation $(X_AUTO_OPTIONS)
|
||||
CONFIG_MODE_q = "$(CONFIG)" "$(CONFIG_MODE)"
|
||||
|
@ -623,7 +626,7 @@ build-from-catalog:
|
|||
$(MAKE) set-server-config
|
||||
$(USER_RACKET) -l- distro-build/pkg-info -o build/pkgs.rktd build/catalog-copy
|
||||
$(USER_RACKET) -l distro-build/install-pkgs $(CONFIG_MODE_q) "$(PKGS) $(TEST_PKGS)" $(SOURCE_USER_AUTO_q) --all-platforms
|
||||
$(USER_RACO) setup --avoid-main $(JOB_OPTIONS)
|
||||
$(USER_RACO) setup $(SETUP_MACHINE_FLAGS) --avoid-main $(JOB_OPTIONS)
|
||||
|
||||
server-cache-config:
|
||||
$(USER_RACO) pkg config -i --set download-cache-dir build/cache
|
||||
|
|
|
@ -613,6 +613,8 @@ sub-commands.
|
|||
@item{@DFlag{dry-run} --- Prevents changes to the current installation. All installation and update work is
|
||||
staged and checked, but the final installation step is skipped.}
|
||||
|
||||
@item{@DFlag{compile-any} or @Flag{M} --- Compiles bytecode to a machine-independent form.}
|
||||
|
||||
@item{@DFlag{no-setup} --- Does not run @exec{raco setup} after installation. This behavior is also the case if the
|
||||
environment variable @envvar{PLT_PKG_NOSETUP} is set to any non-empty value.}
|
||||
|
||||
|
@ -745,6 +747,7 @@ the given @nonterm{pkg-source}s.
|
|||
@item{@DFlag{pull} @nonterm{mode} --- Same as for @command-ref{install}}
|
||||
|
||||
@item{@DFlag{dry-run} --- Same as for @command-ref{install}.}
|
||||
@item{@DFlag{compile-any} or @Flag{M} --- Same as for @command-ref{install}.}
|
||||
@item{@DFlag{no-setup} --- Same as for @command-ref{install}.}
|
||||
@item{@DFlag{jobs} @nonterm{n} or @Flag{j} @nonterm{n} --- Same as for @command-ref{install}.}
|
||||
@item{@DFlag{batch} --- Same as for @command-ref{install}.}
|
||||
|
@ -786,6 +789,7 @@ the given @nonterm{pkg}s.
|
|||
@item{@Flag{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.}
|
||||
@item{@DFlag{scope-dir} @nonterm{dir} --- Selects @nonterm{dir} as the @tech{package scope}, the same as for @command-ref{install}.}
|
||||
@item{@DFlag{dry-run} --- Same as for @command-ref{install}.}
|
||||
@item{@DFlag{compile-any} or @Flag{M} --- Same as for @command-ref{install}.}
|
||||
@item{@DFlag{no-setup} --- Same as for @command-ref{install}.}
|
||||
@item{@DFlag{jobs} @nonterm{n} or @Flag{j} @nonterm{n} --- Same as for @command-ref{install}.}
|
||||
@item{@DFlag{batch} --- Same as for @command-ref{install}.}
|
||||
|
@ -877,6 +881,7 @@ package is created.
|
|||
@item{@DFlag{strict-doc-conflicts} --- Same as for @command-ref{install}.}
|
||||
@item{@DFlag{no-cache} --- Same as for @command-ref{install}.}
|
||||
@item{@DFlag{dry-run} --- Same as for @command-ref{install}.}
|
||||
@item{@DFlag{compile-any} or @Flag{M} --- Same as for @command-ref{install}.}
|
||||
@item{@DFlag{no-setup} --- Same as for @command-ref{install}.}
|
||||
@item{@DFlag{jobs} @nonterm{n} or @Flag{j} @nonterm{n} --- Same as for @command-ref{install}.}
|
||||
]
|
||||
|
|
|
@ -236,6 +236,11 @@ flags:
|
|||
content as the main installation.}
|
||||
|
||||
]}
|
||||
@item{Selecting the target machine:
|
||||
@itemize[
|
||||
@item{@DFlag{compile-any} or @Flag{M} --- compile bytecode to a
|
||||
machine-independent form.}
|
||||
]}
|
||||
@item{Selecting parallelism and other build modes:
|
||||
@itemize[
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
(for-syntax racket/base
|
||||
syntax/strip-context))
|
||||
|
||||
(define (setup what no-setup? fail-fast? setup-collects jobs)
|
||||
(define (setup what no-setup? compile-any? fail-fast? setup-collects jobs)
|
||||
(unless (or (eq? setup-collects 'skip)
|
||||
no-setup?
|
||||
(not (member (getenv "PLT_PKG_NOSETUP") '(#f ""))))
|
||||
|
@ -28,6 +28,7 @@
|
|||
setup-collects))
|
||||
#:tidy? #t
|
||||
#:make-doc-index? #t
|
||||
#:compile-any? compile-any?
|
||||
#:jobs jobs
|
||||
#:fail-fast? fail-fast?)
|
||||
((current-pkg-error)
|
||||
|
@ -253,7 +254,7 @@
|
|||
(pkg-desc p a-type* name checksum #f
|
||||
#:path (and (eq? a-type* 'clone)
|
||||
(path->complete-path clone))))))))
|
||||
(setup "installed" no-setup fail-fast setup-collects jobs))))]
|
||||
(setup "installed" no-setup compile-any fail-fast setup-collects jobs))))]
|
||||
;; ----------------------------------------
|
||||
[update
|
||||
"Update packages"
|
||||
|
@ -357,7 +358,7 @@
|
|||
#:infer-clone-from-dir? (not (or link static-link copy))
|
||||
#:dry-run? dry-run
|
||||
#:use-trash? (not no-trash)))))
|
||||
(setup "updated" no-setup #f setup-collects jobs))))]
|
||||
(setup "updated" no-setup compile-any #f setup-collects jobs))))]
|
||||
;; ----------------------------------------
|
||||
[remove
|
||||
"Remove packages"
|
||||
|
@ -385,7 +386,7 @@
|
|||
#:force? force
|
||||
#:dry-run? dry-run
|
||||
#:use-trash? (not no-trash))))
|
||||
(setup "removed" no-setup #f setup-collects jobs)))]
|
||||
(setup "removed" no-setup compile-any #f setup-collects jobs)))]
|
||||
;; ----------------------------------------
|
||||
[new
|
||||
"Populate a new directory with the stubs of a package"
|
||||
|
@ -484,7 +485,7 @@
|
|||
(and binary-lib 'binary-lib))
|
||||
#:force-strip? force
|
||||
#:dry-run? dry-run))))
|
||||
(setup "migrated" no-setup #f setup-collects jobs)))]
|
||||
(setup "migrated" no-setup compile-any #f setup-collects jobs)))]
|
||||
;; ----------------------------------------
|
||||
[create
|
||||
"Bundle package from a directory or installed package"
|
||||
|
@ -674,7 +675,8 @@
|
|||
#:dry-run-flags
|
||||
([#:bool dry-run () ("Don't actually change package installation")])
|
||||
#:job-flags
|
||||
([#:bool no-setup () ("Don't `raco setup' after changing packages (usually a bad idea)")]
|
||||
([#:bool compile-any ("-M") ("Compile to machine-independent form")]
|
||||
[#:bool no-setup () ("Don't `raco setup' after changing packages (usually a bad idea)")]
|
||||
[(#:num n #f) jobs ("-j") "Setup with <n> parallel jobs"]
|
||||
[#:bool batch () ("Disable interactive mode and all prompts")])
|
||||
#:trash-flags
|
||||
|
|
|
@ -310,6 +310,10 @@
|
|||
(if (on? "--trust-zos")
|
||||
(trust-zos #t)
|
||||
(void))
|
||||
(if (or (on? "-M")
|
||||
(on? "--compile-any"))
|
||||
(current-compile-target-machine #f)
|
||||
(void))
|
||||
(current-load/use-compiled (mk))))
|
||||
|
||||
;; This has to be dynamic, so we get a chance to turn off
|
||||
|
|
|
@ -89,6 +89,10 @@
|
|||
(define-flag-param doc-pdf-dest #f)
|
||||
(define-flag-param fail-fast #f)
|
||||
|
||||
(defined-flag-params (cons (cons 'current-compile-target-machine
|
||||
current-compile-target-machine)
|
||||
(defined-flag-params)))
|
||||
|
||||
(define specific-collections (make-parameter null))
|
||||
(define specific-packages (make-parameter null))
|
||||
(define specific-planet-dirs (make-parameter null))
|
||||
|
|
|
@ -327,6 +327,9 @@
|
|||
[current-directory (if (memq 'set-directory options)
|
||||
dir
|
||||
(current-directory))]
|
||||
[current-compile-target-machine (if (memq 'compile-any options)
|
||||
#f
|
||||
(current-compile-target-machine))]
|
||||
[current-load-relative-directory dir]
|
||||
[current-input-port (open-input-string "")]
|
||||
[current-output-port out-str-port]
|
||||
|
@ -365,9 +368,11 @@
|
|||
#:use-places? use-places?))
|
||||
|
||||
(define (parallel-compile worker-count setup-fprintf append-error collects-tree
|
||||
#:options [options '()]
|
||||
#:use-places? [use-places? #t])
|
||||
(setup-fprintf (current-output-port) #f "--- parallel build using ~a jobs ---" worker-count)
|
||||
(define collects-queue (make-object collects-queue% collects-tree setup-fprintf append-error '(set-directory)))
|
||||
(define collects-queue (make-object collects-queue% collects-tree setup-fprintf append-error
|
||||
(append options '(set-directory))))
|
||||
(parallel-build collects-queue worker-count
|
||||
#:use-places? use-places?))
|
||||
|
||||
|
|
|
@ -126,6 +126,11 @@
|
|||
[("--force-user-docs") "User-specific documentation even if matching installation"
|
||||
(add-flags '((force-user-docs #t)))]
|
||||
#:help-labels
|
||||
" -------------------------- target machine ------------------------- "
|
||||
#:once-each
|
||||
[("-M" "--compile-any") "Compile to machine-independent form"
|
||||
(add-flags `((current-compile-target-machine #f)))]
|
||||
#:help-labels
|
||||
" ------------------------------ modes ------------------------------ "
|
||||
#:once-each
|
||||
[("-j" "--jobs" "--workers") n "Use <n> parallel jobs"
|
||||
|
|
|
@ -1114,7 +1114,10 @@
|
|||
has-module-suffix?)))))
|
||||
(iterate-cct clean-cc cct)
|
||||
(parallel-compile (parallel-workers) setup-fprintf handle-error cct
|
||||
#:use-places? (parallel-use-places))
|
||||
#:use-places? (parallel-use-places)
|
||||
#:options (if (not (current-compile-target-machine))
|
||||
'(compile-any)
|
||||
'()))
|
||||
(for/fold ([gcs 0]) ([cc planet-dirs-to-compile])
|
||||
(compile-cc cc gcs has-module-suffix?)))))
|
||||
(with-specified-mode
|
||||
|
|
|
@ -13,12 +13,17 @@
|
|||
x-archives)
|
||||
(parse-cmdline (current-command-line-arguments)))
|
||||
|
||||
(define (has-x-flag? s)
|
||||
(define (get-x-flag s default)
|
||||
(define a (assq s x-flags))
|
||||
(and a (cadr a)))
|
||||
(if a
|
||||
(cadr a)
|
||||
default))
|
||||
|
||||
(define (has-x-flag? s)
|
||||
(get-x-flag s #f))
|
||||
|
||||
(define (go orig-compile-file-paths)
|
||||
;; Conver parse-cmdline results into parameter settings:
|
||||
;; Convert parse-cmdline results into parameter settings:
|
||||
(parameterize ([current-target-plt-directory-getter
|
||||
(if (has-x-flag? 'all-users)
|
||||
(lambda (preferred main-collects-parent-dir choices)
|
||||
|
@ -26,6 +31,8 @@
|
|||
(current-target-plt-directory-getter))]
|
||||
[trust-existing-zos (or (has-x-flag? 'trust-existing-zos)
|
||||
(trust-existing-zos))]
|
||||
[current-compile-target-machine (get-x-flag 'current-compile-target-machine
|
||||
(current-compile-target-machine))]
|
||||
[specific-collections x-specific-collections]
|
||||
[specific-packages x-specific-packages]
|
||||
[archives x-archives]
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#:tidy? [tidy? #f]
|
||||
#:avoid-main? [avoid-main? #f]
|
||||
#:force-user-docs? [force-user-docs? #f]
|
||||
#:compile-any? [compile-any? #f]
|
||||
#:jobs [parallel #f]
|
||||
#:fail-fast? [fail-fast? #f])
|
||||
(parameterize
|
||||
|
@ -50,6 +51,10 @@
|
|||
|
||||
[force-user-docs (if force-user-docs? #t (force-user-docs))]
|
||||
|
||||
[current-compile-target-machine (if compile-any?
|
||||
#f
|
||||
(current-compile-target-machine))]
|
||||
|
||||
[fail-fast fail-fast?]
|
||||
|
||||
[clean (if clean? #t (clean))]
|
||||
|
|
|
@ -106,7 +106,7 @@ local/Makefile:
|
|||
# Install (common) ----------------------------------------
|
||||
|
||||
INST_CONFIG = -X @DIRCVTPRE@"$(DESTDIR)$(collectsdir)"@DIRCVTPOST@ -G @DIRCVTPRE@"$(DESTDIR)$(configdir)"@DIRCVTPOST@
|
||||
SETUP_RACKET_FLAGS = $(INST_CONFIG) $(SELF_RACKET_FLAGS) @INSTALL_SETUP_RACKET_FLAGS@
|
||||
SETUP_RACKET_FLAGS = $(INST_CONFIG) $(COMPILE_MACHINE_FLAGS) $(SELF_RACKET_FLAGS) @INSTALL_SETUP_RACKET_FLAGS@
|
||||
SETUP_SETUP_FLAGS = @INSTALL_SETUP_FLAGS@ $(PLT_SETUP_OPTIONS) $(PLT_ISO)
|
||||
SETUP_ARGS = $(SETUP_RACKET_FLAGS) -N "raco" -l- setup $(SETUP_SETUP_FLAGS)
|
||||
|
||||
|
|
|
@ -426,7 +426,7 @@
|
|||
(loop (cdr args))]
|
||||
[else
|
||||
(raise-bad-switch arg within-arg)])]
|
||||
[("-M")
|
||||
[("-M" "--compile-any")
|
||||
(set! compile-machine-independent? #t)
|
||||
(loop (cdr args))]
|
||||
[("--")
|
||||
|
|
|
@ -784,7 +784,7 @@ static int run_from_cmd_line(int argc, char *_argv[],
|
|||
argv[0] = "-q";
|
||||
else if (!strcmp("--no-jit", argv[0]))
|
||||
argv[0] = "-j";
|
||||
else if (!strcmp("--compile-mi", argv[0]))
|
||||
else if (!strcmp("--compile-any", argv[0]))
|
||||
argv[0] = "-M";
|
||||
else if (!strcmp("--no-delay", argv[0]))
|
||||
argv[0] = "-d";
|
||||
|
@ -1424,7 +1424,7 @@ static int run_from_cmd_line(int argc, char *_argv[],
|
|||
# else
|
||||
" -j, --no-jit : No effect, since the just-in-time compiler is unavailable\n"
|
||||
# endif
|
||||
" -M, --compile-mi : Compile to machine-independent form\n"
|
||||
" -M, --compile-any : Compile to machine-independent form\n"
|
||||
" -d, --no-delay: Disable on-demand loading of syntax and code\n"
|
||||
" -b, --binary : Read stdin and write stdout/stderr in binary mode\n"
|
||||
" -W <levels>, --warn <levels> : Set stderr logging to <levels>\n"
|
||||
|
|
Loading…
Reference in New Issue
Block a user