Skip to content

Commit 7d5a8b2

Browse files
bors[bot]mntns
andauthored
Merge #842
842: Allow `Cargo.toml` as configuration source r=Emilgardis a=mntns Due to a GitHub mishap in #754, this is a new PR containing the same commits (rebased by `@Emilgardis).` Just for reference, it still addresses #657. Co-authored-by: Niklas Kunz <[email protected]>
2 parents b15c29c + 88bcbda commit 7d5a8b2

File tree

7 files changed

+368
-38
lines changed

7 files changed

+368
-38
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1717
- #678 - Add `target.{target}.pre-build` config for running commands before building the image.
1818
- #772 - added `CROSS_CONTAINER_OPTS` environment variable to replace `DOCKER_OPTS`.
1919
- #767, #788 - added the `cross-util` and `xtask` commands.
20+
- #842 - Add `Cargo.toml` as configuration source
2021
- #745 - added `thumbv7neon-*` targets.
2122
- #741 - added `armv7-unknown-linux-gnueabi` and `armv7-unknown-linux-musleabi` targets.
2223
- #721 - add support for running doctests on nightly if `CROSS_UNSTABLE_ENABLE_DOCTESTS=true`.

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,27 @@ Additional documentation can be found on the [wiki](https://github.com/cross-rs/
8484

8585
## Configuration
8686

87-
You can place a `Cross.toml` file in the root of your Cargo project or use a
88-
`CROSS_CONFIG` environment variable to tweak `cross`'s behavior. The format
89-
of `Cross.toml` is documented in [docs/cross_toml.md](docs/cross_toml.md).
87+
You have three options to configure `cross`. All of these options use the TOML format for configuration and the possible configuration values are documented [here](docs/cross_toml.md).
88+
89+
### Option 1: Configuring `cross` directly in your `Cargo.toml`
90+
91+
You can directly set [configuration values](docs/cross_toml.md) in your `Cargo.toml` file, under the `[package.metadata.cross]` table, i.e. key prefix.
92+
An example config snippet would look like this:
93+
94+
```
95+
[package.metadata.cross.target.aarch64-unknown-linux-gnu]
96+
xargo = false
97+
image = "test-image"
98+
runner = "custom-runner"
99+
```
100+
101+
### Option 2: Configuring `cross` via a `Cross.toml` file
102+
103+
You can put your [configuration](docs/cross_toml.md) inside a `Cross.toml` file in your project root directory.
104+
105+
### Option 3: Using `CROSS_CONFIG` to specify the location of your configuration
106+
107+
By setting the `CROSS_CONFIG` environment variable, you can tell `cross` where it should search for the config file. This way you are not limited to a `Cross.toml` file in the project root.
90108

91109
### Custom Docker images
92110

docs/cross_toml.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
The `cross` configuration in the `Cross.toml` file, can contain the following elements:
1+
The `cross` configuration in the `Cross.toml` file, can contain the elements described below.
2+
3+
If the configuration is given in the `Cargo.toml`, these table headers must be of the form `[package.metadata.cross.<KEY>]`.
24

35
# `build`
46

src/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,9 @@ mod tests {
431431
use std::matches;
432432

433433
fn toml(content: &str) -> Result<crate::CrossToml> {
434-
Ok(CrossToml::parse(content).wrap_err("couldn't parse toml")?.0)
434+
Ok(CrossToml::parse_from_cross(content)
435+
.wrap_err("couldn't parse toml")?
436+
.0)
435437
}
436438

437439
#[test]

0 commit comments

Comments
 (0)