Skip to content
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

feature: allow user to specify the name for include_top_level #45

Open
thoughtpolice opened this issue May 11, 2024 · 0 comments
Open

Comments

@thoughtpolice
Copy link

include_top_level is pretty nice since it lets you build everything as a smoke test. But the generated target name comes across as pretty awkward; for example, given this snippet of a Cargo.toml, to be buckified and located at package third-party//rust:

[workspace]

[package]
name = "rust-third-party"
version = "0.0.0"
publish = false
edition = "2021"

# Dummy target to keep Cargo happy
[[bin]]
name = "top"
path = "top.rs"

[dependencies]
...

You get a fully-qualified target name like third-party//rust:rust-third-party-0.0.0-top, which is pretty verbose and annoying to write without tab completion in Buck.

To work around this, my reindeer.toml contains the following hack:

[buck]
file_name = "BUCK"

rust_library = "cargo.rust_library"
rust_binary = "cargo.rust_binary"
buckfile_imports = """
load("@prelude//rust:cargo_buildscript.bzl", "buildscript_run")
load("@prelude//rust:cargo_package.bzl", "cargo")

# XXX (aseipp): this is a hack to provide a convenient top-level alias.
# this allows us to just build `third-party//rust` without a target name
# to build everything we need.
# this should probably be part of reindeer itself?

alias(
    name = "rust",
    actual = ":rust-third-party-0.0.0-top",
    visibility = ["PUBLIC"],
)

# XXX: normal reindeer-generated code below
"""

By giving the target the name rust, it becomes the default target for the package third-party//rust, and so buck2 build third-party//rust is enough to check that all my Cargo packages build. This is much more convenient.

It would be nice if there was a way to just specify what the name of the top-level target name is inside reindeer.toml, instead of needing this hack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant