1*2fd832c6SAndroid Build Coastguard Worker# Copyright 2017 The Android Open Source Project 2*2fd832c6SAndroid Build Coastguard Worker# 3*2fd832c6SAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 4*2fd832c6SAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 5*2fd832c6SAndroid Build Coastguard Worker# You may obtain a copy of the License at 6*2fd832c6SAndroid Build Coastguard Worker# 7*2fd832c6SAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 8*2fd832c6SAndroid Build Coastguard Worker# 9*2fd832c6SAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*2fd832c6SAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 11*2fd832c6SAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*2fd832c6SAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 13*2fd832c6SAndroid Build Coastguard Worker# limitations under the License. 14*2fd832c6SAndroid Build Coastguard Worker 15*2fd832c6SAndroid Build Coastguard Workerimport os 16*2fd832c6SAndroid Build Coastguard Workerimport subprocess 17*2fd832c6SAndroid Build Coastguard Workerimport sys 18*2fd832c6SAndroid Build Coastguard Worker 19*2fd832c6SAndroid Build Coastguard Worker"""Shared functions for use in tzdata scripts.""" 20*2fd832c6SAndroid Build Coastguard Worker 21*2fd832c6SAndroid Build Coastguard Workerdef GetIanaTarFile(dir_name, file_prefix): 22*2fd832c6SAndroid Build Coastguard Worker matching_files = [] 23*2fd832c6SAndroid Build Coastguard Worker for filename in os.listdir(dir_name): 24*2fd832c6SAndroid Build Coastguard Worker if filename.startswith(file_prefix) and filename.endswith('.tar.gz'): 25*2fd832c6SAndroid Build Coastguard Worker matching_files.append(filename); 26*2fd832c6SAndroid Build Coastguard Worker 27*2fd832c6SAndroid Build Coastguard Worker if len(matching_files) == 0: 28*2fd832c6SAndroid Build Coastguard Worker return None 29*2fd832c6SAndroid Build Coastguard Worker elif len(matching_files) == 1: 30*2fd832c6SAndroid Build Coastguard Worker return '%s/%s' % (dir_name, matching_files[0]) 31*2fd832c6SAndroid Build Coastguard Worker else: 32*2fd832c6SAndroid Build Coastguard Worker print('Multiple %s files found unexpectedly %s' % (file_prefix, matching_files)) 33*2fd832c6SAndroid Build Coastguard Worker sys.exit(1) 34*2fd832c6SAndroid Build Coastguard Worker 35*2fd832c6SAndroid Build Coastguard Worker 36*2fd832c6SAndroid Build Coastguard Workerdef InvokeSoong(android_build_top, build_modules): 37*2fd832c6SAndroid Build Coastguard Worker old_cwd = os.getcwd() 38*2fd832c6SAndroid Build Coastguard Worker os.chdir(android_build_top) 39*2fd832c6SAndroid Build Coastguard Worker subprocess.check_call(['build/soong/soong_ui.bash', '--make-mode', '-j30'] + build_modules) 40*2fd832c6SAndroid Build Coastguard Worker os.chdir(old_cwd) 41