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

Migrate cargo-raze into rules_rust #590

Closed
wants to merge 264 commits into from
Closed

Migrate cargo-raze into rules_rust #590

wants to merge 264 commits into from

Conversation

UebelAndre
Copy link
Collaborator

@UebelAndre UebelAndre commented Feb 16, 2021

This PR moves cargo-raze into this repo. There is a lot of functionality that is coupled between the two projects that I feel it makes sense to have the code in one place.

This is the simplest form of a migration I can think of. It moves all the code into cargo/cargo_raze and adds the directory to .bazelignore so it doesn't affect existing CI.

A future change should be made to better integrate this into CI but that can be a separate PR with tracked changes and more realistically reviewable PRs.

cc: @acmcarther @damienmg @illicitonion @mfarrugi @dfreese @hlopko

acmcarther and others added 30 commits March 4, 2018 16:02
* Support './' in lib.path targets

* Add normal target to test
* WIP

* Add  option

* Fix whitespace somewhere
* Complain to stderr about unused raze settings.

* Provide more useful help message.
…nternals) (#28)

Refactor planning in the manner of `cargo metadata` (but keep using internals)
* Integrate the examples into cargo-raze

* Add the remote examples as well

* Add a README doc for remote examples

* Fix the build after adding remote README

* Remove examples for PR

* Enable -f on `rm` so no error if dirs don't exist

* Explicitly reset working directory back to original

* Rename examples/README.md

* Move the command exists check to a function

* Make sure `command_exists` actually checks for existence

* DIR -> REPO_ROOT
* Fixes for #36

* Updates for Cargo.toml

* Fix some pathing issues with smoke-test.sh

* Fix up travis not liking the new packaging
* Add the sha256 to the generated http_archive

This is good practice to have them and we get them for free from Cargo.

* Remove unused warnings

* Update Cargo.lock

The previous one doesn't build on my platform.

* Address acmcarther@ suggestions
Now that rust_library/rust_binary supports it.
Using native.existing_rules allow to use several crates.bzl file that
would import the same crates without failing with duplicate rules.
* Pass 2 on remote git targets
Previously this worked with the example because it actually resolved to
crates.io even for "git" packages. The example was included before it
was ready, and only because it relied exclusively on things already on
crates.io did it compile in the first place.

Tests back to compiling and running

true -> True

Fix a pathing issue

Fix some unused imports

* Suggested changes
* WIP: RM separate remote_ files

* Simplify build_path slightly

* More progress

* Fix a test, save a life

* Put the remote_crates back
* Update README.md

Update the examples location now that they're inline to the main repository.

* Update README.md

Add back the OpenSSL example
* Wip the first

* Wip the second

* Clean code -- terrible formatter

* Handle a lot of nits, but not the failing tests

* Fix broken index insertion (debug_uggh) and rendering

* Fix bug where root crate was expected to be vendored

* Fix crate_context.build_path and update missing root crate test

* Fix minor bugs with file generations

* Fix tests and update some context var names
This rule is never used and was renamed in recent rust rules into
rust_bechmark.
…ctory (#62)

* Patch examples with latest cargo-raze generated output

* Update deps, fix deprecation warnings, up to 0.1.0
@UebelAndre
Copy link
Collaborator Author

IMHO raze can be cleanly separated in its own repository, and only depend on the public interface of rules_rust. If changes to rules_rust break raze too often, we need to discuss our backwards compatibility policy.

It's not that changes to rules_rust breaks cargo-raze. It's more that someone wants to implement some new functionality that needs to be done in rules_rust and then setup in cargo-raze or cargo-raze was used to generate something but doesn't support some functionality so a change must be made there in order to update/re-generate something in rules_rust.

Again, very interested in your workflow. While I think merging the two repos would be a good idea, It's not (currently) my burning passion. I like the idea that the rules has a standardized tool so that all workflows can, to a more thorough degree, be brought to the same place and everyone can benefit from questions/changes.

@UebelAndre
Copy link
Collaborator Author

One other thing of note, I think if there's considerations for adding something like cargo_universe from #2 (comment) to rules_rust then I think it'd also be beneficial to have cargo_raze in here as well since it's a dependency of cargo_universe.

UebelAndre and others added 8 commits February 19, 2021 15:50
* `rust_rules_workspace_name` now defaults to `rules_rust`
* Renamed `io_bazel_rules_rust` to `rules_rust` throughout the workspace
* Updated branch name for rules_rust
A bug was fixed where the "CARGO" environment variable wasn't
being when looking for a cargo binary. This has been corrected
and is now in use.
@google-cla
Copy link

google-cla bot commented Feb 20, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla
Copy link

google-cla bot commented Feb 20, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@UebelAndre
Copy link
Collaborator Author

@hlopko Thanks to @dfreese I've been able to drop most of the commits going into this change. There are only two commits that are noteworthy now. The merge commit (c965cee) and a commit that adds the new repository to .bazelignore (f5dd0ac).

@dfreese
Copy link
Collaborator

dfreese commented Feb 21, 2021

I've always wondered if it's worth having rules_rust focus explicitly on rustc, and then have other things implemented on top of that. What has been hard, I think is that rules_rust didn't expose enough of an interface for people to build things like clippy or protobuf integration on top of it.

The architecture that is described in #596, which @hlopko has been working towards with rust_common (providing a more rule_cc-like interface to rules rust) starts to solve some of those issues.

This PR is probably an opportune time to think about drawing some clear lines about what is rust and what is cargo.

Where it has been intermixed has led to some weird results, such as rules_proto being stuck on a particular crate version, where updating it would be a breaking change. Proper versioning in rules_rust would probably help (though it has a larger API surface than I would like).

@UebelAndre
Copy link
Collaborator Author

I've always wondered if it's worth having rules_rust focus explicitly on rustc, and then have other things implemented on top of that. What has been hard, I think is that rules_rust didn't expose enough of an interface for people to build things like clippy or protobuf integration on top of it.

I 100% agree. Though, I feel there can be a clear separation of responsibility within the same git repository. I think adding this to the cargo directory is an appropriate thing to do if that's where we're going to put "Cargo-esque" things.

@dfreese
Copy link
Collaborator

dfreese commented Feb 21, 2021

I've always wondered if it's worth having rules_rust focus explicitly on rustc, and then have other things implemented on top of that. What has been hard, I think is that rules_rust didn't expose enough of an interface for people to build things like clippy or protobuf integration on top of it.

I 100% agree. Though, I feel there can be a clear separation of responsibility within the same git repository. I think adding this to the cargo directory is an appropriate thing to do if that's where we're going to put "Cargo-esque" things.

True, but that makes versioning the project a little more tricky if the major sem-ver is attached to both the rust and the cargo, and particularly cargo-raze APIs.

@UebelAndre
Copy link
Collaborator Author

True, but that makes versioning the project a little more tricky if the major sem-ver is attached to both the rust and the cargo, and particularly cargo-raze APIs.

Given that only cargo-raze has any useful notion of versioning, I think that's something we can solve or set the standard for going forward fairly easily as it likely won't disrupt existing users. I personally don't think this is an issue and would imagine we tag releases with the thing actually being released (cargo or rustc rules). Or is that not a reasonable approach? I thought Google was known for monorepos, how is versioning handled internally?

@UebelAndre UebelAndre mentioned this pull request Feb 22, 2021
@acmcarther
Copy link
Collaborator

acmcarther commented Feb 23, 2021

I haven't had the time to do literally anything recently review the comments PR, but driveby comments anyway. Sorry if this tramples on quality discussion that covers these points already.

This mirrors my response to an email to me from @hlopko that I felt should generally be public.


In general I'm against this PR, not because I have some nuanced vision for the future of rules_rust, but primarily because I don't like how cargo-raze deals with the cargo-bazel integration, and would like there to be a vacuum of sorts to leave room for something "better" to fill the space. I think having this moved into rules_rust (by varying degrees, depending on whether it's in the repo "proper", or just lives in a contrib directory, or something else) solidifies this tool as the canonical way of things. I'm not super excited about that possibility.

I think a large part of any compatibility concern can be mitigated by having rules_rust include some test suite that builds a toy application using cargo-raze.

EDIT: https://github.com/facebookincubator/reindeer looks pretty interesting!

@UebelAndre
Copy link
Collaborator Author

I totally get that moving cargo-raze into this repo makes that tool the canonical way to interface with external crates, but I think that's a very realistic thing to do and something the rules should provide some solution for. If cargo-raze is not going to be a part of that, I'd love to hear proposals for what is. I think cargo-raze works fantastically and would be totally fine in the well defined world of "post #596". But I don't quite care what the solution is (even though I've spent a considerable amount of time on cargo-raze), I just care that there's some solution that doesn't expect users to tediously hand author their WORKSPACE dependencies.

@damienmg
Copy link
Collaborator

Hi,

Side-rant: for some reason github seems to hide some earlier comments :/

I also feel mixed about this PR. While I would love to see a canonical way to handle the cargo eco-system I also feel mixed with the current cargo raze approach which has problem scaling with monorepos (maintain 1000s of cargo files) and requires to write dependencies in a different language than the bazel one.

My view of the next step world would be where bazel is responsible for the download and compilation and maybe doing dependency resolution using a tool integrated with cargo (though I am pretty sure cargo graph resolution will blow up at some point). Cargo raze could be the tool doing the dependency resolution but I am not sure it is needed (could be using just the output of cargo instead).

The final world I see would probably require a custom dependency resolution tooling. I.e. I see a final usable states to have a set of depedency declared in a WORKSPACE file and pull their transitive deps the same way Cargo does but that requires also Bazel to get its story straight regarding external dependencies (and to be honest, I don't feel like there is any hope for a satisfying solution in the forseeable future).

@hlopko
Copy link
Member

hlopko commented Feb 24, 2021

(I wrote to the Google Open Source Program Office, will report when I hear back).

Ok let's try to move forward with the discussion. After some thinking I came to the following conclusions:

  • If the decision was solely on me, I'd say no, reason being raze owners don't think raze is the best we can do
  • But the decision is not solely on me, and even if I could (which I don't think I do) I wouldn't veto the PR moving raze to rules_rust
  • But I will not champion the PR

Andre, if you can find a champion, and OSPO approves my proposal, feel free to move forward.

I'd recommend to:

  • Create a new top level package for raze (cargo is there for cargo build script runner and it doesn't make sense to me to put both these into the same directory; I'd be fine with moving cargo build script runner elsewhere, just not both in the single package)
  • Split the import into multiple PRs - 1) raw cp, no modifications 2) make it build in one or more PRs, 3) re-upload pending PRs from raze repo into rules_rust
  • Ideally we want to maintain git history in the process
  • Migrate raze issues into rules_rust issues; create a raze label

@UebelAndre
Copy link
Collaborator Author

* Create a new top level package for raze (cargo is there for cargo build script runner and it doesn't make sense to me to put both these into the same directory; I'd be fine with moving cargo build script runner elsewhere, just not both in the single package)

I would strongly advocate for this going into the cargo package. Put it in a top level package solidifies it as the canonical way to interact with external crates. I see this as purely a cargo tool and I think the cargo package is the right place as a result. If there is a rule that has no reliance on cargo but can do the same task, it can go in it's own package

* Split the import into multiple PRs - 1) raw cp, no modifications 2) make it build in one or more PRs, 3) re-upload pending PRs from raze repo into rules_rust

There's currently only 1 change other than a straight merge and it's the .bazelignore. I'd be happy to do that in a separate PR people feel strongly that there should absolutely be no other changes in the PR.

* Ideally we want to maintain git history in the process

I believe this PR is doing that.

* Migrate raze issues into rules_rust issues; create a raze label

Makes sense but I also don't think it's a blocker for any merge.

Andre, if you can find a champion, and OSPO approves my proposal, feel free to move forward.

Given that seemingly all "champions" are here and have said they don't like, it doesn't seem like this change is going to go through. Additionally, I have no idea how to interface with OSPO and don't think that's clear to anyone outside of Google.

I'm just going to close this because of the amount of push back it's getting. I'm happy to continue any conversations here or in some other form for things people would like to clarify or dig deeper into.

@UebelAndre UebelAndre closed this Feb 24, 2021
@damienmg
Copy link
Collaborator

Thanks for opening that discussion and driving it @UebelAndre, just to clarify the position of most seems like we would like to see a better approach to handling crate than the one cargo raze offer. If you have a good idea on how to deal with the problem, that would be a very interesting discussion to drive.

@tschuett
Copy link

@UebelAndre UebelAndre deleted the cargo-raze branch February 25, 2021 13:29
@hlopko
Copy link
Member

hlopko commented Feb 26, 2021

I heard back from the OSPO, they approved the move. Not relevant anymore here it seems but it can be useful in the future.

+1 to what Damien said. Thank you @UebelAndre for pushing for this (and for all the other work you're doing for this repository!). It seems there is an opportunity to come up with a better solution. The first step would be to collect all the various (and maybe conflicting) requirements people have and come up with a solution that satisfies all. Maybe you can build on the momentum of this PR to collect more information and see if it would be interesting for you to drive the effort.

Thanks again!

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

Successfully merging this pull request may close these issues.

None yet