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

Can't refer to raze dir as a workspace #12

Closed
mfarrugi opened this issue Nov 15, 2017 · 5 comments
Closed

Can't refer to raze dir as a workspace #12

mfarrugi opened this issue Nov 15, 2017 · 5 comments

Comments

@mfarrugi
Copy link
Contributor

I would like to reference the vendored libs as @cargo//:libc, but cargo raze @// is rejected.

Is there another prefix or setup that would work?

@acmcarther
Copy link
Owner

Hmm..

This would work by adding a WORKSPACE file to the cargo directory.

The workspace prefix ("@//") is what is used within the vendor directory itself, so you wouldn't want @cargo//, since all paths there would be workspace-relative. Instead, you'd just want "//" (which may or may not be accepted by the CLI.

So, something like this:

In //cargo/WORKSPACE

workspace(name = "cargo")

Then, in a hypothetical build rule

//hypothetical/BUILD

rust_library(
  name = "hypothetical"
  deps = [
    "@cargo//:libc",
  ]
)

Can you give the above a try and let me know if that works?

@mfarrugi
Copy link
Contributor Author

cli dies on both "@//" and "//", error: Bazel path "@//" should not end with /, you probably want "@/".

I'm using the version of raze from cargo install, which doesn't appear to be using "@//" relative prefixes in the generated BUILD files. I'll try from source at some point.

@acmcarther
Copy link
Owner

acmcarther commented Nov 17, 2017

I was going to go patch the project to tolerate "//", but I have this cryptic comment in the test

    // Vendoring into root is a really annoying edge case, not supported for now.
    assert!(validate_workspace_prefix(Some("//".to_owned())).is_err());

Is nesting raze stuff under a directory acceptable for your immediate usecase?

$  tree
.
├── cargo
│   ├── raze
│   │   └── vendor
│   │       └── libc-0.0.0
│   └── WORKSPACE
└── WORKSPACE

with an invocation like

cargo raze //raze

from within the cargo directory.

I don't recall what the "annoying edge case" was, but I think it might be related to the fact that "/" cannot be trimmed from "//" without breaking things.

EDIT: "nesting cargo" -> "nesting raze stuff".

@mfarrugi
Copy link
Contributor Author

mfarrugi commented Nov 17, 2017 via email

@acmcarther
Copy link
Owner

This isn't actually fixed but I suspect that it isn't what people would be wanting to do. Instead, they'd probably be vendoring into something like //third_party/cargo.

Willing to reopen in google/cargo-raze as "support vendoring directly into root" or something like that. This is probably a prerequisite to a "nicer" kind of integration that supports re-export to crates.io.

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

2 participants