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 11First argument is the project name (e.g. reference). 12The script returns a zero error code if the list of platform names given as 13arguments (following the project name) are available for building. 14If one platform supplied in arguments doesn't exist, the script prints the 15list of supported platforms and returns 1 as an exit code. 16If the script is called with only the project name, it prints the list of 17available platforms and returns 0. 18""" 19 20import sys 21import re 22import os 23 24def Main(): 25 project = sys.argv[1] 26 27 platforms = [] 28 reg = re.compile(r'aarch64_toolchains\("(\w*)') 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 45if __name__ == "__main__": 46 sys.exit(Main()) 47