diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..f45184c --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('base_url', type: 'string', value: 'https://api.originsro.org') diff --git a/src/config.hpp.in b/src/config.hpp.in new file mode 100644 index 0000000..707a64f --- /dev/null +++ b/src/config.hpp.in @@ -0,0 +1,7 @@ +#pragma once + +namespace duck { + +constexpr const char g_base_url[] = "@BASE_URL@"; + +} //namespace duck diff --git a/src/main.cpp b/src/main.cpp index da947ea..21eddb6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,9 @@ #include "oro/api.hpp" +#include "orotool_config.hpp" #include int main() { - oro::Api oro_api("https://api.originsro.org", "RESTC_CPP", "Testing"); + oro::Api oro_api(duck::g_base_url, "RESTC_CPP", "Testing"); auto ping = oro_api.ping(); std::cout << "date: " << ping.first.date << '\n'; diff --git a/src/meson.build b/src/meson.build index 87bbc8a..1c30a8d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -5,11 +5,25 @@ restc_cpp_dep = dependency('restc-cpp', version: '>=0.1.1', ], ) +base_url = get_option('base_url').strip() +if not base_url.endswith('/') + base_url = base_url + '/' +endif + +conf = configuration_data() +conf.set('BASE_URL', base_url) +project_config_file = configure_file( + input: 'config.hpp.in', + output: meson.project_name() + '_config.hpp', + configuration: conf, +) + executable(meson.project_name(), 'main.cpp', 'oro/datatypes.cpp', 'oro/api.cpp', 'oro/dateconv.cpp', + project_config_file, install: true, dependencies: [restc_cpp_dep], include_directories: date_incdir, diff --git a/subprojects/restc-cpp/include/restc-cpp/meson.build b/subprojects/restc-cpp/include/restc-cpp/meson.build index 263f6df..e41ea66 100644 --- a/subprojects/restc-cpp/include/restc-cpp/meson.build +++ b/subprojects/restc-cpp/include/restc-cpp/meson.build @@ -1,5 +1,4 @@ conf = configuration_data() - cpp = meson.get_compiler('cpp') conf.set('RESTC_CPP_WITH_UNIT_TESTS', get_option('restc_cpp_with_unit_tests') ? 1 : false)