From b8e3fd0987677122345e26bbcc31c9f46f5119ff Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 9 Aug 2019 09:52:18 +0100 Subject: [PATCH] Migrate to meson as the build system. Nana needs to be present as a dependency on the system now. You can use meson setup -Dnanaincl=path -Dnanaroot=path ~/memoserv to specify non-standard include and library locations for nana. --- .gitmodules | 3 --- CMakeLists.txt | 10 -------- lib/nana | 1 - meson.build | 3 +++ meson_options.txt | 2 ++ src/gui/CMakeLists.txt | 20 ---------------- src/gui/icon_fetch.cpp | 9 ++++--- src/gui/meson.build | 49 +++++++++++++++++++++++++++++++++++++++ src/gui/resize_harris.cpp | 1 + 9 files changed, 59 insertions(+), 39 deletions(-) delete mode 100644 CMakeLists.txt delete mode 160000 lib/nana create mode 100644 meson.build create mode 100644 meson_options.txt delete mode 100644 src/gui/CMakeLists.txt create mode 100644 src/gui/meson.build diff --git a/.gitmodules b/.gitmodules index 6dbd2d2..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "lib/nana"] - path = lib/nana - url = https://github.com/cnjinhao/nana.git diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 83283bd..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 3.3 FATAL_ERROR) - -set(NANA_CMAKE_INSTALL_INCLUDES OFF CACHE BOOL "") -set(NANA_CMAKE_ENABLE_PNG OFF CACHE BOOL "") -set(NANA_CMAKE_SHARED_LIB ON CACHE BOOL "") -set(NANA_CMAKE_ENABLE_JPEG OFF CACHE BOOL "") -set(NANA_CMAKE_INSTALL OFF CACHE BOOL "") - -add_subdirectory(lib/nana) -add_subdirectory(src/gui) diff --git a/lib/nana b/lib/nana deleted file mode 160000 index 38cdf47..0000000 --- a/lib/nana +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 38cdf4779456ba697d7da863f7c623e25d30f650 diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..94ce71c --- /dev/null +++ b/meson.build @@ -0,0 +1,3 @@ +project('memoserv', 'cpp', default_options:['debug=true', 'cpp_std=c++17']) + +subdir('src/gui') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..3ece163 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,2 @@ +option('nanaroot', type: 'string', description: 'Path to the build directory of Nana') +option('nanaincl', type: 'string', description: 'Path to Nana include directory') diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt deleted file mode 100644 index cb6b589..0000000 --- a/src/gui/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -project(gui CXX) - -add_executable(${PROJECT_NAME} - main.cpp - memorycard.cpp - block.cpp - icon_fetch.cpp - widget/block_grid.cpp - resize_harris.cpp - make_nana_animation.cpp - animation_with_size.cpp -) - -target_link_libraries(${PROJECT_NAME} - PRIVATE nana -) - -target_include_directories(${PROJECT_NAME} - PRIVATE . -) diff --git a/src/gui/icon_fetch.cpp b/src/gui/icon_fetch.cpp index 79d5311..f6336eb 100644 --- a/src/gui/icon_fetch.cpp +++ b/src/gui/icon_fetch.cpp @@ -65,7 +65,7 @@ namespace { } std::vector rgb4_to_float (const std::vector& data, const std::vector& palette, int w, int h) { - assert(w * h); + assert(w * h != 0); std::vector retval(w * h * 3); const int scanl_sz = scanline_size(w, 4); @@ -102,7 +102,7 @@ namespace { const int scanl_sz = scanline_size(w, 24); std::vector retval(scanl_sz * h); assert(retval.size() >= data.size()); - assert(data.size() == w * h * 3); + assert(data.size() == static_cast(w * h * 3)); for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { @@ -119,11 +119,10 @@ std::vector> icon_fetch (const ConstBlock& block, int width, i const int in_height = 16, in_width = 16; const bool scale = (in_width != width or in_height != height); const auto slot_begin = block.cbegin(); - const auto slot_end = block.cend(); const std::vector& palette = block.palette(); assert(palette.size() == 16 * 4); const int32_t palette_padded_size = (not scale) * (((palette.size() * CHAR_BIT + 31) bitand ~31) / CHAR_BIT); - assert(palette.size() == palette_padded_size or scale); + assert(palette.size() == static_cast(palette_padded_size) or scale); const int32_t bpp = (scale ? 24 : 4); const int32_t scan_sz = scanline_size(width, bpp); @@ -154,7 +153,7 @@ std::vector> icon_fetch (const ConstBlock& block, int width, i std::copy(reinterpret_cast(&ihead), reinterpret_cast(&ihead + 1), std::back_inserter(frame)); if (not scale) { std::copy(palette.begin(), palette.end(), std::back_inserter(frame)); - assert(palette_padded_size >= palette.size()); + assert(static_cast(palette_padded_size) >= palette.size()); std::fill_n(std::back_inserter(frame), palette_padded_size - palette.size(), 0); } diff --git a/src/gui/meson.build b/src/gui/meson.build new file mode 100644 index 0000000..6302db6 --- /dev/null +++ b/src/gui/meson.build @@ -0,0 +1,49 @@ +add_project_link_arguments(['-lstdc++fs'], language: 'cpp') + +if get_option('nanaroot') != '' + nana_lib_search = [get_option('nanaroot')] +else + nana_lib_search = [] +endif +if get_option('nanaincl') != '' + nana_incl_search = [include_directories(get_option('nanaincl'))] +else + nana_incl_search = [] +endif + +cpp = meson.get_compiler('cpp') +nana_dep = cpp.find_library('nana', dirs: nana_lib_search) +private_incl = include_directories('.') +x11_dep = dependency('x11') +libjpeg_dep = dependency('libjpeg') +libpng_dep = dependency('libpng') +libxft_dep = dependency('xft') +libfontconfig_dep = dependency('fontconfig') +libthread_dep = dependency('threads') + +is_debug_build = 0 +if get_option('buildtype').startswith('debug') + is_debug_build = 1 +endif + +executable('gui', + 'main.cpp', + 'memorycard.cpp', + 'block.cpp', + 'icon_fetch.cpp', + 'widget/block_grid.cpp', + 'resize_harris.cpp', + 'make_nana_animation.cpp', + 'animation_with_size.cpp', + dependencies: [ + nana_dep, + x11_dep, + libpng_dep, + libjpeg_dep, + libxft_dep, + libfontconfig_dep, + libthread_dep, + ], + install: true, + include_directories: [private_incl] + nana_incl_search, +) diff --git a/src/gui/resize_harris.cpp b/src/gui/resize_harris.cpp index c1972d8..a9f24d5 100644 --- a/src/gui/resize_harris.cpp +++ b/src/gui/resize_harris.cpp @@ -75,6 +75,7 @@ namespace { m_xpos = m_xbegin; ++m_ypos; } + return *this; } void advance_row() { ++m_ypos; }