Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def _write_pbxproj_prefix_test_impl(ctx):
project_options = ctx.attr.project_options,
resolved_repositories_file = ctx.attr.resolved_repositories_file,
separate_index_build_output_base = ctx.attr.separate_index_build_output_base,
suppress_coverage_build = ctx.attr.suppress_coverage_build,
target_ids_list = ctx.attr.target_ids_list,
tool = None,
workspace_directory = ctx.attr.workspace_directory,
Expand Down Expand Up @@ -155,6 +156,7 @@ write_pbxproj_prefix_test = unittest.make(
"project_options": attr.string_dict(mandatory = True),
"resolved_repositories_file": attr.string(mandatory = True),
"separate_index_build_output_base": attr.bool(mandatory = True),
"suppress_coverage_build": attr.bool(mandatory = True),
"target_ids_list": attr.string(mandatory = True),
"workspace_directory": attr.string(mandatory = True),
"xcode_configurations": attr.string_list(mandatory = True),
Expand Down Expand Up @@ -193,6 +195,7 @@ def write_pbxproj_prefix_test_suite(name):
project_options,
resolved_repositories_file,
separate_index_build_output_base = False,
suppress_coverage_build = False,
target_ids_list,
workspace_directory,
xcode_configurations,
Expand All @@ -219,6 +222,7 @@ def write_pbxproj_prefix_test_suite(name):
project_options = project_options,
resolved_repositories_file = resolved_repositories_file,
separate_index_build_output_base = separate_index_build_output_base,
suppress_coverage_build = suppress_coverage_build,
target_ids_list = target_ids_list,
workspace_directory = workspace_directory,
xcode_configurations = xcode_configurations,
Expand Down Expand Up @@ -277,6 +281,8 @@ def write_pbxproj_prefix_test_suite(name):
"some/path/to/index_import",
# separateIndexBuildOutputBase
"0",
# suppressCoverageBuild
"0",
# resolvedRepositoriesFile
"some/path/to/resolved_repositories_file",
# minimumXcodeVersion
Expand Down Expand Up @@ -349,6 +355,8 @@ def write_pbxproj_prefix_test_suite(name):
"some/path/to/index_import",
# separateIndexBuildOutputBase
"1",
# suppressCoverageBuild
"0",
# resolvedRepositoriesFile
"some/path/to/resolved_repositories_file",
# minimumXcodeVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ Path to a file that contains the absolute path to the Bazel execution root.
)
var separateIndexBuildOutputBase: Bool

@Argument(
help: "Whether to suppress coverage builds even when CLANG_COVERAGE_MAPPING is set.",
transform: { $0 == "1" }
)
var suppressCoverageBuild: Bool

@Argument(
help: """
Path to a file that contains a string for the `RESOLVED_REPOSITORIES` build \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ extension Generator {

let pbxProjectBuildSettings: (
_ config: String,
_ createBuildSettingsAttribute: CreateBuildSettingsAttribute,
_ importIndexBuildIndexstores: Bool,
_ legacyIndexImport: String,
_ indexImport: String,
_ indexingProjectDir: String,
_ separateIndexBuildOutputBase: Bool,
_ legacyIndexImport: String,
_ projectDir: String,
_ resolvedRepositories: String,
_ separateIndexBuildOutputBase: Bool,
_ suppressCoverageBuild: Bool,
_ workspace: String,
_ createBuildSettingsAttribute: CreateBuildSettingsAttribute
) -> String

let pbxProjectPrefixPartial: (
Expand Down
11 changes: 6 additions & 5 deletions tools/generators/pbxproj_prefix/src/Generator/Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,23 @@ struct Generator {
let pbxProjectPrefixPartial = environment.pbxProjectPrefixPartial(
/*buildSettings:*/ environment.pbxProjectBuildSettings(
/*config:*/ arguments.config,
/*createBuildSettingsAttribute:*/
environment.createBuildSettingsAttribute,
/*importIndexBuildIndexstores:*/ arguments
.importIndexBuildIndexstores,
/*legacyIndexImport:*/ arguments.legacyIndexImport,
/*indexImport:*/ arguments.indexImport,
/*indexingProjectDir:*/ environment.indexingProjectDir(
/*projectDir:*/ projectDir
),
/*separateIndexBuildOutputBase:*/ arguments.separateIndexBuildOutputBase,
/*legacyIndexImport:*/ arguments.legacyIndexImport,
/*projectDir:*/ projectDir,
/*resolvedRepositories:*/
try environment.readResolvedRepositoriesFile(
arguments.resolvedRepositoriesFile
),
/*workspace:*/ arguments.workspace,
/*createBuildSettingsAttribute:*/
environment.createBuildSettingsAttribute
/*separateIndexBuildOutputBase:*/ arguments.separateIndexBuildOutputBase,
/*suppressCoverageBuild:*/ arguments.suppressCoverageBuild,
/*workspace:*/ arguments.workspace
),
/*compatibilityVersion:*/ environment.compatibilityVersion(
arguments.minimumXcodeVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ extension Generator {
/// - workspace: The absolute path to the Bazel workspace.
static func pbxProjectBuildSettings(
config: String,
createBuildSettingsAttribute: CreateBuildSettingsAttribute,
importIndexBuildIndexstores: Bool,
legacyIndexImport: String,
indexImport: String,
indexingProjectDir: String,
separateIndexBuildOutputBase: Bool,
legacyIndexImport: String,
projectDir: String,
resolvedRepositories: String,
workspace: String,
createBuildSettingsAttribute: CreateBuildSettingsAttribute
separateIndexBuildOutputBase: Bool,
suppressCoverageBuild: Bool,
workspace: String
) -> String {
var buildSettings: [BuildSetting] = [
.init(key: "ALWAYS_SEARCH_USER_PATHS", value: "NO"),
Expand Down Expand Up @@ -175,6 +176,14 @@ extension Generator {
value: #""$(PROJECT_DIR)/../..""#
),
]
if suppressCoverageBuild {
buildSettings.append(
.init(
key: "BAZEL_SUPPRESS_COVERAGE_BUILD",
value: "YES"
)
)
}
if separateIndexBuildOutputBase {
buildSettings.append(contentsOf: [
.init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,114 @@ class PBXProjectBuildSettingsTests: XCTestCase {

let buildSettings = Generator.pbxProjectBuildSettings(
config: config,
createBuildSettingsAttribute: CreateBuildSettingsAttribute(),
importIndexBuildIndexstores: importIndexBuildIndexstores,
legacyIndexImport: legacyIndexImport,
indexImport: indexImport,
indexingProjectDir: indexingProjectDir,
separateIndexBuildOutputBase: false,
legacyIndexImport: legacyIndexImport,
projectDir: projectDir,
resolvedRepositories: resolvedRepositories,
workspace: workspace,
createBuildSettingsAttribute: CreateBuildSettingsAttribute()
separateIndexBuildOutputBase: false,
suppressCoverageBuild: false,
workspace: workspace
)

// Assert

XCTAssertNoDifference(buildSettings, expectedBuildSettings)
}

func testSuppressCoverageBuild() {
let config = "rxcp_custom_config"
let importIndexBuildIndexstores = false
let legacyIndexImport = "external/legacy-index-import"
let indexImport = "external/index-import"
let indexingProjectDir = "/some/indexing/project dir"
let projectDir = "/some/project dir"
let resolvedRepositories = #""" "/tmp/workspace""#
let workspace = "/Users/TimApple/Star Board"

let expectedBuildSettings = #"""
{
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_ASSET_SYMBOLS = NO;
BAZEL_CONFIG = rxcp_custom_config;
BAZEL_EXTERNAL = "$(BAZEL_OUTPUT_BASE)/external";
BAZEL_INTEGRATION_DIR = "$(INTERNAL_DIR)/bazel";
BAZEL_LLDB_INIT = "$(HOME)/.lldbinit-rules_xcodeproj";
BAZEL_OUT = "$(PROJECT_DIR)/bazel-out";
BAZEL_OUTPUT_BASE = "$(_BAZEL_OUTPUT_BASE:standardizepath)";
BAZEL_SUPPRESS_COVERAGE_BUILD = YES;
BAZEL_WORKSPACE_ROOT = "$(SRCROOT)";
BUILD_DIR = "$(SYMROOT)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
BUILD_MARKER_FILE = "$(OBJROOT)/build_marker";
BUILD_WORKSPACE_DIRECTORY = "$(SRCROOT)";
CC = "$(BAZEL_INTEGRATION_DIR)/clang.sh";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_MODULES_AUTOLINK = NO;
CODE_SIGNING_ALLOWED = NO;
CODE_SIGN_STYLE = Manual;
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(BAZEL_PACKAGE_BIN_DIR)";
COPY_PHASE_STRIP = NO;
CXX = "$(BAZEL_INTEGRATION_DIR)/clang.sh";
DEBUG_INFORMATION_FORMAT = dwarf;
DSTROOT = "$(PROJECT_TEMP_DIR)";
ENABLE_DEBUG_DYLIB = NO;
ENABLE_DEFAULT_SEARCH_PATHS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_OPTIMIZATION_LEVEL = 0;
IMPORT_INDEX_BUILD_INDEXSTORES = NO;
INDEXING_PROJECT_DIR__ = "$(INDEXING_PROJECT_DIR__NO)";
INDEXING_PROJECT_DIR__NO = "/some/project dir";
INDEXING_PROJECT_DIR__YES = "/some/indexing/project dir";
INDEX_DATA_STORE_DIR = "$(INDEX_DATA_STORE_DIR)";
INDEX_FORCE_SCRIPT_EXECUTION = YES;
INDEX_IMPORT = "$(BAZEL_EXTERNAL)/index-import";
INSTALL_PATH = "$(BAZEL_PACKAGE_BIN_DIR)/$(TARGET_NAME)/bin";
INTERNAL_DIR = "$(PROJECT_FILE_PATH)/rules_xcodeproj";
LD = "$(BAZEL_INTEGRATION_DIR)/ld";
LDPLUSPLUS = "$(BAZEL_INTEGRATION_DIR)/ld";
LD_DYLIB_INSTALL_NAME = "";
LD_OBJC_ABI_VERSION = "";
LD_RUNPATH_SEARCH_PATHS = "";
LEGACY_INDEX_IMPORT = "$(BAZEL_EXTERNAL)/legacy-index-import";
LIBTOOL = "$(BAZEL_INTEGRATION_DIR)/libtool";
ONLY_ACTIVE_ARCH = YES;
PROJECT_DIR = "/some/project dir";
RESOLVED_REPOSITORIES = "\"\" \"/tmp/workspace\"";
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)";
USE_HEADERMAP = NO;
VALIDATE_WORKSPACE = NO;
_BAZEL_OUTPUT_BASE = "$(PROJECT_DIR)/../..";
}
"""#

let buildSettings = Generator.pbxProjectBuildSettings(
config: config,
createBuildSettingsAttribute: CreateBuildSettingsAttribute(),
importIndexBuildIndexstores: importIndexBuildIndexstores,
indexImport: indexImport,
indexingProjectDir: indexingProjectDir,
legacyIndexImport: legacyIndexImport,
projectDir: projectDir,
resolvedRepositories: resolvedRepositories,
separateIndexBuildOutputBase: false,
suppressCoverageBuild: true,
workspace: workspace
)
XCTAssertNoDifference(buildSettings, expectedBuildSettings)
}

func testSeparateIndexOutputBase() {
// Arrange

Expand Down Expand Up @@ -185,15 +277,16 @@ class PBXProjectBuildSettingsTests: XCTestCase {

let buildSettings = Generator.pbxProjectBuildSettings(
config: config,
createBuildSettingsAttribute: CreateBuildSettingsAttribute(),
importIndexBuildIndexstores: importIndexBuildIndexstores,
legacyIndexImport: legacyIndexImport,
indexImport: indexImport,
indexingProjectDir: indexingProjectDir,
separateIndexBuildOutputBase: true,
legacyIndexImport: legacyIndexImport,
projectDir: projectDir,
resolvedRepositories: resolvedRepositories,
workspace: workspace,
createBuildSettingsAttribute: CreateBuildSettingsAttribute()
separateIndexBuildOutputBase: true,
suppressCoverageBuild: false,
workspace: workspace
)

// Assert
Expand Down
6 changes: 6 additions & 0 deletions xcodeproj/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ string_flag(
visibility = ["//visibility:public"],
)

bool_flag(
name = "suppress_coverage_build",
build_setting_default = False,
visibility = ["//visibility:public"],
)

bool_flag(
name = "separate_index_build_output_base",
build_setting_default = False,
Expand Down
6 changes: 6 additions & 0 deletions xcodeproj/internal/pbxproj_partials.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ def _write_pbxproj_prefix(
project_options,
resolved_repositories_file,
separate_index_build_output_base,
suppress_coverage_build,
target_ids_list,
tool,
workspace_directory,
Expand Down Expand Up @@ -705,6 +706,8 @@ def _write_pbxproj_prefix(
the `RESOLVED_REPOSITORIES` build setting.
separate_index_build_output_base: Whether or not to use a separate
output base for index builds.
suppress_coverage_build: Whether or not to disable coverage builds even
when `CLANG_COVERAGE_MAPPING` is set.
target_ids_list: A `File` containing a list of target IDs.
tool: The executable that will generate the `PBXProj` partial.
workspace_directory: The absolute path to the Bazel workspace
Expand Down Expand Up @@ -749,6 +752,9 @@ def _write_pbxproj_prefix(
# separateIndexBuildOutputBase
args.add(TRUE_ARG if separate_index_build_output_base else FALSE_ARG)

# suppressCoverageBuild
args.add(TRUE_ARG if suppress_coverage_build else FALSE_ARG)

# resolvedRepositoriesFile
args.add(resolved_repositories_file)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ if [ "$ACTION" == "indexbuild" ]; then
apply_sanitizers=0
elif [ "${ENABLE_PREVIEWS:-}" == "YES" ]; then
readonly config="${BAZEL_CONFIG}_swiftuipreviews"
elif [ "${CLANG_COVERAGE_MAPPING:-}" == YES ]; then
elif [ "${CLANG_COVERAGE_MAPPING:-}" == YES ] && [ "${BAZEL_SUPPRESS_COVERAGE_BUILD:-}" != YES ]; then
# Code coverage build
#
# CLANG_COVERAGE_MAPPING is set to YES when the active scheme's test action has code coverage enabled. It is configured
Expand Down
1 change: 1 addition & 0 deletions xcodeproj/internal/templates/generator.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ xcodeproj(
scheme_autogeneration_config = %scheme_autogeneration_config%,
separate_index_build_output_base = %separate_index_build_output_base%,
storekit_configurations_map = %storekit_configurations_map%,
suppress_coverage_build = %suppress_coverage_build%,
tags = %tags%,
target_name_mode = "%target_name_mode%",
top_level_device_targets = %top_level_device_targets%,
Expand Down
5 changes: 5 additions & 0 deletions xcodeproj/internal/xcodeproj_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def _write_project_contents(
resource_bundle_xcode_targets,
selected_model_versions_generator,
separate_index_build_output_base,
suppress_coverage_build,
target_name_mode,
unique_directories,
unowned_extra_files,
Expand Down Expand Up @@ -464,6 +465,7 @@ def _write_project_contents(
project_options = project_options,
resolved_repositories_file = resolved_repositories_file,
separate_index_build_output_base = separate_index_build_output_base,
suppress_coverage_build = suppress_coverage_build,
target_ids_list = target_ids_list,
tool = pbxproj_prefix_generator,
xcode_configurations = xcode_configurations,
Expand Down Expand Up @@ -636,6 +638,7 @@ Are you using an `alias`? `xcodeproj.focused_targets` and \
index_import = ctx.executable._index_import
install_path = ctx.attr.install_path
separate_index_build_output_base = ctx.attr.separate_index_build_output_base
suppress_coverage_build = ctx.attr.suppress_coverage_build
name = ctx.attr.name
workspace_directory = ctx.attr.workspace_directory

Expand Down Expand Up @@ -704,6 +707,7 @@ Are you using an `alias`? `xcodeproj.focused_targets` and \
ctx.executable._selected_model_versions_generator
),
separate_index_build_output_base = separate_index_build_output_base,
suppress_coverage_build = suppress_coverage_build,
target_name_mode = ctx.attr.target_name_mode,
unique_directories = ctx.executable._unique_directories,
unowned_extra_files = ctx.files.unowned_extra_files,
Expand Down Expand Up @@ -830,6 +834,7 @@ def _xcodeproj_attrs(
doc = """\
A dict mapping of Labels for StoreKit Testing configuration files to their File paths.""",
),
"suppress_coverage_build": attr.bool(mandatory = True),
"target_name_mode": attr.string(mandatory = True),
"top_level_device_targets": attr.label_list(
cfg = target_transitions.device,
Expand Down
Loading