summaryrefslogtreecommitdiff
path: root/etc/scons/mongodbtoolchain_v3_clang.vars
diff options
context:
space:
mode:
Diffstat (limited to 'etc/scons/mongodbtoolchain_v3_clang.vars')
-rw-r--r--etc/scons/mongodbtoolchain_v3_clang.vars40
1 files changed, 40 insertions, 0 deletions
diff --git a/etc/scons/mongodbtoolchain_v3_clang.vars b/etc/scons/mongodbtoolchain_v3_clang.vars
new file mode 100644
index 00000000000..a347beb7bca
--- /dev/null
+++ b/etc/scons/mongodbtoolchain_v3_clang.vars
@@ -0,0 +1,40 @@
+# Configures the build to use the GCC toolchain in /opt/mongodbtoolchain/v3
+
+import os
+import subprocess
+import SCons.Defaults
+
+toolchain_root = SCons.Script.Main.GetOption('toolchain-root')
+if not toolchain_root:
+ toolchain_root = '/opt/mongodbtoolchain/v3'
+
+toolchain_bindir = os.path.join(toolchain_root, 'bin')
+
+# Get the default SCons path as a list
+default_path = SCons.Defaults.DefaultEnvironment()['ENV']['PATH'].split(os.pathsep)
+
+# Put the toolchain path first so we prefer all tools from there in subprocs
+ENV = {
+ 'PATH' : os.pathsep.join([toolchain_bindir] + default_path)
+}
+
+# Set any Variables for Tools from the toolchain here. Technically, we
+# shouldn't need the full paths since SCons will find the toolchain
+# ones first, but we don't want to accidentally get the system version
+# if, say, the toolchain is missing. Also, it is clearer that we are
+# getting the right toolchain in build log output when the path is
+# printed for each compiler invocation.
+
+CC = os.path.join(toolchain_bindir, 'clang')
+CXX = os.path.join(toolchain_bindir, 'clang++')
+
+try:
+ AR = subprocess.check_output([CXX, '-print-prog-name=ar']).strip()
+ AS = subprocess.check_output([CXX, '-print-prog-name=as']).strip()
+ OBJCOPY = subprocess.check_output([CXX, '-print-prog-name=objcopy']).strip()
+except subprocess.CalledProcessError as e:
+ print("Failed while invoking toolchain binary " + CXX + ": " + e.output)
+ SCons.Script.Exit(-1)
+except OSError as e:
+ print("Failed to invoke toolchain binary " + CXX + ": " + str(e))
+ SCons.Script.Exit(-1)