From 8a61e57ffc890ae9bb4f3b7440e2e4c2ab702220 Mon Sep 17 00:00:00 2001 From: Adam Dobrowolski Date: Wed, 10 Nov 2021 13:23:00 +0100 Subject: [PATCH] [EGD-7932] Added downloader for assets for Bell With this all fonts and Luts bin are downloaed for other repo which is closed from others. With minimum changes to our cmake and flow Added cache dir as set in cmake for CI CI has to use common cache to not download data all the time Jenkinsfile updated to install lacking dependency --- CMakeLists.txt | 1 + cmake/modules/AddPackage.cmake | 2 + cmake/modules/DiskImage.cmake | 1 + cmake/modules/DownloadAsset2.cmake | 10 ++++ products/BellHybrid/CMakeLists.txt | 2 + products/BellHybrid/assets.json | 59 ++++++++++++++++++++++++ products/PurePhone/CMakeLists.txt | 2 + products/PurePhone/assets.json | 74 ++++++++++++++++++++++++++++++ tools/download_asset2.py | 2 +- tools/requirements.txt | 1 + 10 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 cmake/modules/DownloadAsset2.cmake create mode 100644 products/BellHybrid/assets.json create mode 100644 products/PurePhone/assets.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b1c19edfdc16d42d8da9b992851ee471a0e5e1e..ddefeb1b3cfbb6b753aa600a0cf4eb94d2b59e0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") +set(MUDITA_CACHE_DIR "~/.mudita/" CACHE STRING "cache directory for our downloaded assets") project(PureOS) enable_language(C CXX ASM) diff --git a/cmake/modules/AddPackage.cmake b/cmake/modules/AddPackage.cmake index 1ac5634ab7fdbdeb3d3dabc3ccbf203aa1e0f389..f2c4c1c9658f6bb5ccff51a0f4a1a6cef2415762 100644 --- a/cmake/modules/AddPackage.cmake +++ b/cmake/modules/AddPackage.cmake @@ -39,6 +39,7 @@ function(add_standalone_image SOURCE_TARGET) COMMAND tar -ScJf ${STANDALONE_PKG} ${SOURCE_TARGET}.img WORKING_DIRECTORY ${CMAKE_BINARY_DIR} DEPENDS ${BIN_FILE} + DEPENDS json-target DEPENDS ecoboot.bin-target DEPENDS updater.bin-target DEPENDS ${SOURCE_TARGET}-version.json-target @@ -64,6 +65,7 @@ function(add_update_package SOURCE_TARGET) add_custom_command( OUTPUT ${UPDATE_PKG} + DEPENDS json-target DEPENDS ${SOURCE_TARGET} DEPENDS ${SOURCE_TARGET}-boot.bin DEPENDS ${SOURCE_TARGET}-version.json-target diff --git a/cmake/modules/DiskImage.cmake b/cmake/modules/DiskImage.cmake index b24ad7caebe1fe2a6b378b50ac5d79d692b5b2c9..caeb401fc70a0c442c34ec1c2102d26d5b7763bc 100644 --- a/cmake/modules/DiskImage.cmake +++ b/cmake/modules/DiskImage.cmake @@ -60,6 +60,7 @@ function(add_image) add_custom_command( OUTPUT ${DISK_IMAGE_NAME} DEPENDS ${COMMAND_DEPENDS} + DEPENDS json-target COMMAND ${SCRIPT_PATH} ${DISK_IMAGE_NAME} diff --git a/cmake/modules/DownloadAsset2.cmake b/cmake/modules/DownloadAsset2.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3c6961218de8d1c6fcef5068ddfced1432f10666 --- /dev/null +++ b/cmake/modules/DownloadAsset2.cmake @@ -0,0 +1,10 @@ +function(download_asset2 json install_path cache_dir) + add_custom_target(json-target + COMMAND python3 ${CMAKE_SOURCE_DIR}/tools/download_asset2.py + --json ${json} + github + --install_dir ${install_path} + --cache_dir ${cache_dir} + COMMENT "Download binary assets listed in json file" + ) +endfunction() diff --git a/products/BellHybrid/CMakeLists.txt b/products/BellHybrid/CMakeLists.txt index f4bccb7ad1c90eadab08efda0dc5b24294818bd9..5e65ed5877716a3ed0553319979a095c1a2abe68 100644 --- a/products/BellHybrid/CMakeLists.txt +++ b/products/BellHybrid/CMakeLists.txt @@ -85,6 +85,8 @@ add_hex_target(BellHybrid) include(BinaryAssetsVersions.cmake) include(DownloadAsset) +include(DownloadAsset2) +download_asset2(${CMAKE_CURRENT_SOURCE_DIR}/assets.json ${PROJECT_SOURCE_DIR} ${MUDITA_CACHE_DIR}) download_asset(PureUpdater_RT.bin updater.bin PureUpdater ${UPDATER_BIN_VERSION}) download_asset(ecoboot.bin ecoboot.bin ecoboot ${ECOBOOT_BIN_VERSION}) diff --git a/products/BellHybrid/assets.json b/products/BellHybrid/assets.json new file mode 100644 index 0000000000000000000000000000000000000000..f6ffcc121574c84ca1eafa13e9aab3876977cd15 --- /dev/null +++ b/products/BellHybrid/assets.json @@ -0,0 +1,59 @@ +{ + "comment": "This is kiss structure - asset path & sha", + "assets": [ + { + "name": "./fonts/bell/gt_pressura_regular_38.mpf", + "output": "assets/fonts/gt_pressura_regular_38.mpf", + "ref": "fd168040c5d1216d457e6cf223e8ea9bb76bf7b" + }, + { + "name": "./fonts/bell/gt_pressura_light_38.mpf", + "output": "assets/fonts/gt_pressura_light_38.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a" + }, + { + "name": "./fonts/bell/gt_pressura_regular_90.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_regular_90.mpf" + }, + { + "name": "./fonts/bell/gt_pressura_regular_190.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_regular_190.mpf" + }, + { + "name": "./fonts/common/gt_pressura_light_30.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_light_30.mpf" + }, + { + "name": "./fonts/common/gt_pressura_regular_30.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_regular_30.mpf" + }, + { + "name": "./fonts/common/gt_pressura_bold_30.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_bold_30.mpf" + }, + { + "name": "./fonts/common/gt_pressura_regular_46.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_regular_46.mpf" + }, + { + "name": "./fonts/common/gt_pressura_light_46.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_light_46.mpf" + }, + { + "name": "./fonts/common/gt_pressura_light_90.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_light_90.mpf" + }, + { + "name": "./image/Luts.bin", + "output": "Luts.bin" + } + ] +} diff --git a/products/PurePhone/CMakeLists.txt b/products/PurePhone/CMakeLists.txt index e6e6a085e431045eef49058b761867dceb1b8b8f..fb3b2503f8561eceb2a2ca93206a04c3490c7e4f 100644 --- a/products/PurePhone/CMakeLists.txt +++ b/products/PurePhone/CMakeLists.txt @@ -102,6 +102,8 @@ add_hex_target(PurePhone) include(BinaryAssetsVersions.cmake) include(DownloadAsset) +include(DownloadAsset2) +download_asset2(${CMAKE_CURRENT_SOURCE_DIR}/assets.json ${PROJECT_SOURCE_DIR} ${MUDITA_CACHE_DIR}) download_asset(PureUpdater_RT.bin updater.bin PureUpdater ${UPDATER_BIN_VERSION}) download_asset(ecoboot.bin ecoboot.bin ecoboot ${ECOBOOT_BIN_VERSION}) diff --git a/products/PurePhone/assets.json b/products/PurePhone/assets.json new file mode 100644 index 0000000000000000000000000000000000000000..fdbc941919c5a0757e8b3e60074d9ec89f01c45f --- /dev/null +++ b/products/PurePhone/assets.json @@ -0,0 +1,74 @@ +{ + "assets": [ + { + "name": "./fonts/pure/dejavu_sans_bold_27.mpf", + "output":"assets/fonts/dejavu_sans_bold_27.mpf" + }, + { + "name": "./fonts/pure/gt_pressura_regular_20.mpf", + "output":"assets/fonts/gt_pressura_regular_20.mpf" + }, + { + "name": "./fonts/pure/gt_pressura_bold_20.mpf", + "output":"assets/fonts/gt_pressura_bold_20.mpf" + }, + { + "name": "./fonts/pure/gt_pressura_regular_24.mpf", + "output":"assets/fonts/gt_pressura_regular_24.mpf" + }, + { + "name": "./fonts/pure/gt_pressura_bold_24.mpf", + "output":"assets/fonts/gt_pressura_bold_24.mpf" + }, + { + "name": "./fonts/pure/gt_pressura_light_27.mpf", + "output":"assets/fonts/gt_pressura_light_27.mpf" + }, + { + "name": "./fonts/pure/gt_pressura_regular_27.mpf", + "output":"assets/fonts/gt_pressura_regular_27.mpf" + }, + { + "name": "./fonts/pure/gt_pressura_bold_27.mpf", + "output":"assets/fonts/gt_pressura_bold_27.mpf" + }, + { + "name": "./fonts/pure/gt_pressura_bold_32.mpf", + "output":"assets/fonts/gt_pressura_bold_32.mpf" + }, + { + "name": "./fonts/common/gt_pressura_light_30.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_light_30.mpf" + }, + { + "name": "./fonts/common/gt_pressura_regular_30.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_regular_30.mpf" + }, + { + "name": "./fonts/common/gt_pressura_bold_30.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_bold_30.mpf" + }, + { + "name": "./fonts/common/gt_pressura_regular_46.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_regular_46.mpf" + }, + { + "name": "./fonts/common/gt_pressura_light_46.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_light_46.mpf" + }, + { + "name": "./fonts/common/gt_pressura_light_90.mpf", + "ref": "10c74fcb09c2022325767cad735c0183b6f5393a", + "output": "assets/fonts/gt_pressura_light_90.mpf" + }, + { + "name": "./image/Luts.bin", + "output": "Luts.bin" + } + ] +} diff --git a/tools/download_asset2.py b/tools/download_asset2.py index e21c191462b737d5083e3bc1d510e924b5957e5a..28720237b2eb1ab3900ac35a6844e4ac6ccfbdff 100644 --- a/tools/download_asset2.py +++ b/tools/download_asset2.py @@ -172,7 +172,7 @@ class GitOps: output.parent.mkdir(parents=True, exist_ok=True) self.copy_file(cached, output) except HTTP404NotFoundError as ex: - raise RuntimeError(f'file not found with: {data} err: {ex} on path: {Path(".").absolute()} with cache dir: {self.cache.absolute()} for {val["name"]}') + raise RuntimeError(f'file not found with: {data} err: {ex}') except HTTP403ForbiddenError as ex: # gh is messed up - if you get persistent error on this file, try renaming raise RuntimeError(f'something is wrong with: {data} err: {ex}') diff --git a/tools/requirements.txt b/tools/requirements.txt index efbb1539f18054867f0f967923c75a0096e3b649..11bea2de55ab25f0fe6e5b8ecc4b38c05f405180 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -7,3 +7,4 @@ requests==2.26.0 smmap==4.0.0 tqdm==4.62.2 urllib3==1.26.6 +ghapi