Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
22 changes: 21 additions & 1 deletion rules/legacy_xcodeproj.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ def _xcodeproj_aspect_impl(target, ctx):

deps = []
deps += getattr(ctx.rule.attr, "deps", [])
deps += getattr(ctx.rule.attr, "infoplists", [])

# Hold `infoplists` to be used below when creating infos
infoplists = getattr(ctx.rule.attr, "infoplists", [])
deps += infoplists

deps += getattr(ctx.rule.attr, "extensions", [])
tags = getattr(ctx.rule.attr, "tags", [])

Expand Down Expand Up @@ -258,6 +262,12 @@ def _xcodeproj_aspect_impl(target, ctx):
test_host_appname = test_host_target[_TargetInfo].direct_targets[0].name

framework_includes = depset([], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "framework_includes"))

infoplist = None
if infoplists:
if infoplists[0].files.to_list():
infoplist = infoplists[0].files.to_list()[0]

info = struct(
name = bundle_info.bundle_name,
bundle_id = bundle_info.bundle_id,
Expand Down Expand Up @@ -285,6 +295,7 @@ def _xcodeproj_aspect_impl(target, ctx):
objc_copts = depset([], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "objc_copts")),
commandline_args = commandline_args,
targeted_device_family = _targeted_device_family(ctx),
infoplist = infoplist,
)
if ctx.rule.kind != "apple_framework_packaging":
providers.append(
Expand All @@ -301,6 +312,7 @@ def _xcodeproj_aspect_impl(target, ctx):
swift_copts = info.swift_copts,
objc_copts = info.objc_copts,
swift_module_paths = info.swift_module_paths,
infoplist = info.infoplist,
),
)

Expand Down Expand Up @@ -879,10 +891,16 @@ def _populate_xcodeproj_targets_and_schemes(ctx, targets, src_dot_dots, all_tran

target_settings["BAZEL_LLDB_INIT_FILE"] = lldbinit_file

target_infoplist = None
if target_info.infoplist:
target_infoplist = "$BAZEL_WORKSPACE_ROOT/%s" % target_info.infoplist.path
target_settings["INFOPLIST_FILE"] = target_infoplist

if product_type == "application" or product_type == "app-extension":
# Prevent XcodeGen from inferring a plist path on its own from target source files.
# See PRs #593 and #601 for more context.
target_settings["INFOPLIST_FILE"] = ""
target_infoplist = None
target_settings["PRODUCT_BUNDLE_IDENTIFIER"] = target_info.bundle_id

if product_type == "bundle.unit-test":
Expand Down Expand Up @@ -918,6 +936,8 @@ fi
pre_build_scripts.append({
"name": "Build with bazel",
"script": _BUILD_WITH_BAZEL_SCRIPT,
"outputFiles": [target_infoplist] if target_infoplist else None, # Info.plist files are generated (even when there's no substitutions)
"basedOnDependencyAnalysis": False, # Bazel builds should always run
})

target_settings = _set_target_settings_by_config(ctx, target_settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
/* Begin PBXShellScriptBuildPhase section */
70F3188C2CC462C7F69449B3 /* Build with bazel */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand All @@ -248,13 +249,15 @@
outputFileListPaths = (
);
outputPaths = (
"$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/b/_b.0.info.plist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\nexport BAZEL_DIAGNOSTICS_DIR=\"$BUILD_DIR/../../bazel-xcode-diagnostics/\"\nmkdir -p $BAZEL_DIAGNOSTICS_DIR\nexport DATE_SUFFIX=\"$(date +%Y%m%d.%H%M%S%L)\"\nexport BAZEL_BUILD_EVENT_TEXT_FILENAME=\"$BAZEL_DIAGNOSTICS_DIR/build-event-$DATE_SUFFIX.txt\"\nexport BAZEL_BUILD_EXECUTION_LOG_FILENAME=\"$BAZEL_DIAGNOSTICS_DIR/build-execution-log-$DATE_SUFFIX.log\"\nexport BAZEL_PROFILE_FILENAME=\"$BAZEL_DIAGNOSTICS_DIR/build-profile-$DATE_SUFFIX.log\"\nenv -u RUBYOPT -u RUBY_HOME -u GEM_HOME $BAZEL_BUILD_EXEC $BAZEL_BUILD_TARGET_LABEL\n$BAZEL_INSTALLER\n";
};
C5D6E7B3A3961964E5A34956 /* Build with bazel */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand All @@ -266,13 +269,15 @@
outputFileListPaths = (
);
outputPaths = (
"$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/a/_a.0.info.plist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\nexport BAZEL_DIAGNOSTICS_DIR=\"$BUILD_DIR/../../bazel-xcode-diagnostics/\"\nmkdir -p $BAZEL_DIAGNOSTICS_DIR\nexport DATE_SUFFIX=\"$(date +%Y%m%d.%H%M%S%L)\"\nexport BAZEL_BUILD_EVENT_TEXT_FILENAME=\"$BAZEL_DIAGNOSTICS_DIR/build-event-$DATE_SUFFIX.txt\"\nexport BAZEL_BUILD_EXECUTION_LOG_FILENAME=\"$BAZEL_DIAGNOSTICS_DIR/build-execution-log-$DATE_SUFFIX.log\"\nexport BAZEL_PROFILE_FILENAME=\"$BAZEL_DIAGNOSTICS_DIR/build-profile-$DATE_SUFFIX.log\"\nenv -u RUBYOPT -u RUBY_HOME -u GEM_HOME $BAZEL_BUILD_EXEC $BAZEL_BUILD_TARGET_LABEL\n$BAZEL_INSTALLER\n";
};
E0CB9AFC607751D1F766B333 /* Build with bazel */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand All @@ -291,6 +296,7 @@
};
E3C8FB76F63258C6AE88027A /* Build with bazel */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -359,7 +365,7 @@
FRAMEWORK_SEARCH_PATHS = "$(PLATFORM_DIR)/Developer/Library/Frameworks \"$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/c/c\"";
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
HEADER_SEARCH_PATHS = "\"$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/b/b_public_hmap.hmap\" \"$BAZEL_WORKSPACE_ROOT\"";
INFOPLIST_FILE = ../../../tests/ios/frameworks/dynamic/b/Info.plist;
INFOPLIST_FILE = "$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/b/_b.0.info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACH_O_TYPE = "$(inherited)";
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -445,7 +451,7 @@
FRAMEWORK_SEARCH_PATHS = "$(PLATFORM_DIR)/Developer/Library/Frameworks \"$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/b/b\" \"$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/c/c\"";
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
HEADER_SEARCH_PATHS = "\"$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/a/a_public_hmap.hmap\" \"$BAZEL_WORKSPACE_ROOT\"";
INFOPLIST_FILE = ../../../tests/ios/frameworks/dynamic/a/Info.plist;
INFOPLIST_FILE = "$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/a/_a.0.info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACH_O_TYPE = "$(inherited)";
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -493,7 +499,7 @@
FRAMEWORK_SEARCH_PATHS = "$(PLATFORM_DIR)/Developer/Library/Frameworks \"$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/b/b\" \"$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/c/c\"";
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
HEADER_SEARCH_PATHS = "\"$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/a/a_public_hmap.hmap\" \"$BAZEL_WORKSPACE_ROOT\"";
INFOPLIST_FILE = ../../../tests/ios/frameworks/dynamic/a/Info.plist;
INFOPLIST_FILE = "$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/a/_a.0.info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACH_O_TYPE = "$(inherited)";
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -552,7 +558,7 @@
FRAMEWORK_SEARCH_PATHS = "$(PLATFORM_DIR)/Developer/Library/Frameworks \"$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/c/c\"";
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
HEADER_SEARCH_PATHS = "\"$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/b/b_public_hmap.hmap\" \"$BAZEL_WORKSPACE_ROOT\"";
INFOPLIST_FILE = ../../../tests/ios/frameworks/dynamic/b/Info.plist;
INFOPLIST_FILE = "$BAZEL_WORKSPACE_ROOT/bazel-out/ios-x86_64-min10.0-applebin_ios-ios_x86_64-dbg-ST-d31cf6d5fbab/bin/tests/ios/frameworks/dynamic/b/_b.0.info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACH_O_TYPE = "$(inherited)";
ONLY_ACTIVE_ARCH = YES;
Expand Down