diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-08-17 13:22:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-17 13:22:52 -0500 |
commit | ec53136863f20b80caf165d2f15e8a77d614536e (patch) | |
tree | aea6b11eaa16dfcd2b5cc613e6b9678d3fd09253 /components/script/build.rs | |
parent | b61c45639a264943f8dec61c66b46d40f9d274a1 (diff) | |
parent | dd377164595a91cb5fb6eab5e354cf51814ff7d1 (diff) | |
download | servo-ec53136863f20b80caf165d2f15e8a77d614536e.tar.gz servo-ec53136863f20b80caf165d2f15e8a77d614536e.zip |
Auto merge of #11756 - vvuk:servo-msvc, r=larsbergstrom
MSVC support for Servo, and CMake builds for native code
This is the base PR for MSVC builds of servo and dependent crates. It's got replacements in the Cargo.toml to pull in the right versions, to make sure that crates were properly converted to CMake for all other platforms, not just Windows. (Servo builds with MSVC 2015 with this PR; also with 2013, though a manual change in rust-mozjs to select a different set of bindings is needed.)
This PR isn't quite ready yet, but I want bors-servo to do builds.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11756)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/build.rs')
-rw-r--r-- | components/script/build.rs | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/components/script/build.rs b/components/script/build.rs index a0d693d152f..019a55f25a6 100644 --- a/components/script/build.rs +++ b/components/script/build.rs @@ -2,17 +2,36 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +extern crate cmake; use std::env; -use std::process::Command; use std::time::Instant; fn main() { let start = Instant::now(); - let num_jobs = env::var("NUM_JOBS").unwrap(); - assert!(Command::new("make") - .args(&["-f", "makefile.cargo", "-j", &num_jobs]) - .status() - .unwrap() - .success()); + + // This must use the Ninja generator -- it's the only one that + // parallelizes cmake's output properly. (Cmake generates + // separate makefiles, each of which try to build + // ParserResults.pkl, and then stomp on eachother.) + let mut build = cmake::Config::new("."); + + let target = env::var("TARGET").unwrap(); + if target.contains("windows-msvc") { + // We must use Ninja on Windows for this -- msbuild is painfully slow, + // and ninja is easier to install than make. + build.generator("Ninja"); + // because we're using ninja, we need to explicitly set these + // to VC++, otherwise it'll try to use cc + build.define("CMAKE_C_COMPILER", "cl.exe") + .define("CMAKE_CXX_COMPILER", "cl.exe"); + // 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. + build.define("CMAKE_LINKER", "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\link.exe"); + } + + build.build(); + println!("Binding generation completed in {}s", start.elapsed().as_secs()); } |