Olivier Deprez | f90f1f1 | 2023-11-20 15:03:47 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Copyright 2024 The Hafnium Authors. |
| 4 | # |
| 5 | # Use of this source code is governed by a BSD-style |
| 6 | # license that can be found in the LICENSE file or at |
| 7 | # https://opensource.org/licenses/BSD-3-Clause. |
| 8 | |
| 9 | """Check a list of platforms are defined in a project. |
| 10 | |
| 11 | First argument is the project name (e.g. reference). |
| 12 | The script returns a zero error code if the list of platform names given as |
| 13 | arguments (following the project name) are available for building. |
| 14 | If one platform supplied in arguments doesn't exist, the script prints the |
| 15 | list of supported platforms and returns 1 as an exit code. |
| 16 | If the script is called with only the project name, it prints the list of |
| 17 | available platforms and returns 0. |
| 18 | """ |
| 19 | |
| 20 | import sys |
| 21 | import re |
| 22 | import os |
| 23 | |
| 24 | def Main(): |
| 25 | project = sys.argv[1] |
| 26 | |
| 27 | platforms = [] |
Jayanth Dodderi Chidanand | 2435318 | 2025-08-13 13:05:58 +0100 | [diff] [blame^] | 28 | reg = re.compile(r'aarch64_toolchains\("(\w*)') |
Olivier Deprez | f90f1f1 | 2023-11-20 15:03:47 +0100 | [diff] [blame] | 29 | with open("project/" + project + "/BUILD.gn") as project_file: |
| 30 | for line in project_file: |
| 31 | platforms += reg.findall(line) |
| 32 | |
| 33 | if len(sys.argv) < 3: |
| 34 | print("Supported platforms: ", platforms) |
| 35 | return 0 |
| 36 | |
| 37 | platform_list = sys.argv[2:] |
| 38 | |
| 39 | if not set(platform_list).issubset(platforms): |
| 40 | print("Supported platforms: ", platforms) |
| 41 | return 1 |
| 42 | |
| 43 | return 0 |
| 44 | |
| 45 | if __name__ == "__main__": |
| 46 | sys.exit(Main()) |