1#!/usr/bin/env python 2from __future__ import print_function 3import getopt 4import sys 5 6 7def main(): 8 try: 9 opts, _ = getopt.getopt(sys.argv[1:], '', [ 10 'bitness=', 'compiler=', 'host']) 11 except getopt.GetoptError as err: 12 sys.exit(err) 13 14 bitness = None 15 compiler = 'clang' 16 host = False 17 for opt, val in opts: 18 if opt == '--bitness': 19 bitness = int(val) 20 if bitness not in (32, 64): 21 sys.exit('Invalid bitness: {}'.format(bitness)) 22 elif opt == '--compiler': 23 if val not in ('clang', 'gcc'): 24 sys.exit('Unknown compiler: {}'.format(val)) 25 compiler = val 26 elif opt == '--host': 27 host = True 28 else: 29 raise NotImplementedError('unhandled option: {}'.format(opt)) 30 31 with open('external/libcxx/buildcmds/testconfig.mk', 'w') as test_config: 32 if compiler == 'clang': 33 print('LOCAL_CLANG := true', file=test_config) 34 elif compiler == 'gcc': 35 print('LOCAL_CLANG := false', file=test_config) 36 37 if bitness == 32: 38 print('LOCAL_MULTILIB := 32', file=test_config) 39 elif bitness == 64: 40 print('LOCAL_MULTILIB := 64', file=test_config) 41 42 if compiler == 'clang': 43 print('LOCAL_CXX := $(LOCAL_PATH)/buildcmdscc $(CLANG_CXX)', 44 file=test_config) 45 else: 46 if host: 47 prefix = 'HOST_' 48 else: 49 prefix = 'TARGET_' 50 print('LOCAL_CXX := $(LOCAL_PATH)/buildcmdscc ' 51 '$($(LOCAL_2ND_ARCH_VAR_PREFIX){}CXX)'.format(prefix), 52 file=test_config) 53 54 if host: 55 print('include $(BUILD_HOST_EXECUTABLE)', file=test_config) 56 else: 57 print('include $(BUILD_EXECUTABLE)', file=test_config) 58 59 60if __name__ == '__main__': 61 main() 62