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

Allow for aliases at the top level #187

Closed
wants to merge 2 commits into from

Conversation

GregBowyer
Copy link
Contributor

So in closing out #123 for #162 an important use case was missed, that of allowing top level aliases in the cargo that raze itself is going to load.

This is pretty important for large monorepos where doing a full migration of types upfront is pretty challenging.

Previously aliases could only exist inside targets that cargo-raze
depends on and not in the raze "root" crate itself.

This means that a construction such as the following

bytes = "2.0"
bytes_old = { version = "1.0", package = "bytes" }

Could not allow for the production of top level bazel aliases such as:

"//cargo:bytes",
"//cargo:bytes_old",

This naturally turns up in larger codebases where migrartions are in
progress from one crate to another.

Raze settings come in the form of a [TOML] section like so

```toml
[raze.crates.some-crate.'1.2.3']
some_new_setting = True
```

Where the version number (in the above example `1.2.3`) is a literal, hardcoded
value.

This works but is a little inflexible for dependencies, _especially_
dependencies that are transiant and update a lot (for instance `syn`).

Since Cargo follows [Semver] we can use this fact, along with the richness of
the exported and serialisable `semver::Version` types to perform section
matching with [Semver] in the same fashion as Cargo itself.

This means that the above example can be written with semver expressions, for
example it can be written as:

```toml
[raze.crates.some-crate.'1.2.*']
some_new_setting = True

[raze.crates.some-crate.'~1.2.3']
some_new_setting = True

[raze.crates.some-crate.'^1.2.3']
some_new_setting = True

[raze.crates.some-crate.'=1.6.6']
some_new_setting = True
```

_Note_: Bare versions follow the semantics _as if they had_ specified a `^`,
which is in keeping with [Cargo semver semantics] but is distinct from previous
behaviour of raze (in which these would be interpreted as exacting or `=`).

This is deliberate as we should aim to mirror the semantics of cargo as much as
possible to avoid confusion.

We presently do not allow for multiple matches in raze settings, this is
intentional and is presented to the end user as an error.

[TOML]: https://github.com/toml-lang/toml
[Semver]: https://semver.org/spec/v2.0.0.html
[Cargo semver semantics]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-cratesio
Previously aliases could only exist inside targets that cargo-raze
depends on and not in the raze "root" crate itself.

This means that a construction such as the following

```toml
bytes = "2.0"
bytes_old = { version = "1.0", package = "bytes" }
```

Could not allow for the production of top level bazel aliases such as:

```python
"//cargo:bytes",
"//cargo:bytes_old",
```

This naturally turns up in larger codebases where migrartions are in
progress from one crate to another.
@GregBowyer
Copy link
Contributor Author

This depends on #127 to have the version expressed in the model as a version and not a string, its possible to detangle this but I think we should land #127 then this

GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Nov 6, 2020
…kages

There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunatly, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targetting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of sublte aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Nov 6, 2020
…kages

There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunatly, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targetting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of sublte aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Nov 6, 2020
…kages

There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunatly, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targetting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of sublte aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Nov 6, 2020
…kages

There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunatly, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targetting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of sublte aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
@GregBowyer
Copy link
Contributor Author

This is dead in favor of #282

@GregBowyer GregBowyer closed this Nov 7, 2020
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Nov 7, 2020
…kages

There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunatly, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targetting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of sublte aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Nov 7, 2020
…kages

There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunatly, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targetting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of sublte aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Nov 9, 2020
…kages

There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunatly, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targetting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of sublte aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Feb 4, 2021
There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunately, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targeting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of subtle aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Feb 4, 2021
There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunately, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targeting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of subtle aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Feb 5, 2021
There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunately, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targeting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of subtle aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Apr 23, 2021
There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunately, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targeting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of subtle aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Apr 23, 2021
There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunately, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targeting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of subtle aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Apr 23, 2021
There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunately, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targeting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of subtle aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Apr 23, 2021
There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunately, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targeting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of subtle aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Apr 23, 2021
There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunately, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targeting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of subtle aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Apr 23, 2021
There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunately, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targeting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of subtle aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
GregBowyer added a commit to GregBowyer/cargo-raze that referenced this pull request Apr 24, 2021
There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunately, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targeting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of subtle aliasing bugs.

Fixes google#241, fixes google#269, fixes google#270, resolves google#144, resolves google#187
dfreese pushed a commit that referenced this pull request Aug 9, 2021
There are a range of subtle and irritating bugs that stem from
attempting to work with renames from the package set provided by cargo
metadata.

Fortunately, recent versions of cargo metadata provide a limited version
of the resolve nodes, both as the original node ids and as a newer set
providing both rename and targeting information.

As such we can (hopefully) simplify crate -> dep node resolution, remove
a bunch of subtle aliasing bugs.

Fixes #241, fixes #269, fixes #270, resolves #144, resolves #187
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

Successfully merging this pull request may close these issues.

1 participant