blob: 5a67836b42753e1d6742fc42fdc5a8b6fc5d1fbf [file] [log] [blame]
Neil Fuller56166d32017-06-12 12:57:10 +01001# Copyright 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
Luca Stefani136579e2019-01-04 17:09:55 +010015from __future__ import print_function
16
Neil Fuller56166d32017-06-12 12:57:10 +010017import os
Neil Fullerd322be62019-09-16 16:25:03 +010018import subprocess
Neil Fuller56166d32017-06-12 12:57:10 +010019import sys
20
21"""Shared functions for use in tzdata scripts."""
22
Neil Fuller2aba99c2019-02-26 13:15:34 +000023def GetIanaTarFile(dir_name, file_prefix):
Neil Fuller56166d32017-06-12 12:57:10 +010024 matching_files = []
25 for filename in os.listdir(dir_name):
Neil Fuller2aba99c2019-02-26 13:15:34 +000026 if filename.startswith(file_prefix) and filename.endswith('.tar.gz'):
Neil Fuller56166d32017-06-12 12:57:10 +010027 matching_files.append(filename);
28
29 if len(matching_files) == 0:
30 return None
31 elif len(matching_files) == 1:
32 return '%s/%s' % (dir_name, matching_files[0])
33 else:
Neil Fuller2aba99c2019-02-26 13:15:34 +000034 print('Multiple %s files found unexpectedly %s' % (file_prefix, matching_files))
Neil Fuller56166d32017-06-12 12:57:10 +010035 sys.exit(1)
36
Neil Fullerd322be62019-09-16 16:25:03 +010037
38def InvokeSoong(android_build_top, build_modules):
39 old_cwd = os.getcwd()
40 os.chdir(android_build_top)
41 subprocess.check_call(['build/soong/soong_ui.bash', '--make-mode', '-j30'] + build_modules)
42 os.chdir(old_cwd)