mirror of
https://github.com/topjohnwu/cxx.git
synced 2025-02-14 12:49:23 +00:00
Buck: build and execute proc-macro2 build script
This commit is contained in:
parent
4747311a1a
commit
66bac528d2
8
third-party/BUCK
vendored
8
third-party/BUCK
vendored
@ -1,5 +1,7 @@
|
||||
# To be generated by Facebook's `reindeer` tool once that is open source.
|
||||
|
||||
load("//tools/buck:rust_library.bzl", "rust_library")
|
||||
|
||||
rust_library(
|
||||
name = "bitflags",
|
||||
srcs = glob(["vendor/bitflags-1.3.1/src/**"]),
|
||||
@ -42,15 +44,11 @@ rust_library(
|
||||
rust_library(
|
||||
name = "proc-macro2",
|
||||
srcs = glob(["vendor/proc-macro2-1.0.28/src/**"]),
|
||||
build_script = "vendor/proc-macro2-1.0.28/build.rs",
|
||||
features = [
|
||||
"proc-macro",
|
||||
"span-locations",
|
||||
],
|
||||
rustc_flags = [
|
||||
"--cfg=span_locations",
|
||||
"--cfg=use_proc_macro",
|
||||
"--cfg=wrap_proc_macro",
|
||||
],
|
||||
visibility = ["PUBLIC"],
|
||||
deps = [":unicode-xid"],
|
||||
)
|
||||
|
34
tools/buck/rust_library.bzl
Normal file
34
tools/buck/rust_library.bzl
Normal file
@ -0,0 +1,34 @@
|
||||
load("//tools/buck:genrule.bzl", "genrule")
|
||||
|
||||
def rust_library(
|
||||
name,
|
||||
srcs,
|
||||
features = [],
|
||||
rustc_flags = [],
|
||||
build_script = None,
|
||||
**kwargs):
|
||||
if build_script:
|
||||
rust_binary(
|
||||
name = "%s@build" % name,
|
||||
srcs = srcs + [build_script],
|
||||
crate = "build",
|
||||
crate_root = build_script,
|
||||
features = features,
|
||||
rustc_flags = rustc_flags,
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "%s@cfg" % name,
|
||||
out = "output",
|
||||
cmd = "env RUSTC=rustc TARGET= $(exe :%s@build) | sed -n s/^cargo:rustc-cfg=/--cfg=/p > ${OUT}" % name,
|
||||
)
|
||||
|
||||
rustc_flags = rustc_flags + ["@$(location :%s@cfg)" % name]
|
||||
|
||||
native.rust_library(
|
||||
name = name,
|
||||
srcs = srcs,
|
||||
features = features,
|
||||
rustc_flags = rustc_flags,
|
||||
**kwargs
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user