1 # Copyright (C) 2017 The Android Open Source Project 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 import os 16 import subprocess 17 import sys 18 19 def main(): 20 devnull = open(os.devnull, 'w') 21 for clang in ('clang', 'clang-3.8', 'clang-3.5'): 22 if subprocess.call(['which', clang], stdout=devnull, stderr=devnull) != 0: 23 continue 24 res = subprocess.check_output([clang, '-print-search-dirs']) 25 for line in res.splitlines(): 26 if not line.startswith('libraries:'): 27 continue 28 libs = line.split('=', 1)[1].split(':') 29 for lib in libs: 30 if '/clang/' not in lib or not os.path.isdir(lib + '/lib'): 31 continue 32 print os.path.abspath(lib) 33 print clang 34 print clang.replace('clang', 'clang++') 35 return 0 36 print 'Could not find the LLVM lib dir' 37 return 1 38 39 if __name__ == '__main__': 40 sys.exit(main()) 41