Skip to content

Allow build scripts to add dependencies to the library being built #1417

Closed
@daboross

Description

@daboross

It would be awesome if build scripts could build fully-made crates in the $OUT_DIR folder, including a Cargo.toml, which the library could then depend on.

I'm not sure of the best way to implement this, but here are a few iedas:

  • Add support for parsing a cargo:add-local-dependency:$path output from the build script
  • Add support for environmental variables in Cargo.toml, so you could use:
    [dependencies.generated-module] path = "$OUT_DIR/generated-module/"

The reasoning for doing this instead of just include!()ing the code is for build scripts which generate code which depends on some crates.io library which the main program does not.

Here's my use case for this:

Adding this would allow for a rust program to accept (at compilation time) self-dependent plugin rust files, with dependency information in comments at the top of the file. build.rs would generate a Cargo.toml including what the plugin depends on, which the main library could then depend on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions