From a8ed2b1546bedbb19a3d032cb19541519bc46638 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 5 Jul 2013 11:33:57 -0600 Subject: [PATCH] Add `-j'/`--jobs' argument to `raco pkg install', etc. Also, thread `PLT_SETUP_OPTIONS' though server and client build (so that a `#:j' configuration works as intended). --- Makefile | 9 +++--- .../racket-doc/pkg/scribblings/pkg.scrbl | 14 ++++++---- .../racket-doc/scribblings/raco/setup.scrbl | 5 ++-- racket/lib/collects/pkg/commands.rkt | 17 ++++++++++- racket/lib/collects/pkg/main.rkt | 28 +++++++++++-------- racket/lib/collects/setup/setup-cmdline.rkt | 4 +-- racket/src/worksp/build-at.bat | 9 ++++++ 7 files changed, 61 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index abd832fc83..3c2f94c0bc 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ core: win32-core: IF NOT EXIST build\config cmd /c mkdir -p build\config cmd /c echo #hash((links-search-files . ())) > build\config\config.rktd - cmd /c racket\src\worksp\build-at racket\src\worksp ..\..\..\build\config + cmd /c racket\src\worksp\build-at racket\src\worksp ..\..\..\build\config $(PLT_SETUP_OPTIONS) racket/src/build/Makefile: racket/src/configure racket/src/Makefile.in cd racket/src/build; ../configure $(CONFIGURE_ARGS_qq) @@ -159,11 +159,12 @@ RACKET = racket/bin/racket -A "$(ADDON)" RACO = racket/bin/racket -A "$(ADDON)" -N raco -l- raco WIN32_RACKET = racket\racket -A "$(ADDON)" WIN32_RACO = racket\racket -A "$(ADDON)" -N raco -l- raco -USER_AUTO_OPTIONS = --scope user --skip-installed --deps search-auto +X_AUTO_OPTIONS = --skip-installed --deps search-auto $(PLT_SETUP_OPTIONS) +USER_AUTO_OPTIONS = --scope user $(X_AUTO_OPTIONS) LOCAL_USER_AUTO = --catalog build/local/catalog $(USER_AUTO_OPTIONS) SOURCE_USER_AUTO_q = --catalog "$(SRC_CATALOG)" $(USER_AUTO_OPTIONS) REMOTE_USER_AUTO = --catalog http://$(SERVER):9440/ $(USER_AUTO_OPTIONS) -REMOTE_INST_AUTO = --catalog http://$(SERVER):9440/ --scope installation --deps search-auto +REMOTE_INST_AUTO = --catalog http://$(SERVER):9440/ --scope installation $(X_AUTO_OPTIONS) CONFIG_MODE_q = "$(CONFIG)" "$(CONFIG_MODE)" BUNDLE_CONFIG = bundle/racket/etc/config.rktd @@ -306,7 +307,7 @@ client: COPY_ARGS = SERVER=$(SERVER) PKGS="$(PKGS)" RELEASE_MODE=$(RELEASE_MODE) \ DIST_NAME="$(DIST_NAME)" DIST_BASE=$(DIST_BASE) \ DIST_DIR=$(DIST_DIR) DIST_SUFFIX=$(DIST_SUFFIX) \ - DIST_DESC="$(DIST_DESC)" + DIST_DESC="$(DIST_DESC)" PLT_SETUP_OPTIONS="$(PLT_SETUP_OPTIONS)" win32-client: IF EXIST build\user cmd /c rmdir /S /Q build\user diff --git a/pkgs/racket-pkgs/racket-doc/pkg/scribblings/pkg.scrbl b/pkgs/racket-pkgs/racket-doc/pkg/scribblings/pkg.scrbl index 4e3be57390..0247f1b241 100644 --- a/pkgs/racket-pkgs/racket-doc/pkg/scribblings/pkg.scrbl +++ b/pkgs/racket-pkgs/racket-doc/pkg/scribblings/pkg.scrbl @@ -302,9 +302,6 @@ sub-sub-commands: @item{@DFlag{ignore-checksums} --- Ignores errors verifying package @tech{checksums} (unsafe).} - @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.} - @item{@DFlag{skip-installed} --- Ignore a @nonterm{pkg-source} if a corresponding package is already installed.} @item{@DFlag{link} --- Implies @exec{--type dir} (and overrides any specified type), @@ -329,6 +326,11 @@ sub-sub-commands: @item{@DFlag{catalog} @nonterm{catalog} --- Use @nonterm{catalog} instead of of the currently configured @tech{package catalogs}.} + + @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.} + + @item{@DFlag{jobs} @nonterm{n} or @Flag{j} @nonterm{n} --- Install and setup with @nonterm{n} parallel jobs.} ] } @@ -347,12 +349,13 @@ this command fails without installing any of the @nonterm{pkg}s @item{@DFlag{deps} @nonterm{behavior} --- Same as for @command-ref{install}.} @item{@DFlag{all} or @Flag{a} --- Update all packages, if no packages are given in the argument list.} @item{@DFlag{update-deps} --- Checks the named packages, and their dependencies (transitively) for updates.} - @item{@DFlag{no-setup} --- Same as for @command-ref{install}.} @item{@DFlag{scope} @nonterm{scope} --- Selects a @tech{package scope}, the same as for @command-ref{install}.} @item{@Flag{i} or @DFlag{installation} --- Shorthand for @exec{--scope installation}.} @item{@Flag{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.} @item{@Flag{s} or @DFlag{shared} --- Shorthand for @exec{--scope shared}.} @item{@DFlag{scope-dir} @nonterm{dir} --- Selects @nonterm{dir} as the @tech{package scope}, the 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}.} ] } @@ -366,7 +369,6 @@ removing any of the @nonterm{pkg}s. @itemlist[ @item{@DFlag{force} --- Ignore dependencies when removing packages.} - @item{@DFlag{no-setup} --- Same as for @command-ref{install}.} @item{@DFlag{auto} --- Remove packages that were installed by the @exec{search-auto} or @exec{search-ask} dependency behavior and are no longer required.} @item{@DFlag{scope} @nonterm{scope} --- Selects a @tech{package scope}, the same as for @command-ref{install}.} @@ -374,6 +376,8 @@ removing any of the @nonterm{pkg}s. @item{@Flag{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.} @item{@Flag{s} or @DFlag{shared} --- Shorthand for @exec{--scope shared}.} @item{@DFlag{scope-dir} @nonterm{dir} --- Selects @nonterm{dir} as the @tech{package scope}, the 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}.} ] } diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/raco/setup.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/raco/setup.scrbl index 5d96a813d4..f377dde739 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/raco/setup.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/raco/setup.scrbl @@ -95,9 +95,10 @@ flags: @itemize[ - @item{@DFlag{workers} @nonterm{n} or @Flag{j} @nonterm{n} --- use up + @item{@DFlag{jobs} @nonterm{n}, @DFlag{workers} @nonterm{n}, + or @Flag{j} @nonterm{n} --- use up to @nonterm{n} parallel processes. By default, @exec{raco setup} - uses @racket[(processor-count)] processors, which typically uses + uses @racket[(processor-count)] jobs, which typically uses all of the machine's processing cores.} @item{@DFlag{only} --- restrict setup to specified collections and diff --git a/racket/lib/collects/pkg/commands.rkt b/racket/lib/collects/pkg/commands.rkt index 3b48acd4ca..c72973a176 100644 --- a/racket/lib/collects/pkg/commands.rkt +++ b/racket/lib/collects/pkg/commands.rkt @@ -24,6 +24,18 @@ (format " ~a" s))))) s) +(define ((string->num what) str) + (define n (string->number str)) + (unless (exact-nonnegative-integer? n) + (raise-user-error (string->symbol + (format "~a ~a" + (short-program+command-name) + (current-svn-style-command))) + "invalid <~a> number: ~a" + what + str)) + n) + (begin-for-syntax (define symbol->keyword (compose string->keyword symbol->string)) @@ -39,7 +51,10 @@ #:attr fun #'(string->option 'name '(opt ...))] [pattern (#:str name:id default:expr) #:attr (arg-val 1) (list #'name) - #:attr fun #'identity]) + #:attr fun #'identity] + [pattern (#:num name:id default:expr) + #:attr (arg-val 1) (list #'name) + #:attr fun #'(string->num 'name)]) (define-syntax-class option #:attributes (command-line variable (param 1) (call 1)) diff --git a/racket/lib/collects/pkg/main.rkt b/racket/lib/collects/pkg/main.rkt index a40d4f14af..ef0b1fed6a 100644 --- a/racket/lib/collects/pkg/main.rkt +++ b/racket/lib/collects/pkg/main.rkt @@ -10,7 +10,7 @@ "commands.rkt" (prefix-in setup: setup/setup)) -(define (setup no-setup? setup-collects) +(define (setup no-setup? setup-collects jobs) (unless (or no-setup? (not (member (getenv "PLT_PKG_NOSETUP") '(#f "")))) (define installation? (eq? 'installation (current-pkg-scope))) @@ -22,7 +22,8 @@ (if (list? s) s (list s))) setup-collects)) #:tidy? #t - #:make-doc-index? #t))) + #:make-doc-index? #t + #:jobs jobs))) (define ((pkg-error cmd) . args) (apply raise-user-error @@ -61,8 +62,6 @@ "if not specified, the type is inferred syntactically")] [(#:str name #f) name ("-n") ("Name of package, instead of inferred" "(makes sense only when a single is given)")] - [#:bool no-setup () ("Don't run `raco setup' after changing packages" - "(generally not a good idea)")] #:once-each [(#:sym mode [fail force search-ask search-auto] #f) deps () ("Specify the behavior for dependencies, with as one of" @@ -89,6 +88,9 @@ [(#:str dir #f) scope-dir () "Install for package scope "] #:once-each [(#:str catalog #f) catalog () "Use instead of configured catalogs"] + [#:bool no-setup () ("Don't run `raco setup' after changing packages (generally" + "not a good idea)")] + [(#:num n #f) jobs ("-j") "Setup with parallel jobs"] #:args pkg-source (call-with-package-scope 'install @@ -106,12 +108,10 @@ #:skip-installed? skip-installed (for/list ([p (in-list pkg-source)]) (pkg-desc p (or (and link 'link) type) name #f)))))) - (setup no-setup setup-collects)))] + (setup no-setup setup-collects jobs)))] [update "Update packages" #:once-each - [#:bool no-setup () ("Don't run `raco setup' after changing packages" - "(generally not a good idea)")] [#:bool all ("-a") ("Update all packages;" "only if no packages are given on the command line")] [(#:sym mode [fail force search-ask search-auto] #f) deps () @@ -134,6 +134,10 @@ [#:bool user ("-u") "Shorthand for `--scope user'"] [#:bool shared ("-s") "Shorthand for `--scope shared'"] [(#:str dir #f) scope-dir () "Update for package scope "] + #:once-each + [#:bool no-setup () ("Don't run `raco setup' after changing packages (generally" + "not a good idea)")] + [(#:num n #f) jobs ("-j") "Setup with parallel jobs"] #:args pkg (call-with-package-scope 'update @@ -145,12 +149,10 @@ #:all? all #:dep-behavior deps #:deps? update-deps))) - (setup no-setup setup-collects)))] + (setup no-setup setup-collects jobs)))] [remove "Remove packages" #:once-each - [#:bool no-setup () ("Don't run `raco setup' after changing packages" - "(generally not a good idea)")] [#:bool force () "Force removal of packages"] [#:bool auto () "Remove automatically installed packages with no dependencies"] #:once-any @@ -163,6 +165,10 @@ [#:bool user ("-u") "Shorthand for `--scope user'"] [#:bool shared ("-s") "Shorthand for `--scope shared'"] [(#:str dir #f) scope-dir () "Remove for package scope "] + #:once-each + [#:bool no-setup () ("Don't run `raco setup' after changing packages (generally" + "not a good idea)")] + [(#:num n #f) jobs ("-j") "Setup with parallel jobs"] #:args pkg (call-with-package-scope 'remove @@ -173,7 +179,7 @@ (pkg-remove pkg #:auto? auto #:force? force))) - (setup no-setup setup-collects)))] + (setup no-setup setup-collects jobs)))] [show "Show information about installed packages" #:once-each diff --git a/racket/lib/collects/setup/setup-cmdline.rkt b/racket/lib/collects/setup/setup-cmdline.rkt index 1a5fb2bd09..872b8bd79c 100644 --- a/racket/lib/collects/setup/setup-cmdline.rkt +++ b/racket/lib/collects/setup/setup-cmdline.rkt @@ -33,8 +33,8 @@ #:program long-name #:argv argv #:once-each - [("-j" "--workers") workers "Use <#> parallel-workers" - (add-flags `((parallel-workers ,(string->number workers))))] + [("-j" "--jobs" "--workers") n "Use parallel jobs" + (add-flags `((parallel-workers ,(string->number n))))] [("--only") "Set up only specified s" (add-flags '((make-only #t)))] #:multi diff --git a/racket/src/worksp/build-at.bat b/racket/src/worksp/build-at.bat index cfb44b3a9e..3ba729d843 100644 --- a/racket/src/worksp/build-at.bat +++ b/racket/src/worksp/build-at.bat @@ -1,4 +1,13 @@ cd %1 set BUILD_CONFIG=%2 + set PLT_SETUP_OPTIONS=--no-foreign-libs +:suloop +if "%3"=="" goto sudone +set PLT_SETUP_OPTIONS=%PLT_SETUP_OPTIONS %3 +shift +goto suloop +:sudone + + build