diff --git a/pkgs/compiler-pkgs/compiler-lib/compiler/commands/exe.rkt b/pkgs/compiler-pkgs/compiler-lib/compiler/commands/exe.rkt index cdea3a3153..e1241b11f1 100644 --- a/pkgs/compiler-pkgs/compiler-lib/compiler/commands/exe.rkt +++ b/pkgs/compiler-pkgs/compiler-lib/compiler/commands/exe.rkt @@ -16,6 +16,7 @@ (define exe-embedded-flags (make-parameter '("-U" "--"))) (define exe-embedded-libraries (make-parameter null)) (define exe-aux (make-parameter null)) +(define exe-embedded-config-path (make-parameter "etc")) (define exe-embedded-collects-path (make-parameter null)) (define exe-embedded-collects-dest (make-parameter #f)) @@ -29,6 +30,8 @@ (gui #t)] [("-l" "--launcher") "Generate a launcher" (launcher #t)] + [("--config-path") path "Set as configuration directory for executable" + (exe-embedded-config-path path)] [("--collects-path") path "Set as main collects for executable" (exe-embedded-collects-path path)] [("--collects-dest") dir "Write collection code to " @@ -133,6 +136,7 @@ #:cmdline (exe-embedded-flags) #:collects-path (exe-embedded-collects-path) #:collects-dest (exe-embedded-collects-dest) - #:aux (exe-aux))]) + #:aux (cons `(config-dir . ,(exe-embedded-config-path)) + (exe-aux)))]) (when (verbose) (printf " [output to \"~a\"]\n" dest))) diff --git a/pkgs/compiler-pkgs/compiler-test/tests/compiler/embed/embed-me6b.rkt b/pkgs/compiler-pkgs/compiler-test/tests/compiler/embed/embed-me6b.rkt new file mode 100644 index 0000000000..839af8e0b3 --- /dev/null +++ b/pkgs/compiler-pkgs/compiler-test/tests/compiler/embed/embed-me6b.rkt @@ -0,0 +1,8 @@ +(module embed-me6b racket/base + (with-output-to-file "stdout" + (lambda () + (printf "This is 6\n") + (with-handlers ([void (lambda (exn) (printf "no etc.ss\n"))]) + (printf "~a\n" (and (dynamic-require 'racket/fixnum #f) #t)))) + #:exists 'append)) + diff --git a/pkgs/compiler-pkgs/compiler-test/tests/compiler/embed/test.rkt b/pkgs/compiler-pkgs/compiler-test/tests/compiler/embed/test.rkt index e82a2de4cb..a1e8945895 100644 --- a/pkgs/compiler-pkgs/compiler-test/tests/compiler/embed/test.rkt +++ b/pkgs/compiler-pkgs/compiler-test/tests/compiler/embed/test.rkt @@ -363,46 +363,64 @@ (path->string (build-path (collection-path "tests" "compiler" "embed") "embed-me1.rkt"))) (try-exe (mk-dest mred?) "This is 1\n" mred?) - ;; Check that etc.rkt isn't found if it's not included: - (printf ">>not included\n") - (system* mzc - (if mred? "--gui-exe" "--exe") - (path->string (mk-dest mred?)) - (path->string (build-path (collection-path "tests" "compiler" "embed") "embed-me6.rkt"))) - (try-exe (mk-dest mred?) "This is 6\nno etc.ss\n" mred?) + (define (check-collection-path prog lib in-main?) + ;; Check that etc.rkt isn't found if it's not included: + (printf ">>not included\n") + (system* mzc + (if mred? "--gui-exe" "--exe") + (path->string (mk-dest mred?)) + (path->string (build-path (collection-path "tests" "compiler" "embed") prog))) + (try-exe (mk-dest mred?) "This is 6\nno etc.ss\n" mred?) - ;; And it is found if it is included: - (printf ">>included\n") - (system* mzc - (if mred? "--gui-exe" "--exe") - (path->string (mk-dest mred?)) - "++lib" "mzlib/etc.rkt" - (path->string (build-path (collection-path "tests" "compiler" "embed") "embed-me6.rkt"))) - (try-exe (mk-dest mred?) "This is 6\n#t\n" mred?) + ;; And it is found if it is included: + (printf ">>included\n") + (system* mzc + (if mred? "--gui-exe" "--exe") + (path->string (mk-dest mred?)) + "++lib" lib + (path->string (build-path (collection-path "tests" "compiler" "embed") prog))) + (try-exe (mk-dest mred?) "This is 6\n#t\n" mred?) - ;; Or, it's found if we set the collection path: - (printf ">>set coll path\n") - (system* mzc - (if mred? "--gui-exe" "--exe") - (path->string (mk-dest mred?)) - "--collects-path" - (path->string (find-collects-dir)) - (path->string (build-path (collection-path "tests" "compiler" "embed") "embed-me6.rkt"))) - ;; Don't try a distribution for this one: - (try-one-exe (mk-dest mred?) "This is 6\n#t\n" mred?) + ;; Or, it's found if we set the collection path and the config path (where the latter + ;; finds links for packages): + (printf ">>set coll path\n") + (system* mzc + (if mred? "--gui-exe" "--exe") + (path->string (mk-dest mred?)) + "--collects-path" + (path->string (find-collects-dir)) + (path->string (build-path (collection-path "tests" "compiler" "embed") prog))) + ;; Don't try a distribution for this one: + (try-one-exe (mk-dest mred?) (if in-main? "This is 6\n#t\n" "This is 6\nno etc.ss\n") mred?) - ;; Try --collects-dest mode - (printf ">>--collects-dest\n") - (system* mzc - (if mred? "--gui-exe" "--exe") - (path->string (mk-dest mred?)) - "++lib" "mzlib/etc.rkt" - "--collects-dest" "cts" - "--collects-path" "cts" - (path->string (build-path (collection-path "tests" "compiler" "embed") "embed-me6.rkt"))) - (try-exe (mk-dest mred?) "This is 6\n#t\n" mred? void "cts") ; <- cts copied to distribution - (delete-directory/files "cts") - (test #f system* (mk-dest mred?)) + ;; Or, it's found if we set the collection path and the config path (where the latter + ;; finds links for packages): + (printf ">>set coll path plus config\n") + (system* mzc + (if mred? "--gui-exe" "--exe") + (path->string (mk-dest mred?)) + "--collects-path" + (path->string (find-collects-dir)) + "--config-path" + (path->string (find-config-dir)) + (path->string (build-path (collection-path "tests" "compiler" "embed") prog))) + ;; Don't try a distribution for this one: + (try-one-exe (mk-dest mred?) "This is 6\n#t\n" mred?) + + ;; Try --collects-dest mode + (printf ">>--collects-dest\n") + (system* mzc + (if mred? "--gui-exe" "--exe") + (path->string (mk-dest mred?)) + "++lib" lib + "--collects-dest" "cts" + "--collects-path" "cts" + (path->string (build-path (collection-path "tests" "compiler" "embed") prog))) + (try-exe (mk-dest mred?) "This is 6\n#t\n" mred? void "cts") ; <- cts copied to distribution + (delete-directory/files "cts") + (test #f system* (mk-dest mred?))) + (check-collection-path "embed-me6b.rkt" "racket/fixnum.rkt" #t) + (check-collection-path "embed-me6.rkt" "mzlib/etc.rkt" #f) (void)))