From db24bb4750f9b83034d4d6617c905346e2ae215a Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 13 Feb 2022 19:19:38 +0000 Subject: [PATCH] Make blob patcher respect android driver layout --- tools/blob-patcher.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/tools/blob-patcher.py b/tools/blob-patcher.py index 1c6f36f..2464d7f 100755 --- a/tools/blob-patcher.py +++ b/tools/blob-patcher.py @@ -15,25 +15,26 @@ def patch_lib_base(in_dir, out_dir, libs, in_name, out_name): def patch_lib(in_dir, out_dir, libs, name): patch_lib_base(in_dir, out_dir, libs, "lib" + name + ".so", "not" + name + ".so") -def patch_references(lib_dir, out_dir, vulkan_libname, vulkan_newname, stub_mapper): +def patch_references(lib_dir, out_dir, vulkan_libname, vulkan_newname, shim_mapper): try: os.mkdir(out_dir) + os.mkdir(out_dir + "/hw") except: pass replacement_list = [("libgsl.so", "notgsl.so"), ("libllvm-glnext.so", "notllvm-glnext.so"), ("libdmabufheap.so", "notdmabufheap.so"), ("libadreno_utils.so", "notadreno_utils.so"), ("libllvm-qgl.so", "notllvm-qgl.so")] - if (stub_mapper == 2): - replacement_list += [("vendor.qti.hardware.display.mapper@2.0.so", "vendor.qti.hardware.display.mapperstub.so"), - ("android.hardware.graphics.mapper@2.0.so", "android.hardware.graphics.mapperstub.so"), - ("vendor.qti.hardware.display.mapperextensions@1.0.so", "vendor.qti.hardware.display.mapperextensionsstub.so"), - ("vendor.qti.hardware.display.mapperextensions@1.1.so", "vendor.qti.hardware.display.mapperextensionsstub.so")] - if (stub_mapper <= 3): - replacement_list += [("vendor.qti.hardware.display.mapper@3.0.so", "vendor.qti.hardware.display.mapperstub.so"), - ("android.hardware.graphics.mapper@3.0.so", "android.hardware.graphics.mapperstub.so")] - if (stub_mapper <= 4): - replacement_list += [("vendor.qti.hardware.display.mapper@4.0.so", "vendor.qti.hardware.display.mapperstub.so"), - ("android.hardware.graphics.mapper@4.0.so", "android.hardware.graphics.mapperstub.so")] + if (shim_mapper < 2): + replacement_list += [("vendor.qti.hardware.display.mapper@2.0.so", "vendor.qti.hardware.display.mappershim.so"), + ("android.hardware.graphics.mapper@2.0.so", "android.hardware.graphics.mappershim.so"), + ("vendor.qti.hardware.display.mapperextensions@1.0.so", "vendor.qti.hardware.display.mapperextensionsshim.so"), + ("vendor.qti.hardware.display.mapperextensions@1.1.so", "vendor.qti.hardware.display.mapperextensionsshim.so")] + if (shim_mapper < 3): + replacement_list += [("vendor.qti.hardware.display.mapper@3.0.so", "vendor.qti.hardware.display.mappershim.so"), + ("android.hardware.graphics.mapper@3.0.so", "android.hardware.graphics.mappershim.so")] + if (shim_mapper < 4): + replacement_list += [("vendor.qti.hardware.display.mapper@4.0.so", "vendor.qti.hardware.display.mappershim.so"), + ("android.hardware.graphics.mapper@4.0.so", "android.hardware.graphics.mappershim.so")] for lib in ["gsl", "llvm-glnext", "dmabufheap", "adreno_utils", "llvm-qgl"]: try: @@ -41,24 +42,26 @@ def patch_references(lib_dir, out_dir, vulkan_libname, vulkan_newname, stub_mapp except: pass - patch_lib_base(lib_dir + "/hw/", out_dir, replacement_list, vulkan_libname, vulkan_newname) + patch_lib_base(lib_dir + "/hw/", out_dir + "/hw/", replacement_list, vulkan_libname, vulkan_newname) if (len(sys.argv)!= 6): - print(" ") + print(" ") sys.exit() + + root_path = sys.argv[1] out_path = sys.argv[2] vulkan_libname = sys.argv[3] vulkan_newname = sys.argv[4] -stub_mapper = int(sys.argv[5]) +shim_mapper = int(sys.argv[5]) vendor_path = root_path + "/vendor/" if (len(vulkan_newname) != len(vulkan_libname)): - print("New vk soname must be equal to old one") + print("Errror") sys.exit() for libdir in ["/lib64/", "/lib/"]: - patch_references(vendor_path + libdir, out_path + libdir, vulkan_libname, vulkan_newname, stub_mapper) + patch_references(vendor_path + libdir, out_path + libdir, vulkan_libname, vulkan_newname, shim_mapper) print("done!")