blob: 264a08d5e4873f2654b93fd71628d108f1c48e7c [file] [log] [blame]
Primiano Tucci0825bc82017-09-28 18:50:23 +01001# 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
15import os
16import subprocess
17import sys
18
19def main():
20 res = subprocess.check_output(['clang', '-print-search-dirs'])
21 for line in res.splitlines():
22 if not line.startswith('libraries:'):
23 continue
24 libs = line.split('=', 1)[1].split(':')
25 for lib in libs:
26 if '/clang/' not in lib or not os.path.isdir(lib + '/lib'):
27 continue
28 print os.path.abspath(lib)
29 return 0
30 print 'Could not find the LLVM lib dir'
31 return 1
32
33if __name__ == '__main__':
34 sys.exit(main())