Skip to content

Commit 55142f5

Browse files
Ensure the same env variables are being used during indexing (#292)
1 parent 8449a6e commit 55142f5

File tree

7 files changed

+72
-5
lines changed

7 files changed

+72
-5
lines changed

examples/ios_app/test/fixtures/project.xcodeproj/project.pbxproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@
10211021
);
10221022
runOnlyForDeploymentPostprocessing = 0;
10231023
shellPath = /bin/sh;
1024-
shellScript = "set -eu\n\n# Need to remove the directory that Xcode creates as part of output prep\nrm -rf \"$PROJECT_DIR/bazel-out\"\n\nPATH=\"${PATH//\\/usr\\/local\\/bin//opt/homebrew/bin:/usr/local/bin}\" \\\n ${BAZEL_PATH} \\\n build \\\n --output_groups=generated_inputs \\\n //test/fixtures:fixture\n";
1024+
shellScript = "set -eu\n\n# Need to remove the directory that Xcode creates as part of output prep\nrm -rf \"$PROJECT_DIR/bazel-out\"\n\nenv -i \\\n DEVELOPER_DIR=\"$DEVELOPER_DIR\" \\\n HOME=\"$HOME\" \\\n PATH=\"${PATH//\\/usr\\/local\\/bin//opt/homebrew/bin:/usr/local/bin}\" \\\n USER=\"$USER\" \\\n ${BAZEL_PATH} \\\n build \\\n --output_groups=generated_inputs \\\n //test/fixtures:fixture\n";
10251025
showEnvVarsInLog = 0;
10261026
};
10271027
C977250D6EB972BF2FF38593 /* Fix Modulemaps */ = {
@@ -1574,7 +1574,10 @@
15741574
70E18BE128A25A1F96CAB0FE /* Debug */ = {
15751575
isa = XCBuildConfiguration;
15761576
buildSettings = {
1577+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
15771578
BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj;
1579+
SUPPORTED_PLATFORMS = "watchsimulator watchos macosx iphonesimulator iphoneos driverkit appletvsimulator appletvos";
1580+
SUPPORTS_MACCATALYST = YES;
15781581
TARGET_NAME = Setup;
15791582
};
15801583
name = Debug;
@@ -1670,7 +1673,10 @@
16701673
ACE65DF71AEBC3D1DAF7EF52 /* Debug */ = {
16711674
isa = XCBuildConfiguration;
16721675
buildSettings = {
1676+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
16731677
BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj;
1678+
SUPPORTED_PLATFORMS = "watchsimulator watchos macosx iphonesimulator iphoneos driverkit appletvsimulator appletvos";
1679+
SUPPORTS_MACCATALYST = YES;
16741680
TARGET_NAME = GenerateBazelFiles;
16751681
};
16761682
name = Debug;

test/fixtures/cc/project.xcodeproj/project.pbxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,10 @@
434434
70E18BE128A25A1F96CAB0FE /* Debug */ = {
435435
isa = XCBuildConfiguration;
436436
buildSettings = {
437+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
437438
BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj;
439+
SUPPORTED_PLATFORMS = "watchsimulator watchos macosx iphonesimulator iphoneos driverkit appletvsimulator appletvos";
440+
SUPPORTS_MACCATALYST = YES;
438441
TARGET_NAME = Setup;
439442
};
440443
name = Debug;

test/fixtures/command_line/project.xcodeproj/project.pbxproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@
637637
);
638638
runOnlyForDeploymentPostprocessing = 0;
639639
shellPath = /bin/sh;
640-
shellScript = "set -eu\n\n# Need to remove the directory that Xcode creates as part of output prep\nrm -rf \"$PROJECT_DIR/bazel-out\"\n\nPATH=\"${PATH//\\/usr\\/local\\/bin//opt/homebrew/bin:/usr/local/bin}\" \\\n ${BAZEL_PATH} \\\n build \\\n --output_groups=generated_inputs \\\n //test/fixtures/command_line:xcodeproj\n";
640+
shellScript = "set -eu\n\n# Need to remove the directory that Xcode creates as part of output prep\nrm -rf \"$PROJECT_DIR/bazel-out\"\n\nenv -i \\\n DEVELOPER_DIR=\"$DEVELOPER_DIR\" \\\n HOME=\"$HOME\" \\\n PATH=\"${PATH//\\/usr\\/local\\/bin//opt/homebrew/bin:/usr/local/bin}\" \\\n USER=\"$USER\" \\\n ${BAZEL_PATH} \\\n build \\\n --output_groups=generated_inputs \\\n //test/fixtures/command_line:xcodeproj\n";
641641
showEnvVarsInLog = 0;
642642
};
643643
8B6A1F2475BB65156F63CE12 /* Copy Swift Generated Header */ = {
@@ -951,7 +951,10 @@
951951
70E18BE128A25A1F96CAB0FE /* Debug */ = {
952952
isa = XCBuildConfiguration;
953953
buildSettings = {
954+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
954955
BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj;
956+
SUPPORTED_PLATFORMS = "watchsimulator watchos macosx iphonesimulator iphoneos driverkit appletvsimulator appletvos";
957+
SUPPORTS_MACCATALYST = YES;
955958
TARGET_NAME = Setup;
956959
};
957960
name = Debug;
@@ -1037,7 +1040,10 @@
10371040
ACE65DF71AEBC3D1DAF7EF52 /* Debug */ = {
10381041
isa = XCBuildConfiguration;
10391042
buildSettings = {
1043+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
10401044
BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj;
1045+
SUPPORTED_PLATFORMS = "watchsimulator watchos macosx iphonesimulator iphoneos driverkit appletvsimulator appletvos";
1046+
SUPPORTS_MACCATALYST = YES;
10411047
TARGET_NAME = GenerateBazelFiles;
10421048
};
10431049
name = Debug;

test/fixtures/generator/project.xcodeproj/project.pbxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,10 @@
18271827
70E18BE128A25A1F96CAB0FE /* Debug */ = {
18281828
isa = XCBuildConfiguration;
18291829
buildSettings = {
1830+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
18301831
BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj;
1832+
SUPPORTED_PLATFORMS = "watchsimulator watchos macosx iphonesimulator iphoneos driverkit appletvsimulator appletvos";
1833+
SUPPORTS_MACCATALYST = YES;
18311834
TARGET_NAME = Setup;
18321835
};
18331836
name = Debug;

test/fixtures/tvos_app/project.xcodeproj/project.pbxproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@
467467
);
468468
runOnlyForDeploymentPostprocessing = 0;
469469
shellPath = /bin/sh;
470-
shellScript = "set -eu\n\n# Need to remove the directory that Xcode creates as part of output prep\nrm -rf \"$PROJECT_DIR/bazel-out\"\n\nPATH=\"${PATH//\\/usr\\/local\\/bin//opt/homebrew/bin:/usr/local/bin}\" \\\n ${BAZEL_PATH} \\\n build \\\n --output_groups=generated_inputs \\\n //test/fixtures/tvos_app:xcodeproj\n";
470+
shellScript = "set -eu\n\n# Need to remove the directory that Xcode creates as part of output prep\nrm -rf \"$PROJECT_DIR/bazel-out\"\n\nenv -i \\\n DEVELOPER_DIR=\"$DEVELOPER_DIR\" \\\n HOME=\"$HOME\" \\\n PATH=\"${PATH//\\/usr\\/local\\/bin//opt/homebrew/bin:/usr/local/bin}\" \\\n USER=\"$USER\" \\\n ${BAZEL_PATH} \\\n build \\\n --output_groups=generated_inputs \\\n //test/fixtures/tvos_app:xcodeproj\n";
471471
showEnvVarsInLog = 0;
472472
};
473473
ECDF8E3FB28F2FB706B4D395 /* Create Symlinks */ = {
@@ -677,7 +677,10 @@
677677
70E18BE128A25A1F96CAB0FE /* Debug */ = {
678678
isa = XCBuildConfiguration;
679679
buildSettings = {
680+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
680681
BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj;
682+
SUPPORTED_PLATFORMS = "watchsimulator watchos macosx iphonesimulator iphoneos driverkit appletvsimulator appletvos";
683+
SUPPORTS_MACCATALYST = YES;
681684
TARGET_NAME = Setup;
682685
};
683686
name = Debug;
@@ -703,7 +706,10 @@
703706
ACE65DF71AEBC3D1DAF7EF52 /* Debug */ = {
704707
isa = XCBuildConfiguration;
705708
buildSettings = {
709+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
706710
BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj;
711+
SUPPORTED_PLATFORMS = "watchsimulator watchos macosx iphonesimulator iphoneos driverkit appletvsimulator appletvos";
712+
SUPPORTS_MACCATALYST = YES;
707713
TARGET_NAME = GenerateBazelFiles;
708714
};
709715
name = Debug;

tools/generator/src/Generator+AddTargets.swift

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ import PathKit
22
import XcodeProj
33

44
extension Generator {
5+
// Xcode likes this list as a string, and apparently in reverse
6+
static let allPlatforms = """
7+
watchsimulator \
8+
watchos \
9+
macosx \
10+
iphonesimulator \
11+
iphoneos \
12+
driverkit \
13+
appletvsimulator \
14+
appletvos
15+
"""
16+
517
static func addTargets(
618
in pbxProj: PBXProj,
719
for disambiguatedTargets: [TargetID: DisambiguatedTarget],
@@ -116,7 +128,10 @@ Product for target "\(id)" not found in `products`
116128
let debugConfiguration = XCBuildConfiguration(
117129
name: "Debug",
118130
buildSettings: [
131+
"ALLOW_TARGET_PLATFORM_SPECIALIZATION": true,
119132
"BAZEL_PACKAGE_BIN_DIR": "rules_xcodeproj",
133+
"SUPPORTED_PLATFORMS": allPlatforms,
134+
"SUPPORTS_MACCATALYST": true,
120135
"TARGET_NAME": "Setup",
121136
]
122137
)
@@ -185,7 +200,10 @@ ln -sfn "\#(
185200
let debugConfiguration = XCBuildConfiguration(
186201
name: "Debug",
187202
buildSettings: [
203+
"ALLOW_TARGET_PLATFORM_SPECIALIZATION": true,
188204
"BAZEL_PACKAGE_BIN_DIR": "rules_xcodeproj",
205+
"SUPPORTED_PLATFORMS": allPlatforms,
206+
"SUPPORTS_MACCATALYST": true,
189207
"TARGET_NAME": "GenerateBazelFiles",
190208
]
191209
)
@@ -218,7 +236,11 @@ rm -rf "$PROJECT_DIR/\(filePathResolver.generatedDirectory)"
218236
shellScript: #"""
219237
set -eu
220238
\#(removeWorkspaceBazelOut)
221-
PATH="${PATH//\/usr\/local\/bin//opt/homebrew/bin:/usr/local/bin}" \
239+
env -i \
240+
DEVELOPER_DIR="$DEVELOPER_DIR" \
241+
HOME="$HOME" \
242+
PATH="${PATH//\/usr\/local\/bin//opt/homebrew/bin:/usr/local/bin}" \
243+
USER="$USER" \
222244
${BAZEL_PATH} \
223245
build \
224246
--output_groups=generated_inputs \

tools/generator/test/Fixtures.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,10 +1093,24 @@ bazel-out/a/c.a
10931093

10941094
let pbxProject = pbxProj.rootObject!
10951095

1096+
let allPlatforms = """
1097+
watchsimulator \
1098+
watchos \
1099+
macosx \
1100+
iphonesimulator \
1101+
iphoneos \
1102+
driverkit \
1103+
appletvsimulator \
1104+
appletvos
1105+
"""
1106+
10961107
let setupDebugConfiguration = XCBuildConfiguration(
10971108
name: "Debug",
10981109
buildSettings: [
1110+
"ALLOW_TARGET_PLATFORM_SPECIALIZATION": true,
10991111
"BAZEL_PACKAGE_BIN_DIR": "rules_xcodeproj",
1112+
"SUPPORTED_PLATFORMS": allPlatforms,
1113+
"SUPPORTS_MACCATALYST": true,
11001114
"TARGET_NAME": "Setup",
11011115
]
11021116
)
@@ -1148,7 +1162,10 @@ ln -sfn "\#(
11481162
let generateFilesDebugConfiguration = XCBuildConfiguration(
11491163
name: "Debug",
11501164
buildSettings: [
1165+
"ALLOW_TARGET_PLATFORM_SPECIALIZATION": true,
11511166
"BAZEL_PACKAGE_BIN_DIR": "rules_xcodeproj",
1167+
"SUPPORTED_PLATFORMS": allPlatforms,
1168+
"SUPPORTS_MACCATALYST": true,
11521169
"TARGET_NAME": "GenerateBazelFiles",
11531170
]
11541171
)
@@ -1167,7 +1184,11 @@ ln -sfn "\#(
11671184
shellScript: #"""
11681185
set -eu
11691186
1170-
PATH="${PATH//\/usr\/local\/bin//opt/homebrew/bin:/usr/local/bin}" \
1187+
env -i \
1188+
DEVELOPER_DIR="$DEVELOPER_DIR" \
1189+
HOME="$HOME" \
1190+
PATH="${PATH//\/usr\/local\/bin//opt/homebrew/bin:/usr/local/bin}" \
1191+
USER="$USER" \
11711192
${BAZEL_PATH} \
11721193
build \
11731194
--output_groups=generated_inputs \

0 commit comments

Comments
 (0)