From 55d8d30c7278485df3f137c6c9cee1674331e6e7 Mon Sep 17 00:00:00 2001 From: pineappleEA <67879877+pineappleEA@users.noreply.github.com> Date: Sat, 16 Jan 2021 02:31:38 +0200 Subject: [PATCH] Implement the resource extractor The extractor takes an asset (or multiple assets), in this case yuzu.bmp, and extracts their hex code to the header file yuzu_icon.h in order to be compiled and be embedded into the binary --- src/yuzu_cmd/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index 0b3f2cb54f..08e43436b8 100644 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -1,5 +1,16 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) +function(create_resource file output filename) + # Read hex data from file + file(READ ${file} filedata HEX) + # Convert hex data for C compatibility + string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," filedata ${filedata}) + # Write data to output file + file(WRITE ${output} "const unsigned char ${filename}[] = {${filedata}};\nconst unsigned ${filename}_size = sizeof(${filename});\n") +endfunction() + +create_resource("../../dist/yuzu.bmp" "yuzu_icon.h" "yuzu_icon") + add_executable(yuzu-cmd config.cpp config.h @@ -13,6 +24,7 @@ add_executable(yuzu-cmd resource.h yuzu.cpp yuzu.rc + yuzu_icon.h ) create_target_directory_groups(yuzu-cmd)