Browse Source

build: xmake metadata template

legacy
Dnomd343 2 years ago
parent
commit
d583a09cb2
  1. 13
      src/klotski_core/CMakeLists.txt
  2. 12
      src/klotski_core/utils/metadata.h.in
  3. 15
      src/klotski_core/utils/metadata.h.inx
  4. 59
      src/klotski_core/xmake.lua

13
src/klotski_core/CMakeLists.txt

@ -18,18 +18,19 @@ macro(git_commit_id _hash)
endif() endif()
endmacro() endmacro()
set(GIT_COMMIT_ID "") set(GIT_COMMIT_LONG "")
git_commit_id(GIT_COMMIT_ID) git_commit_id(GIT_COMMIT_LONG)
string(TIMESTAMP BUILD_TIME "%Y-%m-%d %H:%M:%S") set(PLAT "${CMAKE_SYSTEM_NAME}")
set(ARCH "${CMAKE_SYSTEM_PROCESSOR}")
set(VERSION_MAJOR ${klotski-core_VERSION_MAJOR}) set(VERSION_MAJOR ${klotski-core_VERSION_MAJOR})
set(VERSION_MINOR ${klotski-core_VERSION_MINOR}) set(VERSION_MINOR ${klotski-core_VERSION_MINOR})
set(VERSION_PATCH ${klotski-core_VERSION_PATCH}) set(VERSION_ALTER ${klotski-core_VERSION_PATCH})
set(SYSTEM_INFO "${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR}") string(TIMESTAMP BUILD_TIME "%Y-%m-%d %H:%M:%S")
set(COMPILER_INFO "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") set(COMPILER "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
configure_file( configure_file(
${PROJECT_SOURCE_DIR}/utils/metadata.h.in ${PROJECT_SOURCE_DIR}/utils/metadata.h.in

12
src/klotski_core/utils/metadata.h.in

@ -1,15 +1,13 @@
#pragma once #pragma once
/// CMake metadata template
#define VERSION_MAJOR (@VERSION_MAJOR@) #define VERSION_MAJOR (@VERSION_MAJOR@)
#define VERSION_MINOR (@VERSION_MINOR@) #define VERSION_MINOR (@VERSION_MINOR@)
#define VERSION_PATCH (@VERSION_PATCH@) #define VERSION_PATCH (@VERSION_ALTER@)
#define VERSION_STR "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@" #define VERSION_STR "v@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_ALTER@"
#define AUTHOR "dnomd343" #define AUTHOR "dnomd343"
#define SYSTEM "@SYSTEM_INFO@" #define SYSTEM "@PLAT@ @ARCH@"
#define COMPILER "@COMPILER_INFO@" #define COMPILER "@COMPILER@"
#define BUILD_TIME "@BUILD_TIME@" #define BUILD_TIME "@BUILD_TIME@"
#define PROJECT_URL "https://github.com/dnomd343/klotski.git" #define PROJECT_URL "https://github.com/dnomd343/klotski.git"
#define GIT_COMMIT_ID "@GIT_COMMIT_ID@" #define GIT_COMMIT_ID "@GIT_COMMIT_LONG@"

15
src/klotski_core/utils/metadata.h.inx

@ -1,15 +0,0 @@
#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}"

59
src/klotski_core/xmake.lua

@ -1,11 +1,12 @@
set_xmakever("2.0.0") ----------------------------------------------------------------
set_version("0.1.2") set_xmakever("2.5.3")
set_project("klotski-core")
set_version("0.1.2")
set_languages("cxx14") set_languages("cxx14")
set_optimize("fastest") set_optimize("fastest")
set_warnings("everything") set_warnings("everything")
---------------------------------------------------------------- ----------------------------------------------------------------
@ -26,67 +27,73 @@ add_includedirs("benchmark")
---------------------------------------------------------------- ----------------------------------------------------------------
target("utils") target("utils")
set_kind("static") set_kind("object")
add_files("utils/*.cc") add_files("utils/*.cc")
target("all_cases") target("all_cases")
set_kind("static") set_kind("object")
add_files("all_cases/*.cc") add_files("all_cases/*.cc")
target("raw_code") target("raw_code")
set_kind("static") set_kind("object")
add_files("raw_code/*.cc") add_files("raw_code/*.cc")
target("short_code") target("short_code")
set_kind("static") set_kind("object")
add_includedirs("short_code/offset") add_includedirs("short_code/offset")
add_files("short_code/*.cc") add_files("short_code/*.cc")
target("common_code") target("common_code")
set_kind("static") set_kind("object")
add_files("common_code/*.cc") add_files("common_code/*.cc")
target("core") target("core")
set_kind("static") set_kind("object")
add_files("core/*.cc") add_files("core/*.cc")
target("fast_cal") target("fast_cal")
set_kind("static") set_kind("object")
add_files("fast_cal/*.cc") add_files("fast_cal/*.cc")
target("analyse") target("analyse")
set_kind("static") set_kind("object")
add_files("analyse/*.cc") add_files("analyse/*.cc")
target("benchmark") target("benchmark")
set_kind("static") set_kind("object")
add_files("benchmark/*.cc") add_files("benchmark/*.cc")
---------------------------------------------------------------- ----------------------------------------------------------------
-- TODO: generate version.h target("klotski-ffi")
set_kind("object")
add_includedirs(".")
add_files("ffi/*.cc")
set_configvar("COMPILER", "GCC ...")
set_configvar("BUILD_TIME", "...time...")
set_configdir("$(projectdir)/utils")
add_configfiles("utils/metadata.h.in", {
filename = "metadata.h", pattern = "@(.-)@"
})
----------------------------------------------------------------
target("klotski") target("klotski")
set_kind("static") set_kind("static")
add_includedirs(".")
add_files("ffi/*.cc") add_deps("klotski-ffi")
add_deps("utils", "all_cases") add_deps("utils", "all_cases")
add_deps("raw_code", "short_code", "common_code") add_deps("raw_code", "short_code", "common_code")
add_deps("core", "fast_cal", "analyse") add_deps("core", "fast_cal", "analyse")
add_deps("benchmark") add_deps("benchmark")
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_policy("build.merge_archive", true)
-- set_targetdir("../../bin/") set_targetdir("$(projectdir)/../../bin/")
-- os.cp("$(scriptdir)/*.h", "$(scriptdir)/../../bin/") after_build(function (target)
os.cp("$(projectdir)/klotski.h", "$(projectdir)/../../bin/")
end)
---------------------------------------------------------------- ----------------------------------------------------------------

Loading…
Cancel
Save