From cc17bd44387586d774423ed12e18c4c080306aa1 Mon Sep 17 00:00:00 2001 From: Ningyuan Li Date: Tue, 13 Jun 2023 11:54:07 +0900 Subject: [PATCH] updated res tools --- CMakeLists.txt | 16 +++++++++++++--- third_party/commons | 2 +- tools/resource-tools/gulpfile.ts | 18 ++++-------------- tools/resource-tools/symheader.ts | 26 ++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 tools/resource-tools/symheader.ts diff --git a/CMakeLists.txt b/CMakeLists.txt index aff8b6c..7b85eaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,16 +11,26 @@ endif () project(ihsplay VERSION ${IHSPLAY_VERSION} LANGUAGES C) +# To suppress warnings for MbedTLS +if (POLICY CMP0048) + cmake_policy(SET CMP0048 NEW) +endif () +# To suppress warnings for ExternalProject DOWNLOAD_EXTRACT_TIMESTAMP +if (POLICY CMP0135) + cmake_policy(SET CMP0135 NEW) +endif () + enable_testing() -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR}/core/scripts - ${CMAKE_SOURCE_DIR}/third_party/commons/cmake ${CMAKE_SOURCE_DIR}/cmake/sanitizers/cmake) +# Somehow the directory containing FindMbedTLS.cmake must be in the first place +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/core/scripts ${CMAKE_SOURCE_DIR}/third_party/commons/cmake + ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR}/cmake/sanitizers/cmake) # Use `pkg-config` to link needed libraries. find_package(PkgConfig REQUIRED) find_package(Freetype REQUIRED) find_package(Fontconfig REQUIRED) -find_package(MbedTLS) +find_package(MbedTLS REQUIRED) # Use SDL2 for window creation and event handling. pkg_check_modules(SDL2 REQUIRED sdl2) diff --git a/third_party/commons b/third_party/commons index 5242510..6141487 160000 --- a/third_party/commons +++ b/third_party/commons @@ -1 +1 @@ -Subproject commit 5242510091b22b4f36435598f4d509863a62191f +Subproject commit 6141487e73fddfe814cb96c08d916487f7da5043 diff --git a/tools/resource-tools/gulpfile.ts b/tools/resource-tools/gulpfile.ts index 504dab4..de8ab7d 100644 --- a/tools/resource-tools/gulpfile.ts +++ b/tools/resource-tools/gulpfile.ts @@ -1,9 +1,9 @@ import {dest, parallel, src} from "gulp"; import binheader from "./binheader"; import codepoints from "./codepoints"; -import asyncTransform from "./async-transform"; import rename from "gulp-rename"; import subsetFont from "./gulp-subset-font"; +import symheader from "./symheader"; const outDir = '../../app/lvgl/fonts/bootstrap-icons'; @@ -25,19 +25,9 @@ async function iconfont() { async function symlist() { return src('res/bootstrap-icons.woff2') .pipe(codepoints()) - .pipe(asyncTransform(async file => { - const codepoints: Record = codepointsMetadata(file); - let content = '#pragma once\n\n'; - const encoder = new TextEncoder(); - for (let key in codepoints) { - const cp: number = codepoints[key]; - const value = Array.from(encoder.encode(String.fromCodePoint(cp))) - .map(v => `\\x${v.toString(16)}`).join(''); - const name = key.toUpperCase().replace(/[^0-9a-z_]/ig, '_'); - content += `#define BS_SYMBOL_${name} "${value}"\n`; - } - file.contents = Buffer.from(content); - file.basename = 'symbols.h'; + .pipe(symheader({prefix: 'BS'})) + .pipe(rename(file => { + file.basename = 'symbols'; })) .pipe(dest(outDir)); } diff --git a/tools/resource-tools/symheader.ts b/tools/resource-tools/symheader.ts new file mode 100644 index 0000000..f32a91f --- /dev/null +++ b/tools/resource-tools/symheader.ts @@ -0,0 +1,26 @@ +import asyncTransform from "./async-transform"; + +export interface Option { + prefix: string; +} + +function codepointsMetadata(file: any): Record { + return file.codepoints; +} + +export default function symheader(option?: Partial