mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Remove restrictions on cross-compiling on Windows.
This commit is contained in:
parent
e0c95ed855
commit
0d831117ec
3 changed files with 1 additions and 51 deletions
|
@ -1,4 +1,4 @@
|
||||||
project(script)
|
project(script LANGUAGES)
|
||||||
cmake_minimum_required(VERSION 2.6)
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
|
||||||
set(DUMMY ${CMAKE_BUILD_TYPE})
|
set(DUMMY ${CMAKE_BUILD_TYPE})
|
||||||
|
|
|
@ -9,47 +9,12 @@ use std::fmt;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
|
||||||
let target = env::var("TARGET").unwrap();
|
|
||||||
let host = env::var("HOST").unwrap();
|
|
||||||
if target.contains("windows") && host != target {
|
|
||||||
assert_eq!(
|
|
||||||
host, "x86_64-pc-windows-msvc",
|
|
||||||
"Only cross-compiling from x64 is supported"
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
target, "i686-pc-windows-msvc",
|
|
||||||
"Only cross-compiling to x86 is supported"
|
|
||||||
);
|
|
||||||
assert!(env::var("VSINSTALLDIR").is_err());
|
|
||||||
// When cross-compiling on Windows, we need to ensure that the PATH is
|
|
||||||
// set up appropriately for the target before invoking make.
|
|
||||||
if env::var("VCVARSALL_PATH").is_err() {
|
|
||||||
panic!(
|
|
||||||
"Need to provide VCVARSALL_PATH value with path to \
|
|
||||||
vcvarsall.bat from Visual Studio installation"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let vcvars = Command::new("vcvars.bat").output().unwrap();
|
|
||||||
assert!(vcvars.status.success());
|
|
||||||
let output = str::from_utf8(&vcvars.stdout).unwrap();
|
|
||||||
for line in output.lines() {
|
|
||||||
let mut parts = line.splitn(2, '=');
|
|
||||||
if let Some(name) = parts.next() {
|
|
||||||
if let Some(value) = parts.next() {
|
|
||||||
env::set_var(name, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This must use the Ninja generator -- it's the only one that
|
// This must use the Ninja generator -- it's the only one that
|
||||||
// parallelizes cmake's output properly. (Cmake generates
|
// parallelizes cmake's output properly. (Cmake generates
|
||||||
// separate makefiles, each of which try to build
|
// separate makefiles, each of which try to build
|
||||||
|
@ -61,19 +26,6 @@ fn main() {
|
||||||
// We must use Ninja on Windows for this -- msbuild is painfully slow,
|
// We must use Ninja on Windows for this -- msbuild is painfully slow,
|
||||||
// and ninja is easier to install than make.
|
// and ninja is easier to install than make.
|
||||||
build.generator("Ninja");
|
build.generator("Ninja");
|
||||||
// We have to explicitly specify the full path to link.exe,
|
|
||||||
// for reasons that I don't understand. If we just give
|
|
||||||
// link.exe, it tries to use script-*/out/link.exe, which of
|
|
||||||
// course does not exist.
|
|
||||||
let link = std::process::Command::new("where")
|
|
||||||
.arg("link.exe")
|
|
||||||
.output()
|
|
||||||
.unwrap();
|
|
||||||
let link_path: Vec<&str> = std::str::from_utf8(&link.stdout)
|
|
||||||
.unwrap()
|
|
||||||
.split("\r\n")
|
|
||||||
.collect();
|
|
||||||
build.define("CMAKE_LINKER", link_path[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
build.build();
|
build.build();
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
call "%VCVARSALL_PATH%\vcvarsall.bat" x64_x86
|
|
||||||
set
|
|
Loading…
Add table
Add a link
Reference in a new issue