Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Commit

Permalink
add: tips for install Windows cross compile toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
aurexav committed Sep 25, 2019
1 parent 4884e22 commit fb2f1c1
Showing 1 changed file with 60 additions and 26 deletions.
86 changes: 60 additions & 26 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,13 @@ impl EnvVar {
"[target.x86_64-unknown-linux-gnu]\nlinker = \"{}\"",
target_cc.splitn(2, ' ').next().unwrap()
);
set_config_file(
&config,
&mut config_file,
&mut config_file_handler,
"[target.x86_64-unknown-linux-gnu]",
)
.unwrap();

println!(
"{} {}",
Expand All @@ -631,28 +638,21 @@ impl EnvVar {
}
Err(e) => {
if e.kind() == io::ErrorKind::NotFound {
// TODO
if cfg!(target_os = "macos") {
eprintln!(
match *HOST_OS {
OS::macOS => eprintln!(
"{} {}",
"[✗] x86_64-unknown-linux-gnu-gcc:".red(),
"https://github.com/SergioBenitez/homebrew-osxct".red()
);
),
OS::Windows => (), // TODO
_ => unreachable!(),
}
} else {
panic!("{}", e);
}
}
}

set_config_file(
&config,
&mut config_file,
&mut config_file_handler,
"[target.x86_64-unknown-linux-gnu]",
)
.unwrap();

dir.push("linux-x86_64");
chcek_deps(dir.as_path(), &mut deps, LINUX_86_64_DEPS).unwrap();
}
Expand All @@ -666,6 +666,13 @@ impl EnvVar {
"[target.x86_64-pc-windows-gnu]\nlinker = \"{}\"",
target_cc.splitn(2, ' ').next().unwrap()
);
set_config_file(
&config,
&mut config_file,
&mut config_file_handler,
"[target.x86_64-pc-windows-gnu]",
)
.unwrap();

println!(
"{} {}",
Expand All @@ -675,28 +682,55 @@ impl EnvVar {
}
Err(e) => {
if e.kind() == io::ErrorKind::NotFound {
// TODO
if cfg!(target_os = "macos") {
eprintln!(
"{} {}",
match *HOST_OS {
// TODO
OS::Linux(ref distribution) => match distribution {
LinuxDistribution::ArchLinux => eprintln!(
"{} {}\n{}\n{}-{}-{}{}\n{}\n{}",
"[✗] x86_64-w64-mingw32-gcc:".red(),
"pacman -S mingw-w64-gcc".red(),
"follow https://github.com/rust-lang/rust/issues/48272#issuecomment-429596397:".red(),
"cd ~/.rustup/toolchains/nightly",
STABLE_TOOLCHAIN_VERSION,
*HOST,
"/lib/rustlib/x86_64-pc-windows-gnu/lib",
"cp /usr/x86_64-w64-mingw32/lib/*crt2.o ./",
"ln -s /usr/x86_64-w64-mingw32/lib/libiphlpapi.a /usr/x86_64-w64-mingw32/lib/libIphlpapi.a"
),
LinuxDistribution::CentOS => unimplemented!(),
LinuxDistribution::Ubuntu => eprintln!(
"{} {}\n{}\n{}-{}-{}{}\n{}\n{}",
"[✗] x86_64-w64-mingw32-gcc:".red(),
"apt-get install mingw-w64".red(),
"follow https://github.com/rust-lang/rust/issues/48272#issuecomment-429596397:".red(),
"cd ~/.rustup/toolchains/nightly",
STABLE_TOOLCHAIN_VERSION,
*HOST,
"/lib/rustlib/x86_64-pc-windows-gnu/lib",
"cp /usr/x86_64-w64-mingw32/lib/*crt2.o ./",
"ln -s /usr/x86_64-w64-mingw32/lib/libiphlpapi.a /usr/x86_64-w64-mingw32/lib/libIphlpapi.a"
),
LinuxDistribution::Unknown => unimplemented!(),
},
OS::macOS => eprintln!(
"{} {}\n{}\n{}-{}-{}{}\n{}",
"[✗] x86_64-w64-mingw32-gcc:".red(),
"https://formulae.brew.sh/formula/mingw-w64 and MUST CHECK https://github.com/rust-lang/rust/issues/48272#issuecomment-429596397".red()
);
"brew install mingw-w64".red(),
"follow https://github.com/rust-lang/rust/issues/48272#issuecomment-429596397:".red(),
"cd ~/.rustup/toolchains/nightly",
STABLE_TOOLCHAIN_VERSION,
*HOST,
"/lib/rustlib/x86_64-pc-windows-gnu/lib",
"cp -r /usr/local/Cellar/mingw-w64/6.0.0_2/toolchain-x86_64/x86_64-w64-mingw32/lib/*crt2.o ./",
),
_ => unreachable!(),
}
} else {
panic!("{}", e);
}
}
}

set_config_file(
&config,
&mut config_file,
&mut config_file_handler,
"[target.x86_64-pc-windows-gnu]",
)
.unwrap();

dir.push("windows-x86_64");
chcek_deps(dir.as_path(), &mut deps, WINDOWS_86_64_DEPS).unwrap();
}
Expand Down

0 comments on commit fb2f1c1

Please sign in to comment.