Commit 10d2b86e authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

support --directory option, use basename of input filenames, patch by

2007-08-21  Juerg Billeter  <j@bitron.ch>

	* vala/valacodecontext.vala, vala/valasourcefile.vala,
	  gobject/valaccodecompiler.vala, compiler/valacompiler.vala: support
	  --directory option, use basename of input filenames,
	  patch by Nicolas Trangez, fixes bug 465720

svn path=/trunk/; revision=494
parent e057df14
2007-08-21 Jürg Billeter <j@bitron.ch>
* vala/valacodecontext.vala, vala/valasourcefile.vala,
gobject/valaccodecompiler.vala, compiler/valacompiler.vala: support
--directory option, use basename of input filenames,
patch by Nicolas Trangez, fixes bug 465720
2007-08-21 Mathias Hasselmann <mathias.hasselmann@gmx.de>
* gobject/valacodegenerator.vala, vala/valaswitchsection.vala,
......
......@@ -164,6 +164,7 @@ class Vala.Compiler {
context.ccode_only = ccode_only;
context.compile_only = compile_only;
context.output = output;
context.directory = directory;
context.debug = debug;
context.thread = thread;
context.optlevel = optlevel;
......
......@@ -88,7 +88,11 @@ public class Vala.CCodeCompiler {
if (context.compile_only) {
cmdline += " -c";
} else if (context.output != null) {
cmdline += " -o " + Shell.quote (context.output);
string output = context.output;
if (context.directory != null && context.directory != "") {
output = "%s/%s".printf (context.directory, context.output);
}
cmdline += " -o " + Shell.quote (output);
}
cmdline += " " + pkgflags;
if (cc_options != null) {
......@@ -97,6 +101,11 @@ public class Vala.CCodeCompiler {
}
}
/* make sure include files can be found if -d is used */
if (context.directory != null && context.directory != "") {
cmdline += " -I" + Shell.quote ("%s/..".printf (context.directory));
}
/* we're only interested in non-pkg source files */
var source_files = context.get_source_files ();
foreach (SourceFile file in source_files) {
......
......@@ -65,6 +65,11 @@ public class Vala.CodeContext {
*/
public string output { get; set; }
/**
* Code output directory.
*/
public string directory { get; set; }
/**
* Produce debug information.
*/
......
......@@ -153,7 +153,12 @@ public class Vala.SourceFile {
public string! get_cheader_filename () {
if (cheader_filename == null) {
var basename = filename.ndup ((uint) (filename.len () - ".vala".len ()));
cheader_filename = "%s.h".printf (basename);
basename = Path.get_basename (basename);
if (context.directory != null && context.directory != "") {
cheader_filename = "%s/%s.h".printf (context.directory, basename);
} else {
cheader_filename = "%s.h".printf (basename);
}
}
return cheader_filename;
}
......@@ -166,7 +171,12 @@ public class Vala.SourceFile {
public string! get_csource_filename () {
if (csource_filename == null) {
var basename = filename.ndup ((uint) (filename.len () - ".vala".len ()));
csource_filename = "%s.c".printf (basename);
basename = Path.get_basename (basename);
if (context.directory != null && context.directory != "") {
csource_filename = "%s/%s.c".printf (context.directory, basename);
} else {
csource_filename = "%s.c".printf (basename);
}
}
return csource_filename;
}
......@@ -180,6 +190,7 @@ public class Vala.SourceFile {
public string! get_cinclude_filename () {
if (cinclude_filename == null) {
var basename = filename.ndup ((uint) (filename.len () - ".vala".len ()));
basename = Path.get_basename (basename);
if (context.library != null) {
cinclude_filename = "%s/%s.h".printf (context.library, basename);
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment