diff --git a/examples/integration/test/fixtures/bwb.xcodeproj/project.pbxproj b/examples/integration/test/fixtures/bwb.xcodeproj/project.pbxproj index 9c61dfb495..b1287403d1 100644 --- a/examples/integration/test/fixtures/bwb.xcodeproj/project.pbxproj +++ b/examples/integration/test/fixtures/bwb.xcodeproj/project.pbxproj @@ -15397,10 +15397,8 @@ RULES_XCODEPROJ_BUILD_MODE = bazel; SRCROOT = ../../../../..; SUPPORTS_MACCATALYST = NO; - SWIFT_EXEC = "$(BAZEL_INTEGRATION_DIR)/swiftc"; SWIFT_OBJC_INTERFACE_HEADER_NAME = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_USE_INTEGRATED_DRIVER = NO; SWIFT_VERSION = 5.0; TAPI_EXEC = /usr/bin/true; TARGET_TEMP_DIR = "$(PROJECT_TEMP_DIR)/$(BAZEL_PACKAGE_BIN_DIR)/$(COMPILE_TARGET_NAME)"; @@ -17932,10 +17930,8 @@ RULES_XCODEPROJ_BUILD_MODE = bazel; SRCROOT = ../../../../..; SUPPORTS_MACCATALYST = NO; - SWIFT_EXEC = "$(BAZEL_INTEGRATION_DIR)/swiftc"; SWIFT_OBJC_INTERFACE_HEADER_NAME = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_USE_INTEGRATED_DRIVER = NO; SWIFT_VERSION = 5.0; TAPI_EXEC = /usr/bin/true; TARGET_TEMP_DIR = "$(PROJECT_TEMP_DIR)/$(BAZEL_PACKAGE_BIN_DIR)/$(COMPILE_TARGET_NAME)"; diff --git a/examples/rules_ios/test/fixtures/bwb.xcodeproj/project.pbxproj b/examples/rules_ios/test/fixtures/bwb.xcodeproj/project.pbxproj index 4030dd59a2..ee42bd7ff2 100644 --- a/examples/rules_ios/test/fixtures/bwb.xcodeproj/project.pbxproj +++ b/examples/rules_ios/test/fixtures/bwb.xcodeproj/project.pbxproj @@ -4681,10 +4681,8 @@ RULES_XCODEPROJ_BUILD_MODE = bazel; SRCROOT = ../../../../..; SUPPORTS_MACCATALYST = NO; - SWIFT_EXEC = "$(BAZEL_INTEGRATION_DIR)/swiftc"; SWIFT_OBJC_INTERFACE_HEADER_NAME = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_USE_INTEGRATED_DRIVER = NO; SWIFT_VERSION = 5.0; TAPI_EXEC = /usr/bin/true; TARGET_TEMP_DIR = "$(PROJECT_TEMP_DIR)/$(BAZEL_PACKAGE_BIN_DIR)/$(COMPILE_TARGET_NAME)"; diff --git a/tools/generators/legacy/src/Generator/CreateProject.swift b/tools/generators/legacy/src/Generator/CreateProject.swift index 11e23b1567..d3ad855945 100644 --- a/tools/generators/legacy/src/Generator/CreateProject.swift +++ b/tools/generators/legacy/src/Generator/CreateProject.swift @@ -137,8 +137,6 @@ $(PROJECT_TEMP_DIR)/$(BAZEL_PACKAGE_BIN_DIR)/$(COMPILE_TARGET_NAME) "LD": "$(BAZEL_INTEGRATION_DIR)/ld", "LDPLUSPLUS": "$(BAZEL_INTEGRATION_DIR)/ld", "LIBTOOL": "$(BAZEL_INTEGRATION_DIR)/libtool", - "SWIFT_EXEC": "$(BAZEL_INTEGRATION_DIR)/swiftc", - "SWIFT_USE_INTEGRATED_DRIVER": false, "TAPI_EXEC": "/usr/bin/true", ], uniquingKeysWith: { _, r in r }) } else { diff --git a/tools/generators/legacy/test/CreateProjectTests.swift b/tools/generators/legacy/test/CreateProjectTests.swift index 56cc72128f..ed68dcdb7b 100644 --- a/tools/generators/legacy/test/CreateProjectTests.swift +++ b/tools/generators/legacy/test/CreateProjectTests.swift @@ -232,11 +232,9 @@ $(BUILD_DIR)/$(BAZEL_PACKAGE_BIN_DIR) "RULES_XCODEPROJ_BUILD_MODE": "bazel", "SRCROOT": directories.workspace.string, "SUPPORTS_MACCATALYST": false, - "SWIFT_EXEC": "$(BAZEL_INTEGRATION_DIR)/swiftc", "TAPI_EXEC": "/usr/bin/true", "SWIFT_OBJC_INTERFACE_HEADER_NAME": "", "SWIFT_OPTIMIZATION_LEVEL": "-Onone", - "SWIFT_USE_INTEGRATED_DRIVER": false, "SWIFT_VERSION": "5.0", "TARGET_TEMP_DIR": """ $(PROJECT_TEMP_DIR)/$(BAZEL_PACKAGE_BIN_DIR)/$(COMPILE_TARGET_NAME) diff --git a/tools/generators/pbxproj_prefix/README.md b/tools/generators/pbxproj_prefix/README.md index 6c87afac2e..9139203e8c 100644 --- a/tools/generators/pbxproj_prefix/README.md +++ b/tools/generators/pbxproj_prefix/README.md @@ -232,10 +232,8 @@ Here is an example output: RULES_XCODEPROJ_BUILD_MODE = bazel; SRCROOT = /tmp/workspace; SUPPORTS_MACCATALYST = NO; - SWIFT_EXEC = "$(BAZEL_INTEGRATION_DIR)/swiftc"; SWIFT_OBJC_INTERFACE_HEADER_NAME = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_USE_INTEGRATED_DRIVER = NO; SWIFT_VERSION = 5.0; TAPI_EXEC = /usr/bin/true; TARGET_TEMP_DIR = "$(PROJECT_TEMP_DIR)/$(BAZEL_PACKAGE_BIN_DIR)/$(COMPILE_TARGET_NAME)"; @@ -292,10 +290,8 @@ Here is an example output: RULES_XCODEPROJ_BUILD_MODE = bazel; SRCROOT = /tmp/workspace; SUPPORTS_MACCATALYST = NO; - SWIFT_EXEC = "$(BAZEL_INTEGRATION_DIR)/swiftc"; SWIFT_OBJC_INTERFACE_HEADER_NAME = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_USE_INTEGRATED_DRIVER = NO; SWIFT_VERSION = 5.0; TAPI_EXEC = /usr/bin/true; TARGET_TEMP_DIR = "$(PROJECT_TEMP_DIR)/$(BAZEL_PACKAGE_BIN_DIR)/$(COMPILE_TARGET_NAME)"; diff --git a/tools/generators/pbxproj_prefix/src/Generator/PBXProjectBuildSettings.swift b/tools/generators/pbxproj_prefix/src/Generator/PBXProjectBuildSettings.swift index a5561af959..960aadfef1 100644 --- a/tools/generators/pbxproj_prefix/src/Generator/PBXProjectBuildSettings.swift +++ b/tools/generators/pbxproj_prefix/src/Generator/PBXProjectBuildSettings.swift @@ -135,13 +135,8 @@ extension Generator { .init(key: "RULES_XCODEPROJ_BUILD_MODE", value: "bazel"), .init(key: "SRCROOT", value: workspace.pbxProjEscaped), .init(key: "SUPPORTS_MACCATALYST", value: "NO"), - .init( - key: "SWIFT_EXEC", - value: #""$(BAZEL_INTEGRATION_DIR)/swiftc""# - ), .init(key: "SWIFT_OBJC_INTERFACE_HEADER_NAME", value: #""""#), .init(key: "SWIFT_OPTIMIZATION_LEVEL", value: #""-Onone""#), - .init(key: "SWIFT_USE_INTEGRATED_DRIVER", value: "NO"), .init(key: "SWIFT_VERSION", value: "5.0"), .init(key: "TAPI_EXEC", value: "/usr/bin/true"), .init( diff --git a/tools/generators/pbxproj_prefix/test/PBXProjectBuildSettingsTests.swift b/tools/generators/pbxproj_prefix/test/PBXProjectBuildSettingsTests.swift index 46b81a6d7f..509cb7be6e 100644 --- a/tools/generators/pbxproj_prefix/test/PBXProjectBuildSettingsTests.swift +++ b/tools/generators/pbxproj_prefix/test/PBXProjectBuildSettingsTests.swift @@ -65,10 +65,8 @@ class PBXProjectBuildSettingsTests: XCTestCase { RULES_XCODEPROJ_BUILD_MODE = bazel; SRCROOT = "/Users/TimApple/Star Board"; SUPPORTS_MACCATALYST = NO; - SWIFT_EXEC = "$(BAZEL_INTEGRATION_DIR)/swiftc"; SWIFT_OBJC_INTERFACE_HEADER_NAME = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_USE_INTEGRATED_DRIVER = NO; SWIFT_VERSION = 5.0; TAPI_EXEC = /usr/bin/true; TARGET_TEMP_DIR = "$(PROJECT_TEMP_DIR)/$(BAZEL_PACKAGE_BIN_DIR)/$(COMPILE_TARGET_NAME)"; diff --git a/tools/swiftc_stub/main.swift b/tools/swiftc_stub/main.swift index f2bfb7f3e5..e2735de8a2 100644 --- a/tools/swiftc_stub/main.swift +++ b/tools/swiftc_stub/main.swift @@ -6,6 +6,7 @@ enum PathKey: String { case emitModulePath = "-emit-module-path" case emitObjCHeaderPath = "-emit-objc-header-path" case outputFileMap = "-output-file-map" + case supplementaryOutputFileMap = "-supplementary-output-file-map" case sdk = "-sdk" } @@ -32,7 +33,7 @@ func processArgs( if arg == "-wmo" || arg == "-whole-module-optimization" { isWMO = true - } else if arg.hasSuffix(".preview-thunk.swift") { + } else if arg.hasSuffix("usr/lib/swift/host/plugins") || arg.hasSuffix(".preview-thunk.swift") { isPreviewThunk = true } else { previousArg = arg @@ -56,7 +57,7 @@ func processArgs( } return ( - !paths.keys.contains(.outputFileMap) && isPreviewThunk, + isPreviewThunk, isWMO, paths ) @@ -116,11 +117,14 @@ func touchSwiftmoduleArtifacts(paths: [PathKey: URL]) throws { .appendingPathExtension("swiftsourceinfo") var swiftinterfacePath = swiftmodulePath.deletingPathExtension() .appendingPathExtension("swiftinterface") + var swiftconstvaluesPath = swiftmodulePath.deletingPathExtension() + .appendingPathExtension("swiftconstvalues") try swiftmodulePath.touch() try swiftdocPath.touch() try swiftsourceinfoPath.touch() try swiftinterfacePath.touch() + try swiftconstvaluesPath.touch() } if var generatedHeaderPath = paths[PathKey.emitObjCHeaderPath] { @@ -146,6 +150,20 @@ func handleXcodePreviewThunk(args: [String], paths: [PathKey: URL]) throws -> Ne exit(1) } + if let outputFileMapURL = paths[.supplementaryOutputFileMap] { + let data = try! Data(contentsOf: outputFileMapURL) + let constValuesURL = String(data: data, encoding: .utf8)! + .components(separatedBy: .newlines) + .dropFirst() + .first { $0.contains("const-values") }! + .components(separatedBy: "\"")[1] + + var attributes = try FileManager.default.attributesOfItem(atPath: constValuesURL) + let permissions: Int = 0o755 // rwxr-xr-x + attributes[.posixPermissions] = permissions + try FileManager.default.setAttributes(attributes, ofItemAtPath: constValuesURL) + } + // TODO: Make this work with custom toolchains // We could produce this file at the start of the build? let fullRange = NSRange(sdkPath.startIndex..., in: sdkPath) diff --git a/xcodeproj/internal/bazel_integration_files/copy_outputs.sh b/xcodeproj/internal/bazel_integration_files/copy_outputs.sh index e847cf0e27..0b7d0b3a96 100755 --- a/xcodeproj/internal/bazel_integration_files/copy_outputs.sh +++ b/xcodeproj/internal/bazel_integration_files/copy_outputs.sh @@ -28,7 +28,7 @@ if [[ "$ACTION" != indexbuild ]]; then if [[ -f "$BAZEL_OUTPUTS_PRODUCT_BASENAME" ]]; then # Product is a binary, so symlink instead of rsync, to allow for Bazel-set # rpaths to work - ln -sfh "$PWD/$BAZEL_OUTPUTS_PRODUCT_BASENAME" "$TARGET_BUILD_DIR/$PRODUCT_NAME" + ln -sfh "$PWD/$BAZEL_OUTPUTS_PRODUCT_BASENAME" "$TARGET_BUILD_DIR/lib$PRODUCT_NAME.a" else # Product is a bundle rsync \ diff --git a/xcodeproj/internal/bazel_integration_files/generate_bazel_dependencies.sh b/xcodeproj/internal/bazel_integration_files/generate_bazel_dependencies.sh index 7d3e9c5d89..fb7827c5d7 100755 --- a/xcodeproj/internal/bazel_integration_files/generate_bazel_dependencies.sh +++ b/xcodeproj/internal/bazel_integration_files/generate_bazel_dependencies.sh @@ -122,7 +122,7 @@ build_pre_config_flags=( # This is brittle. If different file extensions are used for compilation # inputs, they will need to be added to this list. Ideally we can stop doing # this once Bazel adds support for a Remote Output Service. - "--experimental_remote_download_regex=.*\.indexstore/.*|.*\.(a|cfg|c|C|cc|cl|cpp|cu|cxx|c++|def|h|H|hh|hpp|hxx|h++|hmap|ilc|inc|inl|ipp|tcc|tlh|tli|tpp|m|modulemap|mm|pch|swift|swiftdoc|swiftmodule|swiftsourceinfo|yaml)$" + "--remote_download_regex=.*\.indexstore/.*|.*\.(a|cfg|c|C|cc|cl|cpp|cu|cxx|c++|def|h|H|hh|hpp|hxx|h++|hmap|ilc|inc|inl|ipp|tcc|tlh|tli|tpp|m|modulemap|mm|pch|swift|swiftdoc|swiftmodule|swiftsourceinfo|swiftconstvalues|yaml)$" ) apply_sanitizers=1 diff --git a/xcodeproj/internal/bazel_integration_files/generate_index_build_bazel_dependencies.sh b/xcodeproj/internal/bazel_integration_files/generate_index_build_bazel_dependencies.sh index 9c74f93fb5..a3097837b7 100755 --- a/xcodeproj/internal/bazel_integration_files/generate_index_build_bazel_dependencies.sh +++ b/xcodeproj/internal/bazel_integration_files/generate_index_build_bazel_dependencies.sh @@ -58,7 +58,7 @@ readonly build_pre_config_flags=( # This is brittle. If different file extensions are used for compilation # inputs, they will need to be added to this list. Ideally we can stop doing # this once Bazel adds support for a Remote Output Service. - "--experimental_remote_download_regex=${indexstores_regex}.*|.*\.(cfg|c|C|cc|cl|cpp|cu|cxx|c++|def|h|H|hh|hpp|hxx|h++|hmap|ilc|inc|inl|ipp|tcc|tlh|tli|tpp|m|modulemap|mm|pch|swift|swiftdoc|swiftmodule|swiftsourceinfo|yaml)$" + "--remote_download_regex=${indexstores_regex}.*|.*\.(cfg|c|C|cc|cl|cpp|cu|cxx|c++|def|h|H|hh|hpp|hxx|h++|hmap|ilc|inc|inl|ipp|tcc|tlh|tli|tpp|m|modulemap|mm|pch|swift|swiftdoc|swiftmodule|swiftsourceinfo|swiftconstvalues|yaml)$" ) source "$BAZEL_INTEGRATION_DIR/bazel_build.sh" diff --git a/xcodeproj/internal/bazel_integration_files/ld b/xcodeproj/internal/bazel_integration_files/ld index 2156250535..3bb6cba4b0 100755 --- a/xcodeproj/internal/bazel_integration_files/ld +++ b/xcodeproj/internal/bazel_integration_files/ld @@ -20,6 +20,12 @@ do developer_dir="${1/\/Platforms\/*/}" ;; + *.debug.dylib) + # Pass through for SwiftUI Preview thunk compilation + # TODO: Make this work with custom toolchains + exec "$developer_dir/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" "${passthrough_args[@]}" + ;; + *.preview-thunk.dylib) # Pass through for SwiftUI Preview thunk compilation # TODO: Make this work with custom toolchains diff --git a/xcodeproj/internal/templates/bazel_build.sh b/xcodeproj/internal/templates/bazel_build.sh index c2dea14b56..8e01019268 100755 --- a/xcodeproj/internal/templates/bazel_build.sh +++ b/xcodeproj/internal/templates/bazel_build.sh @@ -114,7 +114,7 @@ echo "Starting Bazel build" ${build_pre_config_flags:+"${build_pre_config_flags[@]}"} \ --config="$config" \ --color=yes \ - ${toolchain:+--define=SWIFT_CUSTOM_TOOLCHAIN="$toolchain"} \ + ${toolchain:+--action_env=TOOLCHAINS="$toolchain"} \ "$output_groups_flag" \ "%generator_label%" \ ${labels:+"--build_metadata=PATTERN=${labels[*]}"} \ diff --git a/xcodeproj/internal/templates/runner.sh b/xcodeproj/internal/templates/runner.sh index 492da0ca2c..4df8f1f074 100644 --- a/xcodeproj/internal/templates/runner.sh +++ b/xcodeproj/internal/templates/runner.sh @@ -239,7 +239,7 @@ else if [[ $cmd == "build" && -n "${generator_output_groups:-}" ]]; then if [[ $download_intermediates -eq 1 ]]; then pre_config_flags=( - "--experimental_remote_download_regex=.*\.indexstore/.*|.*\.(a|cfg|c|C|cc|cl|cpp|cu|cxx|c++|def|h|H|hh|hpp|hxx|h++|hmap|ilc|inc|inl|ipp|tcc|tlh|tli|tpp|m|modulemap|mm|pch|swift|swiftdoc|swiftmodule|swiftsourceinfo|yaml)$" + "--remote_download_regex=.*\.indexstore/.*|.*\.(a|cfg|c|C|cc|cl|cpp|cu|cxx|c++|def|h|H|hh|hpp|hxx|h++|hmap|ilc|inc|inl|ipp|tcc|tlh|tli|tpp|m|modulemap|mm|pch|swift|swiftdoc|swiftmodule|swiftsourceinfo|swiftconstvalues|yaml)$" ) else pre_config_flags=()