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

Add config-based path shorthands #9144

Closed
wants to merge 4 commits into from

Commits on Feb 6, 2021

  1. Add config-based path shorthands

    When doing local development, users may wish to specify many `path`
    dependencies that all live in the same local directory. If that local
    directory is not a short distance from the `Cargo.toml`, this can get
    unwieldy.
    
    This patch introduces the notion of path "prefixes", which are defined
    in `.cargo/config.toml`:
    
    ```toml
    [path]
    devdir = "/home/jon/dev/rust/"
    ```
    
    Which can then be used as the root for path dependencies. For example:
    
    ```toml
    foo = { path = "devdir::foo" }
    bar = { path = "devdir::bar" }
    baz = { path = "devdir::ws/baz" }
    ```
    
    would fetch `foo` from `/home/jon/dev/rust/foo`, `bar` from
    `/home/jon/dev/rust/bar`, and `baz` from `/home/jon/dev/rust/ws/baz`.
    
    This feature also serves as a convenient way for external build systems
    to mask build-dependent paths from the user. Consider a build system
    that vendors first-party dependencies into
    
    ```
    /home/user/workplace/feature-1/build/first-party-package/first-party-package-1.0/x86_64/dev/build/private/rust-vendored/
    ```
    
    Instead of requiring users to hard-code that path, or the relative
    equivalent, into their `Cargo.toml`, the build-system can instead
    produce a project-local `.cargo/config.toml` that defines that path as
    `path.vendored`, and the user can then use vendored dependencies using
    
    ```toml
    foo = { path = "vendored::foo" }
    ```
    Jon Gjengset committed Feb 6, 2021
    Configuration menu
    Copy the full SHA
    e1ac615 View commit details
    Browse the repository at this point in the history

Commits on Feb 8, 2021

  1. Seaprate out base from path as its own field

    Jon Gjengset committed Feb 8, 2021
    Configuration menu
    Copy the full SHA
    852f43e View commit details
    Browse the repository at this point in the history
  2. Add test for path base in patch

    Jon Gjengset committed Feb 8, 2021
    Configuration menu
    Copy the full SHA
    a838c13 View commit details
    Browse the repository at this point in the history

Commits on Feb 23, 2021

  1. Merge branch 'master' into path-shorthand

    Jon Gjengset committed Feb 23, 2021
    Configuration menu
    Copy the full SHA
    152316a View commit details
    Browse the repository at this point in the history