github.com/0xKiwi/rules_go@v0.24.3/tests/core/cross/README.rst (about) 1 Cross compilation 2 ================= 3 4 .. _go_binary: /go/core.rst#go_binary 5 .. _go_library: /go/core.rst#go_library 6 .. _#2523: https://github.com/bazelbuild/rules_go/issues/2523 7 8 Tests to ensure that cross compilation is working as expected. 9 10 .. contents:: 11 12 cross_test 13 ---------- 14 15 16 Tests that cross compilation controlled by the ``goos`` and ``goarch`` 17 attributes on a `go_binary`_ produces executables for the correct platform. 18 19 This builds binaries using `main.go <main.go>`_ in multiple configurations, and 20 then passes them as data to a test `written in go <cross_test.go>`_. 21 22 The test executes the unix command "file" on the binaries to determine their 23 type, and checks they were built for the expected architecture. 24 25 The test also checks that `go_library`_ packages imoprted by `go_binary`_ with 26 ``goos`` set are built in the correct configuration, and ``select`` is applied 27 in that configuration. Each binary depends on ``platform_lib``, which has a 28 different source file (determined by ``select``) for each platform. The source 29 files have a ``goos`` suffix, so they will only be built on the right platform. 30 If the wrong source file is used or if all files are filtered out, the 31 `go_binary`_ will not build. 32 33 ios_select_test 34 --------------- 35 36 Tests that we can cross-compile a library for iOS. We should be able to select 37 a dependency using ``@io_bazel_rules_go//go/platform:darwin``, which is true 38 when building for iOS (tested by ``ios_select_test``) and macOS 39 (tested by ``use_ios_lib``). 40 41 proto_test 42 ---------- 43 44 Tests that a ``go_proto_library`` can be cross-compiled, both with 45 ``--platforms`` and with mode attributes. 46 47 no_context_info 48 --------------- 49 50 Tests that a rule that uses ``@io_bazel_rules_go//go:toolchain`` but does not 51 depend on any other target can call ``go_context`` without error. Verifies 52 `#2523`_.