diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index c872be12..a44094c2 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -29,7 +29,6 @@ jobs: base-devel git ruby - vim mingw-w64-x86_64-cmake mingw-w64-x86_64-meson mingw-w64-x86_64-autotools diff --git a/assets/meson.build b/assets/meson.build index b746281a..6659aa9a 100644 --- a/assets/meson.build +++ b/assets/meson.build @@ -17,10 +17,11 @@ foreach file : embedded_assets_f input: file, output: '@0@.xxd'.format(embedded_assets[count]), command: [ - xxd, '-i', '@INPUT@' + embedtool, + '@INPUT@', + '@OUTPUT@', + 'mkxp_assets_@0@'.format(embedded_assets[count].replace('.', '_')), ], - capture: true, - depend_files: embedded_assets_f[count] ) count += 1 endforeach diff --git a/embedtool.cpp b/embedtool.cpp new file mode 100644 index 00000000..f4fd28a6 --- /dev/null +++ b/embedtool.cpp @@ -0,0 +1,59 @@ +/* +** embedtool.cpp +** +** This file is part of mkxp. +** +** Copyright (C) 2013 - 2021 Amaryllis Kulla +** +** mkxp is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** mkxp is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with mkxp. If not, see . +*/ + +#include +#include + +int main(int argc, char **argv) { + if (argc < 4) { + return 1; + } + + const char *input = argv[1]; + const char *output = argv[2]; + const char *arrayname = argv[3]; + + std::ifstream inputf(input); + if (!inputf.is_open()) { + return 2; + } + + std::ofstream outputf(output); + if (!outputf.is_open()) { + return 3; + } + + outputf << "#include \n#include \nconst uint8_t " << arrayname << "[] = {"; + + uint64_t len = 0; + for (;;) { + unsigned char c = inputf.get(); + if (inputf.eof()) { + break; + } + outputf << (unsigned int)c << ','; + ++len; + } + + outputf << "};\nconst size_t " << arrayname << "_len = " << len << "ULL;"; + + return 0; +} diff --git a/meson.build b/meson.build index 108410db..0fb42fac 100644 --- a/meson.build +++ b/meson.build @@ -12,6 +12,8 @@ if not is_libretro and host_system == 'darwin' error('This Meson project no longer supports macOS. Please use the Xcode project instead.') endif +git_hash = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip() + compilers = {'c': meson.get_compiler('c'), 'cpp': meson.get_compiler('cpp')} global_sources = [] @@ -33,6 +35,8 @@ global_args += '-DHAVE_NANOSLEEP' # ==================== if is_libretro + embedtool = executable('embedtool', sources: 'embedtool.cpp', native: true, override_options: []) + libretro_stage1_path = get_option('libretro_stage1_path') libretro_link_args = [] @@ -587,8 +591,6 @@ if is_emscripten or not compilers['cpp'].compiles('struct E {}; int main() { thr libretro_defines += '-DBOOST_NO_EXCEPTIONS' endif -xxd = find_program('xxd', native: true) - # STEAMWORKS steamworks = false @@ -674,6 +676,9 @@ endif global_args += '-DMKXPZ_INIT_GL_LATER' subdir('src') + +embedtool = executable('embedtool', sources: 'embedtool.cpp', native: true, override_options: []) + subdir('binding') subdir('shader') subdir('assets') diff --git a/shader/meson.build b/shader/meson.build index 197a7139..adae8842 100644 --- a/shader/meson.build +++ b/shader/meson.build @@ -42,10 +42,11 @@ foreach file : embedded_shaders_f input: file, output: '@0@.xxd'.format(embedded_shaders[count]), command: [ - xxd, '-i', '@INPUT@' + embedtool, + '@INPUT@', + '@OUTPUT@', + 'mkxp_shader_@0@'.format(embedded_shaders[count].replace('.', '_')), ], - capture: true, - depend_files: embedded_shaders_f[count] ) count += 1 endforeach diff --git a/src/display/font.cpp b/src/display/font.cpp index 3b4befd6..2b0c1e6f 100644 --- a/src/display/font.cpp +++ b/src/display/font.cpp @@ -55,14 +55,8 @@ #define BUNDLED_FONT wqymicrohei #endif -#define BUNDLED_FONT_DECL(FONT) \ - extern unsigned char ___assets_##FONT##_ttf[]; \ - extern unsigned int ___assets_##FONT##_ttf_len; - -BUNDLED_FONT_DECL(liberation) - -#define BUNDLED_FONT_D(f) ___assets_## f ##_ttf -#define BUNDLED_FONT_L(f) ___assets_## f ##_ttf_len +#define BUNDLED_FONT_D(f) mkxp_assets_## f ##_ttf +#define BUNDLED_FONT_L(f) sizeof mkxp_assets_## f ##_ttf // Go fuck yourself CPP #define BNDL_F_D(f) BUNDLED_FONT_D(f) diff --git a/src/display/gl/shader.cpp b/src/display/gl/shader.cpp index aad98276..44ce4136 100644 --- a/src/display/gl/shader.cpp +++ b/src/display/gl/shader.cpp @@ -74,7 +74,7 @@ #else #define INIT_SHADER(vert, frag, name) \ { \ - Shader::init(___shader_##vert##_vert, ___shader_##vert##_vert_len, ___shader_##frag##_frag, ___shader_##frag##_frag_len, \ + Shader::init(mkxp_shader_##vert##_vert, sizeof mkxp_shader_##vert##_vert, mkxp_shader_##frag##_frag, sizeof mkxp_shader_##frag##_frag, \ #vert, #frag, #name); \ } #endif @@ -168,8 +168,8 @@ static void setupShaderSource(GLuint shader, GLenum type, } #ifndef MKXPZ_BUILD_XCODE - shaderSrc[i] = (const GLchar*) ___shader_common_h; - shaderSrcSize[i] = ___shader_common_h_len; + shaderSrc[i] = (const GLchar*) mkxp_shader_common_h; + shaderSrcSize[i] = sizeof mkxp_shader_common_h; #else shaderSrc[i] = (const GLchar*) Shader::commonHeader().c_str(); shaderSrcSize[i] = Shader::commonHeader().length(); diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 2bd3b808..65085d61 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -184,7 +184,7 @@ void EventThread::process(RGSSThreadData &rtData) SDL_GameControllerAddMappingsFromFile(mkxp_fs::getPathForAsset("gamecontrollerdb", "txt").c_str()); #else SDL_GameControllerAddMappingsFromRW( - SDL_RWFromConstMem(___assets_gamecontrollerdb_txt, ___assets_gamecontrollerdb_txt_len), + SDL_RWFromConstMem(mkxp_assets_gamecontrollerdb_txt, sizeof mkxp_assets_gamecontrollerdb_txt), 1); #endif diff --git a/src/main.cpp b/src/main.cpp index 9aca9c06..92cbe9a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -186,7 +186,7 @@ static void setupWindowIcon(const Config &conf, SDL_Window *win) { if (conf.iconPath.empty()) #ifndef MKXPZ_BUILD_XCODE - iconSrc = SDL_RWFromConstMem(___assets_icon_png, ___assets_icon_png_len); + iconSrc = SDL_RWFromConstMem(mkxp_assets_icon_png, sizeof mkxp_assets_icon_png); #else iconSrc = SDL_RWFromFile(mkxp_fs::getPathForAsset("icon", "png").c_str(), "rb"); #endif