From f78cd4de454c4b55c95137f2db07b4f36b86c3af Mon Sep 17 00:00:00 2001
From: Pyry Kontio <pyry.kontio@drasa.eu>
Date: Sun, 16 Jun 2019 17:10:13 +0900
Subject: [PATCH] Fix building_llvm in sanity check, add swig sanity check.

---
 src/bootstrap/sanity.rs | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
index dc65fb9b79706..4e3930c8da7fc 100644
--- a/src/bootstrap/sanity.rs
+++ b/src/bootstrap/sanity.rs
@@ -78,8 +78,11 @@ pub fn check(build: &mut Build) {
 
     // We need cmake, but only if we're actually building LLVM or sanitizers.
     let building_llvm = build.hosts.iter()
-        .filter_map(|host| build.config.target_config.get(host))
-        .any(|config| config.llvm_config.is_none());
+        .map(|host| build.config.target_config
+            .get(host)
+            .map(|config| config.llvm_config.is_none())
+            .unwrap_or(true))
+        .any(|build_llvm_ourselves| build_llvm_ourselves);
     if building_llvm || build.config.sanitizers {
         cmd_finder.must_have("cmake");
     }
@@ -106,6 +109,14 @@ pub fn check(build: &mut Build) {
                 build.config.ninja = true;
             }
         }
+
+        if build.config.lldb_enabled {
+            cmd_finder.must_have("swig");
+            let out = output(Command::new("swig").arg("-version"));
+            if !out.contains("SWIG Version 3") && !out.contains("SWIG Version 4") {
+                panic!("Ensure that Swig 3.x.x or 4.x.x is installed.");
+            }
+        }
     }
 
     build.config.python = build.config.python.take().map(|p| cmd_finder.must_have(p))