Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow a wider range of C file extensions (e.g. .m, .cpp, ...) when li…

…nking (gsc -link)
  • Loading branch information...
commit 2e89dcd3defadc98677bad6bfe8f2eeb593c51cf 1 parent 394beeb
@feeley authored
Showing with 79 additions and 69 deletions.
  1. +18 −11 doc/gambit-c.txi
  2. +13 −13 gsc/_gsclib.scm
  3. +5 −1 gsc/_t-c-1.scm
  4. +43 −44 gsi/main.scm
View
29 doc/gambit-c.txi
@@ -773,14 +773,17 @@ file unless the @samp{-f} option is specified.
@flindex @var{file}.six
@flindex @var{file}.c
In batch mode @code{gsc} takes a set of file names (with either no
-extension, or a @samp{.c} extension, or some other extension) on the
+extension, or a C file extension, or some other extension) on the
command line and compiles each Scheme file into a C file.
+The recognized C file extensions are @samp{.c}, @samp{.C}, @samp{.cc},
+@samp{.cp}, @samp{.cpp}, @samp{.CPP}, @samp{.cxx}, @samp{.c++},
+@samp{.m}, @samp{.M}, and @samp{.mm}.
The extension can be omitted from @var{file} when the Scheme file has a
@samp{.scm} or @samp{.six} extension. When the extension of the
Scheme file is @samp{.six} the content of the file will be parsed
using the Scheme infix syntax extension (see @ref{Scheme infix syntax
extension}). Otherwise, @code{gsc} will parse the Scheme file using the
-normal Scheme prefix syntax. Files with a @samp{.c} extension must
+normal Scheme prefix syntax. Files with a C file extension must
have been previously produced by @code{gsc}, with the @samp{-c} option,
and are used by Gambit's linker.
@@ -1549,7 +1552,10 @@ Gambit @value{VERSION}
@cindex object file
The @var{file}, @var{options}, and @var{output} parameters have the
-same meaning as for the @code{compile-file-to-c} procedure. The
+same meaning as for the @code{compile-file-to-c} procedure, except that
+@var{file} may be a Scheme source file or a
+C file possibly generated by the Gambit Scheme compiler (for example
+with the @code{compile-file-to-c} procedure). The
@var{cc-options} parameter is a string containing the options to pass
to the C compiler and the @var{ld-options-prelude} and
@var{ld-options} parameters are strings containing the options to pass
@@ -1561,9 +1567,7 @@ The @code{compile-file} procedure compiles the source file @var{file}
into an object file, which is either a file dynamically loadable using
the @code{load} procedure, or a C linkable object file destined to be
linked with the C linker (for example to create a standalone
-executable program). The @var{file} may be a Scheme source file or a
-C file possibly generated by the Gambit Scheme compiler (for example
-with the @code{compile-file-to-c} procedure). The presence of the
+executable program). The presence of the
@code{obj} option in @var{options} will cause the creation of a C
linkable object file and therefore the options
@var{ld-options-prelude} and @var{ld-options} are ignored, otherwise a
@@ -1631,10 +1635,11 @@ hello
@pindex gsc
The first parameter must be a non empty list of strings naming Scheme
-modules to link (extensions must be omitted). An incremental link
+modules to link (the file extension may be omitted). An incremental link
file is generated for the modules specified in @var{module-list}. By
default the link file generated is named @samp{@var{last}_.c}, where
-@var{last} is the name of the last module. The name of the generated
+@var{last} is the name of the last module, without the file extension.
+The name of the generated
link file can be specified with the @var{output} parameter. If
@var{output} is a string naming a directory then the link file is
created in that directory. Otherwise the name of the link file is
@@ -1643,7 +1648,8 @@ created in that directory. Otherwise the name of the link file is
The base link file is specified by the @var{base} parameter, which
must be a string. By default the base link file is the Gambit runtime
library link file @samp{~~lib/_gambc.c}. However, when @var{base} is
-supplied the base link file is named @samp{@var{base}.c}.
+supplied it is the name of the base link file (the file extension
+may be omitted).
The @var{warnings?} parameter controls whether warnings are
generated for undefined references.
@@ -1685,9 +1691,10 @@ world
@pindex gsc
The first parameter must be a non empty list of strings naming Scheme
-modules to link. The first string must be the name of a Scheme module
+modules to link (the file extension may be omitted). The first string
+must be the name of a Scheme module
or the name of a link file and the remaining strings must name Scheme
-modules (in all cases extensions must be omitted). A flat link file
+modules. A flat link file
is generated for the modules specified in @var{module-list}. By
default the link file generated is named @samp{@var{last}_.c}, where
@var{last} is the name of the last module. The name of the generated
View
26 gsc/_gsclib.scm
@@ -74,16 +74,14 @@
(##path-strip-directory
(##path-strip-extension filename))
expanded-output)
- (c#targ-preferred-c-file-extension))))
- (c-filename-no-dir-no-ext
- (##path-strip-directory
- (##path-strip-extension c-filename))))
+ (c#targ-preferred-c-file-extension)))))
(and (c#cf filename
#f
options
c-filename
(or mod-name
- c-filename-no-dir-no-ext))
+ (##path-strip-directory
+ (##path-strip-extension c-filename))))
c-filename)))
(define (compile-file
@@ -371,9 +369,7 @@
(let* ((out
(if (##eq? output (macro-absent-obj))
(##path-directory
- (##path-normalize
- (##string-append (##car rev-mods)
- (c#targ-preferred-c-file-extension))))
+ (##path-normalize (##car rev-mods)))
(macro-force-vars (output)
output)))
(baselib
@@ -411,7 +407,10 @@
expanded-output
(##path-expand
(##path-strip-directory
- (##string-append (##car rev-mods) "_.c"))
+ (##string-append
+ (##path-strip-extension (##car rev-mods))
+ "_"
+ (c#targ-preferred-c-file-extension)))
expanded-output)))
(base-and-mods
(##cons base (##reverse rev-mods))))
@@ -444,9 +443,7 @@
(let* ((out
(if (##eq? output (macro-absent-obj))
(##path-directory
- (##path-normalize
- (##string-append (##car rev-mods)
- (c#targ-preferred-c-file-extension))))
+ (##path-normalize (##car rev-mods)))
(macro-force-vars (output)
output)))
(warn?
@@ -471,7 +468,10 @@
expanded-output
(##path-expand
(##path-strip-directory
- (##string-append (##car rev-mods) "_.c"))
+ (##string-append
+ (##path-strip-extension (##car rev-mods))
+ "_"
+ (c#targ-preferred-c-file-extension)))
expanded-output)))
(mods
(##reverse rev-mods)))
View
6 gsc/_t-c-1.scm
@@ -775,7 +775,11 @@
(string-append module-prefix
(path-strip-directory root)))
(input-files
- (map (lambda (x) (string-append x (targ-preferred-c-file-extension))) inputs))
+ (map (lambda (x)
+ (if (string=? (path-extension x) "")
+ (string-append x (targ-preferred-c-file-extension))
+ x))
+ inputs))
(input-infos
(map targ-read-linker-info input-files))
(input-mods
View
87 gsi/main.scm
@@ -405,46 +405,44 @@
(if (##memq type '(link exe))
- (let ((roots
- (and (##pair? rev-gen-c-files)
- (let* ((roots
- (##map ##path-strip-extension
- (##reverse rev-gen-c-files)))
- (link-file
- (if flat?
- (if (and output
- (##eq? type 'link))
- (link-flat roots
- output: output)
- (link-flat roots))
- (if (and output
- (##eq? type 'link))
- (if base
- (link-incremental
- roots
- output: output
- base: base)
- (link-incremental
- roots
- output: output))
- (if base
- (link-incremental
- roots
- base: base)
- (link-incremental
- roots))))))
- (add-gen-c-file link-file)
- (if (##eq? type 'exe)
- (let ((obj-link-file
- (do-compile-file
- link-file
- (##cons 'obj sym-opts)
- #f)))
- (add-obj-file obj-link-file)
- (add-tmp-file obj-link-file)
- (if (##not (##memq 'keep-c sym-opts))
- (add-tmp-file link-file))))
- roots))))
+ (let ((gen-c-files
+ (##reverse rev-gen-c-files)))
+
+ (if (##pair? gen-c-files)
+ (let* ((link-file
+ (if flat?
+ (if (and output
+ (##eq? type 'link))
+ (link-flat gen-c-files
+ output: output)
+ (link-flat gen-c-files))
+ (if (and output
+ (##eq? type 'link))
+ (if base
+ (link-incremental
+ gen-c-files
+ output: output
+ base: base)
+ (link-incremental
+ gen-c-files
+ output: output))
+ (if base
+ (link-incremental
+ gen-c-files
+ base: base)
+ (link-incremental
+ gen-c-files))))))
+ (add-gen-c-file link-file)
+ (if (##eq? type 'exe)
+ (let ((obj-link-file
+ (do-compile-file
+ link-file
+ (##cons 'obj sym-opts)
+ #f)))
+ (add-obj-file obj-link-file)
+ (add-tmp-file obj-link-file)
+ (if (##not (##memq 'keep-c sym-opts))
+ (add-tmp-file link-file))))))
(if (##eq? type 'exe)
(and (##pair? rev-obj-files)
@@ -461,10 +459,11 @@
expanded-output)))
expanded-output
(##string-append
- (if roots
- (##car (##reverse roots))
- (##path-strip-extension
- (##car rev-obj-files)))
+ (##path-strip-extension
+ (##car
+ (if (##pair? gen-c-files)
+ (##reverse gen-c-files)
+ rev-obj-files)))
##os-exe-extension-string-saved))))))))
(if flat?
Please sign in to comment.
Something went wrong with that request. Please try again.