install-for-docs.rkt (2067B)
1 #lang racket/base 2 (require racket/cmdline 3 racket/file 4 racket/string 5 racket/system 6 compiler/find-exe 7 (only-in "config.rkt" extract-options) 8 distro-build/display-time) 9 10 (module test racket/base) 11 12 (define-values (dir config-file config-mode default-pkgs catalogs) 13 (command-line 14 #:args 15 (dir config-file config-mode default-pkgs . catalog) 16 (values dir config-file config-mode default-pkgs catalog))) 17 18 (define config (extract-options config-file config-mode)) 19 20 (define pkgs 21 (or (hash-ref config '#:pkgs #f) 22 (string-split default-pkgs))) 23 24 (define (build-path/s . a) 25 (path->string (path->complete-path (apply build-path dir a)))) 26 (define (build-path/f . a) 27 (string-append "file://" 28 (path->string (path->complete-path (apply build-path a))))) 29 30 (define ht 31 (hash 'doc-dir (build-path/s "doc") 32 'lib-dir (build-path/s "lib") 33 'share-dir (build-path/s "share") 34 'dll-dir (build-path/s "lib") 35 'links-file (build-path/s "share" "links.rktd") 36 'pkgs-dir (build-path/s "share" "pkgs") 37 'bin-dir (build-path/s "bin") 38 'include-dir (build-path/s "include") 39 'catalogs (map build-path/f catalogs))) 40 41 (make-directory* (build-path dir "etc")) 42 43 (call-with-output-file* 44 (build-path dir "etc" "config.rktd") 45 #:exists 'truncate/replace 46 (lambda (o) 47 (write ht o) 48 (newline o))) 49 50 (display-time) 51 (printf "Running `raco pkg install' for packages:\n") 52 (for ([pkg (in-list pkgs)]) 53 (printf " ~a\n" pkg)) 54 (unless (apply system* (find-exe) 55 "-G" "build/docs/etc" "-l-" 56 "raco" "pkg" "install" 57 "--pkgs" 58 "-i" "--deps" "search-auto" 59 pkgs) 60 (error "install failed")) 61 62 (when (hash-ref config '#:pdf-doc? #f) 63 (display-time) 64 (printf "Running `raco setup' PDF documentation:\n") 65 (unless (system* (find-exe) 66 "-G" "build/docs/etc" "-l-" 67 "raco" "setup" "--doc-pdf" "build/pdf-doc") 68 (error "PDF failed"))) 69 70 (display-time)