|
212 | 212 | bazel build --verbose_failures --objccopt=-DCOPTS_FOO=1 -s \ |
213 | 213 | --xcode_version=$XCODE_VERSION \ |
214 | 214 | //ios:swift_lib >$TEST_log 2>&1 || fail "should build" |
215 | | - expect_log "-module-cache-path bazel-out/local-fastbuild/genfiles/_objc_module_cache" |
| 215 | + expect_log "-module-cache-path bazel-out/darwin_x86_64-fastbuild/genfiles/_objc_module_cache" |
216 | 216 | } |
217 | 217 |
|
218 | 218 | function test_swift_import_objc_framework() { |
|
766 | 766 |
|
767 | 767 | bazel build --verbose_failures --xcode_version=$XCODE_VERSION -s \ |
768 | 768 | //ios:bin >$TEST_log 2>&1 || fail "should build" |
769 | | - expect_log "-Xlinker -add_ast_path -Xlinker bazel-out/local-fastbuild/genfiles/ios/dep/_objs/ios_dep.swiftmodule" |
770 | | - expect_log "-Xlinker -add_ast_path -Xlinker bazel-out/local-fastbuild/genfiles/ios/swift_lib/_objs/ios_swift_lib.swiftmodule" |
| 769 | + expect_log "-Xlinker -add_ast_path -Xlinker bazel-out/darwin_x86_64-fastbuild/genfiles/ios/dep/_objs/ios_dep.swiftmodule" |
| 770 | + expect_log "-Xlinker -add_ast_path -Xlinker bazel-out/darwin_x86_64-fastbuild/genfiles/ios/swift_lib/_objs/ios_swift_lib.swiftmodule" |
771 | 771 | } |
772 | 772 |
|
773 | 773 | function test_swiftc_script_mode() { |
@@ -914,4 +914,134 @@ EOF |
914 | 914 | || fail "should contain DWARF data" |
915 | 915 | } |
916 | 916 |
|
| 917 | +function test_apple_binary_crosstool_ios() { |
| 918 | + rm -rf package |
| 919 | + mkdir -p package |
| 920 | + cat > package/BUILD <<EOF |
| 921 | +objc_library( |
| 922 | + name = "lib_a", |
| 923 | + srcs = ["a.m"], |
| 924 | +) |
| 925 | +objc_library( |
| 926 | + name = "lib_b", |
| 927 | + srcs = ["b.m"], |
| 928 | + deps = [":cc_lib"], |
| 929 | +) |
| 930 | +cc_library( |
| 931 | + name = "cc_lib", |
| 932 | + srcs = ["cc_lib.cc"], |
| 933 | +) |
| 934 | +apple_binary( |
| 935 | + name = "main_binary", |
| 936 | + deps = [":lib_a", ":lib_b"], |
| 937 | + srcs = ["main.m"], |
| 938 | +) |
| 939 | +genrule( |
| 940 | + name = "lipo_run", |
| 941 | + srcs = [":main_binary_lipobin"], |
| 942 | + outs = ["lipo_out"], |
| 943 | + cmd = |
| 944 | + "set -e && " + |
| 945 | + "lipo -info \$(location :main_binary_lipobin) > \$(@)", |
| 946 | + tags = ["requires-darwin"], |
| 947 | +) |
| 948 | +EOF |
| 949 | + touch package/a.m |
| 950 | + touch package/b.m |
| 951 | + cat > package/main.m <<EOF |
| 952 | +int main() { |
| 953 | + return 0; |
| 954 | +} |
| 955 | +EOF |
| 956 | + cat > package/cc_lib.cc << EOF |
| 957 | +#include <string> |
| 958 | +
|
| 959 | +std::string GetString() { return "h3ll0"; } |
| 960 | +EOF |
| 961 | + |
| 962 | + bazel build --verbose_failures //package:lipo_out \ |
| 963 | + --experimental_enable_objc_cc_deps \ |
| 964 | + --experimental_objc_crosstool=all \ |
| 965 | + --apple_crosstool_transition \ |
| 966 | + --ios_multi_cpus=i386,x86_64 \ |
| 967 | + --xcode_version=$XCODE_VERSION \ |
| 968 | + || fail "should build apple_binary and obtain info via lipo" |
| 969 | + |
| 970 | + cat bazel-genfiles/package/lipo_out | grep "i386 x86_64" \ |
| 971 | + || fail "expected output binary to be for x86_64 architecture" |
| 972 | +} |
| 973 | + |
| 974 | +function test_apple_binary_crosstool_watchos() { |
| 975 | + rm -rf package |
| 976 | + mkdir -p package |
| 977 | + cat > package/BUILD <<EOF |
| 978 | +genrule( |
| 979 | + name = "lipo_run", |
| 980 | + srcs = [":main_binary_lipobin"], |
| 981 | + outs = ["lipo_out"], |
| 982 | + cmd = |
| 983 | + "set -e && " + |
| 984 | + "lipo -info \$(location :main_binary_lipobin) > \$(@)", |
| 985 | + tags = ["requires-darwin"], |
| 986 | +) |
| 987 | +
|
| 988 | +apple_binary( |
| 989 | + name = "main_binary", |
| 990 | + srcs = ["main.m"], |
| 991 | + deps = [":lib_a"], |
| 992 | + platform_type = "watchos", |
| 993 | +) |
| 994 | +cc_library( |
| 995 | + name = "cc_lib", |
| 996 | + srcs = ["cc_lib.cc"], |
| 997 | +) |
| 998 | +# By depending on a library which requires it is built for watchos, |
| 999 | +# this test verifies that dependencies of apple_binary are compiled |
| 1000 | +# for the specified platform_type. |
| 1001 | +objc_library( |
| 1002 | + name = "lib_a", |
| 1003 | + srcs = ["a.m"], |
| 1004 | + deps = [":cc_lib"], |
| 1005 | +) |
| 1006 | +EOF |
| 1007 | + cat > package/main.m <<EOF |
| 1008 | +#import <WatchKit/WatchKit.h> |
| 1009 | +
|
| 1010 | +// Note that WKExtensionDelegate is only available in Watch SDK. |
| 1011 | +@interface TestInterfaceMain : NSObject <WKExtensionDelegate> |
| 1012 | +@end |
| 1013 | +
|
| 1014 | +int main() { |
| 1015 | + return 0; |
| 1016 | +} |
| 1017 | +EOF |
| 1018 | + cat > package/a.m <<EOF |
| 1019 | +#import <WatchKit/WatchKit.h> |
| 1020 | +
|
| 1021 | +// Note that WKExtensionDelegate is only available in Watch SDK. |
| 1022 | +@interface TestInterfaceA : NSObject <WKExtensionDelegate> |
| 1023 | +@end |
| 1024 | +
|
| 1025 | +int aFunction() { |
| 1026 | + return 0; |
| 1027 | +} |
| 1028 | +EOF |
| 1029 | + cat > package/cc_lib.cc << EOF |
| 1030 | +#include <string> |
| 1031 | +
|
| 1032 | +std::string GetString() { return "h3ll0"; } |
| 1033 | +EOF |
| 1034 | + |
| 1035 | + bazel build --verbose_failures //package:lipo_out \ |
| 1036 | + --experimental_enable_objc_cc_deps \ |
| 1037 | + --experimental_objc_crosstool=library \ |
| 1038 | + --apple_crosstool_transition \ |
| 1039 | + --watchos_cpus=armv7k \ |
| 1040 | + --xcode_version=$XCODE_VERSION \ |
| 1041 | + || fail "should build watch binary" |
| 1042 | + |
| 1043 | + cat bazel-genfiles/package/lipo_out | grep "armv7k" \ |
| 1044 | + || fail "expected output binary to be for armv7k architecture" |
| 1045 | +} |
| 1046 | + |
917 | 1047 | run_suite "apple_tests" |
0 commit comments