From 7abd6fb67063e69996119e3e718896047a7db291 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sun, 29 Jan 2023 15:08:36 +0800 Subject: [PATCH] build: update xmake script --- .gitignore | 2 +- src/klotski_core/CMakeLists.txt | 7 +- src/klotski_core/ffi/metadata.cc | 2 +- .../utils/{version.h.in => metadata.h.in} | 4 +- src/klotski_core/utils/metadata.h.inx | 15 ++++ src/klotski_core/xmake.lua | 78 +++++++++++-------- 6 files changed, 69 insertions(+), 39 deletions(-) rename src/klotski_core/utils/{version.h.in => metadata.h.in} (79%) create mode 100644 src/klotski_core/utils/metadata.h.inx diff --git a/.gitignore b/.gitignore index 2fa6e20..8b7b67d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ /cmake-build-debug/ /cmake-build-release/ /src/rust_ffi/target/ -/src/klotski_core/utils/version.h +/src/klotski_core/utils/metadata.h diff --git a/src/klotski_core/CMakeLists.txt b/src/klotski_core/CMakeLists.txt index 44a755c..f2ee30c 100644 --- a/src/klotski_core/CMakeLists.txt +++ b/src/klotski_core/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0) set(CMAKE_CXX_STANDARD 14) -project(klotski-core VERSION 0.0.1 LANGUAGES CXX) +project(klotski-core VERSION 0.1.2 LANGUAGES CXX) ################################################################################ @@ -32,9 +32,10 @@ set(SYSTEM_INFO "${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR}") set(COMPILER_INFO "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") configure_file( - utils/version.h.in - ${PROJECT_SOURCE_DIR}/utils/version.h + ${PROJECT_SOURCE_DIR}/utils/metadata.h.in + ${PROJECT_SOURCE_DIR}/utils/metadata.h ) + ################################################################################ include_directories(utils) diff --git a/src/klotski_core/ffi/metadata.cc b/src/klotski_core/ffi/metadata.cc index 882999c..4268550 100644 --- a/src/klotski_core/ffi/metadata.cc +++ b/src/klotski_core/ffi/metadata.cc @@ -1,5 +1,5 @@ #include "klotski.h" -#include "version.h" +#include "metadata.h" int get_version_major() { return VERSION_MAJOR; diff --git a/src/klotski_core/utils/version.h.in b/src/klotski_core/utils/metadata.h.in similarity index 79% rename from src/klotski_core/utils/version.h.in rename to src/klotski_core/utils/metadata.h.in index b2c0587..936794b 100644 --- a/src/klotski_core/utils/version.h.in +++ b/src/klotski_core/utils/metadata.h.in @@ -1,9 +1,11 @@ #pragma once +/// CMake metadata template + #define VERSION_MAJOR (@VERSION_MAJOR@) #define VERSION_MINOR (@VERSION_MINOR@) #define VERSION_PATCH (@VERSION_PATCH@) -#define VERSION_STR "v@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@" +#define VERSION_STR "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@" #define AUTHOR "dnomd343" #define SYSTEM "@SYSTEM_INFO@" diff --git a/src/klotski_core/utils/metadata.h.inx b/src/klotski_core/utils/metadata.h.inx new file mode 100644 index 0000000..4c70fc8 --- /dev/null +++ b/src/klotski_core/utils/metadata.h.inx @@ -0,0 +1,15 @@ +#pragma once + +/// XMake metadata template + +#define VERSION_MAJOR (${VERSION_MAJOR}) +#define VERSION_MINOR (${VERSION_MINOR}) +#define VERSION_PATCH (${VERSION_ALTER}) +#define VERSION_STR "${VERSION}" + +#define AUTHOR "dnomd343" +#define SYSTEM "${PLAT} ${ARCH}" +#define COMPILER "${COMPILER_INFO}" +#define BUILD_TIME "${BUILD_TIME}" +#define PROJECT_URL "https://github.com/dnomd343/klotski.git" +#define GIT_COMMIT_ID "${GIT_COMMIT_LONG}" diff --git a/src/klotski_core/xmake.lua b/src/klotski_core/xmake.lua index 9bbee92..6191362 100644 --- a/src/klotski_core/xmake.lua +++ b/src/klotski_core/xmake.lua @@ -1,80 +1,92 @@ +set_xmakever("2.0.0") + +set_version("0.1.2") + +set_languages("cxx14") + +set_optimize("fastest") + +set_warnings("everything") + +---------------------------------------------------------------- + +add_includedirs("utils") +add_includedirs("all_cases") + +add_includedirs("raw_code") +add_includedirs("short_code") +add_includedirs("common_code") + +add_includedirs("core") +add_includedirs("fast_cal") +add_includedirs("analyse") + +add_includedirs("benchmark") + +---------------------------------------------------------------- + target("utils") set_kind("static") add_files("utils/*.cc") target("all_cases") set_kind("static") - add_includedirs("utils") add_files("all_cases/*.cc") target("raw_code") set_kind("static") - add_includedirs("utils") - add_includedirs("raw_code") - add_includedirs("short_code") - add_includedirs("common_code") add_files("raw_code/*.cc") target("short_code") set_kind("static") - add_includedirs("utils") - add_includedirs("all_cases") - add_includedirs("raw_code") - add_includedirs("short_code") - add_includedirs("common_code") add_includedirs("short_code/offset") add_files("short_code/*.cc") target("common_code") set_kind("static") - add_includedirs("utils") - add_includedirs("raw_code") - add_includedirs("short_code") - add_includedirs("common_code") add_files("common_code/*.cc") target("core") set_kind("static") - add_includedirs("utils") add_files("core/*.cc") target("fast_cal") set_kind("static") - add_includedirs("core") - add_includedirs("utils") - add_includedirs("raw_code") - add_includedirs("short_code") - add_includedirs("common_code") add_files("fast_cal/*.cc") target("analyse") set_kind("static") - add_includedirs("core") - add_includedirs("utils") - add_includedirs("raw_code") - add_includedirs("short_code") - add_includedirs("common_code") add_files("analyse/*.cc") target("benchmark") set_kind("static") - add_includedirs("all_cases") add_files("benchmark/*.cc") +---------------------------------------------------------------- + -- TODO: generate version.h target("klotski") set_kind("static") add_includedirs(".") - add_includedirs("utils") - add_includedirs("all_cases") - add_includedirs("benchmark") - add_includedirs("raw_code") - add_includedirs("short_code") - add_includedirs("common_code") + add_files("ffi/*.cc") add_deps("utils", "all_cases") add_deps("raw_code", "short_code", "common_code") add_deps("core", "fast_cal", "analyse") add_deps("benchmark") - add_files("ffi/*.cc") + + set_configdir("$(scriptdir)/utils") + + set_configvar("COMPILER_INFO", "GNU ...") + set_configvar("BUILD_TIME", "...time...") + + add_configfiles("utils/metadata.h.inx", {filename = "config.h"}) + + -- add_configfiles("config.h.in", {pattern = "@(.-)@"}) + set_policy("build.merge_archive", true) +-- set_targetdir("../../bin/") + +-- os.cp("$(scriptdir)/*.h", "$(scriptdir)/../../bin/") + +----------------------------------------------------------------