Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds deployment target configs based on provided platform_type & minimum_os_version #72

Merged
merged 1 commit into from
Jun 4, 2020
Merged
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
24 changes: 21 additions & 3 deletions rules/xcodeproj.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ def _get_attr_values_for_name(deps, provider, field):

_TargetInfo = provider()
_SrcsInfo = provider()
_PLATFORM_MAPPING = {
"ios": "iOS",
"macos": "macOS",
}

_ARCH_MAPPING = {
"ios": "arm64 arm64e",
"macos": "i386 x86_64",
}

_PRODUCT_SPECIFIER_LENGTH = len("com.apple.product-type.")

def _dir(o):
return [
Expand Down Expand Up @@ -66,7 +77,9 @@ def _xcodeproj_aspect_impl(target, ctx):
srcs = depset([], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "srcs")),
asset_srcs = depset([], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "asset_srcs")),
build_files = depset([ctx.build_file_path], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "build_files")),
product_type = bundle_info.product_type[len("com.apple.product-type."):],
product_type = bundle_info.product_type[_PRODUCT_SPECIFIER_LENGTH:],
platform_type = bundle_info.platform_type,
minimum_os_version = bundle_info.minimum_os_version,
test_env_vars = test_env_vars,
test_commandline_args = test_commandline_args,
test_host_appname = test_host_appname,
Expand All @@ -82,7 +95,7 @@ def _xcodeproj_aspect_impl(target, ctx):
direct_targets = [info]
if test_host_target:
direct_targets.extend(test_host_target[_TargetInfo].direct_targets)
target_info = _TargetInfo(direct_targets = direct_targets, targets = depset([info], transitive = _get_attr_values_for_name(deps, _TargetInfo, "targets")))
target_info = _TargetInfo(direct_targets = direct_targets, targets = depset([info] if info else [], transitive = _get_attr_values_for_name(deps, _TargetInfo, "targets")))
providers.append(target_info)
elif ctx.rule.kind == "apple_framework_packaging":
info = struct(
Expand All @@ -94,6 +107,8 @@ def _xcodeproj_aspect_impl(target, ctx):
asset_srcs = depset([], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "asset_srcs")),
build_files = depset([ctx.build_file_path], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "build_files")),
product_type = "framework",
platform_type = "ios",
minimum_os_version = None,
test_env_vars = test_env_vars,
test_commandline_args = test_commandline_args,
)
Expand Down Expand Up @@ -226,10 +241,13 @@ def _xcodeproj_impl(ctx):
target_dependencies.append({"target": test_host_appname})
target_settings["TEST_HOST"] = "$(BUILT_PRODUCTS_DIR)/{test_host_appname}.app/{test_host_appname}".format(test_host_appname = test_host_appname)

target_settings["VALID_ARCHS"] = _ARCH_MAPPING[target_info.platform_type]

xcodeproj_targets_by_name[target_info.name] = {
"sources": compiled_sources + asset_sources,
"type": target_info.product_type,
"platform": "iOS",
"platform": _PLATFORM_MAPPING[target_info.platform_type],
"deploymentTarget": target_info.minimum_os_version,
"settings": target_settings,
"dependencies": target_dependencies,
"preBuildScripts": [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,11 @@
isa = XCBuildConfiguration;
buildSettings = {
BAZEL_BIN_SUBDIR = /tests/macos/xcodeproj;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_NAME = "Single-Application-UnitTests";
SUPPORTS_MACCATALYST = 0;
VALID_ARCHS = "arm64 arm64e";
};
name = Debug;
};
Expand All @@ -283,9 +285,11 @@
buildSettings = {
BAZEL_BIN_SUBDIR = /rules/test_host_app;
INFOPLIST_FILE = "$BAZEL_STUBS_DIR/Info-stub.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.ios-app-host-12.0";
PRODUCT_NAME = "iOS-12.0-AppHost";
VALID_ARCHS = "arm64 arm64e";
};
name = Debug;
};
Expand All @@ -294,9 +298,11 @@
buildSettings = {
BAZEL_BIN_SUBDIR = /rules/test_host_app;
INFOPLIST_FILE = "$BAZEL_STUBS_DIR/Info-stub.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.ios-app-host-12.0";
PRODUCT_NAME = "iOS-12.0-AppHost";
VALID_ARCHS = "arm64 arm64e";
};
name = Release;
};
Expand Down Expand Up @@ -350,29 +356,35 @@
isa = XCBuildConfiguration;
buildSettings = {
BAZEL_BIN_SUBDIR = /tests/macos/xcodeproj;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_NAME = "Single-Application-RunnableTestSuite";
SUPPORTS_MACCATALYST = 0;
VALID_ARCHS = "arm64 arm64e";
};
name = Debug;
};
D0D546F48AD698CADC2B4CF4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BAZEL_BIN_SUBDIR = /tests/macos/xcodeproj;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_NAME = "Single-Application-RunnableTestSuite";
SUPPORTS_MACCATALYST = 0;
VALID_ARCHS = "arm64 arm64e";
};
name = Release;
};
D60C6B2C219D235429C548BD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BAZEL_BIN_SUBDIR = /tests/macos/xcodeproj;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_NAME = "Single-Application-UnitTests";
SUPPORTS_MACCATALYST = 0;
VALID_ARCHS = "arm64 arm64e";
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,23 @@
isa = XCBuildConfiguration;
buildSettings = {
BAZEL_BIN_SUBDIR = /tests/macos/xcodeproj;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_NAME = "Single-Application-RunnableTestSuite";
SUPPORTS_MACCATALYST = 0;
VALID_ARCHS = "arm64 arm64e";
};
name = Release;
};
2F2231861BAFE20B36281A7D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BAZEL_BIN_SUBDIR = /tests/macos/xcodeproj;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_NAME = "Single-Application-UnitTests";
SUPPORTS_MACCATALYST = 0;
VALID_ARCHS = "arm64 arm64e";
};
name = Debug;
};
Expand Down Expand Up @@ -316,9 +320,11 @@
buildSettings = {
BAZEL_BIN_SUBDIR = /rules/test_host_app;
INFOPLIST_FILE = "$BAZEL_STUBS_DIR/Info-stub.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.ios-app-host-12.0";
PRODUCT_NAME = "iOS-12.0-AppHost";
VALID_ARCHS = "arm64 arm64e";
};
name = Release;
};
Expand All @@ -327,19 +333,23 @@
buildSettings = {
BAZEL_BIN_SUBDIR = /rules/test_host_app;
INFOPLIST_FILE = "$BAZEL_STUBS_DIR/Info-stub.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.ios-app-host-12.0";
PRODUCT_NAME = "iOS-12.0-AppHost";
VALID_ARCHS = "arm64 arm64e";
};
name = Debug;
};
97EC8E812E385E849EB04CE6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BAZEL_BIN_SUBDIR = /tests/macos/xcodeproj;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_NAME = "Single-Application-RunnableTestSuite";
SUPPORTS_MACCATALYST = 0;
VALID_ARCHS = "arm64 arm64e";
};
name = Debug;
};
Expand Down Expand Up @@ -370,9 +380,11 @@
isa = XCBuildConfiguration;
buildSettings = {
BAZEL_BIN_SUBDIR = /tests/macos/xcodeproj;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_NAME = "Single-Application-UnitTests";
SUPPORTS_MACCATALYST = 0;
VALID_ARCHS = "arm64 arm64e";
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,12 @@
isa = XCBuildConfiguration;
buildSettings = {
BAZEL_BIN_SUBDIR = "/tests/ios/unit-test/test-imports-app";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_NAME = "TestImports-Unit-Tests";
SUPPORTS_MACCATALYST = 0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestImports-App.app/TestImports-App";
VALID_ARCHS = "arm64 arm64e";
};
name = Release;
};
Expand All @@ -390,31 +392,37 @@
buildSettings = {
BAZEL_BIN_SUBDIR = "/tests/ios/unit-test/test-imports-app";
INFOPLIST_FILE = "$BAZEL_STUBS_DIR/Info-stub.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.TestImports-App";
PRODUCT_NAME = "TestImports-App";
VALID_ARCHS = "arm64 arm64e";
};
name = Debug;
};
340C72FB682660DC9C8AF45B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BAZEL_BIN_SUBDIR = "/tests/ios/unit-test/test-imports-app";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_NAME = "TestImports-Unit-Tests";
SUPPORTS_MACCATALYST = 0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestImports-App.app/TestImports-App";
VALID_ARCHS = "arm64 arm64e";
};
name = Debug;
};
35319915CD86528CFD9DACD6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BAZEL_BIN_SUBDIR = "/tests/ios/unit-test";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_NAME = DefaultHosted;
SUPPORTS_MACCATALYST = 0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOS-10.0-AppHost.app/iOS-10.0-AppHost";
VALID_ARCHS = "arm64 arm64e";
};
name = Debug;
};
Expand All @@ -423,9 +431,11 @@
buildSettings = {
BAZEL_BIN_SUBDIR = "/tests/ios/unit-test/test-imports-app";
INFOPLIST_FILE = "$BAZEL_STUBS_DIR/Info-stub.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.TestImports-App";
PRODUCT_NAME = "TestImports-App";
VALID_ARCHS = "arm64 arm64e";
};
name = Release;
};
Expand Down Expand Up @@ -457,9 +467,11 @@
buildSettings = {
BAZEL_BIN_SUBDIR = /rules/test_host_app;
INFOPLIST_FILE = "$BAZEL_STUBS_DIR/Info-stub.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.ios-app-host-10.0";
PRODUCT_NAME = "iOS-10.0-AppHost";
VALID_ARCHS = "arm64 arm64e";
};
name = Release;
};
Expand All @@ -468,9 +480,11 @@
buildSettings = {
BAZEL_BIN_SUBDIR = /rules/test_host_app;
INFOPLIST_FILE = "$BAZEL_STUBS_DIR/Info-stub.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.ios-app-host-10.0";
PRODUCT_NAME = "iOS-10.0-AppHost";
VALID_ARCHS = "arm64 arm64e";
};
name = Debug;
};
Expand Down Expand Up @@ -501,10 +515,12 @@
isa = XCBuildConfiguration;
buildSettings = {
BAZEL_BIN_SUBDIR = "/tests/ios/unit-test";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACH_O_TYPE = "$(inherited)";
PRODUCT_NAME = DefaultHosted;
SUPPORTS_MACCATALYST = 0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOS-10.0-AppHost.app/iOS-10.0-AppHost";
VALID_ARCHS = "arm64 arm64e";
};
name = Release;
};
Expand Down