Skip to content

Commit

Permalink
Set -framework and -weak_framework for SDKs
Browse files Browse the repository at this point in the history
This adds support for `apple_static_framework_import`'s `sdk_frameworks` and `weak_sdk_frameworks` attributes.
  • Loading branch information
brentleyjones committed Apr 11, 2022
1 parent a0df290 commit d6b9acd
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 14 deletions.
27 changes: 27 additions & 0 deletions examples/ios_app/test/fixtures/project.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,13 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = (
"-framework",
Foundation,
"-weak_framework",
SwiftUI,
"-ObjC",
);
PRODUCT_MODULE_NAME = Utils;
PRODUCT_NAME = Utils;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1355,6 +1362,10 @@
OTHER_LDFLAGS = (
"-filelist",
"$(PROJECT_DIR)/test/fixtures/project.xcodeproj/rules_xcodeproj/targets/ios-x86_64-min15.0-applebin_ios-ios_x86_64-fastbuild-ST-d3e756bfe7fd/ExampleTests/ExampleTests.__internal__.__test_bundle.LinkFileList,$(BUILD_DIR)",
"-framework",
Foundation,
"-weak_framework",
SwiftUI,
"-ObjC",
);
OTHER_SWIFT_FLAGS = "-Xcc -fstack-protector -Xcc -Wall -Xcc -Wthread-safety -Xcc -Wself-assign -Xcc -fno-omit-frame-pointer -Xcc -no-canonical-prefixes -Xcc -pthread -Xcc -no-canonical-prefixes -Xcc -Wno-builtin-macro-redefined -Xcc -fmodule-map-file=$(PROJECT_DIR)/third_party/ExampleFramework.framework/Modules/module.modulemap -Xcc -fmodule-map-file=$(PROJECT_DIR)/bazel-ios_app/external/examples_ios_app_external/ExternalFramework.framework/Modules/module.modulemap -Xcc -fmodule-map-file=$(BUILD_DIR)/bazel-out/ios-x86_64-min15.0-applebin_ios-ios_x86_64-fastbuild-ST-d3e756bfe7fd/bin/CoreUtilsObjC/CoreUtilsObjC.swift.xcode.modulemap -Xcc -fmodule-map-file=$(BUILD_DIR)/bazel-out/ios-x86_64-min15.0-applebin_ios-ios_x86_64-fastbuild-ST-d3e756bfe7fd/bin/Utils/Utils.swift.xcode.modulemap -Xcc -fmodule-map-file=$(BUILD_DIR)/bazel-out/ios-x86_64-min15.0-applebin_ios-ios_x86_64-fastbuild-ST-d3e756bfe7fd/bin/TestingUtils/TestingUtils.swift.xcode.modulemap -Fthird_party -Fexternal/examples_ios_app_external";
Expand Down Expand Up @@ -1434,6 +1445,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
OTHER_SWIFT_FLAGS = "-Xcc -fstack-protector -Xcc -Wall -Xcc -Wthread-safety -Xcc -Wself-assign -Xcc -fno-omit-frame-pointer -Xcc -no-canonical-prefixes -Xcc -pthread -Xcc -no-canonical-prefixes -Xcc -Wno-builtin-macro-redefined";
PRODUCT_MODULE_NAME = TestingUtils;
PRODUCT_NAME = TestingUtils;
Expand Down Expand Up @@ -1515,6 +1527,13 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = (
"-framework",
Foundation,
"-weak_framework",
SwiftUI,
"-ObjC",
);
PRODUCT_MODULE_NAME = CoreUtils;
PRODUCT_NAME = CoreUtilsObjC;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1591,6 +1610,10 @@
OTHER_LDFLAGS = (
"-filelist",
"$(PROJECT_DIR)/test/fixtures/project.xcodeproj/rules_xcodeproj/targets/ios-x86_64-min15.0-applebin_ios-ios_x86_64-fastbuild-ST-d3e756bfe7fd/Example/Example.LinkFileList,$(BUILD_DIR)",
"-framework",
Foundation,
"-weak_framework",
SwiftUI,
"-ObjC",
);
OTHER_SWIFT_FLAGS = "-Xcc -fstack-protector -Xcc -Wall -Xcc -Wthread-safety -Xcc -Wself-assign -Xcc -fno-omit-frame-pointer -Xcc -no-canonical-prefixes -Xcc -pthread -Xcc -no-canonical-prefixes -Xcc -Wno-builtin-macro-redefined -Xcc -fmodule-map-file=$(PROJECT_DIR)/third_party/ExampleFramework.framework/Modules/module.modulemap -Xcc -fmodule-map-file=$(PROJECT_DIR)/bazel-ios_app/external/examples_ios_app_external/ExternalFramework.framework/Modules/module.modulemap -Xcc -fmodule-map-file=$(BUILD_DIR)/bazel-out/ios-x86_64-min15.0-applebin_ios-ios_x86_64-fastbuild-ST-d3e756bfe7fd/bin/CoreUtilsObjC/CoreUtilsObjC.swift.xcode.modulemap -Xcc -fmodule-map-file=$(BUILD_DIR)/bazel-out/ios-x86_64-min15.0-applebin_ios-ios_x86_64-fastbuild-ST-d3e756bfe7fd/bin/Utils/Utils.swift.xcode.modulemap -Fthird_party -Fexternal/examples_ios_app_external";
Expand Down Expand Up @@ -1667,6 +1690,10 @@
"-L/usr/lib/swift",
"-filelist",
"$(PROJECT_DIR)/test/fixtures/project.xcodeproj/rules_xcodeproj/targets/ios-x86_64-min15.0-applebin_ios-ios_x86_64-fastbuild-ST-d3e756bfe7fd/ExampleObjcTests/ExampleObjcTests.__internal__.__test_bundle.LinkFileList,$(BUILD_DIR)",
"-framework",
Foundation,
"-weak_framework",
SwiftUI,
"-ObjC",
);
PRODUCT_BUNDLE_IDENTIFIER = io.buildbuddy.example.objctests;
Expand Down
41 changes: 41 additions & 0 deletions examples/ios_app/test/fixtures/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-framework",
"Foundation",
"-weak_framework",
"SwiftUI",
"-ObjC"
],
"PRODUCT_MODULE_NAME": "CoreUtils",
"PRODUCT_NAME": "CoreUtilsObjC",
"SWIFT_OBJC_INTERFACE_HEADER_NAME": "",
Expand Down Expand Up @@ -450,6 +457,13 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-framework",
"Foundation",
"-weak_framework",
"SwiftUI",
"-ObjC"
],
"OTHER_SWIFT_FLAGS": "-Fthird_party -Fexternal/examples_ios_app_external",
"PRODUCT_MODULE_NAME": "Example",
"PRODUCT_NAME": "Example.library",
Expand Down Expand Up @@ -682,6 +696,13 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-framework",
"Foundation",
"-weak_framework",
"SwiftUI",
"-ObjC"
],
"PRODUCT_MODULE_NAME": "ExampleObjcTests",
"PRODUCT_NAME": "ExampleObjcTests.library",
"SWIFT_OBJC_INTERFACE_HEADER_NAME": "",
Expand Down Expand Up @@ -937,6 +958,13 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-framework",
"Foundation",
"-weak_framework",
"SwiftUI",
"-ObjC"
],
"OTHER_SWIFT_FLAGS": "-Fthird_party -Fexternal/examples_ios_app_external",
"PRODUCT_MODULE_NAME": "ExampleTests",
"PRODUCT_NAME": "ExampleTests.library",
Expand Down Expand Up @@ -1176,6 +1204,9 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-ObjC"
],
"PRODUCT_MODULE_NAME": "ExampleUITests",
"PRODUCT_NAME": "ExampleUITests.library",
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "DEBUG",
Expand Down Expand Up @@ -1267,6 +1298,9 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-ObjC"
],
"PRODUCT_MODULE_NAME": "TestingUtils",
"PRODUCT_NAME": "TestingUtils",
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "DEBUG AWESOME",
Expand Down Expand Up @@ -1364,6 +1398,13 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-framework",
"Foundation",
"-weak_framework",
"SwiftUI",
"-ObjC"
],
"PRODUCT_MODULE_NAME": "Utils",
"PRODUCT_NAME": "Utils",
"SWIFT_OBJC_INTERFACE_HEADER_NAME": "",
Expand Down
2 changes: 2 additions & 0 deletions examples/ios_app/third_party/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ apple_static_framework_import(
["ExampleFramework.framework/**"],
exclude = ["**/.*"],
),
sdk_frameworks = ["Foundation"],
visibility = ["//visibility:public"],
weak_sdk_frameworks = ["SwiftUI"],
)
3 changes: 3 additions & 0 deletions test/fixtures/cc/project.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = lib_impl;
SDKROOT = macosx;
SWIFT_OBJC_INTERFACE_HEADER_NAME = "";
Expand Down Expand Up @@ -516,6 +517,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = lib_impl;
SDKROOT = macosx;
SWIFT_OBJC_INTERFACE_HEADER_NAME = "";
Expand Down Expand Up @@ -573,6 +575,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = lib_impl;
SDKROOT = macosx;
SWIFT_OBJC_INTERFACE_HEADER_NAME = "";
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/cc/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-ObjC"
],
"PRODUCT_NAME": "lib_impl",
"SWIFT_OBJC_INTERFACE_HEADER_NAME": "",
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
Expand Down Expand Up @@ -146,6 +149,9 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-ObjC"
],
"PRODUCT_NAME": "lib_impl",
"SWIFT_OBJC_INTERFACE_HEADER_NAME": "",
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
Expand Down Expand Up @@ -358,6 +364,9 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-ObjC"
],
"PRODUCT_NAME": "lib_impl",
"SWIFT_OBJC_INTERFACE_HEADER_NAME": "",
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/command_line/project.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = lib_impl;
SDKROOT = macosx;
SWIFT_OBJC_INTERFACE_HEADER_NAME = "";
Expand Down Expand Up @@ -844,6 +845,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = lib_impl;
SDKROOT = macosx;
SWIFT_OBJC_INTERFACE_HEADER_NAME = "";
Expand Down Expand Up @@ -917,6 +919,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
OTHER_SWIFT_FLAGS = "-Xcc -fstack-protector -Xcc -Wall -Xcc -Wthread-safety -Xcc -Wself-assign -Xcc -fno-omit-frame-pointer -Xcc -no-canonical-prefixes -Xcc -pthread -Xcc -no-canonical-prefixes -Xcc -Wno-builtin-macro-redefined -Xcc -fmodule-map-file=$(BUILD_DIR)/bazel-out/macos-x86_64-min11.0-applebin_macos-darwin_x86_64-fastbuild-ST-8946c8252059/bin/examples/command_line/lib/lib_impl.swift.xcode.modulemap";
PRODUCT_MODULE_NAME = LibSwift;
PRODUCT_NAME = lib_swift;
Expand Down Expand Up @@ -1050,6 +1053,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
OTHER_SWIFT_FLAGS = "-Xcc -fstack-protector -Xcc -Wall -Xcc -Wthread-safety -Xcc -Wself-assign -Xcc -fno-omit-frame-pointer -Xcc -no-canonical-prefixes -Xcc -pthread -Xcc -no-canonical-prefixes -Xcc -Wno-builtin-macro-redefined -Xcc -fmodule-map-file=$(BUILD_DIR)/bazel-out/macos-x86_64-min12.0-applebin_macos-darwin_x86_64-fastbuild-ST-f2aadcfcab57/bin/examples/command_line/lib/lib_impl.swift.xcode.modulemap";
PRODUCT_MODULE_NAME = LibSwift;
PRODUCT_NAME = lib_swift;
Expand Down
18 changes: 18 additions & 0 deletions test/fixtures/command_line/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-ObjC"
],
"PRODUCT_MODULE_NAME": "LibSwiftTestsLib",
"PRODUCT_NAME": "LibSwiftTestsLib",
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "DEBUG",
Expand Down Expand Up @@ -295,6 +298,9 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-ObjC"
],
"PRODUCT_NAME": "lib_impl",
"SWIFT_OBJC_INTERFACE_HEADER_NAME": "",
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
Expand Down Expand Up @@ -381,6 +387,9 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-ObjC"
],
"PRODUCT_NAME": "lib_impl",
"SWIFT_OBJC_INTERFACE_HEADER_NAME": "",
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
Expand Down Expand Up @@ -468,6 +477,9 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-ObjC"
],
"PRODUCT_MODULE_NAME": "LibSwift",
"PRODUCT_NAME": "lib_swift",
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "DEBUG",
Expand Down Expand Up @@ -571,6 +583,9 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-ObjC"
],
"PRODUCT_MODULE_NAME": "LibSwift",
"PRODUCT_NAME": "lib_swift",
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "DEBUG",
Expand Down Expand Up @@ -764,6 +779,9 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined"
],
"OTHER_LDFLAGS": [
"-ObjC"
],
"PRODUCT_NAME": "tool.library",
"SWIFT_OBJC_INTERFACE_HEADER_NAME": "",
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/generator/project.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
OTHER_SWIFT_FLAGS = "-Xcc -fstack-protector -Xcc -Wall -Xcc -Wthread-safety -Xcc -Wself-assign -Xcc -fno-omit-frame-pointer -Xcc -no-canonical-prefixes -Xcc -pthread -Xcc -no-canonical-prefixes -Xcc -Wno-builtin-macro-redefined";
PRODUCT_MODULE_NAME = XcodeProj;
PRODUCT_NAME = XcodeProj;
Expand Down Expand Up @@ -1492,6 +1493,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
OTHER_SWIFT_FLAGS = "-Xcc -fstack-protector -Xcc -Wall -Xcc -Wthread-safety -Xcc -Wself-assign -Xcc -fno-omit-frame-pointer -Xcc -no-canonical-prefixes -Xcc -pthread -Xcc -no-canonical-prefixes -Xcc -Wno-builtin-macro-redefined";
PRODUCT_MODULE_NAME = XCTestDynamicOverlay;
PRODUCT_NAME = XCTestDynamicOverlay;
Expand Down Expand Up @@ -1603,6 +1605,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
OTHER_SWIFT_FLAGS = "-Xcc -fstack-protector -Xcc -Wall -Xcc -Wthread-safety -Xcc -Wself-assign -Xcc -fno-omit-frame-pointer -Xcc -no-canonical-prefixes -Xcc -pthread -Xcc -no-canonical-prefixes -Xcc -Wno-builtin-macro-redefined";
PRODUCT_MODULE_NAME = PathKit;
PRODUCT_NAME = PathKit;
Expand Down Expand Up @@ -1725,6 +1728,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
OTHER_SWIFT_FLAGS = "-Xcc -fstack-protector -Xcc -Wall -Xcc -Wthread-safety -Xcc -Wself-assign -Xcc -fno-omit-frame-pointer -Xcc -no-canonical-prefixes -Xcc -pthread -Xcc -no-canonical-prefixes -Xcc -Wno-builtin-macro-redefined";
PRODUCT_MODULE_NAME = generator;
PRODUCT_NAME = generator.library;
Expand Down Expand Up @@ -1778,6 +1782,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
OTHER_SWIFT_FLAGS = "-Xcc -fstack-protector -Xcc -Wall -Xcc -Wthread-safety -Xcc -Wself-assign -Xcc -fno-omit-frame-pointer -Xcc -no-canonical-prefixes -Xcc -pthread -Xcc -no-canonical-prefixes -Xcc -Wno-builtin-macro-redefined";
PRODUCT_MODULE_NAME = CustomDump;
PRODUCT_NAME = CustomDump;
Expand Down Expand Up @@ -1831,6 +1836,7 @@
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
);
OTHER_LDFLAGS = "-ObjC";
OTHER_SWIFT_FLAGS = "-Xcc -fstack-protector -Xcc -Wall -Xcc -Wthread-safety -Xcc -Wself-assign -Xcc -fno-omit-frame-pointer -Xcc -no-canonical-prefixes -Xcc -pthread -Xcc -no-canonical-prefixes -Xcc -Wno-builtin-macro-redefined";
PRODUCT_MODULE_NAME = AEXML;
PRODUCT_NAME = AEXML;
Expand Down
Loading

0 comments on commit d6b9acd

Please sign in to comment.