Skip to content

Commit

Permalink
Merge branch 'v2-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
9chu committed Feb 15, 2024
2 parents 4dbb0ba + 54ce5fa commit 43bd3e3
Show file tree
Hide file tree
Showing 30 changed files with 373 additions and 826 deletions.
66 changes: 0 additions & 66 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,71 +17,10 @@ endif()
set(LSTG_APP_NAME "default" CACHE STRING "Specific the app name, will be used as the folder name in AppData for user data storage")
option(LSTG_PARSE_CMDLINE "Determine whether to parse the command line for advanced options" ON)
option(LSTG_DISABLE_HOT_RELOAD "Disable hot reload support" OFF)
option(LSTG_CROSSCOMPILING_EARLY_BUILD "Enable automatically two-stage build when cross-compiling" ON)
set(LSTG_EARLY_BUILD_GENERATOR "" CACHE STRING "Specific generator when in early build stage")

### 检测平台
include(cmake/Platform.cmake)

### Early build stage
# Early build 阶段用于在 Cross-compiling 情形下生成 native toolset
# https://stackoverflow.com/questions/36084785/building-a-tool-immediately-so-it-can-be-used-later-in-same-cmake-run
set(LSTG_EARLY_BUILD OFF CACHE INTERNAL "Enable for first stage build (for internal usage)")
if(CMAKE_CROSSCOMPILING AND LSTG_CROSSCOMPILING_EARLY_BUILD)
if(NOT LSTG_EARLY_BUILD_COMPLETED)
message(STATUS "[LSTG] Start early build stage")

set(LSTG_EARLY_BUILD_WORKDIR "${CMAKE_CURRENT_BINARY_DIR}/NativeBuild/")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${LSTG_EARLY_BUILD_WORKDIR}")

if(LSTG_EARLY_BUILD_GENERATOR STREQUAL "")
execute_process(COMMAND ${CMAKE_COMMAND}
-E env "CC=" "CXX=" "LD=" # using host default compiler, FIXME: customize?
${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DLSTG_EARLY_BUILD=ON
${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY "${LSTG_EARLY_BUILD_WORKDIR}"
RESULT_VARIABLE EXEC_RET)
else()
execute_process(COMMAND ${CMAKE_COMMAND}
-E env "CC=" "CXX=" "LD=" # using host default compiler, FIXME: customize?
${CMAKE_COMMAND}
-G "${LSTG_EARLY_BUILD_GENERATOR}"
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DLSTG_EARLY_BUILD=ON
${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY "${LSTG_EARLY_BUILD_WORKDIR}"
RESULT_VARIABLE EXEC_RET)
endif()

if(EXEC_RET AND NOT EXEC_RET EQUAL 0)
message(FATAL_ERROR "[LSTG] Generate early build cmake failed")
endif()

execute_process(COMMAND ${CMAKE_COMMAND}
--build . -j
WORKING_DIRECTORY "${LSTG_EARLY_BUILD_WORKDIR}"
RESULT_VARIABLE EXEC_RET)
if(EXEC_RET AND NOT EXEC_RET EQUAL 0)
message(FATAL_ERROR "[LSTG] Early build failed")
endif()

# 设置 Early build 完成
set(LSTG_EARLY_BUILD_COMPLETED ON CACHE INTERNAL
"Determine if first stage build finished (for internal usage)")
set(LSTG_EARLY_BUILD_BINARY_DIR "${LSTG_EARLY_BUILD_WORKDIR}" CACHE INTERNAL
"First stage build directory (for internal usage)")
else()
message(STATUS "[LSTG] Using cached early build")

set(LSTG_EARLY_BUILD_WORKDIR "${LSTG_EARLY_BUILD_BINARY_DIR}")
endif()

# 引用工具
set(IcuBuildTools_DIR "${LSTG_EARLY_BUILD_WORKDIR}")
endif()

### 全局编译选项(影响包含第三方库)
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
Expand Down Expand Up @@ -126,11 +65,6 @@ add_subdirectory(tool/PerfectHashTool)
### 第三方依赖
include(cmake/External.cmake)

if(LSTG_EARLY_BUILD)
# Early build 阶段仅执行到工具生成为止
return()
endif()

### 工程配置

# 全局编译选项
Expand Down
10 changes: 4 additions & 6 deletions COPYRIGHT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,10 @@ Comment: https://github.com/nlohmann/json
Copyright: 2013-2022, Niels Lohmann.
License: Expat

Files: ./*/_deps/ryu-src/
Comment: https://github.com/ulfjack/ryu
Copyright: Ulf Adams.
Stephan T. Lavavej.
Alexander Bolz.
License: Boost-1
Files: ./*/_deps/double-conversion-src/
Comment: https://github.com/google/double-conversion
Copyright: Copyright 2012 the V8 project authors.
License: BSD-3-clause

Files: ./*/_deps/sdl2-src/
Comment: https://github.com/libsdl-org/SDL
Expand Down
Loading

0 comments on commit 43bd3e3

Please sign in to comment.