Skip to content

Commit c05862a

Browse files
committed
Fix srcs collection for cc_binary and swift_binary
Also adjust `//examples/simple` to be a `swift_binary` without any library dependency.
1 parent 01fe171 commit c05862a

File tree

11 files changed

+207
-182
lines changed

11 files changed

+207
-182
lines changed

examples/simple/BUILD

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
1+
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_binary")
22
load("//xcodeproj:xcodeproj.bzl", "xcodeproj")
33
load(":xcodeproj_targets.bzl", "XCODEPROJ_TARGETS")
44

5-
swift_library(
6-
name = "SwiftLib",
5+
swift_binary(
6+
name = "SwiftBin",
77
srcs = glob(["*.swift"]),
8+
module_name = "SwiftBinModuleName",
89
visibility = ["//visibility:public"],
910
)
1011

examples/simple/Simple.swift

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/simple/main.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Hello, world!")

examples/simple/xcodeproj_targets.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Exposes targets used by `xcodeproj` to allow use in fixture tests."""
22

33
XCODEPROJ_TARGETS = [
4-
"//examples/simple:SwiftLib",
4+
"//examples/simple:SwiftBin",
55
]

test/fixtures/simple/bwb.xcodeproj/project.pbxproj

Lines changed: 65 additions & 78 deletions
Large diffs are not rendered by default.

test/fixtures/simple/bwb.xcodeproj/xcshareddata/xcschemes/SwiftLib.xcscheme renamed to test/fixtures/simple/bwb.xcodeproj/xcshareddata/xcschemes/SwiftBin.xcscheme

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
<EnvironmentBuildable>
1515
<BuildableReference
1616
BuildableIdentifier = "primary"
17-
BlueprintIdentifier = "B85E54D3E392F9C984FF4A86"
18-
BuildableName = "SwiftLib"
19-
BlueprintName = "SwiftLib"
17+
BlueprintIdentifier = "364D5AA9408E41F7F9C99C9B"
18+
BuildableName = "SwiftBin"
19+
BlueprintName = "SwiftBin"
2020
ReferencedContainer = "container:test/fixtures/simple/bwb.xcodeproj">
2121
</BuildableReference>
2222
</EnvironmentBuildable>
@@ -32,9 +32,9 @@
3232
buildForAnalyzing = "YES">
3333
<BuildableReference
3434
BuildableIdentifier = "primary"
35-
BlueprintIdentifier = "B85E54D3E392F9C984FF4A86"
36-
BuildableName = "SwiftLib"
37-
BlueprintName = "SwiftLib"
35+
BlueprintIdentifier = "364D5AA9408E41F7F9C99C9B"
36+
BuildableName = "SwiftBin"
37+
BlueprintName = "SwiftBin"
3838
ReferencedContainer = "container:test/fixtures/simple/bwb.xcodeproj">
3939
</BuildableReference>
4040
</BuildActionEntry>
@@ -60,13 +60,45 @@
6060
debugDocumentVersioning = "YES"
6161
debugServiceExtension = "internal"
6262
allowLocationSimulation = "YES">
63+
<BuildableProductRunnable
64+
runnableDebuggingMode = "0">
65+
<BuildableReference
66+
BuildableIdentifier = "primary"
67+
BlueprintIdentifier = "364D5AA9408E41F7F9C99C9B"
68+
BuildableName = "SwiftBin"
69+
BlueprintName = "SwiftBin"
70+
ReferencedContainer = "container:test/fixtures/simple/bwb.xcodeproj">
71+
</BuildableReference>
72+
</BuildableProductRunnable>
73+
<EnvironmentVariables>
74+
<EnvironmentVariable
75+
key = "BUILD_WORKSPACE_DIRECTORY"
76+
value = "$(SRCROOT)"
77+
isEnabled = "YES">
78+
</EnvironmentVariable>
79+
<EnvironmentVariable
80+
key = "BUILD_WORKING_DIRECTORY"
81+
value = "$(BUILT_PRODUCTS_DIR)"
82+
isEnabled = "YES">
83+
</EnvironmentVariable>
84+
</EnvironmentVariables>
6385
</LaunchAction>
6486
<ProfileAction
6587
buildConfiguration = "Debug"
6688
shouldUseLaunchSchemeArgsEnv = "YES"
6789
savedToolIdentifier = ""
6890
useCustomWorkingDirectory = "NO"
6991
debugDocumentVersioning = "YES">
92+
<BuildableProductRunnable
93+
runnableDebuggingMode = "0">
94+
<BuildableReference
95+
BuildableIdentifier = "primary"
96+
BlueprintIdentifier = "364D5AA9408E41F7F9C99C9B"
97+
BuildableName = "SwiftBin"
98+
BlueprintName = "SwiftBin"
99+
ReferencedContainer = "container:test/fixtures/simple/bwb.xcodeproj">
100+
</BuildableReference>
101+
</BuildableProductRunnable>
70102
</ProfileAction>
71103
<AnalyzeAction
72104
buildConfiguration = "Debug">

test/fixtures/simple/bwb_spec.json

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,14 @@
2121
"scheme_autogeneration_mode": "auto",
2222
"target_merges": [],
2323
"targets": [
24-
"//examples/simple:SwiftLib darwin_x86_64-dbg-ST-f7d2792bf9e4",
24+
"//examples/simple:SwiftBin darwin_x86_64-dbg-ST-f7d2792bf9e4",
2525
{
2626
"build_settings": {
2727
"DEBUG_INFORMATION_FORMAT": "dwarf",
2828
"ENABLE_BITCODE": false,
29-
"ENABLE_TESTABILITY": true,
3029
"GCC_OPTIMIZATION_LEVEL": "0",
3130
"MACOSX_DEPLOYMENT_TARGET": "11.0",
32-
"OTHER_SWIFT_FLAGS": "-Xcc -O0 -Xcc -DDEBUG=1 -Xcc -fstack-protector -Xcc -fstack-protector-all -g -static",
33-
"PRODUCT_MODULE_NAME": "examples_simple_SwiftLib",
34-
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "DEBUG",
31+
"PRODUCT_MODULE_NAME": "_SwiftBin_Stub",
3532
"SWIFT_OBJC_INTERFACE_HEADER_NAME": "",
3633
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
3734
"SWIFT_VERSION": "5"
@@ -41,28 +38,24 @@
4138
"info_plist": null,
4239
"inputs": {
4340
"srcs": [
44-
"examples/simple/Simple.swift"
41+
"examples/simple/main.swift"
42+
]
43+
},
44+
"is_swift": false,
45+
"label": "//examples/simple:SwiftBin",
46+
"linker_inputs": {
47+
"linkopts": [
48+
"-headerpad_max_install_names",
49+
"-no-canonical-prefixes",
50+
"-lc++"
4551
]
4652
},
47-
"is_swift": true,
48-
"label": "//examples/simple:SwiftLib",
49-
"linker_inputs": {},
5053
"modulemaps": [],
51-
"name": "SwiftLib",
54+
"name": "SwiftBin",
5255
"outputs": {
53-
"s": {
54-
"d": {
55-
"_": "darwin_x86_64-dbg-ST-f7d2792bf9e4/bin/examples/simple/examples_simple_SwiftLib.swiftdoc",
56-
"t": "g"
57-
},
58-
"m": {
59-
"_": "darwin_x86_64-dbg-ST-f7d2792bf9e4/bin/examples/simple/examples_simple_SwiftLib.swiftmodule",
60-
"t": "g"
61-
},
62-
"s": {
63-
"_": "darwin_x86_64-dbg-ST-f7d2792bf9e4/bin/examples/simple/examples_simple_SwiftLib.swiftsourceinfo",
64-
"t": "g"
65-
}
56+
"p": {
57+
"_": "darwin_x86_64-dbg-ST-f7d2792bf9e4/bin/examples/simple/SwiftBin",
58+
"t": "g"
6659
}
6760
},
6861
"package_bin_dir": "bazel-out/darwin_x86_64-dbg-ST-f7d2792bf9e4/bin/examples/simple",
@@ -73,23 +66,15 @@
7366
"os": "macos"
7467
},
7568
"product": {
76-
"name": "SwiftLib",
69+
"name": "SwiftBin",
7770
"path": {
78-
"_": "darwin_x86_64-dbg-ST-f7d2792bf9e4/bin/examples/simple/libSwiftLib.a",
71+
"_": "darwin_x86_64-dbg-ST-f7d2792bf9e4/bin/examples/simple/SwiftBin",
7972
"t": "g"
8073
},
81-
"type": "com.apple.product-type.library.static"
74+
"type": "com.apple.product-type.tool"
8275
},
8376
"resource_bundle_dependencies": [],
84-
"search_paths": {
85-
"quote_includes": [
86-
".",
87-
{
88-
"_": "darwin_x86_64-dbg-ST-f7d2792bf9e4/bin",
89-
"t": "g"
90-
}
91-
]
92-
},
77+
"search_paths": {},
9378
"swiftmodules": [],
9479
"test_host": null
9580
}

test/fixtures/simple/bwx.xcodeproj/project.pbxproj

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
FE3383EFF1D854D9D4846F60 /* Simple.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C44952DD5F5456C26985341 /* Simple.swift */; };
10+
6B580635F136B2B4F21AECA8 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6CAF173167678D4AA03292A /* main.swift */; };
1111
/* End PBXBuildFile section */
1212

1313
/* Begin PBXFileReference section */
14-
020B724402D287748A1EDA31 /* libSwiftLib.a */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; name = libSwiftLib.a; path = "bazel-out/darwin_x86_64-dbg-ST-ccd9595da841/bin/examples/simple/libSwiftLib.a"; sourceTree = BUILT_PRODUCTS_DIR; };
15-
7C44952DD5F5456C26985341 /* Simple.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Simple.swift; sourceTree = "<group>"; };
1614
805698F32A89163552CCEDA0 /* BUILD */ = {isa = PBXFileReference; explicitFileType = text.script.python; path = BUILD; sourceTree = "<group>"; };
15+
8D5740841C20DDAA295ACE32 /* SwiftBin */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SwiftBin; sourceTree = BUILT_PRODUCTS_DIR; };
16+
B6CAF173167678D4AA03292A /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
1717
CAE9B6B26F2CB596376EB704 /* BUILD */ = {isa = PBXFileReference; explicitFileType = text.script.python; path = BUILD; sourceTree = "<group>"; };
1818
/* End PBXFileReference section */
1919

@@ -29,7 +29,7 @@
2929
462C3519CA354BE1B04D4855 /* Products */ = {
3030
isa = PBXGroup;
3131
children = (
32-
020B724402D287748A1EDA31 /* libSwiftLib.a */,
32+
8D5740841C20DDAA295ACE32 /* SwiftBin */,
3333
);
3434
name = Products;
3535
sourceTree = "<group>";
@@ -46,7 +46,7 @@
4646
isa = PBXGroup;
4747
children = (
4848
805698F32A89163552CCEDA0 /* BUILD */,
49-
7C44952DD5F5456C26985341 /* Simple.swift */,
49+
B6CAF173167678D4AA03292A /* main.swift */,
5050
);
5151
path = simple;
5252
sourceTree = "<group>";
@@ -87,19 +87,20 @@
8787
/* End PBXGroup section */
8888

8989
/* Begin PBXNativeTarget section */
90-
76E061AB0CA7FA140667E530 /* SwiftLib */ = {
90+
5365B2022C99A98F03DF07CA /* SwiftBin */ = {
9191
isa = PBXNativeTarget;
92-
buildConfigurationList = B7432B2E592DE3E3F9D8D947 /* Build configuration list for PBXNativeTarget "SwiftLib" */;
92+
buildConfigurationList = 6E924F0CBE1CE62C4DE78EBB /* Build configuration list for PBXNativeTarget "SwiftBin" */;
9393
buildPhases = (
94-
2E02756FA53287FEE4BA2957 /* Sources */,
94+
068C8466216A7B314C8730B1 /* Sources */,
9595
);
9696
buildRules = (
9797
);
9898
dependencies = (
9999
);
100-
name = SwiftLib;
101-
productName = SwiftLib;
102-
productType = "com.apple.product-type.library.static";
100+
name = SwiftBin;
101+
productName = SwiftBin;
102+
productReference = 8D5740841C20DDAA295ACE32 /* SwiftBin */;
103+
productType = "com.apple.product-type.tool";
103104
};
104105
/* End PBXNativeTarget section */
105106

@@ -111,7 +112,7 @@
111112
LastSwiftUpdateCheck = 1320;
112113
LastUpgradeCheck = 1320;
113114
TargetAttributes = {
114-
76E061AB0CA7FA140667E530 = {
115+
5365B2022C99A98F03DF07CA = {
115116
CreatedOnToolsVersion = 13.2.1;
116117
LastSwiftMigration = 1320;
117118
};
@@ -130,50 +131,50 @@
130131
projectDirPath = ../../..;
131132
projectRoot = "";
132133
targets = (
133-
76E061AB0CA7FA140667E530 /* SwiftLib */,
134+
5365B2022C99A98F03DF07CA /* SwiftBin */,
134135
);
135136
};
136137
/* End PBXProject section */
137138

138139
/* Begin PBXSourcesBuildPhase section */
139-
2E02756FA53287FEE4BA2957 /* Sources */ = {
140+
068C8466216A7B314C8730B1 /* Sources */ = {
140141
isa = PBXSourcesBuildPhase;
141142
buildActionMask = 2147483647;
142143
files = (
143-
FE3383EFF1D854D9D4846F60 /* Simple.swift in Sources */,
144+
6B580635F136B2B4F21AECA8 /* main.swift in Sources */,
144145
);
145146
runOnlyForDeploymentPostprocessing = 0;
146147
};
147148
/* End PBXSourcesBuildPhase section */
148149

149150
/* Begin XCBuildConfiguration section */
150-
0777873EF831E3593AC9BEB8 /* Debug */ = {
151+
5EDDCF1541CCB315EB29DCDE /* Debug */ = {
151152
isa = XCBuildConfiguration;
152153
buildSettings = {
153154
ARCHS = x86_64;
154155
BAZEL_PACKAGE_BIN_DIR = "bazel-out/darwin_x86_64-dbg-ST-ccd9595da841/bin/examples/simple";
155-
BAZEL_TARGET_ID = "//examples/simple:SwiftLib darwin_x86_64-dbg-ST-ccd9595da841";
156+
BAZEL_TARGET_ID = "//examples/simple:SwiftBin darwin_x86_64-dbg-ST-ccd9595da841";
157+
BUILT_PRODUCTS_DIR = "$(CONFIGURATION_BUILD_DIR)";
156158
DEBUG_INFORMATION_FORMAT = dwarf;
159+
DEPLOYMENT_LOCATION = NO;
157160
ENABLE_BITCODE = NO;
158-
ENABLE_TESTABILITY = YES;
159-
EXECUTABLE_EXTENSION = a;
161+
EXECUTABLE_EXTENSION = "";
160162
GCC_OPTIMIZATION_LEVEL = 0;
161163
GENERATE_INFOPLIST_FILE = YES;
162164
MACOSX_DEPLOYMENT_TARGET = 11.0;
163-
OTHER_SWIFT_FLAGS = "-Xcc -O0 -Xcc -DDEBUG=1 -Xcc -fstack-protector -Xcc -fstack-protector-all -g -static";
164-
PRODUCT_MODULE_NAME = examples_simple_SwiftLib;
165-
PRODUCT_NAME = SwiftLib;
165+
OTHER_LDFLAGS = (
166+
"-headerpad_max_install_names",
167+
"-no-canonical-prefixes",
168+
"-lc++",
169+
);
170+
PRODUCT_MODULE_NAME = _SwiftBin_Stub;
171+
PRODUCT_NAME = SwiftBin;
166172
SDKROOT = macosx;
167173
SUPPORTED_PLATFORMS = macosx;
168-
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
169174
SWIFT_OBJC_INTERFACE_HEADER_NAME = "";
170175
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
171176
SWIFT_VERSION = 5;
172-
TARGET_NAME = SwiftLib;
173-
USER_HEADER_SEARCH_PATHS = (
174-
"$(PROJECT_DIR)",
175-
"$(BUILD_DIR)/bazel-out/darwin_x86_64-dbg-ST-ccd9595da841/bin",
176-
);
177+
TARGET_NAME = SwiftBin;
177178
};
178179
name = Debug;
179180
};
@@ -215,18 +216,18 @@
215216
/* End XCBuildConfiguration section */
216217

217218
/* Begin XCConfigurationList section */
218-
8C14447CB8BDD86ECF450932 /* Build configuration list for PBXProject "bwx" */ = {
219+
6E924F0CBE1CE62C4DE78EBB /* Build configuration list for PBXNativeTarget "SwiftBin" */ = {
219220
isa = XCConfigurationList;
220221
buildConfigurations = (
221-
C221D886D6D02D33114D3473 /* Debug */,
222+
5EDDCF1541CCB315EB29DCDE /* Debug */,
222223
);
223224
defaultConfigurationIsVisible = 0;
224225
defaultConfigurationName = Debug;
225226
};
226-
B7432B2E592DE3E3F9D8D947 /* Build configuration list for PBXNativeTarget "SwiftLib" */ = {
227+
8C14447CB8BDD86ECF450932 /* Build configuration list for PBXProject "bwx" */ = {
227228
isa = XCConfigurationList;
228229
buildConfigurations = (
229-
0777873EF831E3593AC9BEB8 /* Debug */,
230+
C221D886D6D02D33114D3473 /* Debug */,
230231
);
231232
defaultConfigurationIsVisible = 0;
232233
defaultConfigurationName = Debug;

test/fixtures/simple/bwx.xcodeproj/xcshareddata/xcschemes/SwiftLib.xcscheme renamed to test/fixtures/simple/bwx.xcodeproj/xcshareddata/xcschemes/SwiftBin.xcscheme

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
buildForAnalyzing = "YES">
1515
<BuildableReference
1616
BuildableIdentifier = "primary"
17-
BlueprintIdentifier = "76E061AB0CA7FA140667E530"
18-
BuildableName = "SwiftLib"
19-
BlueprintName = "SwiftLib"
17+
BlueprintIdentifier = "5365B2022C99A98F03DF07CA"
18+
BuildableName = "SwiftBin"
19+
BlueprintName = "SwiftBin"
2020
ReferencedContainer = "container:test/fixtures/simple/bwx.xcodeproj">
2121
</BuildableReference>
2222
</BuildActionEntry>
@@ -42,13 +42,33 @@
4242
debugDocumentVersioning = "YES"
4343
debugServiceExtension = "internal"
4444
allowLocationSimulation = "YES">
45+
<BuildableProductRunnable
46+
runnableDebuggingMode = "0">
47+
<BuildableReference
48+
BuildableIdentifier = "primary"
49+
BlueprintIdentifier = "5365B2022C99A98F03DF07CA"
50+
BuildableName = "SwiftBin"
51+
BlueprintName = "SwiftBin"
52+
ReferencedContainer = "container:test/fixtures/simple/bwx.xcodeproj">
53+
</BuildableReference>
54+
</BuildableProductRunnable>
4555
</LaunchAction>
4656
<ProfileAction
4757
buildConfiguration = "Debug"
4858
shouldUseLaunchSchemeArgsEnv = "YES"
4959
savedToolIdentifier = ""
5060
useCustomWorkingDirectory = "NO"
5161
debugDocumentVersioning = "YES">
62+
<BuildableProductRunnable
63+
runnableDebuggingMode = "0">
64+
<BuildableReference
65+
BuildableIdentifier = "primary"
66+
BlueprintIdentifier = "5365B2022C99A98F03DF07CA"
67+
BuildableName = "SwiftBin"
68+
BlueprintName = "SwiftBin"
69+
ReferencedContainer = "container:test/fixtures/simple/bwx.xcodeproj">
70+
</BuildableReference>
71+
</BuildableProductRunnable>
5272
</ProfileAction>
5373
<AnalyzeAction
5474
buildConfiguration = "Debug">

0 commit comments

Comments
 (0)