aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar cparsons <cparsons@google.com>2017-05-03 22:13:44 +0200
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-05-04 13:13:49 +0200
commitcc21998c299b4d1f97df37b961552ff8168da17f (patch)
tree85a5a1845a1802842e5bf127d3b07f34c36eb52d /src/test
parent655c07b87161030f73f8e2103aebcf8277051582 (diff)
Rollforward #2 of: Basic open-source crosstool to support targeting apple platform types.
RELNOTES: None. PiperOrigin-RevId: 154993630
Diffstat (limited to 'src/test')
-rwxr-xr-xsrc/test/shell/bazel/apple/bazel_apple_test.sh136
-rwxr-xr-xsrc/test/shell/bazel/external_correctness_test.sh2
-rwxr-xr-xsrc/test/shell/bazel/remote_execution_test.sh7
3 files changed, 141 insertions, 4 deletions
diff --git a/src/test/shell/bazel/apple/bazel_apple_test.sh b/src/test/shell/bazel/apple/bazel_apple_test.sh
index ac6b17cb15..b34063819a 100755
--- a/src/test/shell/bazel/apple/bazel_apple_test.sh
+++ b/src/test/shell/bazel/apple/bazel_apple_test.sh
@@ -212,7 +212,7 @@ EOF
bazel build --verbose_failures --objccopt=-DCOPTS_FOO=1 -s \
--xcode_version=$XCODE_VERSION \
//ios:swift_lib >$TEST_log 2>&1 || fail "should build"
- expect_log "-module-cache-path bazel-out/local-fastbuild/genfiles/_objc_module_cache"
+ expect_log "-module-cache-path bazel-out/darwin_x86_64-fastbuild/genfiles/_objc_module_cache"
}
function test_swift_import_objc_framework() {
@@ -766,8 +766,8 @@ EOF
bazel build --verbose_failures --xcode_version=$XCODE_VERSION -s \
//ios:bin >$TEST_log 2>&1 || fail "should build"
- expect_log "-Xlinker -add_ast_path -Xlinker bazel-out/local-fastbuild/genfiles/ios/dep/_objs/ios_dep.swiftmodule"
- expect_log "-Xlinker -add_ast_path -Xlinker bazel-out/local-fastbuild/genfiles/ios/swift_lib/_objs/ios_swift_lib.swiftmodule"
+ expect_log "-Xlinker -add_ast_path -Xlinker bazel-out/darwin_x86_64-fastbuild/genfiles/ios/dep/_objs/ios_dep.swiftmodule"
+ expect_log "-Xlinker -add_ast_path -Xlinker bazel-out/darwin_x86_64-fastbuild/genfiles/ios/swift_lib/_objs/ios_swift_lib.swiftmodule"
}
function test_swiftc_script_mode() {
@@ -914,4 +914,134 @@ EOF
|| fail "should contain DWARF data"
}
+function test_apple_binary_crosstool_ios() {
+ 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"],
+ deps = [":cc_lib"],
+)
+cc_library(
+ name = "cc_lib",
+ srcs = ["cc_lib.cc"],
+)
+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
+ cat > package/cc_lib.cc << EOF
+#include <string>
+
+std::string GetString() { return "h3ll0"; }
+EOF
+
+ bazel build --verbose_failures //package:lipo_out \
+ --experimental_enable_objc_cc_deps \
+ --experimental_objc_crosstool=all \
+ --apple_crosstool_transition \
+ --ios_multi_cpus=i386,x86_64 \
+ --xcode_version=$XCODE_VERSION \
+ || 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 be for x86_64 architecture"
+}
+
+function test_apple_binary_crosstool_watchos() {
+ rm -rf package
+ mkdir -p package
+ cat > package/BUILD <<EOF
+genrule(
+ name = "lipo_run",
+ srcs = [":main_binary_lipobin"],
+ outs = ["lipo_out"],
+ cmd =
+ "set -e && " +
+ "lipo -info \$(location :main_binary_lipobin) > \$(@)",
+ tags = ["requires-darwin"],
+)
+
+apple_binary(
+ name = "main_binary",
+ srcs = ["main.m"],
+ deps = [":lib_a"],
+ platform_type = "watchos",
+)
+cc_library(
+ name = "cc_lib",
+ srcs = ["cc_lib.cc"],
+)
+# By depending on a library which requires it is built for watchos,
+# this test verifies that dependencies of apple_binary are compiled
+# for the specified platform_type.
+objc_library(
+ name = "lib_a",
+ srcs = ["a.m"],
+ deps = [":cc_lib"],
+)
+EOF
+ cat > package/main.m <<EOF
+#import <WatchKit/WatchKit.h>
+
+// Note that WKExtensionDelegate is only available in Watch SDK.
+@interface TestInterfaceMain : NSObject <WKExtensionDelegate>
+@end
+
+int main() {
+ return 0;
+}
+EOF
+ cat > package/a.m <<EOF
+#import <WatchKit/WatchKit.h>
+
+// Note that WKExtensionDelegate is only available in Watch SDK.
+@interface TestInterfaceA : NSObject <WKExtensionDelegate>
+@end
+
+int aFunction() {
+ return 0;
+}
+EOF
+ cat > package/cc_lib.cc << EOF
+#include <string>
+
+std::string GetString() { return "h3ll0"; }
+EOF
+
+ bazel build --verbose_failures //package:lipo_out \
+ --experimental_enable_objc_cc_deps \
+ --experimental_objc_crosstool=library \
+ --apple_crosstool_transition \
+ --watchos_cpus=armv7k \
+ --xcode_version=$XCODE_VERSION \
+ || fail "should build watch binary"
+
+ cat bazel-genfiles/package/lipo_out | grep "armv7k" \
+ || fail "expected output binary to be for armv7k architecture"
+}
+
run_suite "apple_tests"
diff --git a/src/test/shell/bazel/external_correctness_test.sh b/src/test/shell/bazel/external_correctness_test.sh
index 07bffba9dd..183ee2aa0d 100755
--- a/src/test/shell/bazel/external_correctness_test.sh
+++ b/src/test/shell/bazel/external_correctness_test.sh
@@ -142,7 +142,7 @@ genrule(
)
EOF
bazel build @a//b/c:echo-d &> $TEST_log || fail "Build failed"
- assert_contains "bazel-out/local.*-fastbuild/genfiles/external/a/b/c" \
+ assert_contains "bazel-out/.*-fastbuild/genfiles/external/a/b/c" \
"bazel-genfiles/external/a/b/c/d"
}
diff --git a/src/test/shell/bazel/remote_execution_test.sh b/src/test/shell/bazel/remote_execution_test.sh
index 66a99a6654..051fbe331f 100755
--- a/src/test/shell/bazel/remote_execution_test.sh
+++ b/src/test/shell/bazel/remote_execution_test.sh
@@ -53,6 +53,13 @@ function tear_down() {
}
function test_cc_binary() {
+ if [[ "$PLATFORM" == "darwin" ]]; then
+ # TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
+ # setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
+ # action executors in order to select the appropriate Xcode toolchain.
+ return 0
+ fi
+
mkdir -p a
cat > a/BUILD <<EOF
package(default_visibility = ["//visibility:public"])