aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2025-04-10 11:36:03 +0100
committergingerBill <bill@gingerbill.org>2025-04-10 11:36:03 +0100
commit1f814c33dcfccec9073d15214268457c0d6ea273 (patch)
tree1c1457ecb2768046229a8119e59f82d16f54b207 /src/parser.cpp
parent5e63388de289f6cbf17e3fdae60f3a092f4419e5 (diff)
Support subtargets in build tags: `#build darwin:generic` and `#build linux:android, darwin:ios`
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index f38f79607..a397585e8 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -6157,7 +6157,7 @@ gb_internal String build_tag_get_token(String s, String *out) {
isize width = utf8_decode(&s[n], s.len-n, &rune);
if (n == 0 && rune == '!') {
- } else if (!rune_is_letter(rune) && !rune_is_digit(rune)) {
+ } else if (!rune_is_letter(rune) && !rune_is_digit(rune) && rune != ':') {
isize k = gb_max(gb_max(n, width), 1);
*out = substring(s, k, s.len);
return substring(s, 0, k);
@@ -6209,7 +6209,9 @@ gb_internal bool parse_build_tag(Token token_for_pos, String s) {
continue;
}
- TargetOsKind os = get_target_os_from_string(p);
+ Subtarget subtarget = Subtarget_Default;
+
+ TargetOsKind os = get_target_os_from_string(p, &subtarget);
TargetArchKind arch = get_target_arch_from_string(p);
num_tokens += 1;
@@ -6223,11 +6225,13 @@ gb_internal bool parse_build_tag(Token token_for_pos, String s) {
if (os != TargetOs_Invalid) {
this_kind_os_seen = true;
+ bool same_subtarget = (subtarget == Subtarget_Default) || (subtarget == selected_subtarget);
+
GB_ASSERT(arch == TargetArch_Invalid);
if (is_notted) {
- this_kind_correct = this_kind_correct && (os != build_context.metrics.os);
+ this_kind_correct = this_kind_correct && (os != build_context.metrics.os || !same_subtarget);
} else {
- this_kind_correct = this_kind_correct && (os == build_context.metrics.os);
+ this_kind_correct = this_kind_correct && (os == build_context.metrics.os && same_subtarget);
}
} else if (arch != TargetArch_Invalid) {
this_kind_arch_seen = true;