3 * Copyright (C) 2006-2012 Jürg Billeter
4 * Copyright (C) 1996-2002, 2004, 2005, 2006 Free Software Foundation, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * Jürg Billeter <j@bitron.ch>
27 private const string DEFAULT_COLORS
= "error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01";
29 static string basedir
;
30 static string directory
;
32 static bool api_version
;
33 [CCode (array_length
= false, array_null_terminated
= true)]
34 static string[] sources
;
35 [CCode (array_length
= false, array_null_terminated
= true)]
36 static string[] vapi_directories
;
37 [CCode (array_length
= false, array_null_terminated
= true)]
38 static string[] gir_directories
;
39 [CCode (array_length
= false, array_null_terminated
= true)]
40 static string[] metadata_directories
;
41 static string vapi_filename
;
42 static string library
;
43 static string shared_library
;
45 [CCode (array_length
= false, array_null_terminated
= true)]
46 static string[] packages
;
47 [CCode (array_length
= false, array_null_terminated
= true)]
48 static string[] fast_vapis
;
49 static string target_glib
;
50 [CCode (array_length
= false, array_null_terminated
= true)]
51 static string[] gresources
;
52 [CCode (array_length
= false, array_null_terminated
= true)]
53 static string[] gresources_directories
;
55 static bool ccode_only
;
56 static string header_filename
;
57 static bool use_header
;
58 static string internal_header_filename
;
59 static string internal_vapi_filename
;
60 static string fast_vapi_filename
;
61 static bool vapi_comments
;
62 static string symbols_filename
;
63 static string includedir
;
64 static bool compile_only
;
68 static bool mem_profiler
;
69 static bool disable_assert
;
70 static bool enable_checking
;
71 static bool deprecated
;
72 static bool hide_internal
;
73 static bool experimental
;
74 static bool experimental_non_null
;
75 static bool gobject_tracing
;
76 static bool disable_since_check
;
77 static bool disable_warnings
;
78 static string cc_command
;
79 [CCode (array_length
= false, array_null_terminated
= true)]
80 static string[] cc_options
;
81 static string pkg_config_command
;
82 static string dump_tree
;
83 static bool save_temps
;
84 [CCode (array_length
= false, array_null_terminated
= true)]
85 static string[] defines
;
86 static bool quiet_mode
;
87 static bool verbose_mode
;
88 static string profile
;
90 static bool enable_version_header
;
91 static bool disable_version_header
;
92 static bool fatal_warnings
;
93 static bool disable_colored_output
;
94 static Report
.Colored colored_output
= Report
.Colored
.AUTO
;
95 static string dependencies
;
97 static string entry_point
;
99 static bool run_output
;
101 private CodeContext context
;
103 const OptionEntry
[] options
= {
104 { "vapidir", 0, 0, OptionArg
.FILENAME_ARRAY
, ref vapi_directories
, "Look for package bindings in DIRECTORY", "DIRECTORY..." },
105 { "girdir", 0, 0, OptionArg
.FILENAME_ARRAY
, ref gir_directories
, "Look for .gir files in DIRECTORY", "DIRECTORY..." },
106 { "metadatadir", 0, 0, OptionArg
.FILENAME_ARRAY
, ref metadata_directories
, "Look for GIR .metadata files in DIRECTORY", "DIRECTORY..." },
107 { "pkg", 0, 0, OptionArg
.STRING_ARRAY
, ref packages
, "Include binding for PACKAGE", "PACKAGE..." },
108 { "vapi", 0, 0, OptionArg
.FILENAME
, ref vapi_filename
, "Output VAPI file name", "FILE" },
109 { "library", 0, 0, OptionArg
.STRING
, ref library
, "Library name", "NAME" },
110 { "shared-library", 0, 0, OptionArg
.STRING
, ref shared_library
, "Shared library name used in generated gir", "NAME" },
111 { "gir", 0, 0, OptionArg
.STRING
, ref gir
, "GObject-Introspection repository file name", "NAME-VERSION.gir" },
112 { "basedir", 'b', 0, OptionArg
.FILENAME
, ref basedir
, "Base source directory", "DIRECTORY" },
113 { "directory", 'd', 0, OptionArg
.FILENAME
, ref directory
, "Change output directory from current working directory", "DIRECTORY" },
114 { "version", 0, 0, OptionArg
.NONE
, ref version
, "Display version number", null },
115 { "api-version", 0, 0, OptionArg
.NONE
, ref api_version
, "Display API version number", null },
116 { "ccode", 'C', 0, OptionArg
.NONE
, ref ccode_only
, "Output C code", null },
117 { "header", 'H', 0, OptionArg
.FILENAME
, ref header_filename
, "Output C header file", "FILE" },
118 { "use-header", 0, 0, OptionArg
.NONE
, ref use_header
, "Use C header file", null },
119 { "includedir", 0, 0, OptionArg
.FILENAME
, ref includedir
, "Directory used to include the C header file", "DIRECTORY" },
120 { "internal-header", 'h', 0, OptionArg
.FILENAME
, ref internal_header_filename
, "Output internal C header file", "FILE" },
121 { "internal-vapi", 0, 0, OptionArg
.FILENAME
, ref internal_vapi_filename
, "Output vapi with internal api", "FILE" },
122 { "fast-vapi", 0, 0, OptionArg
.STRING
, ref fast_vapi_filename
, "Output vapi without performing symbol resolution", null },
123 { "use-fast-vapi", 0, 0, OptionArg
.STRING_ARRAY
, ref fast_vapis
, "Use --fast-vapi output during this compile", null },
124 { "vapi-comments", 0, 0, OptionArg
.NONE
, ref vapi_comments
, "Include comments in generated vapi", null },
125 { "deps", 0, 0, OptionArg
.STRING
, ref dependencies
, "Write make-style dependency information to this file", null },
126 { "symbols", 0, 0, OptionArg
.FILENAME
, ref symbols_filename
, "Output symbols file", "FILE" },
127 { "compile", 'c', 0, OptionArg
.NONE
, ref compile_only
, "Compile but do not link", null },
128 { "output", 'o', 0, OptionArg
.FILENAME
, ref output
, "Place output in file FILE", "FILE" },
129 { "debug", 'g', 0, OptionArg
.NONE
, ref debug
, "Produce debug information", null },
130 { "thread", 0, 0, OptionArg
.NONE
, ref thread
, "Enable multithreading support (DEPRECATED AND IGNORED)", null },
131 { "enable-mem-profiler", 0, 0, OptionArg
.NONE
, ref mem_profiler
, "Enable GLib memory profiler", null },
132 { "define", 'D', 0, OptionArg
.STRING_ARRAY
, ref defines
, "Define SYMBOL", "SYMBOL..." },
133 { "main", 0, 0, OptionArg
.STRING
, ref entry_point
, "Use SYMBOL as entry point", "SYMBOL..." },
134 { "nostdpkg", 0, 0, OptionArg
.NONE
, ref nostdpkg
, "Do not include standard packages", null },
135 { "disable-assert", 0, 0, OptionArg
.NONE
, ref disable_assert
, "Disable assertions", null },
136 { "enable-checking", 0, 0, OptionArg
.NONE
, ref enable_checking
, "Enable additional run-time checks", null },
137 { "enable-deprecated", 0, 0, OptionArg
.NONE
, ref deprecated
, "Enable deprecated features", null },
138 { "hide-internal", 0, 0, OptionArg
.NONE
, ref hide_internal
, "Hide symbols marked as internal", null },
139 { "enable-experimental", 0, 0, OptionArg
.NONE
, ref experimental
, "Enable experimental features", null },
140 { "disable-warnings", 0, 0, OptionArg
.NONE
, ref disable_warnings
, "Disable warnings", null },
141 { "fatal-warnings", 0, 0, OptionArg
.NONE
, ref fatal_warnings
, "Treat warnings as fatal", null },
142 { "disable-since-check", 0, 0, OptionArg
.NONE
, ref disable_since_check
, "Do not check whether used symbols exist in local packages", null },
143 { "enable-experimental-non-null", 0, 0, OptionArg
.NONE
, ref experimental_non_null
, "Enable experimental enhancements for non-null types", null },
144 { "enable-gobject-tracing", 0, 0, OptionArg
.NONE
, ref gobject_tracing
, "Enable GObject creation tracing", null },
145 { "cc", 0, 0, OptionArg
.STRING
, ref cc_command
, "Use COMMAND as C compiler command", "COMMAND" },
146 { "Xcc", 'X', 0, OptionArg
.STRING_ARRAY
, ref cc_options
, "Pass OPTION to the C compiler", "OPTION..." },
147 { "pkg-config", 0, 0, OptionArg
.STRING
, ref pkg_config_command
, "Use COMMAND as pkg-config command", "COMMAND" },
148 { "dump-tree", 0, 0, OptionArg
.FILENAME
, ref dump_tree
, "Write code tree to FILE", "FILE" },
149 { "save-temps", 0, 0, OptionArg
.NONE
, ref save_temps
, "Keep temporary files", null },
150 { "profile", 0, 0, OptionArg
.STRING
, ref profile
, "Use the given profile instead of the default", "PROFILE" },
151 { "quiet", 'q', 0, OptionArg
.NONE
, ref quiet_mode
, "Do not print messages to the console", null },
152 { "verbose", 'v', 0, OptionArg
.NONE
, ref verbose_mode
, "Print additional messages to the console", null },
153 { "no-color", 0, 0, OptionArg
.NONE
, ref disable_colored_output
, "Disable colored output, alias for --color=never", null },
154 { "color", 0, OptionFlags
.OPTIONAL_ARG
, OptionArg
.CALLBACK
, (void*) option_parse_color
, "Enable color output, options are 'always', 'never', or 'auto'", "WHEN" },
155 { "target-glib", 0, 0, OptionArg
.STRING
, ref target_glib
, "Target version of glib for code generation", "MAJOR.MINOR" },
156 { "gresources", 0, 0, OptionArg
.FILENAME_ARRAY
, ref gresources
, "XML of gresources", "FILE..." },
157 { "gresourcesdir", 0, 0, OptionArg
.FILENAME_ARRAY
, ref gresources_directories
, "Look for resources in DIRECTORY", "DIRECTORY..." },
158 { "enable-version-header", 0, 0, OptionArg
.NONE
, ref enable_version_header
, "Write vala build version in generated files", null },
159 { "disable-version-header", 0, 0, OptionArg
.NONE
, ref disable_version_header
, "Do not write vala build version in generated files", null },
160 { "", 0, 0, OptionArg
.FILENAME_ARRAY
, ref sources
, null, "FILE..." },
164 static bool option_parse_color (string option_name
, string? val
, void* data
) throws OptionError
{
166 case "auto": colored_output
= Report
.Colored
.AUTO
; break;
167 case "never": colored_output
= Report
.Colored
.NEVER
; break;
169 case "always": colored_output
= Report
.Colored
.ALWAYS
; break;
170 default: throw new OptionError
.FAILED ("Invalid --color argument '%s'", val
);
175 private int quit () {
176 if (context
.report
.get_errors () == 0 && context
.report
.get_warnings () == 0) {
179 if (context
.report
.get_errors () == 0 && (!fatal_warnings
|| context
.report
.get_warnings () == 0)) {
181 stdout
.printf ("Compilation succeeded - %d warning(s)\n", context
.report
.get_warnings ());
186 stdout
.printf ("Compilation failed: %d error(s), %d warning(s)\n", context
.report
.get_errors (), context
.report
.get_warnings ());
193 context
= new
CodeContext ();
194 CodeContext
.push (context
);
196 if (disable_colored_output
) {
197 colored_output
= Report
.Colored
.NEVER
;
200 if (colored_output
!= Report
.Colored
.NEVER
) {
201 unowned
string env_colors
= Environment
.get_variable ("VALA_COLORS");
202 if (env_colors
!= null) {
203 context
.report
.set_colors (env_colors
, colored_output
);
205 context
.report
.set_colors (DEFAULT_COLORS
, colored_output
);
210 // default to build executable
211 if (!ccode_only
&& !compile_only
&& output
== null) {
212 // strip extension if there is one
213 // else we use the default output file of the C compiler
214 if (sources
[0].last_index_of_char ('.') != -1) {
215 int dot
= sources
[0].last_index_of_char ('.');
216 output
= Path
.get_basename (sources
[0].substring (0, dot
));
220 context
.assert
= !disable_assert
;
221 context
.checking
= enable_checking
;
222 context
.deprecated
= deprecated
;
223 context
.since_check
= !disable_since_check
;
224 context
.hide_internal
= hide_internal
;
225 context
.experimental
= experimental
;
226 context
.experimental_non_null
= experimental_non_null
;
227 context
.gobject_tracing
= gobject_tracing
;
228 context
.report
.enable_warnings
= !disable_warnings
;
229 context
.report
.set_verbose_errors (!quiet_mode
);
230 context
.verbose_mode
= verbose_mode
;
231 context
.version_header
= !disable_version_header
;
233 context
.ccode_only
= ccode_only
;
234 if (ccode_only
&& cc_options
!= null) {
235 Report
.warning (null, "-X has no effect when -C or --ccode is set");
237 context
.compile_only
= compile_only
;
238 context
.header_filename
= header_filename
;
239 if (header_filename
== null && use_header
) {
240 Report
.error (null, "--use-header may only be used in combination with --header");
242 context
.use_header
= use_header
;
243 context
.internal_header_filename
= internal_header_filename
;
244 context
.symbols_filename
= symbols_filename
;
245 context
.includedir
= includedir
;
246 context
.output
= output
;
247 if (output
!= null && ccode_only
) {
248 Report
.warning (null, "--output and -o have no effect when -C or --ccode is set");
250 if (basedir
== null) {
251 context
.basedir
= CodeContext
.realpath (".");
253 context
.basedir
= CodeContext
.realpath (basedir
);
255 if (directory
!= null) {
256 context
.directory
= CodeContext
.realpath (directory
);
258 context
.directory
= context
.basedir
;
260 context
.vapi_directories
= vapi_directories
;
261 context
.vapi_comments
= vapi_comments
;
262 context
.gir_directories
= gir_directories
;
263 context
.metadata_directories
= metadata_directories
;
264 context
.debug
= debug
;
265 context
.mem_profiler
= mem_profiler
;
266 context
.save_temps
= save_temps
;
267 if (ccode_only
&& save_temps
) {
268 Report
.warning (null, "--save-temps has no effect when -C or --ccode is set");
270 if (profile
== "gobject-2.0" || profile
== "gobject" || profile
== null) {
272 context
.profile
= Profile
.GOBJECT
;
273 context
.add_define ("GOBJECT");
275 Report
.error (null, "Unknown profile %s".printf (profile
));
277 nostdpkg
|= fast_vapi_filename
!= null;
278 context
.nostdpkg
= nostdpkg
;
280 context
.entry_point_name
= entry_point
;
282 context
.run_output
= run_output
;
284 if (defines
!= null) {
285 foreach (string define
in defines
) {
286 context
.add_define (define
);
290 for (int i
= 2; i
<= 38; i
+= 2) {
291 context
.add_define ("VALA_0_%d".printf (i
));
296 if (target_glib
!= null && target_glib
.scanf ("%d.%d", out glib_major
, out glib_minor
) != 2) {
297 Report
.error (null, "Invalid format for --target-glib");
300 context
.target_glib_major
= glib_major
;
301 context
.target_glib_minor
= glib_minor
;
302 if (context
.target_glib_major
!= 2) {
303 Report
.error (null, "This version of valac only supports GLib 2");
306 for (int i
= 16; i
<= glib_minor
; i
+= 2) {
307 context
.add_define ("GLIB_2_%d".printf (i
));
311 /* default packages */
312 context
.add_external_package ("glib-2.0");
313 context
.add_external_package ("gobject-2.0");
316 if (packages
!= null) {
317 foreach (string package
in packages
) {
318 context
.add_external_package (package
);
323 if (fast_vapis
!= null) {
324 foreach (string vapi
in fast_vapis
) {
325 var rpath
= CodeContext
.realpath (vapi
);
326 var source_file
= new
SourceFile (context
, SourceFileType
.FAST
, rpath
);
327 context
.add_source_file (source_file
);
329 context
.use_fast_vapi
= true;
332 context
.gresources
= gresources
;
333 context
.gresources_directories
= gresources_directories
;
335 if (context
.report
.get_errors () > 0 || (fatal_warnings
&& context
.report
.get_warnings () > 0)) {
339 context
.codegen
= new
GDBusServerModule ();
341 bool has_c_files
= false;
342 bool has_h_files
= false;
344 foreach (string source
in sources
) {
345 if (context
.add_source_filename (source
, run_output
, true)) {
346 if (source
.has_suffix (".c")) {
348 } else if (source
.has_suffix (".h")) {
354 if (ccode_only
&& (has_c_files
|| has_h_files
)) {
355 Report
.warning (null, "C header and source files are ignored when -C or --ccode is set");
358 if (context
.report
.get_errors () > 0 || (fatal_warnings
&& context
.report
.get_warnings () > 0)) {
362 var parser
= new
Parser ();
363 parser
.parse (context
);
365 var genie_parser
= new Genie
.Parser ();
366 genie_parser
.parse (context
);
368 var gir_parser
= new
GirParser ();
369 gir_parser
.parse (context
);
371 if (context
.report
.get_errors () > 0 || (fatal_warnings
&& context
.report
.get_warnings () > 0)) {
375 if (fast_vapi_filename
!= null) {
376 var interface_writer
= new
CodeWriter (CodeWriterType
.FAST
);
377 interface_writer
.write_file (context
, fast_vapi_filename
);
383 if (context
.report
.get_errors () > 0 || (fatal_warnings
&& context
.report
.get_warnings () > 0)) {
387 if (!ccode_only
&& !compile_only
&& library
== null) {
388 // building program, require entry point
389 if (!has_c_files
&& context
.entry_point
== null) {
390 Report
.error (null, "program does not contain a static `main' method");
394 if (dump_tree
!= null) {
395 var code_writer
= new
CodeWriter (CodeWriterType
.DUMP
);
396 code_writer
.write_file (context
, dump_tree
);
399 if (context
.report
.get_errors () > 0 || (fatal_warnings
&& context
.report
.get_warnings () > 0)) {
403 context
.codegen
.emit (context
);
405 if (context
.report
.get_errors () > 0 || (fatal_warnings
&& context
.report
.get_warnings () > 0)) {
409 if (vapi_filename
== null && library
!= null) {
410 // keep backward compatibility with --library option
411 vapi_filename
= "%s.vapi".printf (library
);
414 if (library
!= null) {
416 string gir_base
= Path
.get_basename(gir
);
417 long gir_len
= gir_base
.length
;
418 int last_hyphen
= gir_base
.last_index_of_char ('-');
420 if (last_hyphen
== -1 || !gir_base
.has_suffix (".gir")) {
421 Report
.error (null, "GIR file name `%s' is not well-formed, expected NAME-VERSION.gir".printf (gir
));
423 string gir_namespace
= gir_base
.substring (0, last_hyphen
);
424 string gir_version
= gir_base
.substring (last_hyphen
+ 1, gir_len
- last_hyphen
- 5);
425 gir_version
.canon ("0123456789.", '?');
426 if (gir_namespace
== "" || gir_version
== "" || !gir_version
[0].isdigit () || gir_version
.contains ("?")) {
427 Report
.error (null, "GIR file name `%s' is not well-formed, expected NAME-VERSION.gir".printf (gir
));
429 var gir_writer
= new
GIRWriter ();
431 // put .gir file in current directory unless -d has been explicitly specified
432 string gir_directory
= ".";
433 if (directory
!= null) {
434 gir_directory
= context
.directory
;
437 gir_writer
.write_file (context
, gir_directory
, gir
, gir_namespace
, gir_version
, library
, shared_library
);
447 // The GIRWriter places the gir_namespace and gir_version into the top namespace, so write the vapi after that stage
448 if (vapi_filename
!= null) {
449 var interface_writer
= new
CodeWriter ();
451 // put .vapi file in current directory unless -d has been explicitly specified
452 if (directory
!= null && !Path
.is_absolute (vapi_filename
)) {
453 vapi_filename
= "%s%c%s".printf (context
.directory
, Path
.DIR_SEPARATOR
, vapi_filename
);
456 interface_writer
.write_file (context
, vapi_filename
);
459 if (internal_vapi_filename
!= null) {
460 if (internal_header_filename
== null ||
461 header_filename
== null) {
462 Report
.error (null, "--internal-vapi may only be used in combination with --header and --internal-header");
466 var interface_writer
= new
CodeWriter (CodeWriterType
.INTERNAL
);
467 interface_writer
.set_cheader_override(header_filename
, internal_header_filename
);
468 string vapi_filename
= internal_vapi_filename
;
470 // put .vapi file in current directory unless -d has been explicitly specified
471 if (directory
!= null && !Path
.is_absolute (vapi_filename
)) {
472 vapi_filename
= "%s%c%s".printf (context
.directory
, Path
.DIR_SEPARATOR
, vapi_filename
);
475 interface_writer
.write_file (context
, vapi_filename
);
477 internal_vapi_filename
= null;
480 if (dependencies
!= null) {
481 context
.write_dependencies (dependencies
);
484 if (context
.report
.get_errors () > 0 || (fatal_warnings
&& context
.report
.get_warnings () > 0)) {
489 var ccompiler
= new
CCodeCompiler ();
490 if (cc_command
== null && Environment
.get_variable ("CC") != null) {
491 cc_command
= Environment
.get_variable ("CC");
493 if (pkg_config_command
== null && Environment
.get_variable ("PKG_CONFIG") != null) {
494 pkg_config_command
= Environment
.get_variable ("PKG_CONFIG");
496 if (cc_options
== null) {
497 ccompiler
.compile (context
, cc_command
, new
string[] { }, pkg_config_command
);
499 ccompiler
.compile (context
, cc_command
, cc_options
, pkg_config_command
);
506 static int run_source (string[] args
) {
508 if (args
[i
] != null && args
[i
].has_prefix ("-")) {
510 string[] compile_args
;
511 Shell
.parse_argv ("valac " + args
[1], out compile_args
);
513 var opt_context
= new
OptionContext ("- Vala");
514 opt_context
.set_help_enabled (true);
515 opt_context
.add_main_entries (options
, null);
516 unowned
string[] temp_args
= compile_args
;
517 opt_context
.parse (ref temp_args
);
518 } catch (ShellError e
) {
519 stdout
.printf ("%s\n", e
.message
);
521 } catch (OptionError e
) {
522 stdout
.printf ("%s\n", e
.message
);
523 stdout
.printf ("Run '%s --help' to see a full list of available command line options.\n", args
[0]);
531 stdout
.printf ("Vala %s\n", Config
.BUILD_VERSION
);
533 } else if (api_version
) {
534 stdout
.printf ("%s\n", Config
.API_VERSION
);
538 if (args
[i
] == null) {
539 stderr
.printf ("No source file specified.\n");
543 sources
= { args
[i
] };
544 output
= "%s/%s.XXXXXX".printf (Environment
.get_tmp_dir (), Path
.get_basename (args
[i
]));
545 int outputfd
= FileUtils
.mkstemp (output
);
551 disable_warnings
= true;
554 var compiler
= new
Compiler ();
555 int ret
= compiler
.run ();
560 FileUtils
.close (outputfd
);
561 if (FileUtils
.chmod (output
, 0700) != 0) {
562 FileUtils
.unlink (output
);
566 string[] target_args
= { output
};
567 while (i
< args
.length
) {
568 target_args
+= args
[i
];
574 var loop
= new
MainLoop ();
575 int child_status
= 0;
577 Process
.spawn_async (null, target_args
, null, SpawnFlags
.CHILD_INHERITS_STDIN
| SpawnFlags
.DO_NOT_REAP_CHILD
| SpawnFlags
.FILE_AND_ARGV_ZERO
, null, out pid
);
579 FileUtils
.unlink (output
);
580 ChildWatch
.add (pid
, (pid
, status
) => {
581 child_status
= (status
& 0xff00) >> 8;
588 } catch (SpawnError e
) {
589 stdout
.printf ("%s\n", e
.message
);
594 static int main (string[] args
) {
596 Intl
.setlocale (LocaleCategory
.ALL
, "");
598 if (Path
.get_basename (args
[0]) == "vala" || Path
.get_basename (args
[0]) == "vala" + Config
.PACKAGE_SUFFIX
) {
599 return run_source (args
);
603 var opt_context
= new
OptionContext ("- Vala Compiler");
604 opt_context
.set_help_enabled (true);
605 opt_context
.add_main_entries (options
, null);
606 opt_context
.parse (ref args
);
607 } catch (OptionError e
) {
608 stdout
.printf ("%s\n", e
.message
);
609 stdout
.printf ("Run '%s --help' to see a full list of available command line options.\n", args
[0]);
614 stdout
.printf ("Vala %s\n", Config
.BUILD_VERSION
);
616 } else if (api_version
) {
617 stdout
.printf ("%s\n", Config
.API_VERSION
);
621 if (sources
== null && fast_vapis
== null) {
622 stderr
.printf ("No source file specified.\n");
626 var compiler
= new
Compiler ();
627 return compiler
.run ();