Add +build ignore tag

This commit is contained in:
gingerBill
2020-10-15 16:25:57 +01:00
parent 5a28a7e0f5
commit 289908e0b8
2 changed files with 29 additions and 21 deletions
+11 -4
View File
@@ -4507,12 +4507,14 @@ bool try_add_import_path(Parser *p, String const &path, String const &rel_path,
// NOTE(bill): Single file initial package // NOTE(bill): Single file initial package
if (kind == Package_Init && string_ends_with(path, FILE_EXT)) { if (kind == Package_Init && string_ends_with(path, FILE_EXT)) {
FileInfo fi = {}; FileInfo fi = {};
fi.name = filename_from_path(path); fi.name = filename_from_path(path);
fi.fullpath = path; fi.fullpath = path;
fi.size = get_file_size(path); fi.size = get_file_size(path);
fi.is_dir = false; fi.is_dir = false;
pkg->is_single_file = true;
parser_add_file_to_process(p, pkg, fi, pos); parser_add_file_to_process(p, pkg, fi, pos);
parser_add_package(p, pkg); parser_add_package(p, pkg);
return true; return true;
@@ -4866,7 +4868,14 @@ bool parse_build_tag(Token token_for_pos, String s) {
} }
} }
if (p.len > 0) { if (p.len == 0) {
continue;
}
if (p == "ignore") {
this_kind_correct = false;
continue;
}
TargetOsKind os = get_target_os_from_string(p); TargetOsKind os = get_target_os_from_string(p);
TargetArchKind arch = get_target_arch_from_string(p); TargetArchKind arch = get_target_arch_from_string(p);
if (os != TargetOs_Invalid) { if (os != TargetOs_Invalid) {
@@ -4887,7 +4896,6 @@ bool parse_build_tag(Token token_for_pos, String s) {
syntax_error(token_for_pos, "Invalid build tag platform: %.*s", LIT(p)); syntax_error(token_for_pos, "Invalid build tag platform: %.*s", LIT(p));
break; break;
} }
}
} while (s.len > 0); } while (s.len > 0);
any_correct = any_correct || this_kind_correct; any_correct = any_correct || this_kind_correct;
@@ -4942,7 +4950,7 @@ bool parse_file(Parser *p, AstFile *f) {
} }
f->package_name = package_name.string; f->package_name = package_name.string;
if (docs != nullptr && docs->list.count > 0) { if (!f->pkg->is_single_file && docs != nullptr && docs->list.count > 0) {
for_array(i, docs->list) { for_array(i, docs->list) {
Token tok = docs->list[i]; GB_ASSERT(tok.kind == Token_Comment); Token tok = docs->list[i]; GB_ASSERT(tok.kind == Token_Comment);
String str = tok.string; String str = tok.string;
@@ -4996,7 +5004,6 @@ ParseFileError process_imported_file(Parser *p, ImportedFile const &imported_fil
AstFile *file = gb_alloc_item(heap_allocator(), AstFile); AstFile *file = gb_alloc_item(heap_allocator(), AstFile);
file->pkg = pkg; file->pkg = pkg;
file->id = imported_file.index+1; file->id = imported_file.index+1;
TokenPos err_pos = {0}; TokenPos err_pos = {0};
+1
View File
@@ -128,6 +128,7 @@ struct AstPackage {
String name; String name;
String fullpath; String fullpath;
Array<AstFile *> files; Array<AstFile *> files;
bool is_single_file;
// NOTE(bill): Created/set in checker // NOTE(bill): Created/set in checker
Scope * scope; Scope * scope;