Commit 860f17a2 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

support passing C source files to the command line, patch by Nicolas

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

	* vala/valacodecontext.vala, gobject/valaccodecompiler.vala,
	  compiler/valacompiler.vala: support passing C source files to the
	  command line, patch by Nicolas Trangez

svn path=/trunk/; revision=448
parent 38c6fecb
2007-08-08 Jürg Billeter <j@bitron.ch>
* vala/valacodecontext.vala, gobject/valaccodecompiler.vala,
compiler/valacompiler.vala: support passing C source files to the
command line, patch by Nicolas Trangez
2007-08-08 Mathias Hasselmann <mathias.hasselmann@gmx.de>
* vapi/gtk+-2.0.vala: fix the signatures of some TreeModel
......
......@@ -186,7 +186,13 @@ class Vala.Compiler {
foreach (string source in sources) {
if (FileUtils.test (source, FileTest.EXISTS)) {
context.add_source_file (new SourceFile (context, source));
if (source.has_suffix (".vala")) {
context.add_source_file (new SourceFile (context, source));
} else if (source.has_suffix (".c")) {
context.add_c_source_file (source);
} else {
Report.error (null, "%s is not a supported source file type. Only .vala and .c files are supported.".printf (source));
}
} else {
Report.error (null, "%s not found".printf (source));
}
......@@ -282,13 +288,6 @@ class Vala.Compiler {
return 1;
}
foreach (string source in sources) {
if (!source.has_suffix (".vala")) {
stderr.printf ("Only .vala source files supported.\n");
return 1;
}
}
var compiler = new Compiler ();
return compiler.run ();
}
......
......@@ -90,6 +90,10 @@ public class Vala.CCodeCompiler {
cmdline += " " + Shell.quote (file.get_csource_filename ());
}
}
var c_source_files = context.get_c_source_files ();
foreach (string file in c_source_files) {
cmdline += " " + Shell.quote (file);
}
try {
Process.spawn_command_line_sync (cmdline, null, null, out exit_status);
......
......@@ -86,6 +86,7 @@ public class Vala.CodeContext {
public Method module_init_method { get; set; }
private Gee.List<SourceFile> source_files = new ArrayList<SourceFile> ();
private Gee.List<string> c_source_files = new ArrayList<string> ();
private Namespace! _root = new Namespace (null);
private Gee.List<SourceFileCycle> cycles = new ArrayList<SourceFileCycle> ();
......@@ -109,6 +110,15 @@ public class Vala.CodeContext {
public Collection<SourceFile> get_source_files () {
return new ReadOnlyCollection<SourceFile> (source_files);
}
/**
* Returns a copy of the list of C source files.
*
* @return list of C source files
*/
public Collection<string> get_c_source_files () {
return new ReadOnlyCollection<string> (c_source_files);
}
/**
* Adds the specified file to the list of source files.
......@@ -119,6 +129,15 @@ public class Vala.CodeContext {
source_files.add (file);
}
/**
* Adds the specified file to the list of C source files.
*
* @param file a C source file
*/
public void add_c_source_file (string! file) {
c_source_files.add (file);
}
/**
* Returns a copy of the list of used packages.
*
......
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