Skip to content

Commit c1e0ad2

Browse files
author
root
committed
[ENHANCE] Some Changes.
1 parent aaa2c01 commit c1e0ad2

File tree

14 files changed

+113
-88
lines changed

14 files changed

+113
-88
lines changed

.github/workflows/ci-auto-format-and-commit.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ jobs:
2929
- name: Install formatter
3030
shell: bash
3131
run: |
32-
wget https://apt.llvm.org/llvm.sh && sudo bash ./llvm.sh 20 && rm ./llvm.sh
33-
sudo apt-get install clang-format-20
34-
sudo ln -sf $(which clang-format-20) /usr/bin/clang-format
32+
wget https://apt.llvm.org/llvm.sh && sudo bash ./llvm.sh 19 && rm ./llvm.sh
33+
sudo apt-get install clang-format-19
34+
sudo ln -sf $(which clang-format-19) /usr/bin/clang-format
3535
python -m pip install black
3636
3737
- name: Run format script
3838
shell: bash
3939
run: |
40-
bash ./.templates/common/scripts/format.sh -cxx -py --clang-format-config=./.templates/common/.clang-format
40+
bash ./.templates/common/scripts/format.sh -cxx -py \
41+
--clang-format-config=./.templates/common/.clang-format
4142
4243
- name: Check for Uncommitted Changes
4344
shell: bash

.templates/common/.clangd

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
CompileFlags:
22
Add:
3-
- -Wall
4-
- -Wextra
53
- --cuda-path=<path-to-cuda>
64
- --no-cuda-version-check
75
Remove:
@@ -20,9 +18,13 @@ CompileFlags:
2018
- -fmodule-mapper*
2119
- -fdeps-format*
2220

21+
Index:
22+
Background: Build
23+
StandardLibrary: Yes
24+
2325
Diagnostics:
24-
UnusedIncludes: Strict
25-
MissingIncludes: Strict
26+
UnusedIncludes: None
27+
MissingIncludes: None
2628

2729
ClangTidy:
2830
Add: [
@@ -36,17 +38,19 @@ Diagnostics:
3638
readability-isolate-declaration,
3739
readability-identifier-length,
3840
readability-magic-numbers,
41+
readability-function-cognitive-complexity,
42+
modernize-avoid-c-arrays,
43+
readability-math-missing-parentheses,
3944
]
4045

4146
CheckOptions:
42-
readability-identifier-naming.VariableCase: lowerCamelCase
43-
readability-identifier-naming.ProtectedMemberCase: lowerCamelCase
44-
readability-identifier-naming.PrivateMemberCase: lowerCamelCase
45-
readability-identifier-naming.PublicMemberCase: lowerCamelCase
47+
readability-identifier-naming.VariableCase: aNy_CasE
48+
readability-identifier-naming.ProtectedMemberCase: aNy_CasE
49+
readability-identifier-naming.PrivateMemberCase: aNy_CasE
50+
readability-identifier-naming.PublicMemberCase: aNy_CasE
4651
readability-identifier-naming.NamespaceCase: lower_case
47-
readability-identifier-naming.EnumCase: lowerCamelCase
52+
readability-identifier-naming.EnumCase: camelBack
4853
readability-identifier-naming.ClassCase: CamelCase
4954
readability-identifier-naming.StructCase: CamelCase
50-
readability-identifier-naming.FunctionCase: lowerCamelCase
51-
readability-identifier-naming.ClassMethodCase: lowerCamelCase
52-
readability-identifier-naming.MethodCase: lowerCamelCase
55+
readability-identifier-naming.FunctionCase: camelBack
56+
readability-identifier-naming.ClassMethodCase: camelBack

.templates/common/.github/workflows/ci-auto-format-and-commit.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,31 @@ jobs:
2121
# You should add a Personal Access Token (PAT) to the repository secrets
2222
token: ${{ secrets.PAT || github.token }}
2323

24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.12"
28+
2429
- name: Install formatter
30+
shell: bash
31+
# [TODO] It seems like ubuntu-latest (24.04) in github actions does not
32+
# have llvm-20 in the apt repository yet. I will change the
33+
# version to 20 when it is available.
2534
run: |
26-
sudo apt-get install clang-format
35+
wget https://apt.llvm.org/llvm.sh
36+
sudo chmod +x ./llvm.sh && sudo ./llvm.sh 19 && rm ./llvm.sh
37+
sudo apt-get update
38+
sudo apt-get install clang-format-19
39+
sudo ln -sf $(which clang-format-19) /usr/bin/clang-format
40+
python -m pip install black
2741
2842
- name: Run format script
29-
run: bash ./scripts/format.sh -cxx
43+
shell: bash
44+
run: |
45+
bash ./scripts/format.sh -cxx -py --clang-format-config=.clang-format
3046
3147
- name: Check for Uncommitted Changes
48+
shell: bash
3249
id: format_check
3350
run: |
3451
# Check if clang-format introduced any changes
@@ -41,9 +58,10 @@ jobs:
4158
fi
4259
4360
- name: Commit and Push to main
61+
shell: bash
4462
if : ${{ steps.format_check.outputs.format_status == 'fail' }}
4563
run: |
4664
git config user.name "github-actions[bot]"
4765
git config user.email "github-actions[bot]@users.noreply.github.com"
48-
git commit -am "[skip ci] Auto-format code with clang-format"
66+
git commit -am "[skip ci] Auto-format code with clang-format and black"
4967
git push origin main

.templates/common/.vscode/extensions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"recommendations": [
33
"llvm-vs-code-extensions.vscode-clangd", // clangd
44
"twxs.cmake", // cmake
5+
"josetr.cmake-language-support-vscode",
56
"ms-vscode.cpptools", // C/C++
7+
"ms-python.python", // Python
8+
"ms-python.black-formatter", // Python formatter
9+
"njpwerner.autodocstring", // Python docstring generator
610
]
711
}
Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
{
2-
"editor.formatOnPaste": true,
3-
"editor.formatOnType": true,
2+
"cmake.configureOnOpen": false,
3+
"cmake.showOptionsMovedNotification": false,
4+
"cmake.automaticReconfigure": false,
5+
"cmake.configureOnEdit": false,
6+
"cmake.pinnedCommands": [
7+
"workbench.action.tasks.configureTaskRunner",
8+
"workbench.action.tasks.runTask"
9+
],
10+
"cmake.showConfigureWithDebuggerNotification": false,
11+
"cmake.touchbar.visibility": "hidden",
412
"C_Cpp.errorSquiggles": "disabled",
513
"C_Cpp.intelliSenseEngineFallback": "disabled",
614
"C_Cpp.intelliSenseEngine": "disabled",
7-
"C_Cpp.default.compileCommands": "${workspaceFolder}/compile_commands.json",
15+
"C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json",
16+
"[cpp]": {
17+
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
18+
},
819
"clangd.path": "clangd",
920
"clangd.arguments": [
1021
"--compile-commands-dir=${workspaceFolder}/build",
@@ -14,11 +25,13 @@
1425
"--all-scopes-completion",
1526
"--completion-style=bundled",
1627
"--cross-file-rename",
17-
"--header-insertion=iwyu",
18-
"--header-insertion-decorators",
28+
"--header-insertion=never",
1929
"--background-index",
20-
// "-j=6",
30+
"-j=12",
2131
"--pch-storage=memory",
2232
"--function-arg-placeholders=false",
2333
],
34+
"black-formatter.args": [
35+
"--line-length=79"
36+
]
2437
}

.templates/common/cmake/compilers/cuda-compiler-configs.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# - `CMAKE_CUDA_STANDARD`: CUDA Standard. Default: 20.
88
# ==================================================================================================
99

10-
include(${PROJECT_SOURCE_DIR}/cmake/utils/logging.cmake)
10+
include(${CMAKE_CURRENT_LIST_DIR}/../utils/logging.cmake)
1111

1212
enable_language(CUDA)
1313

@@ -22,6 +22,6 @@ set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
2222
set(CMAKE_CUDA_ARCHITECTURES native)
2323
log_info("CMAKE_CUDA_STANDARD: ${CMAKE_CUDA_STANDARD}")
2424

25-
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr")
26-
set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE} -O3")
27-
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -lineinfo")
25+
string(APPEND CMAKE_CUDA_FLAGS " --expt-relaxed-constexpr")
26+
string(APPEND CMAKE_CUDA_FLAGS_RELEASE " -O3")
27+
string(APPEND CMAKE_CUDA_FLAGS_DEBUG " -lineinfo")

.templates/common/cmake/compilers/cxx-compiler-configs.cmake

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@
1111

1212
include(${PROJECT_SOURCE_DIR}/cmake/utils/common.cmake)
1313

14-
set_default_values(CMAKE_CXX_SCAN_FOR_MODULES OFF)
1514
enable_language(CXX)
15+
set_default_values(
16+
CMAKE_EXPORT_COMPILE_COMMANDS ON
17+
CMAKE_CXX_STANDARD 20
18+
CMAKE_CXX_STANDARD_REQUIRED ON
19+
CMAKE_CXX_SCAN_FOR_MODULES OFF
20+
STACK_SIZE 1048576
21+
)
1622

17-
# Generate compile_commands.json in build directory
18-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
19-
20-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2123
log_info("CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD}")
22-
23-
# Set stack size
24-
if(NOT DEFINED STACK_SIZE)
25-
set(STACK_SIZE 1048576) # 1MB by default
26-
endif()
24+
log_info("CMAKE_CXX_SCAN_FOR_MODULES: ${CMAKE_CXX_SCAN_FOR_MODULES}")
25+
log_info("STACK_SIZE: ${STACK_SIZE}")
2726

2827
# Compiler flags for MSVC
2928
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
@@ -54,8 +53,8 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
5453
else()
5554
string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-zstack-size=${STACK_SIZE}")
5655
endif()
57-
# @todo @jamesnulliu
58-
# |- Add compiler flags for other compilers
56+
# [TODO] @jamesnulliu
57+
# Support more compilers
5958
else()
6059
log_fatal("Unsupported compiler")
6160
endif()

.templates/common/cmake/libraries/libcuda.cmake

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@
33
# @see "https://cliutils.gitlab.io/modern-cmake/chapters/packages/CUDA.html"
44
#
55
# @note Several parameters should be set before including this file:
6-
# - [ENV]{CUDA_HOME}/[ENV]{CUDA_DIR}:
6+
# - CUDA_HOME/CUDA_DIR/ENV{CUDA_HOME}/ENV{CUDA_DIR}:
77
# Path to spdlog libaray installation path.
88
# ==================================================================================================
99

10-
include(${PROJECT_SOURCE_DIR}/cmake/utils/common.cmake)
10+
include(${CMAKE_CURRENT_LIST_DIR}/../utils/common.cmake)
1111

1212
try_get_value(CUDA_HOME HINTS CUDA_HOME CUDA_DIR)
1313
if (NOT CUDA_HOME_FOUND)
14-
log_error("ENV:CUDA_HOME is not set.")
14+
log_error("CUDA_HOME not set.")
1515
endif()
1616

1717
# Append the path to the CMAKE_PREFIX_PATH
18-
set(CUDA_CMAKE_PREFIX_PATH "$CUDA_HOME/lib64/cmake")
18+
set(CUDA_CMAKE_PREFIX_PATH "${CUDA_HOME}/lib64/cmake")
1919
list(APPEND CMAKE_PREFIX_PATH ${CUDA_CMAKE_PREFIX_PATH})
2020

2121
# Find the CUDA package
22-
# @see
23-
# |- All imported targets:
24-
# |- "https://cmake.org/cmake/help/git-stage/module/FindCUDAToolkit.html#imported-targets"
25-
find_package(CUDAToolkit REQUIRED)
22+
# [SEE] All imported targets: https://cmake.org/cmake/help/git-stage/module/FindCUDAToolkit.html#imported-targets
23+
find_package(CUDAToolkit REQUIRED)

.templates/common/cmake/libraries/libpython.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @see "https://cmake.org/cmake/help/latest/module/FindPython.html"
1+
# [SEE] https://cmake.org/cmake/help/latest/module/FindPython.html
22
find_package(
33
Python
44
REQUIRED

.templates/common/cmake/libraries/libspdlog.cmake

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)