diff options
author | Keith Smiley <keithbsmiley@gmail.com> | 2023-07-17 18:00:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-18 01:00:43 +0000 |
commit | 5551b3f2a969253348b9e25c29649791926c36c5 (patch) | |
tree | 56f45b767ffee148d99787cfd06d40c2247f0d16 | |
parent | d9f2bafa88f7398fcfaef4c919af2976e8db94fc (diff) | |
download | bazelbuild-apple_support-5551b3f2a969253348b9e25c29649791926c36c5.tar.gz |
Move starlark_apple_static_library into bzl file (#233)
No reason to complicate the shell tests with generating this test rule
-rw-r--r-- | test/shell/BUILD | 8 | ||||
-rwxr-xr-x | test/shell/apple_test.sh | 6 | ||||
-rwxr-xr-x | test/shell/integration_test_setup.sh | 2 | ||||
-rw-r--r-- | test/starlark_apple_static_library.bzl (renamed from test/shell/apple_common.sh) | 62 |
4 files changed, 17 insertions, 61 deletions
diff --git a/test/shell/BUILD b/test/shell/BUILD index 2045af5..2136ae7 100644 --- a/test/shell/BUILD +++ b/test/shell/BUILD @@ -22,19 +22,12 @@ sh_library( ], ) -sh_library( - name = "apple_common", - testonly = True, - srcs = ["apple_common.sh"], -) - sh_test( name = "objc_test", size = "large", srcs = ["objc_test.sh"], data = [":for_bazel_tests"], deps = [ - ":apple_common", ":bashunit", ], ) @@ -45,7 +38,6 @@ sh_test( data = [":for_bazel_tests"], shard_count = 3, deps = [ - ":apple_common", ":bashunit", ], ) diff --git a/test/shell/apple_test.sh b/test/shell/apple_test.sh index 406c95c..4970852 100755 --- a/test/shell/apple_test.sh +++ b/test/shell/apple_test.sh @@ -120,13 +120,9 @@ EOF function test_apple_static_library() { rm -rf package mkdir -p package - make_starlark_apple_static_library_rule_in package cat > package/BUILD <<EOF -load( - "//package:starlark_apple_static_library.bzl", - "starlark_apple_static_library", -) +load("@build_bazel_apple_support//test:starlark_apple_static_library.bzl", "starlark_apple_static_library") starlark_apple_static_library( name = "static_lib", deps = [":dummy_lib"], diff --git a/test/shell/integration_test_setup.sh b/test/shell/integration_test_setup.sh index 4fddc28..a16ba90 100755 --- a/test/shell/integration_test_setup.sh +++ b/test/shell/integration_test_setup.sh @@ -23,5 +23,3 @@ source "$(rlocation build_bazel_apple_support/test/shell/unittest.bash)" \ || print_message_and_exit "unittest.bash not found!" source "$(rlocation build_bazel_apple_support/test/shell/testenv.sh)" \ || print_message_and_exit "testenv.sh not found!" -source "$(rlocation build_bazel_apple_support/test/shell/apple_common.sh)" \ - || print_message_and_exit "apple_common.sh not found!" diff --git a/test/shell/apple_common.sh b/test/starlark_apple_static_library.bzl index 4d54fb8..c3c135b 100644 --- a/test/shell/apple_common.sh +++ b/test/starlark_apple_static_library.bzl @@ -1,36 +1,11 @@ -#!/bin/bash -# -# Copyright 2022 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Common Bash functions to test Apple rules in Bazel. -# +"""Test rule for static linking with bazel's builtin Apple logic""" -function make_starlark_apple_static_library_rule_in() { - local dir="$1"; shift - - # All of the attributes below are required as part of the implied contract of - # `apple_common.link_multi_arch_static_library` since it asks for attributes - # directly from the rule context. As these requirements are changed from - # implied attributes to function arguments, they can be removed. - cat >> "${dir}/starlark_apple_static_library.bzl" <<EOF def _starlark_apple_static_library_impl(ctx): if not hasattr(apple_common.platform_type, ctx.attr.platform_type): fail('Unsupported platform type \"{}\"'.format(ctx.attr.platform_type)) link_result = apple_common.link_multi_arch_static_library(ctx = ctx) processed_library = ctx.actions.declare_file( - '{}_lipo.a'.format(ctx.label.name) + "{}_lipo.a".format(ctx.label.name), ) files_to_build = [processed_library] runfiles = ctx.runfiles( @@ -50,13 +25,13 @@ def _starlark_apple_static_library_impl(ctx): ), ) args = ctx.actions.args() - args.add('-create') + args.add("-create") args.add_all(lipo_inputs) - args.add('-output', processed_library) + args.add("-output", processed_library) ctx.actions.run( arguments = [args], env = apple_env, - executable = '/usr/bin/lipo', + executable = "/usr/bin/lipo", execution_requirements = xcode_config.execution_info(), inputs = lipo_inputs, outputs = [processed_library], @@ -77,40 +52,35 @@ def _starlark_apple_static_library_impl(ctx): starlark_apple_static_library = rule( _starlark_apple_static_library_impl, attrs = { - '_child_configuration_dummy': attr.label( + "_child_configuration_dummy": attr.label( cfg = apple_common.multi_arch_split, default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"), ), - '_xcode_config': attr.label( + "_xcode_config": attr.label( default = configuration_field( fragment = "apple", name = "xcode_config_label", ), ), - '_xcrunwrapper': attr.label( + "_xcrunwrapper": attr.label( executable = True, - cfg = 'exec', + cfg = "exec", default = Label("@bazel_tools//tools/objc:xcrunwrapper"), ), - 'additional_linker_inputs': attr.label_list( + "additional_linker_inputs": attr.label_list( allow_files = True, ), - 'avoid_deps': attr.label_list( + "avoid_deps": attr.label_list( cfg = apple_common.multi_arch_split, default = [], ), - 'deps': attr.label_list( + "deps": attr.label_list( cfg = apple_common.multi_arch_split, ), - 'linkopts': attr.string_list(), - 'platform_type': attr.string(), - 'minimum_os_version': attr.string(), - }, - outputs = { - 'lipo_archive': '%{name}_lipo.a', + "linkopts": attr.string_list(), + "platform_type": attr.string(), + "minimum_os_version": attr.string(), }, cfg = apple_common.apple_crosstool_transition, - fragments = ['apple', 'objc', 'cpp',], + fragments = ["apple", "objc", "cpp"], ) -EOF -} |