-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solving complex build.rs issues #48
Comments
That looks like a fairly normal |
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"],
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
The text was updated successfully, but these errors were encountered: