From 774be1e65199b55431cbe670cc469f63a68c3f94 Mon Sep 17 00:00:00 2001 From: bog Date: Tue, 17 Oct 2023 15:03:46 +0200 Subject: [PATCH] :tada: meson C++ project. --- .gitignore | 4 ++++ LICENSE | 19 ++++++++++++++++--- Makefile | 8 ++++++++ core/common.hpp | 27 +++++++++++++++++++++++++++ game/config.in.hpp | 6 ++++++ game/main.cpp | 8 ++++++++ meson.build | 44 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 core/common.hpp create mode 100644 game/config.in.hpp create mode 100644 game/main.cpp create mode 100644 meson.build diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10a7aa1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*~* +*\#* +build +.cache \ No newline at end of file diff --git a/LICENSE b/LICENSE index 9edc6af..2a66887 100644 --- a/LICENSE +++ b/LICENSE @@ -2,8 +2,21 @@ MIT License Copyright (c) 2023 bog -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9ea2b5e --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +.PHONY: build install + +build: + meson setup build + meson compile -C build + +install: build + meson install -C build diff --git a/core/common.hpp b/core/common.hpp new file mode 100644 index 0000000..d2278b0 --- /dev/null +++ b/core/common.hpp @@ -0,0 +1,27 @@ +#ifndef maze_COMMON_HPP +#define maze_COMMON_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAZE_GEN_ENUM(X) X +#define MAZE_GEN_STRING(X) #X + +#define MAZE_ENUM(PREFIX, KINDS) \ + enum PREFIX { KINDS(MAZE_GEN_ENUM) }; \ + constexpr char const* PREFIX ## Str [] = { KINDS(MAZE_GEN_STRING) } + +#define MAZE_ERROR(ERR) \ + struct ERR : public std::runtime_error { \ + ERR (std::string const& what): std::runtime_error(what) {} \ + } + +#endif diff --git a/game/config.in.hpp b/game/config.in.hpp new file mode 100644 index 0000000..41ea49c --- /dev/null +++ b/game/config.in.hpp @@ -0,0 +1,6 @@ +#ifndef m4ze_CONFIG_HPP +#define m4ze_CONFIG_HPP + +#define M4ZE_VERSION std::string("@version@") + +#endif diff --git a/game/main.cpp b/game/main.cpp new file mode 100644 index 0000000..9d5799e --- /dev/null +++ b/game/main.cpp @@ -0,0 +1,8 @@ +#include +#include "config.hpp" + +int main(int, char**) +{ + std::cout << "M4ZE: v" << M4ZE_VERSION << std::endl; + return 0; +} diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..46e7e0b --- /dev/null +++ b/meson.build @@ -0,0 +1,44 @@ +project('m4ze', + 'cpp', + version: '0.0.0', + default_options: [ + 'prefix=/usr', + 'warning_level=3', + 'cpp_std=c++17' + ]) + +conf = configuration_data() +conf.set('version', meson.project_version()) + +configure_file( + input: 'game/config.in.hpp', + output: 'config.hpp', + configuration: conf +) + +m4ze_core_lib = static_library( + 'm4ze-core', + sources: [ + ], + include_directories: [ + 'core/', + ], + dependencies: [ + ], +) + +m4ze_core_dep = declare_dependency( + link_with: [m4ze_core_lib], + include_directories: ['core/'] +) + +executable( + 'm4ze', + sources: [ + 'game/main.cpp', + ], + dependencies: [ + m4ze_core_dep + ], + install: true +)