amalgamated: use the toolchain script to find clang
Relying on clang++ existing is not safe because the CI only has
clang++-8 right now. Use the same script the toolchain uses to find the
right clang binary.
Change-Id: I8cd056cc3965e75943e20d2c588b7ee3498e79c0
diff --git a/gn/standalone/toolchain/linux_find_llvm.py b/gn/standalone/toolchain/linux_find_llvm.py
old mode 100644
new mode 100755
index 85d6c93..2ec716e
--- a/gn/standalone/toolchain/linux_find_llvm.py
+++ b/gn/standalone/toolchain/linux_find_llvm.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tools/gen_amalgamated b/tools/gen_amalgamated
index 93274f9..a527b12 100755
--- a/tools/gen_amalgamated
+++ b/tools/gen_amalgamated
@@ -529,7 +529,16 @@
"""Returns an example command line for building the output source."""
source = self._get_nice_path(output_prefix, '%s.cc')
library = self._get_nice_path(output_prefix, 'lib%s.so')
- build_cmd = ['clang++', source, '-o', library, '-shared'] + \
+
+ if sys.platform.startswith('linux'):
+ llvm_script = os.path.join(gn_utils.repo_root(), 'gn',
+ 'standalone', 'toolchain',
+ 'linux_find_llvm.py')
+ cxx = subprocess.check_output([llvm_script]).splitlines()[2]
+ else:
+ cxx = 'clang++'
+
+ build_cmd = [cxx, source, '-o', library, '-shared'] + \
sorted(self.cflags) + sorted(self.ldflags)
for lib in sorted(self.libs):
build_cmd.append('-l%s' % lib)
diff --git a/tools/test_gen_amalgamated.py b/tools/test_gen_amalgamated.py
index 8aa5a94..8be9655 100755
--- a/tools/test_gen_amalgamated.py
+++ b/tools/test_gen_amalgamated.py
@@ -18,6 +18,7 @@
import os
import shutil
import subprocess
+import sys
from compat import quote
from platform import system
@@ -58,7 +59,14 @@
]
if system().lower() == 'linux':
args += ['-lpthread', '-lrt']
- call('clang++', *args)
+
+ if sys.platform.startswith('linux'):
+ llvm_script = os.path.join(ROOT_DIR, 'gn', 'standalone', 'toolchain',
+ 'linux_find_llvm.py')
+ cxx = subprocess.check_output([llvm_script]).splitlines()[2]
+ else:
+ cxx = 'clang++'
+ call(cxx, *args)
def check_amalgamated_dependencies():