1# Copyright 2020 - The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the', help='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', help='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# Script that makes it easy to have the docker build correspond to a particular 16# gfxstream Android build id 17 18import os 19import subprocess 20import sys 21import lxml.etree as etree 22 23gfxstream_manifest_filename = sys.argv[1] 24target_manifest_filename = sys.argv[2] 25 26# Don't need to check out the entire emulator repo to build gfxstream 27gfxstream_projects = set([ 28 "device/generic/goldfish-opengl", 29 "device/generic/vulkan-cereal", 30 "platform/external/angle", 31 "platform/external/astc-codec", 32 "platform/external/boringssl", 33 "platform/external/c-ares", 34 "platform/external/curl", 35 "platform/external/deqp", 36 "platform/external/ffmpeg", 37 "platform/external/googletest", 38 "platform/external/google-benchmark", 39 "platform/external/google-breakpad", 40 "platform/external/grpc-grpc", 41 "platform/external/libffi", 42 "platform/external/libvpx", 43 "platform/external/libyuv", 44 "platform/external/libpng", 45 "platform/external/lz4", 46 "platform/external/protobuf", 47 "platform/external/qemu", 48 "platform/external/tinyobjloader", 49 "platform/external/nasm", 50 "platform/external/zlib", 51 "platform/prebuilts/android-emulator-build/common", 52 "platform/prebuilts/android-emulator-build/curl", 53 "platform/prebuilts/android-emulator-build/mesa", 54 "platform/prebuilts/android-emulator-build/mesa-deps", 55 "platform/prebuilts/android-emulator-build/protobuf", 56 "platform/prebuilts/android-emulator-build/qemu-android-deps", 57 "platform/prebuilts/clang/host/linux-x86", 58 "platform/prebuilts/cmake/linux-x86", 59 "platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8", 60 "platform/prebuilts/ninja/linux-x86", 61]) 62 63def generate_filtered_gfxstream_projects(filename): 64 outs = [] 65 66 out = etree.Element("manifest") 67 68 t = etree.parse(filename) 69 r = t.getroot() 70 71 for e in r.findall("project"): 72 if e.attrib["name"] in gfxstream_projects: 73 outp = etree.SubElement(out, "project") 74 outs.append(outp) 75 outp.set("name", e.attrib["name"]) 76 outp.set("path", e.attrib["path"]) 77 outp.set("revision", e.attrib["revision"]) 78 outp.set("clone-depth", "1") 79 80 return dict(map(lambda e: (e.attrib["name"], e), outs)) 81 82def update_projects(current_gfxstream_projects, target_manifest_filename): 83 target_root = etree.parse( \ 84 target_manifest_filename, 85 etree.XMLParser(remove_blank_text=True)).getroot() 86 87 found_projects = [] 88 89 for e in target_root.findall("project"): 90 if e.attrib["name"] in gfxstream_projects: 91 e.set("revision", current_gfxstream_projects[e.attrib["name"]].attrib["revision"]) 92 e.set("clone-depth", "1") 93 found_projects.append(e.attrib["name"]) 94 95 projects_to_add = gfxstream_projects - set(found_projects) 96 97 for p in projects_to_add: 98 project_element = current_gfxstream_projects[p] 99 outp = etree.SubElement(target_root, "project") 100 outp.set("name", project_element.attrib["name"]) 101 outp.set("path", project_element.attrib["path"]) 102 outp.set("revision", project_element.attrib["revision"]) 103 outp.set("clone-depth", "1") 104 105 return target_root 106 107print("Generating...") 108output_string = etree.tostring( \ 109 update_projects( 110 generate_filtered_gfxstream_projects(gfxstream_manifest_filename), 111 target_manifest_filename), 112 pretty_print=True, 113 xml_declaration=True,encoding="utf-8") 114 115print("Result: ") 116print(output_string.decode()) 117print("Writing result to %s" % target_manifest_filename) 118 119fh = open(target_manifest_filename, 'w') 120fh.write(output_string) 121fh.close() 122