moved find-exe to its own top-level file

This commit is contained in:
Robby Findler 2011-02-08 15:08:34 -06:00
parent b962c6f166
commit e096e4d5a4
3 changed files with 59 additions and 42 deletions

View File

@ -16,7 +16,8 @@
"private/macfw.ss"
"private/mach-o.ss"
"private/windlldir.ss"
"private/collects-path.ss")
"private/collects-path.ss"
"find-exe.rkt")
(provide compiler:embed@)
@ -61,47 +62,6 @@
(path-replace-suffix name #"")))
dest))
;; Find executable relative to the "mzlib"
;; collection.
(define (find-exe mred? variant)
(let* ([base (if mred?
(find-gui-bin-dir)
(find-console-bin-dir))]
[fail
(lambda ()
(error 'create-embedding-executable
"can't find ~a executable for variant ~a"
(if mred? "GRacket" "Racket")
variant))])
(let ([exe (build-path
base
(case (system-type)
[(macosx)
(cond
[(not mred?)
;; Need Racket:
(string-append "racket" (variant-suffix variant #f))]
[mred?
;; Need GRacket:
(let ([sfx (variant-suffix variant #t)])
(build-path (format "GRacket~a.app" sfx)
"Contents" "MacOS"
(format "GRacket~a" sfx)))])]
[(windows)
(format "~a~a.exe" (if mred?
"Gracket"
"Racket")
(variant-suffix variant #t))]
[(unix)
(format "~a~a" (if mred?
"gracket"
"racket")
(variant-suffix variant #f))]))])
(unless (or (file-exists? exe)
(directory-exists? exe))
(fail))
exe)))
(define exe-suffix?
(delay (equal? #"i386-cygwin" (path->bytes (system-library-subpath)))))

View File

@ -0,0 +1,45 @@
#lang racket/base
(require setup/dirs
setup/variant)
(provide find-exe)
;; Find executable relative to the "mzlib"
;; collection.
(define (find-exe mred? [variant (system-type 'gc)])
(let* ([base (if mred?
(find-gui-bin-dir)
(find-console-bin-dir))]
[fail
(lambda ()
(error 'find-exe
"can't find ~a executable for variant ~a"
(if mred? "GRacket" "Racket")
variant))])
(let ([exe (build-path
base
(case (system-type)
[(macosx)
(cond
[(not mred?)
;; Need Racket:
(string-append "racket" (variant-suffix variant #f))]
[mred?
;; Need GRacket:
(let ([sfx (variant-suffix variant #t)])
(build-path (format "GRacket~a.app" sfx)
"Contents" "MacOS"
(format "GRacket~a" sfx)))])]
[(windows)
(format "~a~a.exe" (if mred?
"Gracket"
"Racket")
(variant-suffix variant #t))]
[(unix)
(format "~a~a" (if mred?
"gracket"
"racket")
(variant-suffix variant #f))]))])
(unless (or (file-exists? exe)
(directory-exists? exe))
(fail))
exe)))

View File

@ -425,3 +425,15 @@ Includes the identifiers provided by @racketmodname[compiler/embed].}
@defthing[compiler:embed@ unit?]{
A unit that imports nothing and exports @racket[compiler:embed^].}
@section{Finding the name of the executable}
@defmodule[compiler/find-exe]
@defproc[(find-exe [gracket? boolean?]
[variant (or/c 'cgc '3m) (system-type 'gc)])
path?]{
Finds the path to the racket (or gracket) executable.
}