Add a CLI program to access the memoserv lib.
This commit is contained in:
parent
4c655850de
commit
b2b87c7459
8 changed files with 69 additions and 7 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -0,0 +1,3 @@
|
|||
[submodule "subprojects/cxxopts"]
|
||||
path = subprojects/cxxopts
|
||||
url = https://github.com/jarro2783/cxxopts.git
|
10
meson.build
10
meson.build
|
@ -1,11 +1,17 @@
|
|||
project('memoserv', 'cpp', default_options:['debug=true', 'cpp_std=c++17', 'b_ndebug=if-release'])
|
||||
project('memoserv', 'cpp',
|
||||
version: '0.1.0',
|
||||
meson_version: '>=0.49.2',
|
||||
default_options:['debug=true', 'cpp_std=c++17', 'b_ndebug=if-release']
|
||||
)
|
||||
|
||||
is_debug_build = 0
|
||||
if get_option('buildtype').startswith('debug')
|
||||
is_debug_build = 1
|
||||
endif
|
||||
|
||||
cxxopts_incl = include_directories('subprojects/cxxopts/include')
|
||||
|
||||
memcard_proj = subproject('memcard')
|
||||
memcard_dep = memcard_proj.get_variable('memcard_dep')
|
||||
|
||||
subdir('src/gui')
|
||||
subdir('src')
|
||||
|
|
3
src/cli/config.h.in
Normal file
3
src/cli/config.h.in
Normal file
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
#define APP_NAME "@APP_NAME@"
|
30
src/cli/main.cpp
Normal file
30
src/cli/main.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "memcard/memorycard.hpp"
|
||||
#include "config.h"
|
||||
#include <iostream>
|
||||
#include <cxxopts.hpp>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
using mc::MemoryCard;
|
||||
using std::string;
|
||||
|
||||
cxxopts::Options options(APP_NAME, "PSX memory card inspector");
|
||||
options.add_options()
|
||||
("h,help", "Show this help and quit")
|
||||
("i,input", "Path to the input memory card file", cxxopts::value<string>()->default_value(""))
|
||||
;
|
||||
auto command = options.parse(argc, argv);
|
||||
|
||||
if (command.count("help")) {
|
||||
std::cout << options.help() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string mc_path = command["input"].as<string>();
|
||||
if (mc_path.empty()) {
|
||||
std::cerr << "No input memory card specified, run with --help for usage\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
19
src/cli/meson.build
Normal file
19
src/cli/meson.build
Normal file
|
@ -0,0 +1,19 @@
|
|||
#add_project_link_arguments(['-lstdc++fs'], language: 'cpp')
|
||||
|
||||
conf = configuration_data()
|
||||
conf.set('APP_NAME', meson.project_name())
|
||||
config_file = configure_file(
|
||||
input: 'config.h.in',
|
||||
output: 'config.h',
|
||||
configuration: conf
|
||||
)
|
||||
|
||||
executable(meson.project_name(),
|
||||
'main.cpp',
|
||||
config_file,
|
||||
dependencies: [
|
||||
memcard_dep
|
||||
],
|
||||
install: true,
|
||||
include_directories: cxxopts_incl
|
||||
)
|
|
@ -1,5 +1,3 @@
|
|||
add_project_link_arguments(['-lstdc++fs'], language: 'cpp')
|
||||
|
||||
if get_option('nanaroot') != ''
|
||||
nana_lib_search = [get_option('nanaroot')]
|
||||
else
|
||||
|
@ -13,15 +11,15 @@ 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')
|
||||
fslib_dep = cpp.find_library('stdc++fs', required: false)
|
||||
|
||||
executable('gui',
|
||||
executable(meson.project_name() + 'gui',
|
||||
'main.cpp',
|
||||
'widget/block_grid.cpp',
|
||||
'make_nana_animation.cpp',
|
||||
|
@ -35,7 +33,8 @@ executable('gui',
|
|||
libfontconfig_dep,
|
||||
libthread_dep,
|
||||
memcard_dep,
|
||||
fslib_dep,
|
||||
],
|
||||
install: true,
|
||||
include_directories: [private_incl] + nana_incl_search,
|
||||
include_directories: nana_incl_search,
|
||||
)
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
subdir('gui')
|
||||
subdir('cli')
|
||||
|
|
1
subprojects/cxxopts
Submodule
1
subprojects/cxxopts
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit b0f67a06de3446aa97a4943ad0ad6086460b2b61
|
Loading…
Add table
Reference in a new issue