aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorHarold Brenes <harold@hbrenes.com>2025-07-16 16:05:58 -0400
committerHarold Brenes <harold@hbrenes.com>2025-07-20 14:35:06 -0400
commit7c917d56e9d07a5c8940560d7f1d35c01bc5fe58 (patch)
tree2241e57d3b69260b2a0b967a55af4d395c901ccb /src/parser.cpp
parentb095dd71cbe8386de901674535c9d86ccf4cb9d3 (diff)
Check for invalid subtargets.
- Add 'ios' pseudo-subtarget which triggets with either iPhone or iPhoneSimulator subtargets. - Treat an explicit 'default' subtarget as exclusive only to the default subtarget, not an other platform-compatible subtargets. - 'generic' continues to resolve to true for any platform-compatible subtarget as it names appears to imply such behavior.
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 5d0a75f8a..7a2693e29 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -6220,9 +6220,10 @@ gb_internal bool parse_build_tag(Token token_for_pos, String s) {
continue;
}
- Subtarget subtarget = Subtarget_Default;
+ Subtarget subtarget = Subtarget_Invalid;
+ String subtarget_str = {};
- TargetOsKind os = get_target_os_from_string(p, &subtarget);
+ TargetOsKind os = get_target_os_from_string(p, &subtarget, &subtarget_str);
TargetArchKind arch = get_target_arch_from_string(p);
num_tokens += 1;
@@ -6233,10 +6234,29 @@ gb_internal bool parse_build_tag(Token token_for_pos, String s) {
break;
}
+ bool is_ios_subtarget = false;
+ if (subtarget == Subtarget_Invalid) {
+ // Special case for pseudo subtarget
+ if (!str_eq_ignore_case(subtarget_str, "ios")) {
+ syntax_error(token_for_pos, "Invalid subtarget '%.*s'.", LIT(subtarget_str));
+ break;
+ }
+
+ is_ios_subtarget = true;
+ }
+
+
if (os != TargetOs_Invalid) {
this_kind_os_seen = true;
- bool same_subtarget = (subtarget == Subtarget_Default) || (subtarget == selected_subtarget);
+ // NOTE: Only testing for 'default' and not 'generic' because the 'generic' nomenclature implies any subtarget.
+ bool is_explicit_default_subtarget = str_eq_ignore_case(subtarget_str, "default");
+ bool same_subtarget = (subtarget == Subtarget_Default && !is_explicit_default_subtarget) || (subtarget == selected_subtarget);
+
+ // Special case for iPhone or iPhoneSimulator
+ if (is_ios_subtarget && (selected_subtarget == Subtarget_iPhone || selected_subtarget == Subtarget_iPhoneSimulator)) {
+ same_subtarget = true;
+ }
GB_ASSERT(arch == TargetArch_Invalid);
if (is_notted) {