From 5860621c80ad13cd490bb2fa994db81978e8741a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Mon, 7 Jun 2021 22:33:34 +0300 Subject: [PATCH] add cgo example; fix zig url --- BUILD | 7 +++++++ test/BUILD | 2 ++ test/hello.go | 9 +++++++++ zig-toolchains/defs.bzl | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/hello.go diff --git a/BUILD b/BUILD index e69de29..47ecbd2 100644 --- a/BUILD +++ b/BUILD @@ -0,0 +1,7 @@ +load("@bazel_gazelle//:def.bzl", "gazelle") +load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") + +# gazelle:build_file_name BUILD +gazelle(name = "gazelle") + +buildifier(name = "buildifier") diff --git a/test/BUILD b/test/BUILD index 2c48a9c..a98f4d4 100644 --- a/test/BUILD +++ b/test/BUILD @@ -11,3 +11,5 @@ cc_binary( name = "exception", srcs = ["exception.cpp"], ) + +# go build -ldflags "-linkmode external -extldflags -static" hello.go diff --git a/test/hello.go b/test/hello.go new file mode 100644 index 0000000..ffd599c --- /dev/null +++ b/test/hello.go @@ -0,0 +1,9 @@ +package main + +// #include +// void helloworld() { printf("hello, world\n"); } +import "C" + +func main() { + C.helloworld() +} diff --git a/zig-toolchains/defs.bzl b/zig-toolchains/defs.bzl index 12350de..2a8cc0b 100644 --- a/zig-toolchains/defs.bzl +++ b/zig-toolchains/defs.bzl @@ -82,7 +82,7 @@ def toolchain_repositories(): name = "com_github_ziglang_zig", version = "0.8.0", - url_format = "https://ziglang.org/builds/zig-{host_platform}-{version}.tar.xz", + url_format = "https://ziglang.org/download/{version}/zig-{host_platform}-{version}.tar.xz", host_platform_sha256 = { "linux-x86_64": "502625d3da3ae595c5f44a809a87714320b7a40e6dff4a895b5fa7df3391d01e", "macos-x86_64": "279f9360b5cb23103f0395dc4d3d0d30626e699b1b4be55e98fd985b62bc6fbe",