github.com/0xKiwi/rules_go@v0.24.3/tests/core/go_binary/BUILD.bazel (about)

     1  load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
     2  load("@io_bazel_rules_go//go/tools/bazel_testing:def.bzl", "go_bazel_test")
     3  load(":many_deps.bzl", "many_deps")
     4  
     5  test_suite(name = "go_binary")
     6  
     7  go_binary(
     8      name = "hello",
     9      srcs = ["hello.go"],
    10      visibility = ["//visibility:public"],
    11  )
    12  
    13  go_test(
    14      name = "go_default_test",
    15      srcs = ["out_test.go"],
    16      data = [":custom_bin"],
    17  )
    18  
    19  go_bazel_test(
    20      name = "package_conflict_test",
    21      srcs = ["package_conflict_test.go"],
    22  )
    23  
    24  go_binary(
    25      name = "custom_bin",
    26      srcs = ["custom_bin.go"],
    27      out = "alt_bin",
    28  )
    29  
    30  go_binary(
    31      name = "goos_pure_bin",
    32      srcs = [
    33          "broken_cgo.go",
    34          "hello.go",
    35      ],
    36      goarch = "amd64",
    37      goos = "plan9",
    38  )
    39  
    40  many_deps(name = "many_deps")
    41  
    42  go_test(
    43      name = "stamp_test",
    44      srcs = ["stamp_test.go"],
    45      data = [":stamp_bin"],
    46      rundir = ".",
    47      deps = ["@io_bazel_rules_go//go/tools/bazel:go_default_library"],
    48  )
    49  
    50  go_binary(
    51      name = "stamp_bin",
    52      srcs = ["stamp_bin.go"],
    53      embed = [":stamp_embed"],
    54      x_defs = {
    55          "Bin": "Bin",
    56          "example.com/stamp_dep.DepBin": "DepBin",
    57      },
    58      deps = [":stamp_dep"],
    59  )
    60  
    61  go_library(
    62      name = "stamp_embed",
    63      srcs = ["stamp_embed.go"],
    64      importpath = "example.com/stamp_embed",
    65      x_defs = {
    66          "Embed": "Embed",
    67      },
    68  )
    69  
    70  go_library(
    71      name = "stamp_dep",
    72      srcs = ["stamp_dep.go"],
    73      importpath = "example.com/stamp_dep",
    74      x_defs = {
    75          "DepSelf": "DepSelf",
    76      },
    77  )
    78  
    79  go_binary(
    80      name = "hello_pie_bin",
    81      srcs = ["hello.go"],
    82      cgo = True,
    83      linkmode = "pie",
    84      tags = ["manual"],
    85  )
    86  
    87  go_binary(
    88      name = "hello_nopie_bin",
    89      srcs = ["hello.go"],
    90      cgo = True,
    91      tags = ["manual"],
    92  )
    93  
    94  go_test(
    95      name = "pie_test",
    96      srcs = [
    97          "pie_darwin_test.go",
    98          "pie_linux_test.go",
    99      ],
   100      data = select({
   101          "@io_bazel_rules_go//go/platform:darwin": [
   102              ":hello_nopie_bin",
   103              ":hello_pie_bin",
   104          ],
   105          "@io_bazel_rules_go//go/platform:linux": [
   106              ":hello_nopie_bin",
   107              ":hello_pie_bin",
   108          ],
   109          "//conditions:default": [],
   110      }),
   111      rundir = ".",
   112      deps = ["@io_bazel_rules_go//go/tools/bazel:go_default_library"],
   113  )
   114  
   115  go_test(
   116      name = "static_test",
   117      srcs = ["static_test.go"],
   118      data = select({
   119          "@io_bazel_rules_go//go/platform:linux": [
   120              ":static_bin",
   121              ":static_cgo_bin",
   122              ":static_pure_bin",
   123          ],
   124          "//conditions:default": [],
   125      }),
   126      rundir = ".",
   127      deps = ["//go/tools/bazel:go_default_library"],
   128  )
   129  
   130  go_binary(
   131      name = "static_bin",
   132      srcs = ["static_bin.go"],
   133      static = "on",
   134      tags = ["manual"],
   135      deps = ["@org_golang_x_sys//unix:go_default_library"],
   136  )
   137  
   138  go_binary(
   139      name = "static_cgo_bin",
   140      srcs = ["static_cgo_bin.go"],
   141      cgo = True,
   142      static = "on",
   143      tags = ["manual"],
   144  )
   145  
   146  go_binary(
   147      name = "static_pure_bin",
   148      srcs = ["static_pure_bin.go"],
   149      pure = "on",
   150      static = "on",
   151      tags = ["manual"],
   152  )
   153  
   154  go_binary(
   155      name = "tags_bin",
   156      srcs = [
   157          "tags_main_bad.go",
   158          "tags_main_good.go",
   159      ],
   160      gotags = ["good"],
   161      deps = [":tags_lib"],
   162  )
   163  
   164  go_library(
   165      name = "tags_lib",
   166      srcs = [
   167          "tags_lib_bad.go",
   168          "tags_lib_good.go",
   169      ],
   170      importpath = "tags_lib",
   171      tags = ["manual"],
   172  )
   173  
   174  go_binary(
   175      name = "prefix",
   176      embed = ["//tests/core/go_binary/prefix"],
   177  )