]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
add --cc and -X options to be able to specify custom command and options
authorJuerg Billeter <j@bitron.ch>
Tue, 24 Jul 2007 14:37:09 +0000 (14:37 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Tue, 24 Jul 2007 14:37:09 +0000 (14:37 +0000)
2007-07-24  Juerg Billeter  <j@bitron.ch>

* gobject/valaccodecompiler.vala, compiler/valacompiler.vala: add --cc
  and -X options to be able to specify custom command and options for
  the C compiler

svn path=/trunk/; revision=381

ChangeLog
compiler/valacompiler.vala
gobject/valaccodecompiler.vala

index 6bdf9d4a1c5a08a7fe34d1b7664442468eb0044f..beda22185818540f954b89d16c80aed18dc222b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-07-24  Jürg Billeter  <j@bitron.ch>
+
+       * gobject/valaccodecompiler.vala, compiler/valacompiler.vala: add --cc
+         and -X options to be able to specify custom command and options for
+         the C compiler
+
 2007-07-24  Jürg Billeter  <j@bitron.ch>
 
        * gobject/valacodegenerator.vala,
index e824f0e20558f852fa395eaaf4249bd3f89258f3..d7be88cb1bea335b5682dc9f389942320d61e5ae 100644 (file)
@@ -42,6 +42,9 @@ class Vala.Compiler {
        static int optlevel;
        static bool disable_assert;
        static bool enable_checking;
+       static string cc_command;
+       [NoArrayLength]
+       static string[] cc_options;
 
        private CodeContext context;
 
@@ -60,6 +63,8 @@ class Vala.Compiler {
                { "optimize", 'O', 0, OptionArg.INT, ref optlevel, "Optimization level", "OPTLEVEL" },
                { "disable-assert", 0, 0, OptionArg.NONE, ref disable_assert, "Disable assertions", null },
                { "enable-checking", 0, 0, OptionArg.NONE, ref enable_checking, "Enable run-time checks", null },
+               { "cc", 0, 0, OptionArg.STRING, out cc_command, "Use COMMAND as C compiler command", "COMMAND" },
+               { "Xcc", 'X', 0, OptionArg.STRING_ARRAY, out cc_options, "Pass OPTION to the C compiler", "OPTION..." },
                { "", 0, 0, OptionArg.FILENAME_ARRAY, out sources, null, "FILE..." },
                { null }
        };
@@ -245,7 +250,7 @@ class Vala.Compiler {
 
                if (!ccode_only) {
                        var ccompiler = new CCodeCompiler ();
-                       ccompiler.compile (context);
+                       ccompiler.compile (context, cc_command, cc_options);
                }
 
                return quit ();
index 2de7a591d76667ca0f87521414d97a304c6b7ed2..8517cf4c51be0def79e10f556b1e0ac539b6f9eb 100644 (file)
@@ -35,7 +35,8 @@ public class Vala.CCodeCompiler {
         *
         * @param context a code context
         */
-       public void compile (CodeContext! context) {
+       [NoArrayLength]
+       public void compile (CodeContext! context, string cc_command, string[] cc_options) {
                string pc = "pkg-config --cflags";
                if (!context.compile_only) {
                        pc += " --libs";
@@ -62,7 +63,10 @@ public class Vala.CCodeCompiler {
 
                // TODO compile the C code files in parallel
 
-               string cmdline = "cc";
+               if (cc_command == null) {
+                       cc_command = "cc";
+               }
+               string cmdline = cc_command;
                if (context.debug) {
                        cmdline += " -g";
                }
@@ -73,6 +77,11 @@ public class Vala.CCodeCompiler {
                        cmdline += " -o " + Shell.quote (context.output);
                }
                cmdline += " " + pkgflags;
+               if (cc_options != null) {
+                       foreach (string cc_option in cc_options) {
+                               cmdline += " " + cc_option;
+                       }
+               }
 
                /* we're only interested in non-pkg source files */
                var source_files = context.get_source_files ();