From 3288c5a2f77ab523c43b8fb47893b32b886c9c75 Mon Sep 17 00:00:00 2001 From: Jim Ursetto Date: Wed, 13 Apr 2016 21:04:54 -0500 Subject: [PATCH 1/3] Replace csc shell out to chicken with direct call (#1277) Calls to chicken using the (system) call are changed to use (process-run) instead, permitting blacklisted environment variables such as DYLD_LIBRARY_PATH to work on OS X 10.11, and addressing a problem with `make check` in bug #1277. --- csc.scm | 63 ++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/csc.scm b/csc.scm index 07cb67b..5fa5246 100644 --- a/csc.scm +++ b/csc.scm @@ -94,8 +94,11 @@ (string-translate path #\\ #\/) path)) +(define (normalize str) + (back-slash->forward-slash (normalize-pathname str))) + (define (quotewrap str) - (qs (back-slash->forward-slash (normalize-pathname str)))) + (qs (normalize str))) (define (quotewrap-no-slash-trans str) (qs (normalize-pathname str))) @@ -104,11 +107,11 @@ (prefix "" "share" (if host-mode INSTALL_SHARE_HOME TARGET_SHARE_HOME))) (define translator - (quotewrap + (normalize (prefix "chicken" "bin" - (make-pathname - INSTALL_BIN_HOME - CHICKEN_PROGRAM)))) + (make-pathname + INSTALL_BIN_HOME + CHICKEN_PROGRAM)))) (define compiler (quotewrap (if host-mode INSTALL_CC TARGET_CC))) (define c++-compiler (quotewrap (if host-mode INSTALL_CXX TARGET_CXX))) @@ -834,25 +837,24 @@ EOF (when (member fc c-files) (stop "C file generated from `~a' will overwrite explicitly given source file `~a'" f fc)) - (command - (string-intersperse - (cons* translator (quotewrap f) - (append + (exec + translator + (cons (normalize f) + (append (if to-stdout '("-to-stdout") - `("-output-file" ,(quotewrap fc)) ) + `("-output-file" ,fc)) (if (##sys#fudge 13) '("-:d") '()) - (map quote-option - (append - extra-features - translate-options - (cond (cpp-mode '("-feature" "chicken-scheme-to-c++")) - (objc-mode '("-feature" "chicken-scheme-to-objc")) - (else '())) - translation-optimization-options)) ) ) - " ") ) + (append + extra-features + translate-options + (cond (cpp-mode '("-feature" "chicken-scheme-to-c++")) + (objc-mode '("-feature" "chicken-scheme-to-objc")) + (else '())) + translation-optimization-options)) + )) (set! c-files (append (list fc) c-files)) (set! generated-c-files (append (list fc) generated-c-files)))) scheme-files)) @@ -1066,6 +1068,29 @@ EOF (unless (zero? ($system str)) (exit last-exit-code))) +(define ($exec cmd args) + (let ((str (string-intersperse (cons cmd args)))) ; no quoting is rendered + (when verbose (print str)) + (receive (_ normal return-code) + (if dry-run + (values #f #t 0) + (process-wait (process-run cmd args))) + (cond ((= 0 return-code) + (if normal + 0 + (error '$exec "unexpected 0 return code with abnormal exit"))) + (normal + (printf "\nError: command terminated with non-zero exit status ~S: ~A~%" return-code str) + 1) + (else + (printf "\nError: command terminated on signal ~S: ~A~%" return-code str) + 1))))) + +(define (exec cmd args) + (let ((rc ($exec cmd args))) + (unless (= 0 rc) + (exit rc)))) + (define ($delete-file str) (when verbose (print "rm " str) ) -- 2.2.1