Add -outcurrentdir option

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10947 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2008-11-25 23:36:23 +00:00
commit 6994737f19
3 changed files with 24 additions and 8 deletions

View file

@ -1,6 +1,12 @@
Version 1.3.37 (in progress) Version 1.3.37 (in progress)
============================ ============================
2008-11-24: wsfulton
Add -outcurrentdir option. This sets the default output directory to the current
directory instead of the path specified by the input file. This option enables
behaviour similar to c/c++ compilers. Note that this controls the output directory,
but only in the absence of the -o and/or -outdir options.
2008-11-23: wsfulton 2008-11-23: wsfulton
[ruby] Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in [ruby] Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in
ruby 1.9. ruby 1.9.

View file

@ -139,6 +139,7 @@ can be obtained by typing <tt>swig -help</tt> or <tt>swig
-l<em>file</em> Include a SWIG library file. -l<em>file</em> Include a SWIG library file.
-module <em>name</em> Set the name of the SWIG module -module <em>name</em> Set the name of the SWIG module
-o <em>outfile</em> Name of output file -o <em>outfile</em> Name of output file
-outcurrentdir Set default output dir to current dir instead of input file's path
-outdir <em>dir</em> Set language specific files output directory -outdir <em>dir</em> Set language specific files output directory
-swiglib Show location of SWIG library -swiglib Show location of SWIG library
-version Show SWIG version number -version Show SWIG version number

View file

@ -117,7 +117,8 @@ static const char *usage3 = (const char *) "\
-fastdispatch -fvirtual \n\ -fastdispatch -fvirtual \n\
-o <outfile> - Set name of the output file to <outfile>\n\ -o <outfile> - Set name of the output file to <outfile>\n\
-oh <headfile> - Set name of the output header file to <headfile>\n\ -oh <headfile> - Set name of the output header file to <headfile>\n\
-outdir <dir> - Set language specific files output directory <dir>\n\ -outcurrentdir - Set default output dir to current dir instead of input file's path\n\
-outdir <dir> - Set language specific files output directory to <dir>\n\
-small - Compile in virtual elimination & compact mode\n\ -small - Compile in virtual elimination & compact mode\n\
-swiglib - Report location of SWIG library and exit\n\ -swiglib - Report location of SWIG library and exit\n\
-templatereduce - Reduce all the typedefs in templates\n\ -templatereduce - Reduce all the typedefs in templates\n\
@ -153,6 +154,7 @@ static char *cpp_extension = (char *) "cxx";
static char *depends_extension = (char *) "d"; static char *depends_extension = (char *) "d";
static String *outdir = 0; static String *outdir = 0;
static String *xmlout = 0; static String *xmlout = 0;
static int outcurrentdir = 0;
static int help = 0; static int help = 0;
static int checkout = 0; static int checkout = 0;
static int cpp_only = 0; static int cpp_only = 0;
@ -694,6 +696,9 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else { } else {
Swig_arg_error(); Swig_arg_error();
} }
} else if (strcmp(argv[i], "-outcurrentdir") == 0) {
Swig_mark_arg(i);
outcurrentdir = 1;
} else if (strcmp(argv[i], "-Wall") == 0) { } else if (strcmp(argv[i], "-Wall") == 0) {
Swig_mark_arg(i); Swig_mark_arg(i);
Swig_warnall(); Swig_warnall();
@ -1018,11 +1023,13 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (depend) { if (depend) {
if (!no_cpp) { if (!no_cpp) {
String *outfile; String *outfile;
char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(input_file): Char(input_file));
if (!outfile_name) { if (!outfile_name) {
if (CPlusPlus || lang->cplus_runtime_mode()) { if (CPlusPlus || lang->cplus_runtime_mode()) {
outfile = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), cpp_extension); outfile = NewStringf("%s_wrap.%s", basename, cpp_extension);
} else { } else {
outfile = NewStringf("%s_wrap.c", Swig_file_basename(input_file)); outfile = NewStringf("%s_wrap.c", basename);
} }
} else { } else {
outfile = NewString(outfile_name); outfile = NewString(outfile_name);
@ -1034,7 +1041,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
SWIG_exit(EXIT_FAILURE); SWIG_exit(EXIT_FAILURE);
} }
} else if (!depend_only) { } else if (!depend_only) {
String *filename = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), depends_extension); String *filename = NewStringf("%s_wrap.%s", basename, depends_extension);
f_dependencies_file = NewFile(filename, "w", SWIG_output_files()); f_dependencies_file = NewFile(filename, "w", SWIG_output_files());
if (!f_dependencies_file) { if (!f_dependencies_file) {
FileErrorDisplay(filename); FileErrorDisplay(filename);
@ -1151,21 +1158,23 @@ int SWIG_main(int argc, char *argv[], Language *l) {
} }
Setattr(top, "infile", infile); // Note: if nopreprocess then infile is the original input file, otherwise input_file Setattr(top, "infile", infile); // Note: if nopreprocess then infile is the original input file, otherwise input_file
Setattr(top, "inputfile", input_file); Setattr(top, "inputfile", input_file);
char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(infile): Char(infile));
if (!outfile_name) { if (!outfile_name) {
if (CPlusPlus || lang->cplus_runtime_mode()) { if (CPlusPlus || lang->cplus_runtime_mode()) {
Setattr(top, "outfile", NewStringf("%s_wrap.%s", Swig_file_basename(infile), cpp_extension)); Setattr(top, "outfile", NewStringf("%s_wrap.%s", basename, cpp_extension));
} else { } else {
Setattr(top, "outfile", NewStringf("%s_wrap.c", Swig_file_basename(infile))); Setattr(top, "outfile", NewStringf("%s_wrap.c", basename));
} }
} else { } else {
Setattr(top, "outfile", outfile_name); Setattr(top, "outfile", outfile_name);
} }
if (!outfile_name_h) { if (!outfile_name_h) {
Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", Swig_file_basename(infile), hpp_extension)); Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", basename, hpp_extension));
} else { } else {
Setattr(top, "outfile_h", outfile_name_h); Setattr(top, "outfile_h", outfile_name_h);
} }
set_outdir(Swig_file_dirname(Getattr(top, "outfile"))); set_outdir(Swig_file_dirname(basename));
if (Swig_contract_mode_get()) { if (Swig_contract_mode_get()) {
Swig_contracts(top); Swig_contracts(top);
} }