1 # Copyright (C) 2014 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 import os 15 16 17 def main(): 18 build_mk_path = 'external/libcxx/test/Android.build.mk' 19 for root, _dirs, files in os.walk('.'): 20 tests = [] 21 for test in [x for x in files if x.endswith('.pass.cpp')]: 22 path = os.path.join(root, test) 23 out_name = os.path.splitext(path)[0] # trim .cpp 24 out_name = os.path.splitext(out_name)[0] # trim .pass 25 out_name = os.path.normpath(out_name) 26 tests.append((test, out_name)) 27 with open(os.path.join(root, 'Android.mk'), 'w') as makefile: 28 makefile_path = os.path.normpath(os.path.join( 29 'external/libcxx/test/', root, 'Android.mk')) 30 makefile.write('''# 31 # Copyright (C) 2014 The Android Open Source Project 32 # 33 # Licensed under the Apache License, Version 2.0 (the "License"); 34 # you may not use this file except in compliance with the License. 35 # You may obtain a copy of the License at 36 # 37 # http://www.apache.org/licenses/LICENSE-2.0 38 # 39 # Unless required by applicable law or agreed to in writing, software 40 # distributed under the License is distributed on an "AS IS" BASIS, 41 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 42 # See the License for the specific language governing permissions and 43 # limitations under the License. 44 # 45 ''') 46 makefile.write('LOCAL_PATH := $(call my-dir)\n') 47 makefile.write('test_makefile := {}\n'.format(makefile_path)) 48 if len(tests) > 0: 49 for test, out_name in tests: 50 makefile.write(''' 51 test_name := {} 52 test_src := {} 53 include {} 54 '''.format(out_name, test, build_mk_path)) 55 makefile.write( 56 '\ninclude $(call all-makefiles-under,$(LOCAL_PATH))') 57 58 59 if __name__ == '__main__': 60 main() 61