1#!/usr/bin/python3 2# Copyright 2020 - The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the', help='License'); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an', help='AS IS' BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16# Script that makes it easy to have the docker build correspond to a particular 17# gfxstream Android build id 18 19import os 20import subprocess 21import sys 22import lxml.etree as etree 23 24gfxstream_manifest_filename = sys.argv[1] 25target_manifest_filename = sys.argv[2] 26 27# Don't need to check out the entire emulator repo to build gfxstream 28gfxstream_projects = set([ 29 "device/generic/goldfish-opengl", 30 "device/generic/vulkan-cereal", 31 "platform/external/angle", 32 "platform/external/astc-codec", 33 "platform/external/boringssl", 34 "platform/external/c-ares", 35 "platform/external/curl", 36 "platform/external/deqp", 37 "platform/external/ffmpeg", 38 "platform/external/googletest", 39 "platform/external/google-benchmark", 40 "platform/external/google-breakpad", 41 "platform/external/grpc-grpc", 42 "platform/external/libffi", 43 "platform/external/libvpx", 44 "platform/external/libyuv", 45 "platform/external/libpng", 46 "platform/external/libusb", 47 "platform/external/lz4", 48 "platform/external/protobuf", 49 "platform/external/qemu", 50 "platform/external/tinyobjloader", 51 "platform/external/nasm", 52 "platform/external/zlib", 53 "platform/prebuilts/android-emulator-build/common", 54 "platform/prebuilts/android-emulator-build/curl", 55 "platform/prebuilts/android-emulator-build/mesa", 56 "platform/prebuilts/android-emulator-build/mesa-deps", 57 "platform/prebuilts/android-emulator-build/protobuf", 58 "platform/prebuilts/android-emulator-build/qemu-android-deps", 59 "platform/prebuilts/clang/host/linux-x86", 60 "platform/prebuilts/cmake/linux-x86", 61 "platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8", 62 "platform/prebuilts/ninja/linux-x86", 63]) 64 65def generate_filtered_gfxstream_projects(filename): 66 outs = [] 67 68 out = etree.Element("manifest") 69 70 t = etree.parse(filename) 71 r = t.getroot() 72 73 for e in r.findall("project"): 74 if e.attrib["name"] in gfxstream_projects: 75 outp = etree.SubElement(out, "project") 76 outs.append(outp) 77 outp.set("name", e.attrib["name"]) 78 outp.set("path", e.attrib["path"]) 79 outp.set("revision", e.attrib["revision"]) 80 outp.set("clone-depth", "1") 81 82 return dict(map(lambda e: (e.attrib["name"], e), outs)) 83 84def update_projects(current_gfxstream_projects, target_manifest_filename): 85 target_root = etree.parse( \ 86 target_manifest_filename, 87 etree.XMLParser(remove_blank_text=True)).getroot() 88 89 found_projects = [] 90 91 for e in target_root.findall("project"): 92 if e.attrib["name"] in gfxstream_projects: 93 e.set("revision", current_gfxstream_projects[e.attrib["name"]].attrib["revision"]) 94 e.set("clone-depth", "1") 95 found_projects.append(e.attrib["name"]) 96 97 projects_to_add = gfxstream_projects - set(found_projects) 98 99 for p in projects_to_add: 100 project_element = current_gfxstream_projects[p] 101 outp = etree.SubElement(target_root, "project") 102 outp.set("name", project_element.attrib["name"]) 103 outp.set("path", project_element.attrib["path"]) 104 outp.set("revision", project_element.attrib["revision"]) 105 outp.set("clone-depth", "1") 106 107 return target_root 108 109print("Generating...") 110output_string = etree.tostring( \ 111 update_projects( 112 generate_filtered_gfxstream_projects(gfxstream_manifest_filename), 113 target_manifest_filename), 114 pretty_print=True, 115 xml_declaration=True,encoding="utf-8") 116 117print("Result: ") 118print(output_string.decode()) 119print("Writing result to %s" % target_manifest_filename) 120 121fh = open(target_manifest_filename, 'wb') 122fh.write(output_string) 123fh.close() 124