aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Chris Parsons <cparsons@google.com>2016-05-27 19:00:42 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-05-30 09:20:19 +0000
commit0f4927f30a1ab99ebdc9d41df708800d73a76adf (patch)
tree7492dc777e814114e61c755c10c8a419d2de6344 /src
parent197543a596dc989311eabe3c9c979c49d3f4e645 (diff)
Add exoblaze and bazel tests for apple_binary
-- MOS_MIGRATED_REVID=123441206
Diffstat (limited to 'src')
-rwxr-xr-xsrc/test/shell/bazel/bazel_apple_test.sh80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/test/shell/bazel/bazel_apple_test.sh b/src/test/shell/bazel/bazel_apple_test.sh
index 3cb2dbeef7..c9283acc85 100755
--- a/src/test/shell/bazel/bazel_apple_test.sh
+++ b/src/test/shell/bazel/bazel_apple_test.sh
@@ -251,6 +251,86 @@ EOF
//ios:swift_lib >$TEST_log 2>&1 || fail "should build"
}
+function test_fat_apple_binary() {
+ rm -rf package
+ mkdir -p package
+ cat > package/BUILD <<EOF
+objc_library(
+ name = "lib_a",
+ srcs = ["a.m"],
+)
+objc_library(
+ name = "lib_b",
+ srcs = ["b.m"],
+)
+apple_binary(
+ name = "main_binary",
+ deps = [":lib_a", ":lib_b"],
+ srcs = ["main.m"],
+)
+genrule(
+ name = "lipo_run",
+ srcs = [":main_binary_lipobin"],
+ outs = ["lipo_out"],
+ cmd =
+ "set -e && " +
+ "lipo -info \$(location :main_binary_lipobin) > \$(@)",
+ tags = ["requires-darwin"],
+)
+EOF
+ touch package/a.m
+ touch package/b.m
+ cat > package/main.m <<EOF
+int main() {
+ return 0;
+}
+EOF
+
+ bazel build --verbose_failures //package:lipo_out \
+ --ios_multi_cpus=i386,x86_64 || fail "should build apple_binary and obtain info via lipo"
+
+ cat bazel-genfiles/package/lipo_out | grep "i386 x86_64" \
+ || fail "expected output binary to contain 2 architectures"
+}
+
+function test_apple_binary_lipo_archive() {
+ rm -rf package
+ mkdir -p package
+ cat > package/BUILD <<EOF
+apple_binary(
+ name = "main_binary",
+ srcs = ["a.m"],
+)
+genrule(
+ name = "extract_archives",
+ srcs = [":main_binary_lipo.a"],
+ outs = ["info_x86_64", "info_i386"],
+ cmd =
+ "set -e && " +
+ "lipo -extract x86_64 \$(location :main_binary_lipo.a) " +
+ "-output archive_x86_64.a && " +
+ "lipo -extract i386 \$(location :main_binary_lipo.a) " +
+ "-output archive_i386.a && " +
+ "file archive_x86_64.a > \$(location :info_x86_64) && " +
+ "file archive_i386.a > \$(location :info_i386)",
+ tags = ["requires-darwin"],
+)
+EOF
+ cat > package/a.m <<EOF
+int main() {
+ return 0;
+}
+EOF
+
+
+ bazel build --verbose_failures //package:extract_archives \
+ --ios_multi_cpus=i386,x86_64 \
+ || fail "should build multi-architecture archive"
+
+ assert_contains "x86_64.*archive" bazel-genfiles/package/info_x86_64
+ assert_contains "i386.*archive" bazel-genfiles/package/info_i386
+}
+
function test_swift_imports_swift() {
rm -rf ios
mkdir -p ios