Support specifying additional config files/values in environment variable. #14508
Labels
A-config-cli
Area: --config CLI option
A-configuration
Area: cargo config files and env vars
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
S-triage
Status: This issue is waiting on initial triage.
Problem
TL;DR I have a separate Cargo config
web.toml
that I use with a particular target, and I want to be able to use Cargo-wrapping tools like Trunk to build that target and specify my custom config file via an environment variable.More details...
I'm trying to make a cross-platform project for desktop and web. My project uses threads, so for the web build only, I need to enable the following Cargo options:
I know that it's possible to gate the rustflags on the web target:
But it's not currently possible to do the same for
build-std
. So I have two options:std
when compiling for native (not great)..config/web.toml
and require passing--config .config/web.toml
to Cargo when compiling for web (acceptable).This works fine until it comes time to use Trunk to package my web app. Trunk doesn't provide an option to pass arbitrary flags to Cargo (though there is an open issue requesting this functionality).
Proposed Solution
In addition to accepting
--config BLAH
on the command line, Cargo should also accept an environment variable likeCARGO_CONFIG=BLAH
.This would allow me to run:
Notes
IMO I think Trunk really should add the ability to pass more flags to Cargo. But I also think that supporting a
CARGO_CONFIG
environment variable is very much in line with the way Cargo already works for many other things.An open question that I'm not experienced enough to decide on: how should this fit in with the current config precedence rules?
The text was updated successfully, but these errors were encountered: