rust-lang / rust-lang/cargo

Allow specifying target-dependent build.rs scripts

Open
#4,932 6 comments 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-build-dependencies A-build-scripts C-feature-request S-needs-design
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

Currently it is possible to specify something like following in Cargo.toml:

[target.'cfg(unix)'.build-dependencies.cc]
version = "1.0"

however it is not feasible to use this functionality, because you cannot conditionally extern use crates or specify per-target build.rs scripts (i.e. the following does not work):

[target.'cfg(unix)'.package]
build = "build/unix.rs"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the target-specific dependency example in Cargo.toml and the proposed build script path build/unix.rs. Trace how target-specific package metadata and build-dependencies are represented and selected. Done means a target can select its own build.rs script and conditionally use its build dependencies, with tests covering the unix example.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.