Browse Source

build: update xmake script

legacy
Dnomd343 2 years ago
parent
commit
7abd6fb670
  1. 2
      .gitignore
  2. 7
      src/klotski_core/CMakeLists.txt
  3. 2
      src/klotski_core/ffi/metadata.cc
  4. 4
      src/klotski_core/utils/metadata.h.in
  5. 15
      src/klotski_core/utils/metadata.h.inx
  6. 78
      src/klotski_core/xmake.lua

2
.gitignore

@ -5,4 +5,4 @@
/cmake-build-debug/ /cmake-build-debug/
/cmake-build-release/ /cmake-build-release/
/src/rust_ffi/target/ /src/rust_ffi/target/
/src/klotski_core/utils/version.h /src/klotski_core/utils/metadata.h

7
src/klotski_core/CMakeLists.txt

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_STANDARD 14) 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}") set(COMPILER_INFO "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
configure_file( configure_file(
utils/version.h.in ${PROJECT_SOURCE_DIR}/utils/metadata.h.in
${PROJECT_SOURCE_DIR}/utils/version.h ${PROJECT_SOURCE_DIR}/utils/metadata.h
) )
################################################################################ ################################################################################
include_directories(utils) include_directories(utils)

2
src/klotski_core/ffi/metadata.cc

@ -1,5 +1,5 @@
#include "klotski.h" #include "klotski.h"
#include "version.h" #include "metadata.h"
int get_version_major() { int get_version_major() {
return VERSION_MAJOR; return VERSION_MAJOR;

4
src/klotski_core/utils/version.h.in → src/klotski_core/utils/metadata.h.in

@ -1,9 +1,11 @@
#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_PATCH@)
#define VERSION_STR "v@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@" #define VERSION_STR "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@"
#define AUTHOR "dnomd343" #define AUTHOR "dnomd343"
#define SYSTEM "@SYSTEM_INFO@" #define SYSTEM "@SYSTEM_INFO@"

15
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}"

78
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") target("utils")
set_kind("static") set_kind("static")
add_files("utils/*.cc") add_files("utils/*.cc")
target("all_cases") target("all_cases")
set_kind("static") set_kind("static")
add_includedirs("utils")
add_files("all_cases/*.cc") add_files("all_cases/*.cc")
target("raw_code") target("raw_code")
set_kind("static") set_kind("static")
add_includedirs("utils")
add_includedirs("raw_code")
add_includedirs("short_code")
add_includedirs("common_code")
add_files("raw_code/*.cc") add_files("raw_code/*.cc")
target("short_code") target("short_code")
set_kind("static") 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_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("static")
add_includedirs("utils")
add_includedirs("raw_code")
add_includedirs("short_code")
add_includedirs("common_code")
add_files("common_code/*.cc") add_files("common_code/*.cc")
target("core") target("core")
set_kind("static") set_kind("static")
add_includedirs("utils")
add_files("core/*.cc") add_files("core/*.cc")
target("fast_cal") target("fast_cal")
set_kind("static") 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") add_files("fast_cal/*.cc")
target("analyse") target("analyse")
set_kind("static") 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") add_files("analyse/*.cc")
target("benchmark") target("benchmark")
set_kind("static") set_kind("static")
add_includedirs("all_cases")
add_files("benchmark/*.cc") add_files("benchmark/*.cc")
----------------------------------------------------------------
-- TODO: generate version.h -- TODO: generate version.h
target("klotski") target("klotski")
set_kind("static") set_kind("static")
add_includedirs(".") add_includedirs(".")
add_includedirs("utils") add_files("ffi/*.cc")
add_includedirs("all_cases")
add_includedirs("benchmark")
add_includedirs("raw_code")
add_includedirs("short_code")
add_includedirs("common_code")
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")
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_policy("build.merge_archive", true)
-- set_targetdir("../../bin/")
-- os.cp("$(scriptdir)/*.h", "$(scriptdir)/../../bin/")
----------------------------------------------------------------

Loading…
Cancel
Save