From a7916b14397b7e9116d514e7595a27d18a043afd Mon Sep 17 00:00:00 2001 From: Erwin Jansen <jansene@google.com> Date: Fri, 26 Oct 2018 09:44:10 -0700 Subject: [PATCH] Add checksum support for CMakeList generation We now embed a checksum in the generated CMakeLists.txt files. The emulators cmake build system will use this to make sure the makefiles have not changed. Changing the makefiles without regenerating the CMakeLists.txt will result in a build break in the emulator. Change-Id: I242dd3292b0d876d80d92cd36bdbe62c6197d259 --- CMakeLists.txt | 1 + android-emu/CMakeLists.txt | 1 + cmake_transform.py | 17 +++++++++++++++++ shared/OpenglCodecCommon/CMakeLists.txt | 1 + system/GLESv1/CMakeLists.txt | 1 + system/GLESv1_enc/CMakeLists.txt | 1 + system/GLESv2/CMakeLists.txt | 1 + system/GLESv2_enc/CMakeLists.txt | 1 + system/OpenglSystemCommon/CMakeLists.txt | 1 + system/egl/CMakeLists.txt | 1 + system/gralloc/CMakeLists.txt | 2 ++ system/renderControl_enc/CMakeLists.txt | 1 + system/vulkan/CMakeLists.txt | 1 + system/vulkan_enc/CMakeLists.txt | 1 + 14 files changed, 31 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2b1f18..ac15aad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. set(GOLDFISH_DEVICE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/./Android.mk" "8a354859d6be293140931db80edcbaf2c4db30118482356373f9ed2c92059806") add_subdirectory(shared/OpenglCodecCommon) add_subdirectory(system/GLESv1_enc) add_subdirectory(system/GLESv2_enc) diff --git a/android-emu/CMakeLists.txt b/android-emu/CMakeLists.txt index 432b3b8..9e3218d 100644 --- a/android-emu/CMakeLists.txt +++ b/android-emu/CMakeLists.txt @@ -1,6 +1,7 @@ # This is an autogenerated file! Do not edit! # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/android-emu/Android.mk" "4b9cd7741f05b6dd1384a3dbc317d971365ed9c96ee19f42c1dcc075a2df10ba") set(androidemu_src android/base/AlignedBuf.cpp android/base/files/MemStream.cpp android/base/files/Stream.cpp android/base/files/StreamSerializing.cpp android/base/Pool.cpp android/base/StringFormat.cpp android/utils/debug.c) android_add_library(androidemu) target_include_directories(androidemu PRIVATE ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest) diff --git a/cmake_transform.py b/cmake_transform.py index 834dd4b..3e8d9c5 100644 --- a/cmake_transform.py +++ b/cmake_transform.py @@ -1,5 +1,6 @@ #!/bin/python import argparse +import hashlib import json import logging import os @@ -69,10 +70,22 @@ def header(): ] +def checksum(fname): + """Calculates a SHA256 digest of the given file name.""" + m = hashlib.sha256() + with open(fname, 'r') as mk: + m.update(mk.read()) + return m.hexdigest() + + def generate_module(module): """Generates a cmake module.""" name = remove_lib_prefix(module['module']) make = header() + mkfile = os.path.join(module['path'], 'Android.mk') + sha256 = checksum(mkfile) + make.append( + 'android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/%s" "%s")' % (mkfile, sha256)) make.append('set(%s_src %s)' % (name, ' '.join(module['src']))) if module['type'] == 'SHARED_LIBRARY': make.append('android_add_shared_library(%s)' % name) @@ -149,8 +162,12 @@ def main(argv=None): # The root, it will basically just include all the generated files. root = os.path.join(args.outdir, 'CMakeLists.txt') + mkfile = os.path.join(args.outdir, 'Android.mk') + sha256 = checksum(mkfile) cmake[root] = header() cmake[root].append('set(GOLDFISH_DEVICE_ROOT ${CMAKE_CURRENT_SOURCE_DIR})') + cmake[root].append( + 'android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/%s" "%s")' % (mkfile, sha256)) # Generate the modules. for module in modules: diff --git a/shared/OpenglCodecCommon/CMakeLists.txt b/shared/OpenglCodecCommon/CMakeLists.txt index 712891b..6f1f4ea 100644 --- a/shared/OpenglCodecCommon/CMakeLists.txt +++ b/shared/OpenglCodecCommon/CMakeLists.txt @@ -1,6 +1,7 @@ # This is an autogenerated file! Do not edit! # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon/Android.mk" "b90bb271cb6f2c60c9d50bfe2a1273396e77e082d3482316f50185efdfb534c9") set(OpenglCodecCommon_host_src GLClientState.cpp GLESTextureUtils.cpp ChecksumCalculator.cpp GLSharedGroup.cpp glUtils.cpp IndexRangeCache.cpp SocketStream.cpp TcpStream.cpp auto_goldfish_dma_context.cpp goldfish_dma_host.cpp qemu_pipe_host.cpp) android_add_shared_library(OpenglCodecCommon_host) target_include_directories(OpenglCodecCommon_host PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest) diff --git a/system/GLESv1/CMakeLists.txt b/system/GLESv1/CMakeLists.txt index 1fdf943..e1e73a8 100644 --- a/system/GLESv1/CMakeLists.txt +++ b/system/GLESv1/CMakeLists.txt @@ -1,6 +1,7 @@ # This is an autogenerated file! Do not edit! # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/GLESv1/Android.mk" "e095cb082e3791719749cfc80b90560afd7348eb0d7895449d2509aa129bea75") set(GLESv1_CM_emulation_src gl.cpp) android_add_shared_library(GLESv1_CM_emulation) target_include_directories(GLESv1_CM_emulation PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest) diff --git a/system/GLESv1_enc/CMakeLists.txt b/system/GLESv1_enc/CMakeLists.txt index 3cf6f18..1b86cdb 100644 --- a/system/GLESv1_enc/CMakeLists.txt +++ b/system/GLESv1_enc/CMakeLists.txt @@ -1,6 +1,7 @@ # This is an autogenerated file! Do not edit! # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc/Android.mk" "953e6b7371d10eed63a4be555f8f1fb6f347338484a78102fa8f55dff96f5d3b") set(GLESv1_enc_src GLEncoder.cpp GLEncoderUtils.cpp gl_client_context.cpp gl_enc.cpp gl_entry.cpp) android_add_shared_library(GLESv1_enc) target_include_directories(GLESv1_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest) diff --git a/system/GLESv2/CMakeLists.txt b/system/GLESv2/CMakeLists.txt index 48717aa..8078bda 100644 --- a/system/GLESv2/CMakeLists.txt +++ b/system/GLESv2/CMakeLists.txt @@ -1,6 +1,7 @@ # This is an autogenerated file! Do not edit! # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/GLESv2/Android.mk" "d8f9dda69ec57ad8b7a65f02c3335b16a4724f612dec1d1a2cd793c28c0a10f9") set(GLESv2_emulation_src gl2.cpp) android_add_shared_library(GLESv2_emulation) target_include_directories(GLESv2_emulation PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest) diff --git a/system/GLESv2_enc/CMakeLists.txt b/system/GLESv2_enc/CMakeLists.txt index 22dabeb..87534fc 100644 --- a/system/GLESv2_enc/CMakeLists.txt +++ b/system/GLESv2_enc/CMakeLists.txt @@ -1,6 +1,7 @@ # This is an autogenerated file! Do not edit! # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc/Android.mk" "61772afe3e393d4ff6add7929ed232da8e614e44bf903018a91c774bc5b54a18") set(GLESv2_enc_src GL2EncoderUtils.cpp GL2Encoder.cpp GLESv2Validation.cpp gl2_client_context.cpp gl2_enc.cpp gl2_entry.cpp ../enc_common/IOStream_common.cpp) android_add_shared_library(GLESv2_enc) target_include_directories(GLESv2_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest) diff --git a/system/OpenglSystemCommon/CMakeLists.txt b/system/OpenglSystemCommon/CMakeLists.txt index 6b41902..9add96f 100644 --- a/system/OpenglSystemCommon/CMakeLists.txt +++ b/system/OpenglSystemCommon/CMakeLists.txt @@ -1,6 +1,7 @@ # This is an autogenerated file! Do not edit! # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/Android.mk" "5ee7d71d6652a9dae3d1de93b9ff1ac36a26a40193aa8d2604965c766d2ed8ab") set(OpenglSystemCommon_src FormatConversions.cpp HostConnection.cpp QemuPipeStream.cpp ProcessPipe.cpp ThreadInfo_host.cpp) android_add_shared_library(OpenglSystemCommon) target_include_directories(OpenglSystemCommon PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest) diff --git a/system/egl/CMakeLists.txt b/system/egl/CMakeLists.txt index 19ea7dd..c2da5f1 100644 --- a/system/egl/CMakeLists.txt +++ b/system/egl/CMakeLists.txt @@ -1,6 +1,7 @@ # This is an autogenerated file! Do not edit! # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/egl/Android.mk" "4a6be27a2b501a86cad12c5876d0e766966574b11376ff8614fd92ffe94eb4b3") set(EGL_emulation_src eglDisplay.cpp egl.cpp ClientAPIExts.cpp) android_add_shared_library(EGL_emulation) target_include_directories(EGL_emulation PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest) diff --git a/system/gralloc/CMakeLists.txt b/system/gralloc/CMakeLists.txt index b4ee9ac..cddfe09 100644 --- a/system/gralloc/CMakeLists.txt +++ b/system/gralloc/CMakeLists.txt @@ -1,6 +1,7 @@ # This is an autogenerated file! Do not edit! # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/gralloc/Android.mk" "3898852aade0f86cf9db2d73e90a5294e04aebb513e4757bf5f9ceaaeab528bb") set(gralloc.goldfish_src gralloc.cpp) android_add_shared_library(gralloc.goldfish) target_include_directories(gralloc.goldfish PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest) @@ -10,6 +11,7 @@ target_link_libraries(gralloc.goldfish PRIVATE OpenglSystemCommon android-emu-sh # This is an autogenerated file! Do not edit! # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/gralloc/Android.mk" "3898852aade0f86cf9db2d73e90a5294e04aebb513e4757bf5f9ceaaeab528bb") set(gralloc.ranchu_src gralloc.cpp) android_add_shared_library(gralloc.ranchu) target_include_directories(gralloc.ranchu PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest) diff --git a/system/renderControl_enc/CMakeLists.txt b/system/renderControl_enc/CMakeLists.txt index cde8386..40280fd 100644 --- a/system/renderControl_enc/CMakeLists.txt +++ b/system/renderControl_enc/CMakeLists.txt @@ -1,6 +1,7 @@ # This is an autogenerated file! Do not edit! # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc/Android.mk" "f314acdb6134d3e545889739e6e9bf8837177ce2f3318106394c7656c5d8b992") set(_renderControl_enc_src renderControl_client_context.cpp renderControl_enc.cpp renderControl_entry.cpp) android_add_shared_library(_renderControl_enc) target_include_directories(_renderControl_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest) diff --git a/system/vulkan/CMakeLists.txt b/system/vulkan/CMakeLists.txt index cdd1520..1c22caf 100644 --- a/system/vulkan/CMakeLists.txt +++ b/system/vulkan/CMakeLists.txt @@ -1,6 +1,7 @@ # This is an autogenerated file! Do not edit! # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/vulkan/Android.mk" "62b77340124f9e5f36e0bf639e4e6691f19083b9e875746d18118ae7c0b5c337") set(vulkan.ranchu_src func_table.cpp goldfish_vulkan.cpp) android_add_shared_library(vulkan.ranchu) target_include_directories(vulkan.ranchu PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/system/vulkan ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/host/include) diff --git a/system/vulkan_enc/CMakeLists.txt b/system/vulkan_enc/CMakeLists.txt index a319513..ef940a0 100644 --- a/system/vulkan_enc/CMakeLists.txt +++ b/system/vulkan_enc/CMakeLists.txt @@ -1,6 +1,7 @@ # This is an autogenerated file! Do not edit! # instead run make from .../device/generic/goldfish-opengl # which will re-generate this file. +android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc/Android.mk" "0399a3d0120297d932fe5beeebd874abde31b4ff8de0793a54d61e62f5e3938e") set(vulkan_enc_src VulkanStream.cpp HandleWrappers.cpp VkEncoder.cpp goldfish_vk_marshaling_guest.cpp) android_add_shared_library(vulkan_enc) target_include_directories(vulkan_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/host/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/host/include/vulkan) -- GitLab