diff --git a/pkgs/racket-doc/scribblings/raco/config.scrbl b/pkgs/racket-doc/scribblings/raco/config.scrbl index 8a0de22fc7..17fe02a107 100644 --- a/pkgs/racket-doc/scribblings/raco/config.scrbl +++ b/pkgs/racket-doc/scribblings/raco/config.scrbl @@ -88,6 +88,16 @@ directory}: @filepath{bin} sibling directory of the @tech{main collection directory}.} + @item{@indexed-racket['gui-bin-dir] --- a path, string, or byte + string for the installation's directory containing GUI + executables. It defaults to a the @racket['bin-dir] value, if + configured, or otherwise defaults in a platform-specific way: + to the @filepath{bin} sibling directory of the @tech{main + collection directory} on Unix, and to the parent of the + @tech{main collection directory} on Windows and Mac OS. + + @history[#:added "6.8.0.2"]} + @item{@indexed-racket['apps-dir] --- a path, string, or byte string for the installation's directory for @filepath{.desktop} files. It defaults to a @filepath{applications} subdirectory of the diff --git a/pkgs/racket-doc/scribblings/raco/launcher.scrbl b/pkgs/racket-doc/scribblings/raco/launcher.scrbl index 9a9913444d..297532f8da 100644 --- a/pkgs/racket-doc/scribblings/raco/launcher.scrbl +++ b/pkgs/racket-doc/scribblings/raco/launcher.scrbl @@ -6,7 +6,8 @@ launcher/launcher-sig launcher/launcher-unit compiler/embed - racket/gui/base)) + racket/gui/base + setup/dirs)) @title[#:tag "launcher"]{Installation-Specific Launchers} @@ -267,7 +268,8 @@ arguments.} @defproc[(gracket-program-launcher-path [name string?] [#:user? user? any/c #f] - [#:tethered? tethered? any/c #f]) + [#:tethered? tethered? any/c #f] + [#:console? console? any/c #f]) path?]{ Returns a pathname for an executable called something like @racket[name] @@ -299,17 +301,25 @@ suffix is automatically appended to @racket[name]. For Unix, the Racket installation. For Mac OS, the @filepath{.app} suffix is appended to @racket[name]. -@history[#:changed "6.5.0.2" @elem{Added the @racket[#:tethered?] argument.}]} +If @racket[console?] is true, then the path is in the console +executable directory, such as the one reported by +@racket[(find-console-bin-dir)], instead of the GUI executable +directory, such as the one reported by @racket[(find-gui-bin-dir)]. + +@history[#:changed "6.5.0.2" @elem{Added the @racket[#:tethered?] argument.} + #:changed "6.8.0.2" @elem{Added the @racket[#:console?] argument.}]} @defproc[(racket-program-launcher-path [name string?] [#:user? user? any/c #f] - [#:tethered? tethered? any/c #f]) + [#:tethered? tethered? any/c #f] + [#:console? console? any/c #f]) path?]{ -Returns the same path as @racket[(gracket-program-launcher-path name #:user? user? #:tethered tethered?)]. +Returns the same path as @racket[(gracket-program-launcher-path name #:user? user? #:tethered tethered? #:console? console?)]. -@history[#:changed "6.5.0.2" @elem{Added the @racket[#:tethered?] argument.}]} +@history[#:changed "6.5.0.2" @elem{Added the @racket[#:tethered?] argument.} + #:changed "6.8.0.2" @elem{Added the @racket[#:console?] argument.}]} @defproc[(gracket-launcher-is-directory?) boolean?]{ diff --git a/pkgs/racket-doc/scribblings/raco/setup.scrbl b/pkgs/racket-doc/scribblings/raco/setup.scrbl index 1590fe5ac5..bf82ade9db 100644 --- a/pkgs/racket-doc/scribblings/raco/setup.scrbl +++ b/pkgs/racket-doc/scribblings/raco/setup.scrbl @@ -1232,9 +1232,13 @@ function for installing a single @filepath{.plt} file. @section[#:tag "dirs"]{API for Finding Installation Directories} -@defmodule[setup/dirs]{ - The @racketmodname[setup/dirs] library provides several procedures for locating - installation directories:} +@defmodule[setup/dirs]{ The @racketmodname[setup/dirs] library + provides several procedures for locating installation directories. + Many of these paths can be configured through the + @tech{configuration directory} (see @secref["config-file"]).} + +@(define-syntax-rule (see-config id) + @elem{See also @racket['id] in @secref["config-file"].}) @defproc[(find-collects-dir) (or/c path? #f)]{ Returns a path to the installation's main @filepath{collects} directory, or @@ -1271,7 +1275,9 @@ function for installing a single @filepath{.plt} file. @defproc[(find-links-file) path?]{ Returns a path to the installation's @tech[#:doc reference-doc]{collection links file}. The file indicated by the - returned path may or may not exist.} + returned path may or may not exist. + + @see-config[links-file]} @defproc[(find-user-links-file [vers string? (get-installation-name)]) path?]{ Returns a path to the user's @tech[#:doc reference-doc]{collection @@ -1284,12 +1290,16 @@ function for installing a single @filepath{.plt} file. order. (Normally, the result includes the result of @racket[(find-links-file)], which is where new installation-wide links are installed by @exec{raco link} or @racket[links].) The - files indicated by the returned paths may or may not exist.} + files indicated by the returned paths may or may not exist. + + @see-config[links-search-files]} @defproc[(find-pkgs-dir) path?]{ Returns a path to the directory containing packages with installation scope; the directory indicated by the returned path may - or may not exist.} + or may not exist. + + @see-config[pkgs-dir]} @defproc[(find-user-pkgs-dir [vers string? (get-installation-name)]) path?]{ Returns a path to the directory containing packages with @@ -1301,11 +1311,15 @@ function for installing a single @filepath{.plt} file. installation scope. (Normally, the result includes the result of @racket[(find-pkgs-dir)], which is where new packages are installed by @exec{raco pkg install}.) The directories indicated by the returned - paths may or may not exist.} + paths may or may not exist. + + @see-config[pkgs-search-dirs]} @defproc[(find-doc-dir) (or/c path? #f)]{ Returns a path to the installation's @filepath{doc} directory. - The result is @racket[#f] if no such directory is available.} + The result is @racket[#f] if no such directory is available. + + @see-config[doc-dir]} @defproc[(find-user-doc-dir) path?]{ Returns a path to a user-specific @filepath{doc} directory. The directory @@ -1317,12 +1331,16 @@ function for installing a single @filepath{.plt} file. configured otherwise, the result includes any non-@racket[#f] result of @racket[(find-doc-dir)] and @racket[(find-user-doc-dir)]---but the latter is included only if the value of the @racket[use-user-specific-search-paths] - parameter is @racket[#t].} + parameter is @racket[#t]. + + @see-config[doc-search-dirs]} @defproc[(find-lib-dir) (or/c path? #f)]{ Returns a path to the installation's @filepath{lib} directory, which contains libraries and other build information. The result is @racket[#f] if no such - directory is available.} + directory is available. + + @see-config[lib-dir]} @defproc[(find-user-lib-dir) path?]{ Returns a path to a user-specific @filepath{lib} directory; the directory @@ -1336,6 +1354,8 @@ function for installing a single @filepath{.plt} file. value of the @racket[use-user-specific-search-paths] parameter is @racket[#t]. + @see-config[lib-search-dirs] + @history[#:changed "6.1.1.4" @elem{Dropped @racket[(find-dll-dir)] from the set of paths to explicitly include in the @@ -1351,7 +1371,9 @@ function for installing a single @filepath{.plt} file. @defproc[(find-share-dir) (or/c path? #f)]{ Returns a path to the installation's @filepath{share} directory, which contains installed packages and other platform-independent files. The result is - @racket[#f] if no such directory is available.} + @racket[#f] if no such directory is available. + + @see-config[share-dir]} @defproc[(find-user-share-dir) path?]{ Returns a path to a user-specific @filepath{share} directory; the directory @@ -1360,7 +1382,9 @@ function for installing a single @filepath{.plt} file. @defproc[(find-include-dir) (or/c path? #f)]{ Returns a path to the installation's @filepath{include} directory, which contains @filepath{.h} files for building Racket extensions and embedding - programs. The result is @racket[#f] if no such directory is available.} + programs. The result is @racket[#f] if no such directory is available. + + @see-config[include-dir]} @defproc[(find-user-include-dir) path?]{ Returns a path to a user-specific @filepath{include} directory; the @@ -1371,17 +1395,23 @@ function for installing a single @filepath{.plt} file. configured otherwise, the result includes any non-@racket[#f] result of @racket[(find-include-dir)] and @racket[(find-user-include-dir)]---but the latter is included only if the value of the - @racket[use-user-specific-search-paths] parameter is @racket[#t].} + @racket[use-user-specific-search-paths] parameter is @racket[#t]. + + @see-config[include-search-dirs]} @defproc[(find-console-bin-dir) (or/c path? #f)]{ Returns a path to the installation's executable directory, where the stand-alone Racket executable resides. The result is @racket[#f] if no - such directory is available.} + such directory is available. + + @see-config[bin-dir]} @defproc[(find-gui-bin-dir) (or/c path? #f)]{ Returns a path to the installation's executable directory, where the stand-alone GRacket executable resides. The result is @racket[#f] if no such - directory is available.} + directory is available. + + @see-config[gui-bin-dir]} @defproc[(find-user-console-bin-dir) path?]{ Returns a path to the user's executable directory; the directory @@ -1395,7 +1425,9 @@ function for installing a single @filepath{.plt} file. @defproc[(find-apps-dir) (or/c path? #f)]{ Returns a path to the installation's directory @filepath{.desktop} files (for Unix). The result is @racket[#f] if no such directory - exists.} + exists. + + @see-config[apps-dir]} @defproc[(find-user-apps-dir) path?]{ Returns a path to the user's directory for @filepath{.desktop} files @@ -1404,7 +1436,7 @@ function for installing a single @filepath{.plt} file. @defproc[(find-man-dir) (or/c path? #f)]{ Returns a path to the installation's man-page directory. The result is - @racket[#f] if no such directory exists.} + @racket[#f] if no such directory exists. @see-config[man-dir]} @defproc[(find-user-man-dir) path?]{ Returns a path to the user's man-page directory; the directory @@ -1412,7 +1444,9 @@ function for installing a single @filepath{.plt} file. @defproc[(get-doc-search-url) string?]{ Returns a string that is used by the documentation system, augmented - with a version and search-key query, for remote documentation links.} + with a version and search-key query, for remote documentation links. + + @see-config[doc-search-url]} @defproc[(get-doc-open-url) (or/c string? #f)]{ Returns @racket[#f] or a string for a root URL to be used as an @@ -1421,6 +1455,8 @@ function for installing a single @filepath{.plt} file. performs keyword searches for documentation via the specified URL instead of from locally installed documentation. + @see-config[doc-open-url] + @history[#:added "6.0.1.6"]} @defproc[(get-installation-name) string?]{ Returns the current @@ -1469,7 +1505,7 @@ function for installing a single @filepath{.plt} file. @exec{raco setup} creates the executable copies, then further package build and setup operations through the entry points will be confined to the sandbox and not affect a user's default environment. - + @history[#:added "6.5.0.2"]} diff --git a/racket/collects/compiler/embed.rkt b/racket/collects/compiler/embed.rkt index 01de4c6e18..64822447f0 100644 --- a/racket/collects/compiler/embed.rkt +++ b/racket/collects/compiler/embed.rkt @@ -1486,9 +1486,8 @@ (mac-dest->executable dest mred?) mred?) (when mred? - ;; adjust relative path (since GRacket is normally off by one): - (define rel (find-relative-path (find-gui-bin-dir) - (find-lib-dir))) + ;; adjust relative path, since exe may change directory : + (define rel (find-relative-path* dest (find-lib-dir))) (update-framework-path (format "@executable_path/../../../~a" (path->directory-path rel)) (mac-dest->executable dest mred?) @@ -1508,8 +1507,8 @@ (if m (if (cdr m) (update-dll-dir dest (cdr m)) - ;; adjust relative path (since GRacket is off by one): - (update-dll-dir dest "lib")) + ;; adjust relative path, since exe directory can change: + (update-dll-dir dest (find-relative-path* dest (find-dll-dir)))) ;; Check whether we need an absolute path to DLLs: (let ([dir (get-current-dll-dir dest)]) (when (relative-path? dir) @@ -1523,19 +1522,29 @@ (if osx? (mac-dest->executable dest mred?) dest))]) + (define (gui-bin->config rel) + ;; Find the path to config-dir relative to the executable + (define p (find-relative-path* dest (find-config-dir))) + (simplify-path + (if (eq? rel 'same) + p + (build-path rel p)) + #f)) (if m (if (cdr m) (update-config-dir (dest->executable dest) (cdr m)) (when mred? (cond [osx? - ;; adjust relative path (since GRacket is off by one): + ;; adjust relative path (since GRacket is likely off by one): (update-config-dir (mac-dest->executable dest mred?) - "../../../etc/")] + (gui-bin->config "../../.."))] [(eq? 'windows (cross-system-type)) (unless keep-exe? - ;; adjust relative path (since GRacket is off by one): - (update-config-dir dest "etc/"))]))) + ;; adjust relative path (since GRacket is likely off by one): + (update-config-dir dest (gui-bin->config 'same)))] + [else + (update-config-dir dest (gui-bin->config 'same))]))) ;; Check whether we need an absolute path to config: (let ([dir (get-current-config-dir (dest->executable dest))]) (when (relative-path? dir) @@ -1695,11 +1704,14 @@ (cond [osx? ;; default path in `gracket' is off by one: - (set-collects-path dest-exe #"../../../collects")] + (set-collects-path dest-exe (path->bytes + (build-path 'up 'up 'up + (find-relative-path* dest (find-collects-dir)))))] [(eq? 'windows (cross-system-type)) (unless keep-exe? ;; off by one in this case, too: - (set-collects-path dest-exe #"collects"))])]) + (set-collects-path dest-exe (path->bytes + (find-relative-path* dest (find-collects-dir)))))])]) (cond [(and use-starter-info? osx?) (finish-osx-mred dest full-cmdline exe keep-exe? relative?)] @@ -1808,3 +1820,7 @@ [(list? p) (map mac-mred-collects-path-adjust p)] [(relative-path? p) (build-path 'up 'up 'up p)] [else p])) + +(define (find-relative-path* wrt-exe p) + (define-values (wrt base name) (split-path (path->complete-path wrt-exe))) + (find-relative-path (simplify-path wrt) (simplify-path p))) diff --git a/racket/collects/launcher/launcher.rkt b/racket/collects/launcher/launcher.rkt index bbf35b4b36..f1c3f58ab0 100644 --- a/racket/collects/launcher/launcher.rkt +++ b/racket/collects/launcher/launcher.rkt @@ -423,7 +423,9 @@ [(equal? cdir gdir) p] [else rel])) p)))) - (find-console-bin-dir))]) + (if (eq? kind 'mred) + (find-gui-bin-dir) + (find-console-bin-dir)))]) (if (let ([a (assq 'relative? aux)]) (and a (cdr a))) (make-relative-path-header dest bindir use-librktdir?) @@ -468,8 +470,11 @@ (when use-librktdir? (display "# {{{ librktdir\n") (display "librktdir=\"$bindir/") - (display (find-relative-path (find-console-bin-dir) - (find-lib-dir))) + (display (find-relative-path (simplify-path + (let-values ([(base name dir?) (split-path (path->complete-path dest))]) + base)) + (simplify-path + (find-lib-dir)))) (display "\"\n") (display "# }}} librktdir\n")) (newline) @@ -924,13 +929,13 @@ (string-append (if mred? file (unix-sfx file mred?)) ".exe")] [else file])) -(define (program-launcher-path name mred? user? tethered?) +(define (program-launcher-path name mred? user? tethered? console?) (let* ([variant (current-launcher-variant)] [mac-script? (and (eq? (cross-system-type) 'macosx) (script-variant? variant))]) (let ([p (add-file-suffix (build-path - (if (or mac-script? (not mred?)) + (if (or mac-script? (not mred?) console?) (if user? (or (and tethered? (find-addon-tethered-console-bin-dir)) @@ -953,10 +958,19 @@ (path-replace-extension p #".app") p)))) -(define (gracket-program-launcher-path name #:user? [user? #f] #:tethered? [tethered? #f]) - (program-launcher-path name #t user? tethered?)) -(define (mred-program-launcher-path name #:user? [user? #f] #:tethered? [tethered? #f]) - (gracket-program-launcher-path name #:user? user? #:tethered? tethered?)) +(define (gracket-program-launcher-path name + #:user? [user? #f] + #:tethered? [tethered? #f] + #:console? [console? #f]) + (program-launcher-path name #t user? tethered? console?)) +(define (mred-program-launcher-path name + #:user? [user? #f] + #:tethered? [tethered? #f] + #:console? [console? #f]) + (gracket-program-launcher-path name + #:user? user? + #:tethered? tethered? + #:console? console?)) (define (racket-program-launcher-path name #:user? [user? #f] #:tethered? [tethered? #f]) (case (cross-system-type) @@ -971,7 +985,7 @@ (unix-sfx name #f)) (current-launcher-variant) #f)] - [else (program-launcher-path name #f user? tethered?)])) + [else (program-launcher-path name #f user? tethered? #t)])) (define (mzscheme-program-launcher-path name #:user? [user? #f] #:tethered? [tethered? #f]) (racket-program-launcher-path name #:user? user? #:tethered? tethered?)) diff --git a/racket/collects/setup/dirs.rkt b/racket/collects/setup/dirs.rkt index b60419199c..db63babcf4 100644 --- a/racket/collects/setup/dirs.rkt +++ b/racket/collects/setup/dirs.rkt @@ -25,7 +25,7 @@ [(macosx unix) "bin"])) (define-finder provide - config:bin-dir + config:gui-bin-dir find-gui-bin-dir find-user-gui-bin-dir (case (cross-system-type) diff --git a/racket/collects/setup/private/dirs.rkt b/racket/collects/setup/private/dirs.rkt index 9715086475..f0429303b4 100644 --- a/racket/collects/setup/private/dirs.rkt +++ b/racket/collects/setup/private/dirs.rkt @@ -58,6 +58,8 @@ (define-config config:include-dir 'include-dir to-path) (define-config config:include-search-dirs 'include-search-dirs to-path) (define-config config:bin-dir 'bin-dir to-path) +(define-config config:gui-bin-dir/raw 'gui-bin-dir to-path) +(define config:gui-bin-dir (delay/sync (or (force config:gui-bin-dir/raw) (force config:bin-dir)))) (define-config config:config-tethered-console-bin-dir 'config-tethered-console-bin-dir to-path) (define-config config:config-tethered-gui-bin-dir 'config-tethered-gui-bin-dir to-path) (define-config config:man-dir 'man-dir to-path) @@ -271,6 +273,7 @@ ;; `setup/dirs` (provide config:bin-dir + config:gui-bin-dir config:config-tethered-console-bin-dir config:config-tethered-gui-bin-dir)