forked from Simple-XX/SimpleKernel
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Zone.N <[email protected]>
- Loading branch information
Showing
3 changed files
with
76 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,59 @@ | ||
|
||
# This file is a part of Simple-XX/SimpleKernel | ||
# (https://github.com/Simple-XX/SimpleKernel). | ||
# | ||
# project_config.cmake for Simple-XX/SimpleKernel. | ||
# 配置信息 | ||
|
||
# 在目标环境搜索 program | ||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
# 在目标环境搜索库文件 | ||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
# 在目标环境搜索头文件 | ||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
SET (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
|
||
# 要运行的平台 | ||
list(APPEND VALID_PLATFORM qemu) | ||
if (NOT DEFINED PLATFORM) | ||
set(PLATFORM qemu) | ||
endif () | ||
message(STATUS "PLATFORM is: ${PLATFORM}") | ||
LIST (APPEND VALID_PLATFORM qemu) | ||
IF(NOT DEFINED PLATFORM) | ||
SET (PLATFORM qemu) | ||
ENDIF() | ||
MESSAGE (STATUS "PLATFORM is: ${PLATFORM}") | ||
# 如果不合法则报错 | ||
if (NOT PLATFORM IN_LIST VALID_PLATFORM) | ||
message(FATAL_ERROR "PLATFORM must be one of ${VALID_PLATFORM}") | ||
endif () | ||
IF(NOT PLATFORM IN_LIST VALID_PLATFORM) | ||
MESSAGE (FATAL_ERROR "PLATFORM must be one of ${VALID_PLATFORM}") | ||
ENDIF() | ||
|
||
# 目标架构 | ||
list(APPEND VALID_CMAKE_SYSTEM_PROCESSOR x86_64 riscv64 aarch64) | ||
LIST (APPEND VALID_CMAKE_SYSTEM_PROCESSOR x86_64 riscv64 aarch64) | ||
# 默认构建 x86_64 | ||
if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR) | ||
set(CMAKE_SYSTEM_PROCESSOR x86_64) | ||
endif () | ||
message(STATUS "CMAKE_SYSTEM_PROCESSOR is: ${CMAKE_SYSTEM_PROCESSOR}") | ||
IF(NOT DEFINED CMAKE_SYSTEM_PROCESSOR) | ||
SET (CMAKE_SYSTEM_PROCESSOR x86_64) | ||
ENDIF() | ||
MESSAGE (STATUS "CMAKE_SYSTEM_PROCESSOR is: ${CMAKE_SYSTEM_PROCESSOR}") | ||
# 如果不合法则报错 | ||
if (NOT CMAKE_SYSTEM_PROCESSOR IN_LIST VALID_CMAKE_SYSTEM_PROCESSOR) | ||
message(FATAL_ERROR "CMAKE_SYSTEM_PROCESSOR must be one of ${VALID_CMAKE_SYSTEM_PROCESSOR}") | ||
endif () | ||
IF(NOT CMAKE_SYSTEM_PROCESSOR IN_LIST VALID_CMAKE_SYSTEM_PROCESSOR) | ||
MESSAGE (FATAL_ERROR "CMAKE_SYSTEM_PROCESSOR must be one of \ | ||
${VALID_CMAKE_SYSTEM_PROCESSOR}") | ||
ENDIF() | ||
|
||
message(STATUS "CMAKE_TOOLCHAIN_FILE is: ${CMAKE_TOOLCHAIN_FILE}") | ||
MESSAGE (STATUS "CMAKE_TOOLCHAIN_FILE is: ${CMAKE_TOOLCHAIN_FILE}") | ||
# 编译器只支持 gnu-gcc 或 clang | ||
if (NOT ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")) | ||
message(FATAL_ERROR "Only support gnu-gcc/clang") | ||
endif () | ||
IF(NOT ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" | ||
MATCHES "Clang")) | ||
MESSAGE (FATAL_ERROR "Only support gnu-gcc/clang") | ||
ENDIF() | ||
|
||
# qemu gdb 调试端口 | ||
if (NOT DEFINED QEMU_GDB_PORT) | ||
set(QEMU_GDB_PORT tcp::1234) | ||
endif () | ||
IF(NOT DEFINED QEMU_GDB_PORT) | ||
SET (QEMU_GDB_PORT tcp::1234) | ||
ENDIF() | ||
|
||
# qemu monitor 参数 | ||
if (NOT DEFINED QEMU_MONITOR_ARG) | ||
set(QEMU_MONITOR_ARG | ||
telnet::2333,server,nowait | ||
) | ||
endif () | ||
IF(NOT DEFINED QEMU_MONITOR_ARG) | ||
SET (QEMU_MONITOR_ARG telnet::2333,server,nowait) | ||
ENDIF() | ||
|
||
# 生成项目配置头文件,传递给代码 | ||
configure_file(${CMAKE_SOURCE_DIR}/tools/project_config.h.in ${CMAKE_SOURCE_DIR}/src/project_config.h @ONLY) | ||
CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/tools/project_config.h.in | ||
${CMAKE_SOURCE_DIR}/src/project_config.h @ONLY) | ||
CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/tools/.pre-commit-config.yaml.in | ||
${CMAKE_SOURCE_DIR}/.pre-commit-config.yaml @ONLY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
fail_fast: false | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v5.0.0 | ||
hooks: | ||
- id: check-case-conflict | ||
- id: check-illegal-windows-names | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: check-symlinks | ||
- id: check-xml | ||
- id: check-yaml | ||
- id: destroyed-symlinks | ||
- id: detect-private-key | ||
- id: end-of-file-fixer | ||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
|
||
- repo: https://github.com/cpp-linter/cpp-linter-hooks | ||
rev: v0.5.1 | ||
hooks: | ||
- id: clang-format | ||
args: | ||
- --style=file | ||
- id: clang-tidy | ||
args: | ||
- --checks=.clang-tidy | ||
- -p=@CMAKE_BINARY_DIR@/compiler_commands.json | ||
- -extra-arg=--std=c++2b | ||
|
||
- repo: https://github.com/koalaman/shellcheck-precommit | ||
rev: v0.10.0 | ||
hooks: | ||
- id: shellcheck | ||
|
||
- repo: https://github.com/cheshirekow/cmake-format-precommit | ||
rev: v0.6.13 | ||
hooks: | ||
- id: cmake-format | ||
- id: cmake-lint |