if (sym.external_package || (!decl_space.is_header && CodeContext.get ().use_header && !sym.is_internal_symbol ())) {
// add appropriate include file
foreach (string header_filename in get_ccode_header_filenames (sym).split (",")) {
- decl_space.add_include (header_filename, !sym.external_package);
+ decl_space.add_include (header_filename, !sym.external_package ||
+ (sym.external_package &&
+ sym.from_commandline));
}
// declaration complete
return true;
bool has_c_files = false;
foreach (string source in sources) {
- if (context.add_source_filename (source, run_output)) {
+ if (context.add_source_filename (source, run_output, true)) {
if (source.has_suffix (".c")) {
has_c_files = true;
}
*
* @param filename a filename
* @param is_source true to force adding the file as .vala or .gs
+ * @param cmdline true if the file came from the command line.
* @return false if the file is not recognized or the file does not exist
*/
- public bool add_source_filename (string filename, bool is_source = false) {
+ public bool add_source_filename (string filename, bool is_source = false, bool cmdline = false) {
if (!FileUtils.test (filename, FileTest.EXISTS)) {
Report.error (null, "%s not found".printf (filename));
return false;
var rpath = realpath (filename);
if (is_source || filename.has_suffix (".vala") || filename.has_suffix (".gs")) {
- var source_file = new SourceFile (this, SourceFileType.SOURCE, rpath);
+ var source_file = new SourceFile (this, SourceFileType.SOURCE, rpath, null, cmdline);
source_file.relative_filename = filename;
if (profile == Profile.POSIX) {
add_source_file (source_file);
} else if (filename.has_suffix (".vapi") || filename.has_suffix (".gir")) {
- var source_file = new SourceFile (this, SourceFileType.PACKAGE, rpath);
+ var source_file = new SourceFile (this, SourceFileType.PACKAGE, rpath, null, cmdline);
source_file.relative_filename = filename;
add_source_file (source_file);
*/
public SourceFileType file_type { get; set; }
+ /**
+ * Specifies whether this file came from the command line directly.
+ */
+ public bool from_commandline { get; set; }
+
/**
* GIR Namespace for this source file, if it's a VAPI package
*/
* @param pkg true if this is a VAPI package file
* @return newly created source file
*/
- public SourceFile (CodeContext context, SourceFileType type, string filename, string? content = null) {
+ public SourceFile (CodeContext context, SourceFileType type, string filename, string? content = null, bool cmdline = false) {
this.context = context;
this.file_type = type;
this.filename = filename;
this.content = content;
+ this.from_commandline = cmdline;
}
/**
}
}
+ /**
+ * Specifies whether the implementation came from the commandline.
+ */
+ public bool from_commandline {
+ get {
+ if (source_reference != null) {
+ return source_reference.file.from_commandline;
+ } else {
+ return false;
+ }
+ }
+ }
+
/**
* Gets the SourceFileType of the source file that this symbol
* came from, or SourceFileType.NONE.