From 02219642bc5e8a9454ff4d6c6b0ede16a321ab9d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 21 Jul 2017 21:22:26 -0700 Subject: [PATCH] rustc: Add some build scripts for librustc crates This commit adds some "boilerplate" build scripts to librustc/libsyntax crates to declare dependencies on various environment variables that are configured throughout the build. Cargo recently gained the ability to depend on environment variables in build scripts which can help trigger recompilation of a crate. This should fix weird bugs where after you make a commit or a few days later you'll get weird "not built with the same compiler" errors hopefully. --- src/librustc/build.rs | 15 +++++++++++++++ src/librustc_back/build.rs | 15 +++++++++++++++ src/librustc_driver/build.rs | 17 +++++++++++++++++ src/librustc_incremental/build.rs | 14 ++++++++++++++ src/librustc_metadata/build.rs | 14 ++++++++++++++ src/librustc_trans/build.rs | 16 ++++++++++++++++ src/libsyntax/build.rs | 15 +++++++++++++++ 7 files changed, 106 insertions(+) create mode 100644 src/librustc/build.rs create mode 100644 src/librustc_back/build.rs create mode 100644 src/librustc_driver/build.rs create mode 100644 src/librustc_incremental/build.rs create mode 100644 src/librustc_metadata/build.rs create mode 100644 src/librustc_trans/build.rs create mode 100644 src/libsyntax/build.rs diff --git a/src/librustc/build.rs b/src/librustc/build.rs new file mode 100644 index 0000000000000..4df5f0e64050c --- /dev/null +++ b/src/librustc/build.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=CFG_LIBDIR_RELATIVE"); + println!("cargo:rerun-if-env-changed=CFG_COMPILER_HOST_TRIPLE"); +} diff --git a/src/librustc_back/build.rs b/src/librustc_back/build.rs new file mode 100644 index 0000000000000..16f0872b25ac1 --- /dev/null +++ b/src/librustc_back/build.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=CFG_DEFAULT_LINKER"); + println!("cargo:rerun-if-env-changed=CFG_DEFAULT_AR"); +} diff --git a/src/librustc_driver/build.rs b/src/librustc_driver/build.rs new file mode 100644 index 0000000000000..9844f3b557a1f --- /dev/null +++ b/src/librustc_driver/build.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=CFG_RELEASE"); + println!("cargo:rerun-if-env-changed=CFG_VERSION"); + println!("cargo:rerun-if-env-changed=CFG_VER_DATE"); + println!("cargo:rerun-if-env-changed=CFG_VER_HASH"); +} diff --git a/src/librustc_incremental/build.rs b/src/librustc_incremental/build.rs new file mode 100644 index 0000000000000..f18a3f9b94016 --- /dev/null +++ b/src/librustc_incremental/build.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=CFG_VERSION"); +} diff --git a/src/librustc_metadata/build.rs b/src/librustc_metadata/build.rs new file mode 100644 index 0000000000000..f18a3f9b94016 --- /dev/null +++ b/src/librustc_metadata/build.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=CFG_VERSION"); +} diff --git a/src/librustc_trans/build.rs b/src/librustc_trans/build.rs new file mode 100644 index 0000000000000..97accbb4b8fe6 --- /dev/null +++ b/src/librustc_trans/build.rs @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=CFG_VERSION"); + println!("cargo:rerun-if-env-changed=CFG_PREFIX"); + println!("cargo:rerun-if-env-changed=CFG_LLVM_ROOT"); +} diff --git a/src/libsyntax/build.rs b/src/libsyntax/build.rs new file mode 100644 index 0000000000000..d39340c332690 --- /dev/null +++ b/src/libsyntax/build.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=CFG_RELEASE_CHANNEL"); + println!("cargo:rerun-if-env-changed=CFG_DISABLE_UNSTABLE_FEATURES"); +}