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

Set target using config file #2335

Merged
merged 1 commit into from Feb 5, 2016

Conversation

Projects
None yet
8 participants
@fpgaminer
Copy link
Contributor

fpgaminer commented Jan 30, 2016

Fixed #2332.

This PR adds build.target to the Cargo config file, which behaves in the same way as passing --target to Cargo. Example .cargo/config:

[build]
target = "thumbv6m-none-eabi"

Similar to how --jobs overrides build.jobs, --target will override build.target.

I added documentation to config.md, and a test to test_cargo_cross_compile.rs. I couldn't get cross compile working on my machine for cargo test. Hopefully travis passes it.

This is my first PR against Cargo; sorry if I missed any procedures.

@rust-highfive

This comment has been minimized.

Copy link

rust-highfive commented Jan 30, 2016

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jan 31, 2016

Thanks for the PR! This implementation all looks good to me, I'm just not sure if we want to implement it just yet. I'll bring this up with the @rust-lang/tools team to see if others have opinions as well.

While that happens, can you be sure to update the documentation as well to reflect that this option exists?

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Feb 2, 2016

Makes sense to me.

@fpgaminer

This comment has been minimized.

Copy link
Contributor Author

fpgaminer commented Feb 3, 2016

While that happens, can you be sure to update the documentation as well to reflect that this option exists?

Would you mind pointing me at the documentation that needs to be updated? This pull request already updates src/doc/config.md, which is the only relevant documentation I could find in this repo (grepping for jobs shows that as the only place that config.build.jobs is documented, which I used as the template for config.build.target).

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Feb 3, 2016

Oh oops sorry I overlooked that by accident, src/doc/config.md is what I was thinking of!

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Feb 5, 2016

@bors: r+ 7442050

Thanks again @fpgaminer!

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 5, 2016

⌛️ Testing commit 7442050 with merge a1c3ab3...

bors added a commit that referenced this pull request Feb 5, 2016

Auto merge of #2335 - fpgaminer:config-target, r=alexcrichton
Fixed #2332.

This PR adds `build.target` to the Cargo config file, which behaves in the same way as passing `--target` to Cargo.  Example `.cargo/config`:

```
[build]
target = "thumbv6m-none-eabi"
```

Similar to how `--jobs` overrides `build.jobs`, `--target` will override `build.target`.

I added documentation to `config.md`, and a test to `test_cargo_cross_compile.rs`.  I couldn't get cross compile working on my machine for `cargo test`.  Hopefully travis passes it.

This is my first PR against Cargo; sorry if I missed any procedures.
@bors

This comment has been minimized.

@bors bors merged commit 7442050 into rust-lang:master Feb 5, 2016

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@VikingMew

This comment has been minimized.

Copy link

VikingMew commented Oct 26, 2017

Can we set this as a crate specific parameter?

@andrewdavidmackenzie

This comment has been minimized.

Copy link

andrewdavidmackenzie commented Jan 27, 2019

Looks like this is not going in? Any alternative (similar) option progressing or already added?

@ehuss

This comment has been minimized.

Copy link
Contributor

ehuss commented Jan 28, 2019

@andrewdavidmackenzie I'm not sure what you mean. This was added a few years ago. Are you having some kind of issue? If so, it would be probably be best to open a new issue.

@andrewdavidmackenzie

This comment has been minimized.

Copy link

andrewdavidmackenzie commented Jan 28, 2019

Well, Alex commented:
"I'm just not sure if we want to implement it just yet."

I didn't see any merge for it and when I tried it I got an "unused key" warning from cargo.

I'm on mobile now, but will check again later.

@andrewdavidmackenzie

This comment has been minimized.

Copy link

andrewdavidmackenzie commented Jan 28, 2019

Is this intended only for binary builds in Cargo?

I can't find any mention of it in the Cargo manifest book:
https://doc.rust-lang.org/cargo/reference/manifest.html

When I try what's described in this issue:

Here is my Cargo.toml of a library with functions I want compiled to wasm:

[package]
name = "reverse"
version = "0.1.0"
authors = ["Andrew Mackenzie <andrew@mackenzie-serres.net>"]

[build]
target = "wasm32-unknown-unknown"

[lib]
name = "reverse"
crate-type = ["cdylib"]

# This field points at where the crate is located, relative to the `Cargo.toml`.
path = "src/reverse.rs"

[dependencies]
serde_json = "1.0"

[workspace]
exclude = [".."]

When I build it cargo tells me:

$  cargo build
warning: /Users/andrew/workspace/flow/samples/reverse-echo/Cargo.toml: unused manifest key: build
    Finished dev [unoptimized + debuginfo] target(s) in 0.43s
@ehuss

This comment has been minimized.

Copy link
Contributor

ehuss commented Jan 28, 2019

The value goes into the config file .cargo/config documented at https://doc.rust-lang.org/cargo/reference/config.html.

@andrewdavidmackenzie

This comment has been minimized.

Copy link

andrewdavidmackenzie commented Jan 28, 2019

OK, I understand now. I guess it makes more sense there than in the manifest?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.