[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-hackers] [PATCH] always use temporary filenames in csc
From: |
.alyn.post. |
Subject: |
Re: [Chicken-hackers] [PATCH] always use temporary filenames in csc |
Date: |
Wed, 7 Nov 2012 12:29:34 -0700 |
It would nice if create-temporary-file also accepted a prefix
option, so that file.scm compiled to something like file-XXXXX.scm,
rather than XXXXX.scm.
Such a thing shouldn't hold up this patch, but it would make it
easier to sort out the results from the -k (keep) option and others
flags like it.
And thank you for this Felix, I saw right away *why* such a thing
had happened, and that a fix would not be naively straightforward.
-Alan
On Wed, Nov 07, 2012 at 08:15:32PM +0100, Felix wrote:
> The attached patch modifies csc to use temporary files (as created
> by "create-temporary-file") for intermediate .c and .o files. This
> is actually trickier than it sounds. The tests succeed so far,
> but there may be corner cases that are not covered yet.
>
> This fixes #946, which was reported by Alan Post.
>
>
> cheers,
> felix
> From 9ddf370a73a8e6df3e71ffbf6d3df09c314a7477 Mon Sep 17 00:00:00 2001
> From: felix <address@hidden>
> Date: Tue, 6 Nov 2012 21:29:33 +0100
> Subject: [PATCH] use temporary files in csc where possible
>
> ---
> csc.scm | 46 +++++++++++++++++++++++++++++-----------------
> 1 files changed, 29 insertions(+), 17 deletions(-)
>
> diff --git a/csc.scm b/csc.scm
> index 21c416e..7bc2a48 100644
> --- a/csc.scm
> +++ b/csc.scm
> @@ -802,13 +802,15 @@ EOF
> (define (run-translation)
> (for-each
> (lambda (f)
> - (let ([fc (pathname-replace-extension
> - (if (= 1 (length scheme-files))
> - target-filename
> - f)
> - (cond (cpp-mode "cpp")
> + (let ((ext (cond (cpp-mode "cpp")
> (objc-mode "m")
> - (else "c") ) ) ] )
> + (else "c") ) )
> + (fc #f))
> + (cond (translate-only
> + (set! fc (pathname-replace-extension f ext)))
> + (else
> + (set! fc (create-temporary-file ext))
> + (set! generated-c-files (cons fc generated-c-files))))
> (command
> (string-intersperse
> (cons* translator (quotewrap f)
> @@ -827,9 +829,7 @@ EOF
> (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))
>
>
> @@ -838,8 +838,19 @@ EOF
> (define (run-compilation)
> (let ((ofiles '()))
> (for-each
> - (lambda (f)
> - (let ([fo (pathname-replace-extension f object-extension)])
> + (lambda (p)
> + (let ((f (car p))
> + (fo #f))
> + (cond (compile-only
> + (set! fo
> + (pathname-replace-extension
> + (if (cdr p)
> + f
> + target-filename)
> + object-extension)))
> + (else
> + (set! fo (create-temporary-file object-extension))
> + (set! generated-object-files (cons fo generated-object-files))))
> (command
> (string-intersperse
> (list (cond (cpp-mode c++-compiler)
> @@ -850,10 +861,10 @@ EOF
> (if (and cpp-mode (string=? "g++" c++-compiler))
> "-Wno-write-strings"
> "")
> - (compiler-options) ) ) )
> - (set! generated-object-files (cons fo generated-object-files))
> - (set! ofiles (cons fo ofiles))))
> - c-files)
> + (compiler-options) ) ) )))
> + (append
> + (map (cut cons <> #f) generated-c-files)
> + (map (cut cons <> #t) c-files)))
> (when (and generate-manifest (eq? 'windows (software-type)))
> (let ((rcf (pathname-replace-extension target-filename "rc")))
> (create-win-manifest (pathname-file target-filename) rcf)
> @@ -885,7 +896,7 @@ EOF
> ;;; Link object files and libraries:
>
> (define (run-linking)
> - (let* ((files (map quotewrap object-files))
> + (let* ((files (map quotewrap (append generated-object-files object-files)))
> (target (quotewrap target-filename))
> (targetdir #f))
> (when deploy
> @@ -938,7 +949,8 @@ EOF
> (create-mac-bundle
> (pathname-file target-filename)
> targetdir)))
> - (unless keep-files (for-each $delete-file generated-object-files)) ) )
> + (unless keep-files
> + (for-each $delete-file generated-object-files)) ) )
>
> (define (lib-path)
> (prefix ""
> --
> 1.7.0.4
>
> _______________________________________________
> Chicken-hackers mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/chicken-hackers
--
.i ma'a lo bradi cu penmi gi'e du