Add support for command line parameters

Using tclap library, released under MIT. This adds the meson
wrap file along with the minimal custom meson.build for tclap,
all the meson code to get config files generated and the
integration of the tclap parser.
This commit is contained in:
King_DuckZ 2025-04-08 02:04:52 +01:00
commit 42a4fbc686
9 changed files with 185 additions and 5 deletions

View file

@ -0,0 +1,34 @@
/* Copyright 2025, Michele "King_DuckZ" Santullo
* This file is part of ducktorrent.
*
* Ducktorrent 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 3 of the License, or
* (at your option) any later version.
*
* Ducktorrent 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 ducktorrent. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#if defined(__cplusplus)
namespace duck {
constexpr char g_project_name[] = @PROJECT_NAME@;
constexpr char g_project_version[] = "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@";
constexpr unsigned int g_proj_ver_major = @PROJECT_VERSION_MAJOR@;
constexpr unsigned int g_proj_ver_minor = @PROJECT_VERSION_MINOR@;
constexpr unsigned int g_proj_ver_patch = @PROJECT_VERSION_PATCH@;
} //namespace duck
#endif
#define PROJECT_NAME @PROJECT_NAME@
#define PROJECT_VERSION "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@"
#define PROJ_VER_MAJOR @PROJECT_VERSION_MAJOR@
#define PROJ_VER_MINOR @PROJECT_VERSION_MINOR@
#define PROJ_VER_PATCH @PROJECT_VERSION_PATCH@

View file

@ -0,0 +1,26 @@
/* Copyright 2025, Michele "King_DuckZ" Santullo
* This file is part of ducktorrent.
*
* Ducktorrent 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 3 of the License, or
* (at your option) any later version.
*
* Ducktorrent 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 ducktorrent. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#if defined(__cplusplus)
namespace duck {
constexpr char g_proj_git_sha1[] = "@VCS_TAG@";
} //namespace duck
#endif
#define PROJ_GIT_SHA1 "@VCS_TAG@"

35
templates/meson.build Normal file
View file

@ -0,0 +1,35 @@
git_prog = find_program('git', required: false)
conf_data = configuration_data()
conf_data.set_quoted('PROJECT_ROOT', meson.project_source_root())
conf_data.set_quoted('PROJECT_NAME', meson.project_name())
version_arr = meson.project_version().split('.')
conf_data.set('PROJECT_VERSION_MAJOR', version_arr[0])
conf_data.set('PROJECT_VERSION_MINOR', version_arr[1])
conf_data.set('PROJECT_VERSION_PATCH', version_arr[2])
if git_prog.found()
gitrev_config_file = vcs_tag(
command: [git_prog.path(), 'rev-parse', 'HEAD'],
input: 'git_version.h.in',
output: 'git_version.h',
fallback: ''
)
else
conf = configuration_data()
conf.set('VCS_TAG', '')
gitrev_config_file = configure_file(
input: 'git_version.h.in',
output: 'git_version.h',
configuration: conf
)
unset_variable('conf')
endif
misc_config_file = configure_file(
input: meson.project_name() + '_config.h.in',
output: meson.project_name() + '_config.h',
configuration: conf_data
)
unset_variable('conf_data')
unset_variable('version_arr')