facebookincubator / reindeer

Reindeer is a tool to transform Rust Cargo dependencies into generated Buck build rules
MIT License
184 stars 30 forks source link

How do you correctly handle fixups for multiple crate versions? #21

Closed photex closed 1 year ago

photex commented 1 year ago

Ahoy!

Because Cargo is a cursed dependency system and provides absolutely no control over this, it's possible to end up having two versions of sckt-adwaita in your vendored sources.

This causes trouble since the latest version brought in needs a fixup to specify some extra_srcs, but the older version doesn't. reindeer buckify actually ends up failing because it can't find the extra sources that have been specified in the fixups.toml in the older version.

What is the correct way to resolve this situation with reindeer?

zertosh commented 1 year ago

platform_fixup has a version field. Here are some actual examples from internal Meta uses:

bitvec/fixups.toml ``` [env] # Only <1.0 really needs this. CARGO_PKG_REPOSITORY = "" # Version rather than platform-specific [platform_fixup.'cfg(all())'] version = ">=1.0" extra_srcs = ["README.md", "doc/**/*.md"] ```
libloading/fixups.toml ``` buildscript = [] [platform_fixup.'cfg(unix)'] # libloading prior to 0.6.4 has a buildscript building a little library. version = "<0.6.4" [[platform_fixup.'cfg(unix)'.buildscript]] [platform_fixup.'cfg(unix)'.buildscript.cxx_library] name = "global-static" srcs = ["src/os/unix/global_static.c"] deps = ["third-party//glibc:dl"] [platform_fixup.'cfg(any(unix))'] # Post 0.6.4 we just need to link with libdl. version = ">=0.6.4" extra_deps = ["third-party//glibc:dl"] ```
termwiz/fixups.toml ``` # Version rather than platform-specific [platform_fixup.'cfg(all())'] version = ">=0.18" extra_srcs = ["src/tmux_cc/tmux.pest"] # pest depends on `CARGO_MANIFEST_DIR` pointing to termwiz's # crate root. cargo_env = true ```