deprecate use of include path to find the input file for behaviour that is compatible with other compilers and interopability for ccache
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10936 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a41c66d9a4
commit
533ccb5097
7 changed files with 43 additions and 21 deletions
|
|
@ -1,6 +1,11 @@
|
||||||
Version 1.3.37 (in progress)
|
Version 1.3.37 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2008-11-21: wsfulton
|
||||||
|
The use of the include path to find the input file is now deprecated.
|
||||||
|
This makes the behaviour of SWIG the same as C/C++ compilers in preparation
|
||||||
|
for use with ccache.
|
||||||
|
|
||||||
2008-11-16: wsfulton
|
2008-11-16: wsfulton
|
||||||
Fix -nopreprocess option to:
|
Fix -nopreprocess option to:
|
||||||
- correctly report file names in warning and error messages.
|
- correctly report file names in warning and error messages.
|
||||||
|
|
|
||||||
|
|
@ -1886,16 +1886,19 @@ fragment_directive: FRAGMENT LPAREN fname COMMA kwargs RPAREN HBLOCK {
|
||||||
;
|
;
|
||||||
|
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
%includefile "filename" [ declarations ]
|
%includefile "filename" [option1="xyz", ...] [ declarations ]
|
||||||
%importfile "filename" [ declarations ]
|
%importfile "filename" [option1="xyz", ...] [ declarations ]
|
||||||
------------------------------------------------------------ */
|
------------------------------------------------------------ */
|
||||||
|
|
||||||
include_directive: includetype options string LBRACKET {
|
include_directive: includetype options string LBRACKET {
|
||||||
$1.filename = Copy(cparse_file);
|
$1.filename = Copy(cparse_file);
|
||||||
$1.line = cparse_line;
|
$1.line = cparse_line;
|
||||||
scanner_set_location(NewString($3),1);
|
scanner_set_location(NewString($3),1);
|
||||||
if ($2 && GetFlag($2, "maininput"))
|
if ($2) {
|
||||||
scanner_set_main_input_file(NewString($3));
|
String *maininput = Getattr($2, "maininput");
|
||||||
|
if (maininput)
|
||||||
|
scanner_set_main_input_file(NewString(maininput));
|
||||||
|
}
|
||||||
} interface RBRACKET {
|
} interface RBRACKET {
|
||||||
String *mname = 0;
|
String *mname = 0;
|
||||||
$$ = $6;
|
$$ = $6;
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@
|
||||||
#define WARN_DEPRECATED_NOEXTERN 122
|
#define WARN_DEPRECATED_NOEXTERN 122
|
||||||
#define WARN_DEPRECATED_NODEFAULT 123
|
#define WARN_DEPRECATED_NODEFAULT 123
|
||||||
#define WARN_DEPRECATED_TYPEMAP_LANG 124
|
#define WARN_DEPRECATED_TYPEMAP_LANG 124
|
||||||
|
#define WARN_DEPRECATED_INPUT_FILE 125
|
||||||
|
|
||||||
/* -- Preprocessor -- */
|
/* -- Preprocessor -- */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -947,7 +947,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
||||||
if (!s) {
|
if (!s) {
|
||||||
fprintf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file);
|
fprintf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file);
|
||||||
} else {
|
} else {
|
||||||
FILE *f = Swig_open(outfile);
|
FILE *f = Swig_include_open(outfile);
|
||||||
if (f) {
|
if (f) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
fprintf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile);
|
fprintf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile);
|
||||||
|
|
@ -974,17 +974,22 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
||||||
String *fs = NewString("");
|
String *fs = NewString("");
|
||||||
FILE *df = Swig_open(input_file);
|
FILE *df = Swig_open(input_file);
|
||||||
if (!df) {
|
if (!df) {
|
||||||
char *cfile = Char(input_file);
|
df = Swig_include_open(input_file);
|
||||||
if (cfile && cfile[0] == '-') {
|
if (!df) {
|
||||||
Printf(stderr, "Unable to find option or file '%s', ", input_file);
|
char *cfile = Char(input_file);
|
||||||
Printf(stderr, "use 'swig -help' for more information.\n");
|
if (cfile && cfile[0] == '-') {
|
||||||
|
Printf(stderr, "Unable to find option or file '%s', ", input_file);
|
||||||
|
Printf(stderr, "use 'swig -help' for more information.\n");
|
||||||
|
} else {
|
||||||
|
Printf(stderr, "Unable to find file '%s'.\n", input_file);
|
||||||
|
}
|
||||||
|
SWIG_exit(EXIT_FAILURE);
|
||||||
} else {
|
} else {
|
||||||
Printf(stderr, "Unable to find file '%s'.\n", input_file);
|
Swig_warning(WARN_DEPRECATED_INPUT_FILE, "SWIG", 1, "Use of the include path to find the input file is deprecated and will not work with ccache. Please include the path when specifying the input file.\n"); // so that behaviour is like c/c++ compilers
|
||||||
}
|
}
|
||||||
SWIG_exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
fclose(df);
|
|
||||||
if (!no_cpp) {
|
if (!no_cpp) {
|
||||||
|
fclose(df);
|
||||||
Printf(fs, "%%include <swig.swg>\n");
|
Printf(fs, "%%include <swig.swg>\n");
|
||||||
if (allkw) {
|
if (allkw) {
|
||||||
Printf(fs, "%%include <allkw.swg>\n");
|
Printf(fs, "%%include <allkw.swg>\n");
|
||||||
|
|
@ -992,7 +997,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
||||||
if (lang_config) {
|
if (lang_config) {
|
||||||
Printf(fs, "\n%%include <%s>\n", lang_config);
|
Printf(fs, "\n%%include <%s>\n", lang_config);
|
||||||
}
|
}
|
||||||
Printf(fs, "%%include(maininput=1) \"%s\"\n", Swig_last_file());
|
Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", input_file, Swig_last_file());
|
||||||
for (i = 0; i < Len(libfiles); i++) {
|
for (i = 0; i < Len(libfiles); i++) {
|
||||||
Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i));
|
Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i));
|
||||||
}
|
}
|
||||||
|
|
@ -1000,8 +1005,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
||||||
cpps = Preprocessor_parse(fs);
|
cpps = Preprocessor_parse(fs);
|
||||||
Delete(fs);
|
Delete(fs);
|
||||||
} else {
|
} else {
|
||||||
df = Swig_open(input_file);
|
|
||||||
cpps = Swig_read_file(df);
|
cpps = Swig_read_file(df);
|
||||||
|
fclose(df);
|
||||||
}
|
}
|
||||||
if (Swig_error_count()) {
|
if (Swig_error_count()) {
|
||||||
SWIG_exit(EXIT_FAILURE);
|
SWIG_exit(EXIT_FAILURE);
|
||||||
|
|
|
||||||
|
|
@ -1624,7 +1624,7 @@ public:
|
||||||
} else if (Strcmp(code, "include") == 0) {
|
} else if (Strcmp(code, "include") == 0) {
|
||||||
/* Include a file into the .pm file */
|
/* Include a file into the .pm file */
|
||||||
if (value) {
|
if (value) {
|
||||||
FILE *f = Swig_open(value);
|
FILE *f = Swig_include_open(value);
|
||||||
if (!f) {
|
if (!f) {
|
||||||
Printf(stderr, "%s : Line %d. Unable to locate file %s\n", input_file, line_number, value);
|
Printf(stderr, "%s : Line %d. Unable to locate file %s\n", input_file, line_number, value);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -151,10 +151,11 @@ List *Swig_search_path() {
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Swig_open()
|
* Swig_open()
|
||||||
*
|
*
|
||||||
* Looks for a file and open it. Returns an open FILE * on success.
|
* open a file, optionally looking for it in the include path. Returns an open
|
||||||
|
* FILE * on success.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static FILE *Swig_open_any(const String_or_char *name, int sysfile) {
|
static FILE *Swig_open_file(const String_or_char *name, int sysfile, int use_include_path) {
|
||||||
FILE *f;
|
FILE *f;
|
||||||
String *filename;
|
String *filename;
|
||||||
List *spath = 0;
|
List *spath = 0;
|
||||||
|
|
@ -169,7 +170,7 @@ static FILE *Swig_open_any(const String_or_char *name, int sysfile) {
|
||||||
filename = NewString(cname);
|
filename = NewString(cname);
|
||||||
assert(filename);
|
assert(filename);
|
||||||
f = fopen(Char(filename), "r");
|
f = fopen(Char(filename), "r");
|
||||||
if (!f) {
|
if (!f && use_include_path) {
|
||||||
spath = Swig_search_path_any(sysfile);
|
spath = Swig_search_path_any(sysfile);
|
||||||
ilen = Len(spath);
|
ilen = Len(spath);
|
||||||
for (i = 0; i < ilen; i++) {
|
for (i = 0; i < ilen; i++) {
|
||||||
|
|
@ -193,8 +194,14 @@ static FILE *Swig_open_any(const String_or_char *name, int sysfile) {
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Open a file - searching the include paths to find it */
|
||||||
|
FILE *Swig_include_open(const String_or_char *name) {
|
||||||
|
return Swig_open_file(name, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Open a file - does not use include paths to find it */
|
||||||
FILE *Swig_open(const String_or_char *name) {
|
FILE *Swig_open(const String_or_char *name) {
|
||||||
return Swig_open_any(name, 0);
|
return Swig_open_file(name, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -235,7 +242,7 @@ static String *Swig_include_any(const String_or_char *name, int sysfile) {
|
||||||
String *str;
|
String *str;
|
||||||
String *file;
|
String *file;
|
||||||
|
|
||||||
f = Swig_open_any(name, sysfile);
|
f = Swig_open_file(name, sysfile, 1);
|
||||||
if (!f)
|
if (!f)
|
||||||
return 0;
|
return 0;
|
||||||
str = Swig_read_file(f);
|
str = Swig_read_file(f);
|
||||||
|
|
@ -265,7 +272,7 @@ String *Swig_include_sys(const String_or_char *name) {
|
||||||
int Swig_insert_file(const String_or_char *filename, File *outfile) {
|
int Swig_insert_file(const String_or_char *filename, File *outfile) {
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
int nbytes;
|
int nbytes;
|
||||||
FILE *f = Swig_open(filename);
|
FILE *f = Swig_include_open(filename);
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ extern void Swig_push_directory(const String_or_char *dirname);
|
||||||
extern void Swig_pop_directory(void);
|
extern void Swig_pop_directory(void);
|
||||||
extern String *Swig_last_file(void);
|
extern String *Swig_last_file(void);
|
||||||
extern List *Swig_search_path(void);
|
extern List *Swig_search_path(void);
|
||||||
|
extern FILE *Swig_include_open(const String_or_char *name);
|
||||||
extern FILE *Swig_open(const String_or_char *name);
|
extern FILE *Swig_open(const String_or_char *name);
|
||||||
extern String *Swig_read_file(FILE *f);
|
extern String *Swig_read_file(FILE *f);
|
||||||
extern String *Swig_include(const String_or_char *name);
|
extern String *Swig_include(const String_or_char *name);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue