fix problems with distributing unix executables Merge to v5.0

This commit is contained in:
Matthew Flatt 2010-05-28 10:32:05 -06:00 committed by Matthew Flatt
parent 7f2d57e827
commit eec92017c4
2 changed files with 41 additions and 33 deletions

View File

@ -23,7 +23,7 @@
(case (system-type) (case (system-type)
[(windows) #f] [(windows) #f]
[(unix) "bin"] [(unix) "bin"]
[(macosx) (if (memq type '(mredcgc mred3m)) [(macosx) (if (memq type '(gracketcgc gracket3m))
#f #f
"bin")])) "bin")]))
orig-binaries orig-binaries
@ -38,7 +38,7 @@
(make-directory dest-dir)) (make-directory dest-dir))
(let-values ([(base name dir?) (split-path b)]) (let-values ([(base name dir?) (split-path b)])
(let ([dest (build-path dest-dir name)]) (let ([dest (build-path dest-dir name)])
(if (and (memq type '(mredcgc mred3m)) (if (and (memq type '(gracketcgc gracket3m))
(eq? 'macosx (system-type))) (eq? 'macosx (system-type)))
(begin (begin
(copy-app b dest) (copy-app b dest)
@ -51,7 +51,7 @@
types)] types)]
[single-mac-app? (and (eq? 'macosx (system-type)) [single-mac-app? (and (eq? 'macosx (system-type))
(= 1 (length types)) (= 1 (length types))
(memq (car types) '(mredcgc mred3m)))]) (memq (car types) '(gracketcgc gracket3m)))])
;; Create directories for libs, collects, and extensions: ;; Create directories for libs, collects, and extensions:
(let-values ([(lib-dir collects-dir relative-collects-dir exts-dir relative-exts-dir) (let-values ([(lib-dir collects-dir relative-collects-dir exts-dir relative-exts-dir)
(if single-mac-app? (if single-mac-app?
@ -110,7 +110,7 @@
[sub-dir [sub-dir
(build-path 'up relative-dir)] (build-path 'up relative-dir)]
[(and (eq? 'macosx (system-type)) [(and (eq? 'macosx (system-type))
(memq type '(mredcgc mred3m)) (memq type '(gracketcgc gracket3m))
(not single-mac-app?)) (not single-mac-app?))
(build-path 'up 'up 'up relative-dir)] (build-path 'up 'up 'up relative-dir)]
[else [else
@ -152,33 +152,33 @@
(list (list
"iconv.dll" "iconv.dll"
"UnicoWS.dll")) "UnicoWS.dll"))
(when (or (memq 'mzschemecgc types) (when (or (memq 'racketcgc types)
(memq 'mredcgc types)) (memq 'gracketcgc types))
(map copy-dll (map copy-dll
(list (list
(versionize "libracket~a.dll") (versionize "libracket~a.dll")
(versionize "libmzgc~a.dll")))) (versionize "libmzgc~a.dll"))))
(when (or (memq 'mzscheme3m types) (when (or (memq 'racket3m types)
(memq 'mred3m types)) (memq 'gracket3m types))
(map copy-dll (map copy-dll
(list (list
(versionize "libracket3m~a.dll")))) (versionize "libracket3m~a.dll"))))
(when (memq 'mredcgc types) (when (memq 'gracketcgc types)
(map copy-dll (map copy-dll
(list (list
(versionize "libgracket~a.dll")))) (versionize "libgracket~a.dll"))))
(when (memq 'mred3m types) (when (memq 'gracket3m types)
(map copy-dll (map copy-dll
(list (list
(versionize "libgracket3m~a.dll")))))] (versionize "libgracket3m~a.dll")))))]
[(macosx) [(macosx)
(when (memq 'mzschemecgc types) (when (memq 'racketcgc types)
(copy-framework "Racket" #f lib-dir)) (copy-framework "Racket" #f lib-dir))
(when (memq 'mzscheme3m types) (when (memq 'racket3m types)
(copy-framework "Racket" #t lib-dir)) (copy-framework "Racket" #t lib-dir))
(when (memq 'mredcgc types) (when (memq 'gracketcgc types)
(copy-framework "GRacket" #f lib-dir)) (copy-framework "GRacket" #f lib-dir))
(when (memq 'mred3m types) (when (memq 'gracket3m types)
(copy-framework "GRacket" #t lib-dir))] (copy-framework "GRacket" #t lib-dir))]
[(unix) [(unix)
(let ([lib-plt-dir (build-path lib-dir "plt")]) (let ([lib-plt-dir (build-path lib-dir "plt")])
@ -190,25 +190,25 @@
(format "~a~a" name (variant-suffix variant #f))) (format "~a~a" name (variant-suffix variant #f)))
(build-path lib-plt-dir (build-path lib-plt-dir
(format "~a~a-~a" name variant (version)))))]) (format "~a~a-~a" name variant (version)))))])
(when (memq 'mzschemecgc types) (when (memq 'racketcgc types)
(copy-bin "racket" 'cgc)) (copy-bin "racket" 'cgc))
(when (memq 'mzscheme3m types) (when (memq 'racket3m types)
(copy-bin "racket" '3m)) (copy-bin "racket" '3m))
(when (memq 'mredcgc types) (when (memq 'gracketcgc types)
(copy-bin "gracket" 'cgc)) (copy-bin "gracket" 'cgc))
(when (memq 'mred3m types) (when (memq 'gracket3m types)
(copy-bin "gracket" '3m))) (copy-bin "gracket" '3m)))
(when (shared-libraries?) (when (shared-libraries?)
(when (or (memq 'mzschemecgc types) (when (or (memq 'racketcgc types)
(memq 'mredcgc types)) (memq 'gracketcgc types))
(copy-shared-lib "racket" lib-dir) (copy-shared-lib "racket" lib-dir)
(copy-shared-lib "mzgc" lib-dir)) (copy-shared-lib "mzgc" lib-dir))
(when (or (memq 'mzscheme3m types) (when (or (memq 'racket3m types)
(memq 'mred3m types)) (memq 'gracket3m types))
(copy-shared-lib "racket3m" lib-dir)) (copy-shared-lib "racket3m" lib-dir))
(when (memq 'mredcgc types) (when (memq 'gracketcgc types)
(copy-shared-lib "gracket" lib-dir)) (copy-shared-lib "gracket" lib-dir))
(when (memq 'mred3m types) (when (memq 'gracket3m types)
(copy-shared-lib "gracket3m" lib-dir))))])) (copy-shared-lib "gracket3m" lib-dir))))]))
(define (search-dll dll-dir dll) (define (search-dll dll-dir dll)
@ -293,18 +293,18 @@
binaries)] binaries)]
[(macosx) [(macosx)
(if (and (= 1 (length types)) (if (and (= 1 (length types))
(memq (car types) '(mredcgc mred3m))) (memq (car types) '(gracketcgc gracket3m)))
;; Special case for single GRacket app: ;; Special case for single GRacket app:
(update-framework-path "@executable_path/../Frameworks/" (update-framework-path "@executable_path/../Frameworks/"
(car binaries) (car binaries)
#t) #t)
;; General case: ;; General case:
(for-each (lambda (b type) (for-each (lambda (b type)
(update-framework-path (if (memq type '(mzschemecgc mzscheme3m)) (update-framework-path (if (memq type '(racketcgc racket3m))
"@executable_path/../lib/" "@executable_path/../lib/"
"@executable_path/../../../lib/" ) "@executable_path/../../../lib/" )
b b
(memq type '(mredcgc mred3m)))) (memq type '(gracketcgc gracket3m))))
binaries types))] binaries types))]
[(unix) [(unix)
(for-each (lambda (b type) (for-each (lambda (b type)
@ -568,11 +568,11 @@
(let ([3m? (equal? (list-ref m 4) #"3")]) (let ([3m? (equal? (list-ref m 4) #"3")])
(if (equal? (caddr m) #"r") (if (equal? (caddr m) #"r")
(if 3m? (if 3m?
'mred3m 'gracket3m
'mredcgc) 'gracketcgc)
(if 3m? (if 3m?
'mzscheme3m 'racket3m
'mzschemecgc)))) 'racketcgc))))
(error 'assemble-distribution (error 'assemble-distribution
"file is not a PLT executable: ~e" "file is not a PLT executable: ~e"
b)))))) b))))))

View File

@ -229,7 +229,7 @@ int main(int argc, char **argv)
{ {
char *me = argv[0], *data, **new_argv; char *me = argv[0], *data, **new_argv;
char *exe_path, *lib_path, *dll_path; char *exe_path, *lib_path, *dll_path;
int start, prog_end, end, count, fd, v, x11; int start, prog_end, end, count, fd, v, en, x11;
int argpos, inpos, collcount = 1; int argpos, inpos, collcount = 1;
if (config[7] == '[') { if (config[7] == '[') {
@ -423,11 +423,19 @@ int main(int argc, char **argv)
/* Execute the original binary: */ /* Execute the original binary: */
v = execv(exe_path, new_argv); v = execv(exe_path, new_argv);
en = errno;
write_str(2, argv[0]); write_str(2, argv[0]);
write_str(2, ": failed to start "); write_str(2, ": failed to start ");
write_str(2, exe_path); write_str(2, exe_path);
write_str(2, "\n"); write_str(2, " (");
write_str(2, strerror(en));
write_str(2, ")\n");
if (*lib_path) {
write_str(2, " used library path ");
write_str(2, lib_path);
write_str(2, "\n");
}
return v; return v;
} }