diff options
Diffstat (limited to 'tests/legacy/examples/cgo/example_command')
-rw-r--r-- | tests/legacy/examples/cgo/example_command/BUILD.bazel | 26 | ||||
-rw-r--r-- | tests/legacy/examples/cgo/example_command/generate_test.bzl | 17 | ||||
-rw-r--r-- | tests/legacy/examples/cgo/example_command/main.go | 13 |
3 files changed, 56 insertions, 0 deletions
diff --git a/tests/legacy/examples/cgo/example_command/BUILD.bazel b/tests/legacy/examples/cgo/example_command/BUILD.bazel new file mode 100644 index 00000000..db480ab7 --- /dev/null +++ b/tests/legacy/examples/cgo/example_command/BUILD.bazel @@ -0,0 +1,26 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary") +load(":generate_test.bzl", "generate_script") + +package( + default_visibility = ["//visibility:public"], +) + +go_binary( + name = "example_command", + srcs = ["main.go"], + deps = [ + "//tests/legacy/examples/cgo:go_default_library", + ], +) + +generate_script( + name = "example_command_script", + binary = ":example_command", +) + +sh_test( + name = "example_command_test", + size = "small", + srcs = [":example_command_script"], + data = [":example_command"], +) diff --git a/tests/legacy/examples/cgo/example_command/generate_test.bzl b/tests/legacy/examples/cgo/example_command/generate_test.bzl new file mode 100644 index 00000000..c3c991df --- /dev/null +++ b/tests/legacy/examples/cgo/example_command/generate_test.bzl @@ -0,0 +1,17 @@ +def _generate_script_impl(ctx): + script_file = ctx.actions.declare_file(ctx.label.name + ".bash") + ctx.actions.write(output = script_file, is_executable = True, content = """ +{0} +""".format(ctx.file.binary.short_path)) + return struct( + files = depset([script_file]), + ) + +generate_script = rule( + _generate_script_impl, + attrs = { + "binary": attr.label( + allow_single_file = True, + ), + }, +) diff --git a/tests/legacy/examples/cgo/example_command/main.go b/tests/legacy/examples/cgo/example_command/main.go new file mode 100644 index 00000000..8f0bfd6a --- /dev/null +++ b/tests/legacy/examples/cgo/example_command/main.go @@ -0,0 +1,13 @@ +package main + +import ( + "fmt" + + "github.com/bazelbuild/rules_go/examples/cgo" +) + +func main() { + fmt.Println("floor(sqrt(10)) = ", cgo.Nsqrt(10)) + cgo.PrintGoVersion() + cgo.PrintCXXVersion() +} |