Open pnathan opened 4 months ago
That looks like a fairly normal gen_srcs
fixup with env
to set MIME_TYPES_GENERATED_PATH
.
Hacked it into working for now. The issue is that the env option sets the variable for both build script and library. So had to find a way to manually resolve the path. Please let me know if there is a better alternative!
# fixup.toml
version = "=2.0.5"
[env]
# HACK: In place of $(location :mime_guess-2.0.5-build-script-run[out_dir])/mime_types_generated.rs
# The correct method causes cyclic dependency because the variable is set for both:
# :mime_guess-2.0.5 [library]
# :mime_guess-2.0.5-build-script-build [binary]
# the latter of which is a dependency of :mime_guess-2.0.5-build-script-run[out_dir].
# This only works because the OUT_DIR (set by buildscript.gen_srcs) depends on :mime_guess-2.0.5-build-script-run[out_dir].
MIME_TYPES_GENERATED_PATH = "$(location //third-party:third-party)/../../../rust/__mime_guess-2.0.5-build-script-run__/OUT_DIR/mime_types_generated.rs"
[[buildscript]]
[buildscript.gen_srcs]
# third-party BUCK
genrule(name = "third-party", cmd = "echo third-party> $OUT", out = "third-party", visibility = ["PUBLIC"])
# generated BUCK
cargo.rust_library(
name = "mime_guess-2.0.5",
srcs = [":mime_guess-2.0.5.crate"],
crate = "mime_guess",
crate_root = "mime_guess-2.0.5.crate/src/lib.rs",
edition = "2015",
env = {
"MIME_TYPES_GENERATED_PATH": "$(location //third-party:third-party)/../../../rust/__mime_guess-2.0.5-build-script-run__/OUT_DIR/mime_types_generated.rs",
"OUT_DIR": "$(location :mime_guess-2.0.5-build-script-run[out_dir])",
},
rustc_flags = ["@$(location :mime_guess-2.0.5-build-script-run[rustc_flags])"],
visibility = [],
deps = [
":mime-0.3.17",
":unicase-2.7.0",
],
)
cargo.rust_binary(
name = "mime_guess-2.0.5-build-script-build",
srcs = [":mime_guess-2.0.5.crate"],
crate = "build_script_build",
crate_root = "mime_guess-2.0.5.crate/build.rs",
edition = "2015",
env = {
"MIME_TYPES_GENERATED_PATH": "$(location //third-party:third-party)/../../../rust/__mime_guess-2.0.5-build-script-run__/OUT_DIR/mime_types_generated.rs",
},
visibility = [],
deps = [":unicase-2.7.0"],
)
Hi,
I'm experimenting with converting my cargo project to buck and I found that I have mime-guess as a dependency about 3 levels down. Its build.rs is really quite special! https://github.com/abonander/mime_guess/blob/master/build.rs
How should I address this in the fixup?