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.
This commit is contained in:
King_DuckZ 2019-08-09 09:52:18 +01:00
parent b448766c21
commit b8e3fd0987
9 changed files with 59 additions and 39 deletions

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "lib/nana"]
path = lib/nana
url = https://github.com/cnjinhao/nana.git

View file

@ -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)

@ -1 +0,0 @@
Subproject commit 38cdf4779456ba697d7da863f7c623e25d30f650

3
meson.build Normal file
View file

@ -0,0 +1,3 @@
project('memoserv', 'cpp', default_options:['debug=true', 'cpp_std=c++17'])
subdir('src/gui')

2
meson_options.txt Normal file
View file

@ -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')

View file

@ -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 .
)

View file

@ -65,7 +65,7 @@ namespace {
} }
std::vector<float> rgb4_to_float (const std::vector<char>& data, const std::vector<uint8_t>& palette, int w, int h) { std::vector<float> rgb4_to_float (const std::vector<char>& data, const std::vector<uint8_t>& palette, int w, int h) {
assert(w * h); assert(w * h != 0);
std::vector<float> retval(w * h * 3); std::vector<float> retval(w * h * 3);
const int scanl_sz = scanline_size(w, 4); const int scanl_sz = scanline_size(w, 4);
@ -102,7 +102,7 @@ namespace {
const int scanl_sz = scanline_size(w, 24); const int scanl_sz = scanline_size(w, 24);
std::vector<char> retval(scanl_sz * h); std::vector<char> retval(scanl_sz * h);
assert(retval.size() >= data.size()); assert(retval.size() >= data.size());
assert(data.size() == w * h * 3); assert(data.size() == static_cast<std::size_t>(w * h * 3));
for (int y = 0; y < h; ++y) { for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) { for (int x = 0; x < w; ++x) {
@ -119,11 +119,10 @@ std::vector<std::vector<char>> icon_fetch (const ConstBlock& block, int width, i
const int in_height = 16, in_width = 16; const int in_height = 16, in_width = 16;
const bool scale = (in_width != width or in_height != height); const bool scale = (in_width != width or in_height != height);
const auto slot_begin = block.cbegin(); const auto slot_begin = block.cbegin();
const auto slot_end = block.cend();
const std::vector<uint8_t>& palette = block.palette(); const std::vector<uint8_t>& palette = block.palette();
assert(palette.size() == 16 * 4); assert(palette.size() == 16 * 4);
const int32_t palette_padded_size = (not scale) * (((palette.size() * CHAR_BIT + 31) bitand ~31) / CHAR_BIT); 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<std::size_t>(palette_padded_size) or scale);
const int32_t bpp = (scale ? 24 : 4); const int32_t bpp = (scale ? 24 : 4);
const int32_t scan_sz = scanline_size(width, bpp); const int32_t scan_sz = scanline_size(width, bpp);
@ -154,7 +153,7 @@ std::vector<std::vector<char>> icon_fetch (const ConstBlock& block, int width, i
std::copy(reinterpret_cast<char*>(&ihead), reinterpret_cast<char*>(&ihead + 1), std::back_inserter(frame)); std::copy(reinterpret_cast<char*>(&ihead), reinterpret_cast<char*>(&ihead + 1), std::back_inserter(frame));
if (not scale) { if (not scale) {
std::copy(palette.begin(), palette.end(), std::back_inserter(frame)); std::copy(palette.begin(), palette.end(), std::back_inserter(frame));
assert(palette_padded_size >= palette.size()); assert(static_cast<std::size_t>(palette_padded_size) >= palette.size());
std::fill_n(std::back_inserter(frame), palette_padded_size - palette.size(), 0); std::fill_n(std::back_inserter(frame), palette_padded_size - palette.size(), 0);
} }

49
src/gui/meson.build Normal file
View file

@ -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,
)

View file

@ -75,6 +75,7 @@ namespace {
m_xpos = m_xbegin; m_xpos = m_xbegin;
++m_ypos; ++m_ypos;
} }
return *this;
} }
void advance_row() { ++m_ypos; } void advance_row() { ++m_ypos; }