Neil Fuller | 56166d3 | 2017-06-12 12:57:10 +0100 | [diff] [blame] | 1 | # 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 | |
| 15 | import os |
Neil Fuller | d322be6 | 2019-09-16 16:25:03 +0100 | [diff] [blame] | 16 | import subprocess |
Neil Fuller | 56166d3 | 2017-06-12 12:57:10 +0100 | [diff] [blame] | 17 | import sys |
| 18 | |
| 19 | """Shared functions for use in tzdata scripts.""" |
| 20 | |
Neil Fuller | 2aba99c | 2019-02-26 13:15:34 +0000 | [diff] [blame] | 21 | def GetIanaTarFile(dir_name, file_prefix): |
Neil Fuller | 56166d3 | 2017-06-12 12:57:10 +0100 | [diff] [blame] | 22 | matching_files = [] |
| 23 | for filename in os.listdir(dir_name): |
Neil Fuller | 2aba99c | 2019-02-26 13:15:34 +0000 | [diff] [blame] | 24 | if filename.startswith(file_prefix) and filename.endswith('.tar.gz'): |
Neil Fuller | 56166d3 | 2017-06-12 12:57:10 +0100 | [diff] [blame] | 25 | matching_files.append(filename); |
| 26 | |
| 27 | if len(matching_files) == 0: |
| 28 | return None |
| 29 | elif len(matching_files) == 1: |
| 30 | return '%s/%s' % (dir_name, matching_files[0]) |
| 31 | else: |
Neil Fuller | 2aba99c | 2019-02-26 13:15:34 +0000 | [diff] [blame] | 32 | print('Multiple %s files found unexpectedly %s' % (file_prefix, matching_files)) |
Neil Fuller | 56166d3 | 2017-06-12 12:57:10 +0100 | [diff] [blame] | 33 | sys.exit(1) |
| 34 | |
Neil Fuller | d322be6 | 2019-09-16 16:25:03 +0100 | [diff] [blame] | 35 | |
| 36 | def InvokeSoong(android_build_top, build_modules): |
| 37 | old_cwd = os.getcwd() |
| 38 | os.chdir(android_build_top) |
| 39 | subprocess.check_call(['build/soong/soong_ui.bash', '--make-mode', '-j30'] + build_modules) |
| 40 | os.chdir(old_cwd) |