facebook / buck2

Build system, successor to Buck
https://buck2.build/
Apache License 2.0
3.37k stars 199 forks source link

Zig support #564

Closed CallistoM closed 4 months ago

CallistoM commented 4 months ago

I was wondering if there is more documentation on how to compile Zig projects, I tried the following, which does not result in an error but I am not able to use it in the project itself.

toolchains\BUCK

load("@prelude//toolchains/cxx/zig:defs.bzl", "cxx_zig_toolchain", "download_zig_distribution")

download_zig_distribution(
    name = "zig",
    version = "0.11.0",
)

cxx_zig_toolchain(
    name = "cxx_zig",
    distribution = ":zig",
    visibility = ["PUBLIC"],
)

app\BUCK

cxx_zig(
    name = "app",
    srcs = ["main.zig"],
    link_style = "static",
    visibility = ["PUBLIC"]
)

When I use cxx_binary it does compile. Is it even possible to compile Zig? In prelude\decls\cxx_rules.bzl I do see cxx_binary being assigned and cxx_zig is not defined anywhere.

Thanks!

JakobDegen commented 4 months ago

As far as I know, the standard prelude doesn't actually support compiling zig. The rules you're seeing there are only for using the zig toolchain to compile C/C++, not actually for compiling zig

CallistoM commented 4 months ago

@JakobDegen Yes I figured as much. Zig toolchain to compile C/C++ only works for Linux since zig\defs.bzl only calls linux shell commands.