Add -j'/--jobs' <n> argument to `raco pkg install', etc.

Also, thread `PLT_SETUP_OPTIONS' though server and client build
(so that a `#:j' configuration works as intended).
This commit is contained in:
Matthew Flatt 2013-07-05 11:33:57 -06:00
parent ddbc8e5f40
commit a8ed2b1546
7 changed files with 61 additions and 25 deletions

View File

@ -69,7 +69,7 @@ core:
win32-core: win32-core:
IF NOT EXIST build\config cmd /c mkdir -p build\config IF NOT EXIST build\config cmd /c mkdir -p build\config
cmd /c echo #hash((links-search-files . ())) > build\config\config.rktd 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 racket/src/build/Makefile: racket/src/configure racket/src/Makefile.in
cd racket/src/build; ../configure $(CONFIGURE_ARGS_qq) 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 RACO = racket/bin/racket -A "$(ADDON)" -N raco -l- raco
WIN32_RACKET = racket\racket -A "$(ADDON)" WIN32_RACKET = racket\racket -A "$(ADDON)"
WIN32_RACO = racket\racket -A "$(ADDON)" -N raco -l- raco 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) LOCAL_USER_AUTO = --catalog build/local/catalog $(USER_AUTO_OPTIONS)
SOURCE_USER_AUTO_q = --catalog "$(SRC_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_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)" CONFIG_MODE_q = "$(CONFIG)" "$(CONFIG_MODE)"
BUNDLE_CONFIG = bundle/racket/etc/config.rktd BUNDLE_CONFIG = bundle/racket/etc/config.rktd
@ -306,7 +307,7 @@ client:
COPY_ARGS = SERVER=$(SERVER) PKGS="$(PKGS)" RELEASE_MODE=$(RELEASE_MODE) \ COPY_ARGS = SERVER=$(SERVER) PKGS="$(PKGS)" RELEASE_MODE=$(RELEASE_MODE) \
DIST_NAME="$(DIST_NAME)" DIST_BASE=$(DIST_BASE) \ DIST_NAME="$(DIST_NAME)" DIST_BASE=$(DIST_BASE) \
DIST_DIR=$(DIST_DIR) DIST_SUFFIX=$(DIST_SUFFIX) \ DIST_DIR=$(DIST_DIR) DIST_SUFFIX=$(DIST_SUFFIX) \
DIST_DESC="$(DIST_DESC)" DIST_DESC="$(DIST_DESC)" PLT_SETUP_OPTIONS="$(PLT_SETUP_OPTIONS)"
win32-client: win32-client:
IF EXIST build\user cmd /c rmdir /S /Q build\user IF EXIST build\user cmd /c rmdir /S /Q build\user

View File

@ -302,9 +302,6 @@ sub-sub-commands:
@item{@DFlag{ignore-checksums} --- Ignores errors verifying package @tech{checksums} (unsafe).} @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{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), @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 @item{@DFlag{catalog} @nonterm{catalog} --- Use @nonterm{catalog} instead of of the currently configured
@tech{package catalogs}.} @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{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{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{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{@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{i} or @DFlag{installation} --- Shorthand for @exec{--scope installation}.}
@item{@Flag{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.} @item{@Flag{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.}
@item{@Flag{s} or @DFlag{shared} --- Shorthand for @exec{--scope shared}.} @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{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[ @itemlist[
@item{@DFlag{force} --- Ignore dependencies when removing packages.} @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} @item{@DFlag{auto} --- Remove packages that were installed by the @exec{search-auto} or @exec{search-ask}
dependency behavior and are no longer required.} dependency behavior and are no longer required.}
@item{@DFlag{scope} @nonterm{scope} --- Selects a @tech{package scope}, the same as for @command-ref{install}.} @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{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.}
@item{@Flag{s} or @DFlag{shared} --- Shorthand for @exec{--scope shared}.} @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{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}.}
] ]
} }

View File

@ -95,9 +95,10 @@ flags:
@itemize[ @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} 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.} all of the machine's processing cores.}
@item{@DFlag{only} --- restrict setup to specified collections and @item{@DFlag{only} --- restrict setup to specified collections and

View File

@ -24,6 +24,18 @@
(format " ~a" s))))) (format " ~a" s)))))
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 (begin-for-syntax
(define symbol->keyword (define symbol->keyword
(compose string->keyword symbol->string)) (compose string->keyword symbol->string))
@ -39,7 +51,10 @@
#:attr fun #'(string->option 'name '(opt ...))] #:attr fun #'(string->option 'name '(opt ...))]
[pattern (#:str name:id default:expr) [pattern (#:str name:id default:expr)
#:attr (arg-val 1) (list #'name) #: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 (define-syntax-class option
#:attributes (command-line variable (param 1) (call 1)) #:attributes (command-line variable (param 1) (call 1))

View File

@ -10,7 +10,7 @@
"commands.rkt" "commands.rkt"
(prefix-in setup: setup/setup)) (prefix-in setup: setup/setup))
(define (setup no-setup? setup-collects) (define (setup no-setup? setup-collects jobs)
(unless (or no-setup? (unless (or no-setup?
(not (member (getenv "PLT_PKG_NOSETUP") '(#f "")))) (not (member (getenv "PLT_PKG_NOSETUP") '(#f ""))))
(define installation? (eq? 'installation (current-pkg-scope))) (define installation? (eq? 'installation (current-pkg-scope)))
@ -22,7 +22,8 @@
(if (list? s) s (list s))) (if (list? s) s (list s)))
setup-collects)) setup-collects))
#:tidy? #t #:tidy? #t
#:make-doc-index? #t))) #:make-doc-index? #t
#:jobs jobs)))
(define ((pkg-error cmd) . args) (define ((pkg-error cmd) . args)
(apply raise-user-error (apply raise-user-error
@ -61,8 +62,6 @@
"if not specified, the type is inferred syntactically")] "if not specified, the type is inferred syntactically")]
[(#:str name #f) name ("-n") ("Name of package, instead of inferred" [(#:str name #f) name ("-n") ("Name of package, instead of inferred"
"(makes sense only when a single <pkg-source> is given)")] "(makes sense only when a single <pkg-source> is given)")]
[#:bool no-setup () ("Don't run `raco setup' after changing packages"
"(generally not a good idea)")]
#:once-each #:once-each
[(#:sym mode [fail force search-ask search-auto] #f) deps () [(#:sym mode [fail force search-ask search-auto] #f) deps ()
("Specify the behavior for dependencies, with <mode> as one of" ("Specify the behavior for dependencies, with <mode> as one of"
@ -89,6 +88,9 @@
[(#:str dir #f) scope-dir () "Install for package scope <dir>"] [(#:str dir #f) scope-dir () "Install for package scope <dir>"]
#:once-each #:once-each
[(#:str catalog #f) catalog () "Use <catalog> instead of configured catalogs"] [(#:str catalog #f) catalog () "Use <catalog> 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 <n> parallel jobs"]
#:args pkg-source #:args pkg-source
(call-with-package-scope (call-with-package-scope
'install 'install
@ -106,12 +108,10 @@
#:skip-installed? skip-installed #:skip-installed? skip-installed
(for/list ([p (in-list pkg-source)]) (for/list ([p (in-list pkg-source)])
(pkg-desc p (or (and link 'link) type) name #f)))))) (pkg-desc p (or (and link 'link) type) name #f))))))
(setup no-setup setup-collects)))] (setup no-setup setup-collects jobs)))]
[update [update
"Update packages" "Update packages"
#:once-each #:once-each
[#:bool no-setup () ("Don't run `raco setup' after changing packages"
"(generally not a good idea)")]
[#:bool all ("-a") ("Update all packages;" [#:bool all ("-a") ("Update all packages;"
"only if no packages are given on the command line")] "only if no packages are given on the command line")]
[(#:sym mode [fail force search-ask search-auto] #f) deps () [(#:sym mode [fail force search-ask search-auto] #f) deps ()
@ -134,6 +134,10 @@
[#:bool user ("-u") "Shorthand for `--scope user'"] [#:bool user ("-u") "Shorthand for `--scope user'"]
[#:bool shared ("-s") "Shorthand for `--scope shared'"] [#:bool shared ("-s") "Shorthand for `--scope shared'"]
[(#:str dir #f) scope-dir () "Update for package scope <dir>"] [(#:str dir #f) scope-dir () "Update for package scope <dir>"]
#: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 <n> parallel jobs"]
#:args pkg #:args pkg
(call-with-package-scope (call-with-package-scope
'update 'update
@ -145,12 +149,10 @@
#:all? all #:all? all
#:dep-behavior deps #:dep-behavior deps
#:deps? update-deps))) #:deps? update-deps)))
(setup no-setup setup-collects)))] (setup no-setup setup-collects jobs)))]
[remove [remove
"Remove packages" "Remove packages"
#:once-each #: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 force () "Force removal of packages"]
[#:bool auto () "Remove automatically installed packages with no dependencies"] [#:bool auto () "Remove automatically installed packages with no dependencies"]
#:once-any #:once-any
@ -163,6 +165,10 @@
[#:bool user ("-u") "Shorthand for `--scope user'"] [#:bool user ("-u") "Shorthand for `--scope user'"]
[#:bool shared ("-s") "Shorthand for `--scope shared'"] [#:bool shared ("-s") "Shorthand for `--scope shared'"]
[(#:str dir #f) scope-dir () "Remove for package scope <dir>"] [(#:str dir #f) scope-dir () "Remove for package scope <dir>"]
#: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 <n> parallel jobs"]
#:args pkg #:args pkg
(call-with-package-scope (call-with-package-scope
'remove 'remove
@ -173,7 +179,7 @@
(pkg-remove pkg (pkg-remove pkg
#:auto? auto #:auto? auto
#:force? force))) #:force? force)))
(setup no-setup setup-collects)))] (setup no-setup setup-collects jobs)))]
[show [show
"Show information about installed packages" "Show information about installed packages"
#:once-each #:once-each

View File

@ -33,8 +33,8 @@
#:program long-name #:program long-name
#:argv argv #:argv argv
#:once-each #:once-each
[("-j" "--workers") workers "Use <#> parallel-workers" [("-j" "--jobs" "--workers") n "Use <n> parallel jobs"
(add-flags `((parallel-workers ,(string->number workers))))] (add-flags `((parallel-workers ,(string->number n))))]
[("--only") "Set up only specified <collection>s" [("--only") "Set up only specified <collection>s"
(add-flags '((make-only #t)))] (add-flags '((make-only #t)))]
#:multi #:multi

View File

@ -1,4 +1,13 @@
cd %1 cd %1
set BUILD_CONFIG=%2 set BUILD_CONFIG=%2
set PLT_SETUP_OPTIONS=--no-foreign-libs 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 build