diff --git a/Makefile b/Makefile index 965a305a16..dd9666e2bd 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,9 @@ WIN32_RUN_RACO = $(WIN32_RUN_RACKET) -N raco -l- raco DEFAULT_SRC_CATALOG = https://pkgs.racket-lang.org +# Options passed along to any `raco setup` run: +PLT_SETUP_OPTIONS = + # Belongs in the "Configuration options" section, but here # to accomodate nmake: SRC_CATALOG = $(DEFAULT_SRC_CATALOG) @@ -66,6 +69,10 @@ INSTALL_PKGS_ARGS = $(JOB_OPTIONS) --no-setup --pkgs \ $(REQUIRED_PKGS) $(PKGS) ALL_PLT_SETUP_OPTIONS = $(JOB_OPTIONS) $(PLT_SETUP_OPTIONS) +# Allow `--error-out`, etc., for final setup setp, so `make both` can +# continue from errors at that level +IN_PLACE_SETUP_OPTIONS = + plain-in-place: $(MAKE) plain-minimal-in-place $(MAKE) in-place-setup @@ -85,7 +92,7 @@ plain-minimal-in-place-after-base: $(RUN_RACO) setup --only-foreign-libs $(ALL_PLT_SETUP_OPTIONS) in-place-setup: - $(RUN_RACO) setup $(ALL_PLT_SETUP_OPTIONS) + $(RUN_RACO) setup $(ALL_PLT_SETUP_OPTIONS) $(IN_PLACE_SETUP_OPTIONS) win32-in-place: $(MAKE) win32-base @@ -103,7 +110,7 @@ win32-minimal-in-place-after-base: win32-in-place-after-base: $(MAKE) win32-minimal-in-place-after-base PKGS="$(PKGS)" SRC_CATALOG="$(SRC_CATALOG)" WIN32_PLAIN_RACKET="$(WIN32_PLAIN_RACKET)" - $(WIN32_RUN_RACO) setup $(ALL_PLT_SETUP_OPTIONS) + $(WIN32_RUN_RACO) setup $(ALL_PLT_SETUP_OPTIONS) $(IN_PLACE_SETUP_OPTIONS) # Rebuild without consulting catalogs or package sources: @@ -121,7 +128,7 @@ plain-as-is: win32-as-is: $(MAKE) win32-base - $(WIN32_RUN_RACO) setup $(ALL_PLT_SETUP_OPTIONS) + $(WIN32_RUN_RACO) setup $(ALL_PLT_SETUP_OPTIONS) $(IN_PLACE_SETUP_OPTIONS) # ------------------------------------------------------------ # Unix-style build (Unix and Mac OS, only) @@ -458,8 +465,8 @@ racket/src/build/cross/cs/c/Makefile: racket/src/cs/c/configure racket/src/cs/c/ # ... but update packages and builds docs only once both: - $(MAKE) in-place - $(MAKE) also-cs + $(MAKE) in-place IN_PLACE_SETUP_OPTIONS="--error-out build/step" + $(MAKE) also-cs IN_PLACE_SETUP_OPTIONS="--error-in build/step" also-cs: $(MAKE) cs CS_SETUP_TARGET=in-place-setup PLT_SETUP_OPTIONS="-D $(PLT_SETUP_OPTIONS)" diff --git a/pkgs/racket-doc/scribblings/raco/setup.scrbl b/pkgs/racket-doc/scribblings/raco/setup.scrbl index a166de7176..e5e15de953 100644 --- a/pkgs/racket-doc/scribblings/raco/setup.scrbl +++ b/pkgs/racket-doc/scribblings/raco/setup.scrbl @@ -273,6 +273,19 @@ flags: @item{@DFlag{fail-fast} --- attempt to break as soon as any error is discovered.} + @item{@DFlag{error-out} @nonterm{file} --- handle survivable errors + by writing @nonterm{file} and exiting as successful, which + facilitates chaining multiple @exec{raco setup} invocations in + combination with @DFlag{error-in}. If there are no errors and + @nonterm{file} already exists, it is deleted.} + + @item{@DFlag{error-in} @nonterm{file} --- treat the existence of + @nonterm{file} as a ``errors were reported by a previous process'' + error. Typically, @nonterm{file} is created by previous @exec{raco + setup} run using @DFlag{error-out}. A file for @DFlag{error-in} is + detected before creating a file via @DFlag{error-out}, so the same + file can be used to chain a sequence of @exec{raco setup} steps.} + @item{@DFlag{pause} or @Flag{p} --- pause for user input if any errors are reported (so that a user has time to inspect output that might otherwise disappear when the @exec{raco setup} process ends).} @@ -337,7 +350,8 @@ update a compiled file's timestamp if the file is not recompiled. #:changed "6.1.1" @elem{Added the @DFlag{force-user-docs} flag.} #:changed "6.1.1.6" @elem{Added the @DFlag{only-foreign-libs} flag.} #:changed "6.6.0.3" @elem{Added support for @envvar{PLT_COMPILED_FILE_CHECK}.} - #:changed "7.0.0.19" @elem{Added @DFlag{places} and @DFlag{processes}.}] + #:changed "7.0.0.19" @elem{Added @DFlag{places} and @DFlag{processes}.} + #:changed "7.2.0.7" @elem{Added @DFlag{error-in} and @DFlag{error-out}.}] @; ------------------------------------------------------------------------ diff --git a/racket/collects/setup/option.rkt b/racket/collects/setup/option.rkt index 0d93dba90a..f329f9e2de 100644 --- a/racket/collects/setup/option.rkt +++ b/racket/collects/setup/option.rkt @@ -88,6 +88,8 @@ (define-flag-param force-unpacks #f) (define-flag-param doc-pdf-dest #f) (define-flag-param fail-fast #f) +(define-flag-param next-error-out-file #f) +(define-flag-param previous-error-in-file #f) (define specific-collections (make-parameter null)) (define specific-packages (make-parameter null)) diff --git a/racket/collects/setup/setup-cmdline.rkt b/racket/collects/setup/setup-cmdline.rkt index f66ad6b559..de149b6f42 100644 --- a/racket/collects/setup/setup-cmdline.rkt +++ b/racket/collects/setup/setup-cmdline.rkt @@ -147,6 +147,10 @@ (add-flags `((compile-mode ,mode)))] [("--fail-fast") "Trigger a break on the first error" (add-flags '((fail-fast #t)))] + [("--error-out") file "On continuable error, create and exit as success" + (add-flags `((next-error-out-file ,file)))] + [("--error-in") file "Check for report of previous errors" + (add-flags `((previous-error-in-file ,file)))] [("-p" "--pause") "Pause at the end if there are any errors" (add-flags '((pause-on-errors #t)))] #:help-labels diff --git a/racket/collects/setup/setup-core.rkt b/racket/collects/setup/setup-core.rkt index 3725706449..b06026138c 100644 --- a/racket/collects/setup/setup-core.rkt +++ b/racket/collects/setup/setup-core.rkt @@ -206,9 +206,29 @@ (when (pause-on-errors) (eprintf "INSTALLATION FAILED.\nPress Enter to continue...\n") (read-line)) - (exit 1)) + (set! exit-code 1)) + (manage-prevous-and-next) (exit exit-code)) + (define (manage-prevous-and-next) + (define prev (previous-error-in-file)) + (when (and prev (file-exists? prev)) + (setup-printf #f "--- previous errors ---") + (setup-printf #f "errors were~a reported by a previous process" + (if (zero? exit-code) "" " also")) + (set! exit-code 1)) + (define next (next-error-out-file)) + (when next + (cond + [(zero? exit-code) + (delete-directory/files next #:must-exist? #f)] + [else + (call-with-output-file* + next + #:exists 'truncate/replace + (lambda (o) (fprintf o "Errors reported\n"))) + (set! exit-code 0)]))) + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Archive Unpacking ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;