setup/setup: a keyword-based API for running `raco setup'

Mostly moves the implementation out of `setup/plt-single-installer'
into a more generic format.
This commit is contained in:
Matthew Flatt 2012-11-28 09:49:28 -07:00
parent 610587bf6e
commit 88a729df56
3 changed files with 132 additions and 61 deletions

View File

@ -411,6 +411,55 @@ Optional @filepath{info.rkt} fields trigger additional actions by
@section[#:tag "setup-plt-plt"]{API for Installation} @section[#:tag "setup-plt-plt"]{API for Installation}
@defmodule[setup/setup]
@defproc[(setup [#:file file (or/c #f path-string?) #f]
[#:collections collections (or/c #f (listof (listof path-string?))) #f]
[#:planet-specs planet-specs (or/c #f
(listof (list/c string?
string?
exact-nonnegative-integer?
exact-nonnegative-integer?)))
#f]
[#:make-user? make-user? any/c #t]
[#:make-docs? make-docs? any/c #t]
[#:clean? clean? any/c #f]
[#:jobs jobs exact-nonnegative-integer? #f]
[#:get-target-dir get-target-dir (or/c #f (-> path-string?)) #f])
void?]{
Runs @exec{raco setup} with various options:
@itemlist[
@item{@racket[file] --- if not @racket[#f], installs @racket[file] as
a @filepath{.plt} archive.}
@item{@racket[collections] --- if not @racket[#f], constrains setup to
the named collections, along with @racket[planet-specs], if any}
@item{@racket[planet-spec] --- if not @racket[#f], constrains setup to
the named @|PLaneT| packages, along with @racket[collections], if any}
@item{@racket[make-docs?] --- if @racket[#f], disables any
documentation-specific setup actions}
@item{@racket[make-user?] --- if @racket[#f], disables any
user-specific setup actions}
@item{@racket[clean?] --- if true, enables cleaning mode instead of setup mode}
@item{@racket[jobs] --- if not @racket[#f], determines the maximum number of parallel
tasks used for setup}
@item{@racket[get-target-dir] --- if not @racket[#f], treated as a
value for @sigelem[setup-option^ current-target-directory-getter]}
]}
@subsection{@exec{raco setup} Unit}
@defmodule[setup/setup-unit]
The @racketmodname[setup/setup-unit] library provides @exec{raco setup} in unit The @racketmodname[setup/setup-unit] library provides @exec{raco setup} in unit
form. The associated @racket[setup/option-sig] and form. The associated @racket[setup/option-sig] and
@racket[setup/option-unit] libraries provides the interface for @racket[setup/option-unit] libraries provides the interface for
@ -434,10 +483,6 @@ initialized between them, e.g.:
_...) _...)
] ]
@subsection{@exec{raco setup} Unit}
@defmodule[setup/setup-unit]
@defthing[setup@ unit?]{ @defthing[setup@ unit?]{
Imports Imports
@ -573,7 +618,7 @@ form.}
documentation is built, then suitable documentation start pages, search pages, documentation is built, then suitable documentation start pages, search pages,
and master index pages are re-built. @defaults[@racket[#t]]} and master index pages are re-built. @defaults[@racket[#t]]}
@defparam[current-target-directory-getter thunk (-> . path-string?)]{ @defparam[current-target-directory-getter thunk (-> path-string?)]{
A thunk that returns the target directory for unpacking a relative A thunk that returns the target directory for unpacking a relative
@filepath{.plt} archive; when unpacking an archive, either this or @filepath{.plt} archive; when unpacking an archive, either this or
the procedure in @racket[current-target-plt-directory-getter] will the procedure in @racket[current-target-plt-directory-getter] will

View File

@ -1,17 +1,6 @@
#lang racket/base #lang racket/base
(require racket/unit (require racket/unit
"setup.rkt")
;; All the rest are to get the imports for setup@:
"option-sig.rkt"
"setup-unit.rkt"
"option-unit.rkt"
launcher/launcher-sig
launcher/launcher-unit
dynext/dynext-sig
dynext/dynext-unit
compiler/sig
compiler/option-unit
compiler/compiler-unit)
(provide run-single-installer install-planet-package clean-planet-package reindex-user-documentation) (provide run-single-installer install-planet-package clean-planet-package reindex-user-documentation)
@ -46,50 +35,11 @@
(define thd (define thd
(thread (thread
(lambda () (lambda ()
(define-unit set-options@ (setup #:jobs 1
(import setup-option^ compiler^) #:file file
(export) #:get-target-dir get-target-dir
;; >>>>>>>>>>>>>> <<<<<<<<<<<<<<< #:planet-spec (and planet-spec (list planet-spec))
;; Here's where we tell setup the archive file: #:collections collections))))
(unless (or clean? (not file))
(archives (list file))
(when planet-spec
(archive-implies-reindex #f)))
;; Here's where we make get a directory:
(current-target-directory-getter
get-target-dir)
(when planet-spec
(specific-planet-dirs (list planet-spec)))
(when collections
(specific-collections collections))
(when clean?
(clean #t)
(make-zo #f)
(make-launchers #f)
(make-info-domain #t)
(call-install #f)
(make-docs #f))
(setup-program-name "raco setup")
(parallel-workers 1))
(invoke-unit
(compound-unit/infer
(import)
(export)
(link launcher@
dynext:compile@
dynext:link@
dynext:file@
compiler:option@
compiler@
setup:option@
set-options@
setup@))))))
(dynamic-wind (dynamic-wind
void void
(lambda () (lambda ()

76
collects/setup/setup.rkt Normal file
View File

@ -0,0 +1,76 @@
#lang racket/base
(require racket/unit
;; All the rest are to get the imports for setup@:
"option-sig.rkt"
"setup-unit.rkt"
"option-unit.rkt"
launcher/launcher-sig
launcher/launcher-unit
dynext/dynext-sig
dynext/dynext-unit
compiler/sig
compiler/option-unit
compiler/compiler-unit)
(provide setup)
(define (setup #:file [file #f]
#:get-target-dir [get-target-dir #f]
#:planet-specs [planet-specs #f]
#:collections [collections #f]
#:make-docs? [make-docs? #t]
#:make-user? [make-user? #t]
#:clean? [clean? #f]
#:jobs [parallel #f])
(define-unit set-options@
(import setup-option^ compiler^)
(export)
;; >>>>>>>>>>>>>> <<<<<<<<<<<<<<<
;; Here's where we tell setup the archive file:
(unless (or clean? (not file))
(archives (list file))
(when planet-specs
(archive-implies-reindex #f)))
;; Here's where we make get a directory:
(current-target-directory-getter
get-target-dir)
(when planet-specs
(specific-planet-dirs planet-specs))
(when collections
(specific-collections collections))
(unless make-user?
(make-user #f))
(unless make-docs?
(make-docs #f))
(when clean?
(clean #t)
(make-zo #f)
(make-launchers #f)
(make-info-domain #t)
(call-install #f)
(make-docs #f))
(setup-program-name "raco setup")
(when parallel
(parallel-workers parallel)))
(invoke-unit
(compound-unit/infer
(import)
(export)
(link launcher@
dynext:compile@
dynext:link@
dynext:file@
compiler:option@
compiler@
setup:option@
set-options@
setup@))))