Skip to content

Commit

Permalink
Recognize wider set of C file extensions (.c .C .cc .cp .cpp .CPP .cx…
Browse files Browse the repository at this point in the history
…x .c++ .m .M .mm)
  • Loading branch information
feeley committed May 19, 2011
1 parent 5d82751 commit 4f42f83
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 30 deletions.
23 changes: 14 additions & 9 deletions gsc/_gsclib.scm
@@ -1,8 +1,8 @@
;;;============================================================================

;;; File: "_gsclib.scm", Time-stamp: <2011-03-20 21:15:32 feeley>
;;; File: "_gsclib.scm"

;;; Copyright (c) 1994-2009 by Marc Feeley, All Rights Reserved.
;;; Copyright (c) 1994-2011 by Marc Feeley, All Rights Reserved.

(include "generic.scm")

Expand Down Expand Up @@ -74,7 +74,7 @@
(##path-strip-directory
(##path-strip-extension filename))
expanded-output)
".c")))
(c#targ-preferred-c-file-extension))))
(c-filename-no-dir-no-ext
(##path-strip-directory
(##path-strip-extension c-filename))))
Expand Down Expand Up @@ -175,10 +175,13 @@
root
(generate-next-version-of-object-file root)))))

(let* ((c-filename
(##string-append (##path-strip-extension filename) ".c"))
(input-is-c-file?
(##string=? filename c-filename))
(let* ((input-is-c-file?
(##assoc (##path-extension filename) c#targ-c-file-extensions))
(c-filename
(if input-is-c-file?
filename
(##string-append (##path-strip-extension filename)
(c#targ-preferred-c-file-extension))))
(expanded-output
(##path-normalize output))
(output-filename
Expand Down Expand Up @@ -369,7 +372,8 @@
(if (##eq? output (macro-absent-obj))
(##path-directory
(##path-normalize
(##string-append (##car rev-mods) ".c")))
(##string-append (##car rev-mods)
(c#targ-preferred-c-file-extension))))
(macro-force-vars (output)
output)))
(baselib
Expand Down Expand Up @@ -441,7 +445,8 @@
(if (##eq? output (macro-absent-obj))
(##path-directory
(##path-normalize
(##string-append (##car rev-mods) ".c")))
(##string-append (##car rev-mods)
(c#targ-preferred-c-file-extension))))
(macro-force-vars (output)
output)))
(warn?
Expand Down
10 changes: 8 additions & 2 deletions gsc/_host.scm
@@ -1,8 +1,8 @@
;;;============================================================================

;;; File: "_host.scm", Time-stamp: <2009-07-31 10:22:27 feeley>
;;; File: "_host.scm"

;;; Copyright (c) 1994-2007 by Marc Feeley, All Rights Reserved.
;;; Copyright (c) 1994-2011 by Marc Feeley, All Rights Reserved.

;;;============================================================================

Expand Down Expand Up @@ -314,6 +314,10 @@
(string-set! result (- j i) (string-ref path j))
(loop2 (- j 1)))))))))

(define scheme-file-extensions
'((".scm" . #f)
(".six" . six)))

;; Bytevector data types.

(define s8vect-tag (list 's8vect))
Expand Down Expand Up @@ -791,6 +795,8 @@
(define (path-strip-directory path)
(##path-strip-directory path))

(define scheme-file-extensions ##scheme-file-extensions)

(define (make-s8vect n) (##make-s8vector n 0))
(define s8vect? ##s8vector?)
(define s8vect->list ##s8vector->list)
Expand Down
12 changes: 4 additions & 8 deletions gsc/_source.scm
@@ -1,8 +1,8 @@
;;;============================================================================

;;; File: "_source.scm", Time-stamp: <2009-02-16 14:58:03 feeley>
;;; File: "_source.scm"

;;; Copyright (c) 1994-2009 by Marc Feeley, All Rights Reserved.
;;; Copyright (c) 1994-2011 by Marc Feeley, All Rights Reserved.

(include "fixnum.scm")

Expand Down Expand Up @@ -321,7 +321,7 @@
(if expanded-filename
(if (equal? (path-extension expanded-filename) "")

(let loop ((exts scm-file-exts))
(let loop ((exts (append (map car scheme-file-extensions) '(""))))
(if (pair? exts)
(let* ((ext (car exts))
(full-name (string-append expanded-filename ext))
Expand Down Expand Up @@ -390,10 +390,6 @@

sources)))

;; Filename extensions to try in order to find source files from module name.

(define scm-file-exts '(".scm" ".six" "")) ; "" means no extension

(define (read-source path relative-to-path try-scheme-file-extensions?)

(define (read-source-from-path path)
Expand Down Expand Up @@ -1545,7 +1541,7 @@
(if expanded-filename
(if (equal? (path-extension expanded-filename) "")

(let loop ((exts scm-file-exts))
(let loop ((exts (append (map car scheme-file-extensions) '(""))))
(if (pair? exts)
(let* ((ext (car exts))
(full-name (string-append expanded-filename ext))
Expand Down
27 changes: 22 additions & 5 deletions gsc/_t-c-1.scm
@@ -1,8 +1,8 @@
;;;============================================================================

;;; File: "_t-c-1.scm", Time-stamp: <2010-06-10 15:24:05 feeley>
;;; File: "_t-c-1.scm"

;;; Copyright (c) 1994-2010 by Marc Feeley, All Rights Reserved.
;;; Copyright (c) 1994-2011 by Marc Feeley, All Rights Reserved.

(include "fixnum.scm")

Expand Down Expand Up @@ -317,7 +317,7 @@

(targ-heap-dump
(or output
(string-append output-root ".c"))
(string-append output-root (targ-preferred-c-file-extension)))
(proc-obj-name (car procs))
c-decls
c-inits
Expand Down Expand Up @@ -770,12 +770,12 @@
(path-strip-extension output)))
(out
(or output
(string-append root ".c")))
(string-append root (targ-preferred-c-file-extension))))
(name
(string-append module-prefix
(path-strip-directory root)))
(input-files
(map (lambda (x) (string-append x ".c")) inputs))
(map (lambda (x) (string-append x (targ-preferred-c-file-extension))) inputs))
(input-infos
(map targ-read-linker-info input-files))
(input-mods
Expand Down Expand Up @@ -2215,4 +2215,21 @@
(define (targ-name->c-id s)
(scheme-id->c-id s))

(define targ-c-file-extensions #f)
(set! targ-c-file-extensions
'((".c" . C)
(".C" . C++)
(".cc" . C++)
(".cp" . C++)
(".cpp" . C++)
(".CPP" . C++)
(".cxx" . C++)
(".c++" . C++)
(".m" . Objective-C)
(".M" . Objective-C++)
(".mm" . Objective-C++)))

(define (targ-preferred-c-file-extension)
(caar targ-c-file-extensions))

;;;----------------------------------------------------------------------------
6 changes: 3 additions & 3 deletions gsi/main.scm
@@ -1,8 +1,8 @@
;;;============================================================================

;;; File: "main.scm", Time-stamp: <2011-01-24 11:54:13 feeley>
;;; File: "main.scm"

;;; Copyright (c) 1994-2009 by Marc Feeley, All Rights Reserved.
;;; Copyright (c) 1994-2011 by Marc Feeley, All Rights Reserved.

;;;----------------------------------------------------------------------------

Expand Down Expand Up @@ -113,7 +113,7 @@
(define (compiler-batch-mode options arguments)

(define (c-file? file)
(##string=? (##path-extension file) ".c"))
(##assoc (##path-extension file) c#targ-c-file-extensions))

(define (obj-file? file)
(##string=? (##path-extension file) ##os-obj-extension-string-saved))
Expand Down
2 changes: 1 addition & 1 deletion include/stamp.h
Expand Up @@ -3,4 +3,4 @@
*/

#define ___STAMP_YMD 20110519
#define ___STAMP_HMS 134826
#define ___STAMP_HMS 175028
4 changes: 2 additions & 2 deletions lib/_io.scm
@@ -1,8 +1,8 @@
;;;============================================================================

;;; File: "_io.scm", Time-stamp: <2010-01-07 12:06:38 feeley>
;;; File: "_io.scm"

;;; Copyright (c) 1994-2010 by Marc Feeley, All Rights Reserved.
;;; Copyright (c) 1994-2011 by Marc Feeley, All Rights Reserved.

;;;============================================================================

Expand Down

0 comments on commit 4f42f83

Please sign in to comment.