mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-30 19:30:06 +00:00
Add +build ignore tag
This commit is contained in:
+28
-21
@@ -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,28 +4868,34 @@ bool parse_build_tag(Token token_for_pos, String s) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p.len > 0) {
|
if (p.len == 0) {
|
||||||
TargetOsKind os = get_target_os_from_string(p);
|
continue;
|
||||||
TargetArchKind arch = get_target_arch_from_string(p);
|
}
|
||||||
if (os != TargetOs_Invalid) {
|
if (p == "ignore") {
|
||||||
GB_ASSERT(arch == TargetArch_Invalid);
|
this_kind_correct = false;
|
||||||
if (is_notted) {
|
continue;
|
||||||
this_kind_correct = this_kind_correct && (os != build_context.metrics.os);
|
}
|
||||||
} else {
|
|
||||||
this_kind_correct = this_kind_correct && (os == build_context.metrics.os);
|
TargetOsKind os = get_target_os_from_string(p);
|
||||||
}
|
TargetArchKind arch = get_target_arch_from_string(p);
|
||||||
} else if (arch != TargetArch_Invalid) {
|
if (os != TargetOs_Invalid) {
|
||||||
if (is_notted) {
|
GB_ASSERT(arch == TargetArch_Invalid);
|
||||||
this_kind_correct = this_kind_correct && (arch != build_context.metrics.arch);
|
if (is_notted) {
|
||||||
} else {
|
this_kind_correct = this_kind_correct && (os != build_context.metrics.os);
|
||||||
this_kind_correct = this_kind_correct && (arch == build_context.metrics.arch);
|
} else {
|
||||||
}
|
this_kind_correct = this_kind_correct && (os == build_context.metrics.os);
|
||||||
}
|
}
|
||||||
if (os == TargetOs_Invalid && arch == TargetArch_Invalid) {
|
} else if (arch != TargetArch_Invalid) {
|
||||||
syntax_error(token_for_pos, "Invalid build tag platform: %.*s", LIT(p));
|
if (is_notted) {
|
||||||
break;
|
this_kind_correct = this_kind_correct && (arch != build_context.metrics.arch);
|
||||||
|
} else {
|
||||||
|
this_kind_correct = this_kind_correct && (arch == build_context.metrics.arch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (os == TargetOs_Invalid && arch == TargetArch_Invalid) {
|
||||||
|
syntax_error(token_for_pos, "Invalid build tag platform: %.*s", LIT(p));
|
||||||
|
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};
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user