mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 05:08:14 +00:00
Fix //+build system
This commit is contained in:
+46
-44
@@ -4585,8 +4585,12 @@ String build_tag_get_token(String s, String *out) {
|
|||||||
while (n < s.len) {
|
while (n < s.len) {
|
||||||
Rune rune = 0;
|
Rune rune = 0;
|
||||||
isize width = gb_utf8_decode(&s[n], s.len-n, &rune);
|
isize width = gb_utf8_decode(&s[n], s.len-n, &rune);
|
||||||
if (rune_is_whitespace(rune)) {
|
if (n == 0 && rune == ',') {
|
||||||
*out = substring(s, n+width, s.len);
|
*out = substring(s, width, s.len);
|
||||||
|
return substring(s, 0, width);
|
||||||
|
}
|
||||||
|
if (!rune_is_letter(rune) && !rune_is_digit(rune)) {
|
||||||
|
*out = substring(s, n, s.len);
|
||||||
return substring(s, 0, n);
|
return substring(s, 0, n);
|
||||||
}
|
}
|
||||||
n += width;
|
n += width;
|
||||||
@@ -4606,54 +4610,52 @@ bool parse_build_tag(Token token_for_pos, String s) {
|
|||||||
|
|
||||||
bool any_correct = false;
|
bool any_correct = false;
|
||||||
|
|
||||||
do {
|
while (s.len > 0) {
|
||||||
String p = build_tag_get_token(s, &s);
|
bool this_kind_correct = true;
|
||||||
if (p.len == 0) break;
|
|
||||||
bool is_notted = false;
|
|
||||||
if (p[0] == '!') {
|
|
||||||
is_notted = true;
|
|
||||||
p = substring(p, 1, p.len);
|
|
||||||
if (p.len == 0) {
|
|
||||||
syntax_error(token_for_pos, "Expected a build platform after '!'");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p.len > 0) {
|
do {
|
||||||
TargetOsKind os = get_target_os_from_string(p);
|
String p = build_tag_get_token(s, &s);
|
||||||
TargetArchKind arch = get_target_arch_from_string(p);
|
if (p.len == 0) break;
|
||||||
if (os != TargetOs_Invalid) {
|
if (p == ",") break;
|
||||||
GB_ASSERT(arch == TargetArch_Invalid);
|
|
||||||
any_correct = true;
|
bool is_notted = false;
|
||||||
if (is_notted) {
|
if (p[0] == '!') {
|
||||||
if (os != build_context.metrics.os) {
|
is_notted = true;
|
||||||
return true;
|
p = substring(p, 1, p.len);
|
||||||
}
|
if (p.len == 0) {
|
||||||
} else if (os == build_context.metrics.os) {
|
syntax_error(token_for_pos, "Expected a build platform after '!'");
|
||||||
return true;
|
break;
|
||||||
}
|
|
||||||
} else if (arch != TargetArch_Invalid) {
|
|
||||||
any_correct = true;
|
|
||||||
if (is_notted) {
|
|
||||||
if (arch != build_context.metrics.arch) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (arch == build_context.metrics.arch) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (os == TargetOs_Invalid && arch == TargetArch_Invalid) {
|
|
||||||
syntax_error(token_for_pos, "Invalid build tag platform: %.*s", LIT(p));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (s.len > 0);
|
|
||||||
|
|
||||||
if (any_correct) {
|
if (p.len > 0) {
|
||||||
return false;
|
TargetOsKind os = get_target_os_from_string(p);
|
||||||
|
TargetArchKind arch = get_target_arch_from_string(p);
|
||||||
|
if (os != TargetOs_Invalid) {
|
||||||
|
GB_ASSERT(arch == TargetArch_Invalid);
|
||||||
|
if (is_notted && os == build_context.metrics.os) {
|
||||||
|
this_kind_correct = false;
|
||||||
|
} else if (os != build_context.metrics.os) {
|
||||||
|
this_kind_correct = false;
|
||||||
|
}
|
||||||
|
} else if (arch != TargetArch_Invalid) {
|
||||||
|
if (is_notted && arch == build_context.metrics.arch) {
|
||||||
|
this_kind_correct = false;
|
||||||
|
} else if (arch != build_context.metrics.arch) {
|
||||||
|
this_kind_correct = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (os == TargetOs_Invalid && arch == TargetArch_Invalid) {
|
||||||
|
syntax_error(token_for_pos, "Invalid build tag platform: %.*s", LIT(p));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (s.len > 0);
|
||||||
|
|
||||||
|
any_correct = any_correct || this_kind_correct;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return any_correct;
|
||||||
}
|
}
|
||||||
|
|
||||||
String dir_from_path(String path) {
|
String dir_from_path(String path) {
|
||||||
|
|||||||
Reference in New Issue
Block a user