Skip to content

Commit f0773ab

Browse files
Merge pull request #21 from FrozenLemonTee/pre-0.1.6
Pre 0.1.6
2 parents 6e85f2b + 27426a4 commit f0773ab

98 files changed

Lines changed: 5851 additions & 592 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gdbinit

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set unwind-on-signal on
2+
set pagination off
3+
python
4+
import sys
5+
import os
6+
sys.path.insert(0, os.path.join(os.getcwd(), 'debug'))
7+
import gdbinit
8+
print("GDB pretty-printer for original initialized.")
9+
end

.github/workflows/basic-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
name: Test Branch CI - Basic Tests
44

55
on:
6-
push:
6+
pull_request:
77
branches: [ test ]
88

99
jobs:

.github/workflows/deploy-docs-latest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88

99
jobs:
1010
build-and-deploy:
11+
if: github.repository == 'FrozenLemonTee/original'
1112
runs-on: ubuntu-latest
1213

1314
steps:

.github/workflows/deploy-docs-stable.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ name: Deploy Documentation - Stable
55
on:
66
push:
77
branches: [ master ]
8+
tags:
9+
- 'v*.*.*'
810

911
jobs:
1012
build-and-deploy:
13+
if: github.repository == 'FrozenLemonTee/original'
1114
runs-on: ubuntu-latest
1215

1316
steps:

.github/workflows/deploy-docs-tags.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99

1010
jobs:
1111
build-and-deploy:
12+
if: github.repository == 'FrozenLemonTee/original'
1213
runs-on: ubuntu-latest
1314

1415
steps:

.github/workflows/full-tests.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
5757
- name: Run tests
5858
run: |
59-
cd build && ctest --output-on-failure
59+
cd build && ctest --verbose --output-on-failure
6060
6161
windows-tests:
6262
runs-on: windows-latest
@@ -75,4 +75,32 @@ jobs:
7575
7676
- name: Run tests
7777
run: |
78-
cd build && ctest -C ${{ matrix.build_type }} --output-on-failure
78+
cd build && ctest --verbose -C ${{ matrix.build_type }} --output-on-failure
79+
80+
macos-tests:
81+
runs-on: macos-latest
82+
continue-on-error: true
83+
strategy:
84+
matrix:
85+
build_type: [ Debug, Release ]
86+
87+
steps:
88+
- name: Checkout
89+
uses: actions/checkout@v4
90+
91+
- name: Install dependencies
92+
run: |
93+
brew update
94+
brew install cmake ninja
95+
96+
- name: Configure and Build
97+
run: |
98+
export CC=clang
99+
export CXX=clang++
100+
101+
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -G Ninja
102+
cmake --build build --config ${{ matrix.build_type }}
103+
104+
- name: Run tests
105+
run: |
106+
cd build && ctest --verbose --output-on-failure

.gitignore

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
cmake-build-debug/
2-
.idea/
3-
test.exe
4-
original.zip
5-
original.rar
1+
cmake-build-*/
2+
**/.idea/
63
build/
74
install/
85
.vs/
6+
.vscode/
97
out/
10-
original/
8+
original/
9+
**/__pycache__/
10+
.cache/
11+
12+
test.exe
13+
original.zip
14+
original.rar
15+
src/.DS_Store

CMakeLists.txt

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,53 @@
11
# CMakeLists.txt Main
22

3-
cmake_minimum_required(VERSION 3.31)
3+
set(CMAKE_VERSION_MINIMUM 3.31)
4+
cmake_minimum_required(VERSION ${CMAKE_VERSION_MINIMUM})
5+
message(STATUS "Cmake version: ${CMAKE_VERSION} (>= ${CMAKE_VERSION_MINIMUM} ✓)")
6+
if(CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES "Ninja Multi-Config")
7+
set(CMAKE_GENERATOR_PLATFORM x64 CACHE STRING "Platform" FORCE)
8+
endif()
49
project(original LANGUAGES CXX)
5-
set(ORIGINAL_VERSION 0.1.5)
10+
set(ORIGINAL_VERSION 0.1.6)
611
set(CMAKE_CXX_STANDARD 23)
712
set(CMAKE_CXX_STANDARD_REQUIRED True)
13+
set(CMAKE_CXX_EXTENSIONS OFF)
14+
15+
find_package(Threads REQUIRED)
16+
17+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
18+
set(COMPILER_GCC_VERSION_MINIMUM 13.0)
19+
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${COMPILER_GCC_VERSION_MINIMUM})
20+
message(FATAL_ERROR "GCC version too old. Minimum required: ${COMPILER_GCC_VERSION_MINIMUM}. Current: ${CMAKE_CXX_COMPILER_VERSION}")
21+
else()
22+
message(STATUS "GCC version: ${CMAKE_CXX_COMPILER_VERSION} (>= ${COMPILER_GCC_VERSION_MINIMUM} ✓)")
23+
endif()
24+
endif()
25+
26+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
27+
set(COMPILER_CLANG_VERSION_MINIMUM 20.0)
28+
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${COMPILER_CLANG_VERSION_MINIMUM})
29+
message(FATAL_ERROR "Clang version too old. Minimum required: ${COMPILER_CLANG_VERSION_MINIMUM}. Current: ${CMAKE_CXX_COMPILER_VERSION}")
30+
else()
31+
message(STATUS "Clang version: ${CMAKE_CXX_COMPILER_VERSION} (>= ${COMPILER_CLANG_VERSION_MINIMUM} ✓)")
32+
endif()
33+
endif()
34+
if(MSVC)
35+
set(COMPILER_MSVC_VERSION_MINIMUM 1944)
36+
if(MSVC_VERSION LESS ${COMPILER_MSVC_VERSION_MINIMUM})
37+
message(FATAL_ERROR "MSVC version too old. Minimum required: ${COMPILER_MSVC_VERSION_MINIMUM}. Current: ${MSVC_VERSION}")
38+
else()
39+
message(STATUS "MSVC version: ${MSVC_VERSION} (>= ${COMPILER_MSVC_VERSION_MINIMUM} ✓)")
40+
endif()
41+
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION "10.0" CACHE STRING "Windows Target Platform Version")
42+
endif()
43+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
44+
include(CheckCXXCompilerFlag)
45+
check_cxx_compiler_flag("-std=c++23" HAS_CXX23_FLAG)
46+
if(NOT HAS_CXX23_FLAG)
47+
message(WARNING "Compiler may not fully support C++23 standard")
48+
endif()
49+
endif()
50+
851
if (NOT CMAKE_BUILD_TYPE)
952
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type (default Release)" FORCE)
1053
endif()
@@ -20,6 +63,7 @@ file(GLOB ORIGINAL_HEADERS
2063
"${ORIGINAL_SRC_DIR}/vibrant/*.h"
2164
)
2265
add_library(original STATIC ${ORIGINAL_HEADERS} src/original.cpp)
66+
target_link_libraries(original PUBLIC Threads::Threads)
2367

2468
target_include_directories(original PUBLIC
2569
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
@@ -69,24 +113,12 @@ install(FILES
69113
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/original
70114
)
71115

116+
add_subdirectory(debug)
117+
72118
option(BUILD_TESTING "Build the testing directories" ON)
73119

74120
if (BUILD_TESTING)
75121
include(CTest)
76-
if(MSVC)
77-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi")
78-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Zi")
79-
else()
80-
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
81-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g")
82-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -g")
83-
else()
84-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
85-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
86-
endif()
87-
endif()
88-
89-
# test cases
90-
add_subdirectory(test/other)
91-
add_subdirectory(test/unit_test)
122+
enable_testing()
123+
add_subdirectory(test)
92124
endif ()

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ Original是一个C++基础工具库,也是本人的第一个正式项目,用
99
## 文档
1010
[文档-Original](https://documents-original.vercel.app/)
1111

12+
## 环境要求
13+
14+
为了编译和使用 Original,请确保开发环境满足以下最低版本要求:
15+
16+
- **C++ 标准**: C++23
17+
- **CMake**: 3.31 或更高版本
18+
- **编译器**(任选其一):
19+
- **GCC**: 13.0 或更高版本
20+
- **Clang**: 20.0 或更高版本
21+
- **MSVC**(Visual Studio 2022):17.10 (版本 14.44.35207) 或更高版本
22+
23+
> 注意:如果使用 GCC 或 Clang,请确保支持 `-std=c++23` 标志。
24+
1225
## 安装
1326

1427
这里以项目`hello_original`为例:
@@ -21,7 +34,7 @@ Original是一个C++基础工具库,也是本人的第一个正式项目,用
2134

2235
配置`CMakeLists.txt`
2336
```cmake
24-
cmake_minimum_required(VERSION 3.30)
37+
cmake_minimum_required(VERSION 3.31)
2538
project(hello_original)
2639
2740
set(CMAKE_CXX_STANDARD 23)
@@ -60,7 +73,7 @@ cmake -P install.cmake
6073

6174
配置`CMakeLists.txt`
6275
```cmake
63-
cmake_minimum_required(VERSION 3.30)
76+
cmake_minimum_required(VERSION 3.31)
6477
project(hello_original)
6578
6679
set(CMAKE_CXX_STANDARD 23)
@@ -103,7 +116,7 @@ array("hello world!")
103116

104117
##### 容器接口:
105118

106-
格式化输出接口 printable,元素比较接口 comparable,堆对象深拷贝接口 cloneable,可迭代接口 iterable
119+
格式化输出接口 printable,元素比较接口 comparable,堆对象深拷贝接口 cloneable,可迭代接口 iterable,数组视图 arrayView
107120

108121
##### 算法库:
109122

@@ -166,6 +179,10 @@ array("hello world!")
166179

167180
任务包装类 taskBase/task,任务委派器 taskDelegator
168181

182+
##### 协程:
183+
184+
生成器 coroutine::generator
185+
169186
#### matrix
170187

171188
计划实现,包含张量,线性代数工具功能。

debug/CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# debug/CMakeLists.txt
2+
3+
if(CMAKE_BUILD_TYPE MATCHES "Debug")
4+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "MinGW")
5+
message(STATUS "[GDB CONFIG] Detected GNU/MinGW toolchain, setting up GDB auto-load permissions")
6+
7+
if(WIN32)
8+
file(TO_CMAKE_PATH "$ENV{USERPROFILE}" USER_HOME)
9+
else()
10+
file(TO_CMAKE_PATH "$ENV{HOME}" USER_HOME)
11+
endif()
12+
13+
set(GDB_GLOBAL_INIT "${USER_HOME}/.config/gdb/gdbinit")
14+
if(NOT EXISTS "${GDB_GLOBAL_INIT}")
15+
set(GDB_GLOBAL_INIT "${USER_HOME}/.gdbinit")
16+
endif()
17+
18+
set(PROJECT_GDBINIT "${CMAKE_SOURCE_DIR}/.gdbinit")
19+
20+
set(GDB_CONFIG_LINES
21+
"set auto-load local-gdbinit on
22+
add-auto-load-safe-path ${PROJECT_GDBINIT}\n"
23+
)
24+
25+
get_filename_component(GDB_CONFIG_DIR "${GDB_GLOBAL_INIT}" DIRECTORY)
26+
file(MAKE_DIRECTORY "${GDB_CONFIG_DIR}")
27+
28+
if(EXISTS "${GDB_GLOBAL_INIT}")
29+
file(READ "${GDB_GLOBAL_INIT}" EXISTING_CONTENT)
30+
string(FIND "${EXISTING_CONTENT}" "${PROJECT_GDBINIT}" ALREADY_ADDED)
31+
else()
32+
set(ALREADY_ADDED -1)
33+
endif()
34+
35+
if(ALREADY_ADDED EQUAL -1)
36+
file(APPEND "${GDB_GLOBAL_INIT}" "\n# Added by Original CMake auto-config\n${GDB_CONFIG_LINES}")
37+
message(STATUS "[GDB CONFIG] Added safe-path for ${PROJECT_GDBINIT} in ${GDB_GLOBAL_INIT}")
38+
else()
39+
message(STATUS "[GDB CONFIG] Safe-path already configured in ${GDB_GLOBAL_INIT}")
40+
endif()
41+
endif()
42+
endif()

0 commit comments

Comments
 (0)