|
1 | 1 | fn main() {
|
2 | 2 | let build_env = rustc_codegen_clr::compile_test::cargo_build_env();
|
3 |
| - println!("In order to compile cargo crates with `rustc_codegen_clr`, please set the RUSTFLAGS enviorment variable to:"); |
| 3 | + let print_raw_env = std::env::args().any(|arg| arg == "--print_raw_env"); |
| 4 | + let setup_command = std::env::args().any(|arg| arg == "--setup_command"); |
| 5 | + if print_raw_env{ |
| 6 | + println!("\"{build_env}\""); |
| 7 | + return; |
| 8 | + } |
| 9 | + if setup_command{ |
| 10 | + #[cfg(target_family = "unix")] |
| 11 | + println!("export RUSTFLAGS=\"{build_env}\""); |
| 12 | + #[cfg(target_family = "windows")] |
| 13 | + println!("$Env:RUSTFLAGS = '{build_env}'"); |
| 14 | + return |
| 15 | + } |
| 16 | + println!("Welcome to the `rustc_codegen_clr` environment setup helper!"); |
| 17 | + println!("This tool will help you use the codegen to compile Rust projects."); |
| 18 | + println!("WARNING: Please note, the project is currently in the early stages of development. Bugs, crashes and miscompilations will occur."); |
| 19 | + println!("Currently, there is no way to permanently install the codegen. It is enabled on a per-shell-session basis (enabled for your particular command prompt window)."); |
| 20 | + println!(""); |
| 21 | + println!("In order to compile cargo crates with `rustc_codegen_clr`, please set the RUSTFLAGS environment variable to:"); |
4 | 22 | println!();
|
5 |
| - println!("\"{build_env}\""); |
6 |
| - println!(); |
7 |
| - println!("On linux, you may use the following commmand to quickly set the required enviroment variables:"); |
8 |
| - println!(); |
9 |
| - println!("export RUSTFLAGS=\"{build_env}\""); |
10 | 23 | println!();
|
11 |
| - println!("On windows(powershell), you may use the following commmand to quickly set the required enviroment variables:"); |
12 |
| - println!(); |
13 |
| - println!("$Env:RUSTFLAGS = '{build_env}'"); |
14 |
| - println!(); |
15 |
| - println!("After you are done working with `rustc_codegen_clr` either unset the enviroment variable OR restart your shell(close the command prompt window)."); |
16 |
| - println!("On linux, you may use the following commmand to quickly unset the required enviroment variables:"); |
| 24 | + println!("\"{build_env}\""); |
17 | 25 | println!();
|
18 |
| - println!("unset RUSTFLAGS"); |
19 | 26 | println!();
|
20 |
| - println!("Please note that those varaibles may change when the codegen is updated/rebuilt."); |
21 |
| - println!("After each time the codegen is rebuilt, please use this tool again to get updated build enviroment variables."); |
| 27 | + #[cfg(target_family = "unix")]{ |
| 28 | + println!("You may use the following command to quickly set the required environment variables:"); |
| 29 | + println!(); |
| 30 | + println!(); |
| 31 | + println!("export RUSTFLAGS=\"{build_env}\""); |
| 32 | + println!(); |
| 33 | + println!(); |
| 34 | + } |
| 35 | + #[cfg(target_family = "windows")]{ |
| 36 | + println!("You may use the following command to quickly set the required environment variables:"); |
| 37 | + println!(); |
| 38 | + println!(); |
| 39 | + println!("$Env:RUSTFLAGS = '{build_env}'"); |
| 40 | + println!(); |
| 41 | + println!(); |
| 42 | + } |
| 43 | + println!("After you are done working with `rustc_codegen_clr` either unset the environment variable OR restart your shell (close the command prompt window)."); |
| 44 | + #[cfg(target_family = "unix")]{ |
| 45 | + println!("You may use the following command to quickly unset the required environment variables:"); |
| 46 | + println!(); |
| 47 | + println!(); |
| 48 | + println!("unset RUSTFLAGS"); |
| 49 | + println!(); |
| 50 | + println!(); |
| 51 | + } |
| 52 | + #[cfg(target_family = "windows")]{ |
| 53 | + println!(); |
| 54 | + } |
| 55 | + println!("Please note that those variables may change when the codegen is updated/rebuilt."); |
| 56 | + println!("After each time the codegen is rebuilt, please use this tool again to get updated build environment variables."); |
22 | 57 | println!();
|
23 | 58 | println!("If you are using the project, please remember to:");
|
24 | 59 | println!("1. Update BOTH rustc and the project on a regular basis.");
|
25 |
| - println!("2. Report compiler bugs to the maintainers of `rustc_codegen_clr` not the maintainers of the compiler as a whole."); |
26 |
| - println!(" In 99.999% of the cases, the bug is wihin this project and not the compiler."); |
| 60 | + println!("2. Report compiler bugs to the maintainers of `rustc_codegen_clr`, and not the maintainers of the Rust compiler as a whole."); |
| 61 | + println!(" In 99.999% of the cases, the bug is within this project and not the Rust compiler."); |
| 62 | + println!(""); |
| 63 | + // std::env::set_var("RUSTFLAGS", build_env); |
27 | 64 | }
|
0 commit comments