diff --git a/BUILD b/BUILD index 158480f..9f1adc5 100644 --- a/BUILD +++ b/BUILD @@ -4,7 +4,7 @@ load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") # gazelle:map_kind go_binary go_binary //rules:rules_go.bzl # gazelle:build_file_name BUILD -# gazelle:prefix github.com/motiejus/bazel-zig-cc +# gazelle:prefix git.sr.ht/~motiejus/bazel-zig-cc gazelle(name = "gazelle") buildifier(name = "buildifier") diff --git a/go.mod b/go.mod index 51be187..3d42c35 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/motiejus/bazel-zig-cc/test +module git.sr.ht/~motiejus/bazel-zig-cc go 1.16 diff --git a/repositories.bzl b/repositories.bzl index 3696421..8f9b41c 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -1,4 +1,2 @@ -load("@bazel_gazelle//:deps.bzl", "go_repository") - def go_repositories(): pass diff --git a/test/BUILD b/test/BUILD index acf368b..8c8cf94 100644 --- a/test/BUILD +++ b/test/BUILD @@ -7,18 +7,25 @@ go_library( cgo = True, importpath = "github.com/motiejus/bazel-zig-cc/test", visibility = ["//visibility:private"], - deps = ["@com_github_mattn_go_sqlite3//:go-sqlite3"], ) go_binary( name = "hello", - embed = [":hello_lib"], + embed = [":test_lib"], static = "on", visibility = ["//visibility:public"], ) go_test( - name = "hello_test", + name = "test_test", srcs = ["hello_test.go"], - embed = [":hello_lib"], + embed = [":test_lib"], +) + +go_library( + name = "test_lib", + srcs = ["hello.go"], + cgo = True, + importpath = "git.sr.ht/~motiejus/bazel-zig-cc/test", + visibility = ["//visibility:private"], ) diff --git a/test/hello.go b/test/hello.go index 52d90cf..5235bed 100644 --- a/test/hello.go +++ b/test/hello.go @@ -9,6 +9,6 @@ func main() { C.printhello() } -func chello() string { +func Chello() string { return C.GoString(C.hello()) } diff --git a/test/hello_test.go b/test/hello_test.go index 4d5e8b2..75978f3 100644 --- a/test/hello_test.go +++ b/test/hello_test.go @@ -1,10 +1,12 @@ package main -import "testing" +import ( + "testing" +) func TestHello(t *testing.T) { want := "hello, world" - got := chello() + got := Chello() if got != want { t.Errorf("expected %q, got %q", want, got) }