Skip to content

Commit 63c919d

Browse files
authored
Merge branch 'master' into pathfinder_history
2 parents 8d216b9 + cfeb492 commit 63c919d

File tree

30 files changed

+1194
-1014
lines changed

30 files changed

+1194
-1014
lines changed

.github/PULL_REQUEST_TEMPLATES/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
- [ ] I have read the [contribution guide](doc/contributing.md)
77
- [ ] I have added my info to [copying.md](copying.md) (only first time contributors)
8-
- [ ] I have run `make checkall` and fixed all mentioned problems
8+
- [ ] I have run `make checkmerge` and fixed all mentioned problems
99

1010

1111
### Description

.github/workflows/ubuntu-24.04.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Build openage
4242
run: |
4343
sudo docker run --rm -v "$(pwd)":/mnt/openage -w /mnt/openage openage-devenv:latest \
44-
bash -c 'mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=$(which gcc-11) -DCMAKE_CXX_COMPILER=$(which g++-11) -DCMAKE_CXX_FLAGS='' -DCMAKE_EXE_LINKER_FLAGS='' -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_MODULE_LINKER_FLAGS='' -DCMAKE_SHARED_LINKER_FLAGS='' -DDOWNLOAD_NYAN=YES -DCXX_OPTIMIZATION_LEVEL=auto -DCXX_SANITIZE_FATAL=False -DCXX_SANITIZE_MODE=none -DWANT_BACKTRACE=if_available -DWANT_GPERFTOOLS_PROFILER=if_available -DWANT_GPERFTOOLS_TCMALLOC=False -DWANT_INOTIFY=if_available -DWANT_NCURSES=if_available -DWANT_OPENGL=if_available -DWANT_VULKAN=if_available -G Ninja .. && cmake --build . --parallel $(nproc) -- -k1'
44+
bash -c 'mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=$(which gcc) -DCMAKE_CXX_COMPILER=$(which g++) -DCMAKE_CXX_FLAGS='' -DCMAKE_EXE_LINKER_FLAGS='' -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_MODULE_LINKER_FLAGS='' -DCMAKE_SHARED_LINKER_FLAGS='' -DDOWNLOAD_NYAN=YES -DCXX_OPTIMIZATION_LEVEL=auto -DCXX_SANITIZE_FATAL=False -DCXX_SANITIZE_MODE=none -DWANT_BACKTRACE=if_available -DWANT_GPERFTOOLS_PROFILER=if_available -DWANT_GPERFTOOLS_TCMALLOC=False -DWANT_INOTIFY=if_available -DWANT_NCURSES=if_available -DWANT_OPENGL=if_available -DWANT_VULKAN=if_available -G Ninja .. && cmake --build . --parallel $(nproc) -- -k1'
4545
- name: Compress build artifacts
4646
run: |
4747
mkdir -p /tmp/openage

.github/workflows/windows-server-2019.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ jobs:
5050
$FLEX_PATH = (Get-ChildItem ./download -Recurse -Force -Filter 'win_flex.exe')[0].FullName
5151
mkdir build
5252
cd build
53-
cmake -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TRY_COMPILE_CONFIGURATION=Release -DCMAKE_CXX_FLAGS='/Zc:__cplusplus /permissive- /EHsc' -DCMAKE_EXE_LINKER_FLAGS='' -DCMAKE_MODULE_LINKER_FLAGS='' -DCMAKE_SHARED_LINKER_FLAGS='' -DDOWNLOAD_NYAN=YES -DCXX_OPTIMIZATION_LEVEL=auto -DCXX_SANITIZE_FATAL=False -DCXX_SANITIZE_MODE=none -DWANT_BACKTRACE=if_available -DWANT_GPERFTOOLS_PROFILER=if_available -DWANT_GPERFTOOLS_TCMALLOC=False -DWANT_INOTIFY=if_available -DWANT_NCURSES=if_available -DWANT_OPENGL=if_available -DWANT_VULKAN=if_available -DFLEX_EXECUTABLE="$FLEX_PATH" -G "Visual Studio 16 2019" -A x64 ../source
54-
cmake --build . --config RelWithDebInfo -- -nologo -maxCpuCount
53+
cmake -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TRY_COMPILE_CONFIGURATION=Debug -DCMAKE_CXX_FLAGS='/Zc:__cplusplus /permissive- /EHsc' -DCMAKE_EXE_LINKER_FLAGS='' -DCMAKE_MODULE_LINKER_FLAGS='' -DCMAKE_SHARED_LINKER_FLAGS='' -DDOWNLOAD_NYAN=YES -DCXX_OPTIMIZATION_LEVEL=auto -DCXX_SANITIZE_FATAL=False -DCXX_SANITIZE_MODE=none -DWANT_BACKTRACE=if_available -DWANT_GPERFTOOLS_PROFILER=if_available -DWANT_GPERFTOOLS_TCMALLOC=False -DWANT_INOTIFY=if_available -DWANT_NCURSES=if_available -DWANT_OPENGL=if_available -DWANT_VULKAN=if_available -DFLEX_EXECUTABLE="$FLEX_PATH" -G "Visual Studio 16 2019" -A x64 ../source
54+
cmake --build . --config Debug -- -nologo -maxCpuCount
5555
shell: pwsh
5656
- name: Package
5757
run: |

.github/workflows/windows-server-2022.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ jobs:
5050
$FLEX_PATH = (Get-ChildItem ./download -Recurse -Force -Filter 'win_flex.exe')[0].FullName
5151
mkdir build
5252
cd build
53-
cmake -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TRY_COMPILE_CONFIGURATION=Release -DCMAKE_CXX_FLAGS='/Zc:__cplusplus /permissive- /EHsc' -DCMAKE_EXE_LINKER_FLAGS='' -DCMAKE_MODULE_LINKER_FLAGS='' -DCMAKE_SHARED_LINKER_FLAGS='' -DDOWNLOAD_NYAN=YES -DCXX_OPTIMIZATION_LEVEL=auto -DCXX_SANITIZE_FATAL=False -DCXX_SANITIZE_MODE=none -DWANT_BACKTRACE=if_available -DWANT_GPERFTOOLS_PROFILER=if_available -DWANT_GPERFTOOLS_TCMALLOC=False -DWANT_INOTIFY=if_available -DWANT_NCURSES=if_available -DWANT_OPENGL=if_available -DWANT_VULKAN=if_available -DFLEX_EXECUTABLE="$FLEX_PATH" -G "Visual Studio 17 2022" -A x64 ../source
54-
cmake --build . --config RelWithDebInfo -- -nologo -maxCpuCount
53+
cmake -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TRY_COMPILE_CONFIGURATION=Debug -DCMAKE_CXX_FLAGS='/Zc:__cplusplus /permissive- /EHsc' -DCMAKE_EXE_LINKER_FLAGS='' -DCMAKE_MODULE_LINKER_FLAGS='' -DCMAKE_SHARED_LINKER_FLAGS='' -DDOWNLOAD_NYAN=YES -DCXX_OPTIMIZATION_LEVEL=auto -DCXX_SANITIZE_FATAL=False -DCXX_SANITIZE_MODE=none -DWANT_BACKTRACE=if_available -DWANT_GPERFTOOLS_PROFILER=if_available -DWANT_GPERFTOOLS_TCMALLOC=False -DWANT_INOTIFY=if_available -DWANT_NCURSES=if_available -DWANT_OPENGL=if_available -DWANT_VULKAN=if_available -DFLEX_EXECUTABLE="$FLEX_PATH" -G "Visual Studio 17 2022" -A x64 ../source
54+
cmake --build . --config Debug -- -nologo -maxCpuCount
5555
shell: pwsh
5656
- name: Package
5757
run: |

.mailmap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ Tobias Feldballe <[email protected]> <[email protected]>
2121
Jonas Borchelt <[email protected]>
2222
2323
Nikhil Ghosh <[email protected]>
24-
24+
25+
Ngô Xuân Minh <[email protected]>

Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,26 @@ mrproperer: mrproper
128128
checkfast:
129129
python3 -m buildsystem.codecompliance --fast
130130

131-
.PHONY: checkall
132-
checkall:
133-
python3 -m buildsystem.codecompliance --all
131+
.PHONY: checkmerge
132+
checkmerge:
133+
python3 -m buildsystem.codecompliance --merge
134134

135135
.PHONY: checkchanged
136136
checkchanged:
137-
python3 -m buildsystem.codecompliance --all --only-changed-files=origin/master
137+
python3 -m buildsystem.codecompliance --merge --only-changed-files=origin/master
138138

139139
.PHONY: checkuncommited
140140
checkuncommited:
141-
python3 -m buildsystem.codecompliance --all --only-changed-files=HEAD
141+
python3 -m buildsystem.codecompliance --merge --only-changed-files=HEAD
142142

143143
.PHONY: checkpy
144144
checkpy:
145145
python3 -m buildsystem.codecompliance --pystyle --pylint
146146

147+
.PHONY: checkall
148+
checkall:
149+
python3 -m buildsystem.codecompliance --all
150+
147151
.PHONY: help
148152
help: $(BUILDDIR)/Makefile
149153
@echo "openage Makefile"
@@ -175,6 +179,7 @@ help: $(BUILDDIR)/Makefile
175179
@echo "tests -> run the tests (py + cpp)"
176180
@echo ""
177181
@echo "checkall -> full code compliance check"
182+
@echo "checkmerge -> code compliance check for merging to master"
178183
@echo "checkfast -> fast checks only"
179184
@echo "checkchanged -> full check for all files changed since origin/master"
180185
@echo "checkuncommited -> full check for all currently uncommited files"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ If you're interested, we wrote detailed explanations on our blog: [Part 1](https
8787

8888
| Operating System | Build status |
8989
| :-----------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
90-
| Debian Sid | [Todo: Kevin #11] |
90+
| Debian Sid | [![Kevin CI status](https://cidata.sft.lol/openage/branches/master/status.svg)](/kevinfile) |
9191
| Ubuntu 24.04 LTS | [![Ubuntu 24.04 build status](https://github.com/SFTTech/openage/actions/workflows/ubuntu-24.04.yml/badge.svg?branch=master)](https://github.com/SFTtech/openage/actions/workflows/ubuntu-24.04.yml) |
9292
| macOS | [![macOS build status](https://github.com/SFTtech/openage/workflows/macOS-CI/badge.svg)](https://github.com/SFTtech/openage/actions?query=workflow%3AmacOS-CI) |
9393
| Windows Server 2019 | [![Windows Server 2019 build status](https://github.com/SFTtech/openage/actions/workflows/windows-server-2019.yml/badge.svg?branch=master)](https://github.com/SFTtech/openage/actions/workflows/windows-server-2019.yml) |

buildsystem/HandlePythonOptions.cmake

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2015-2023 the openage authors. See copying.md for legal info.
1+
# Copyright 2015-2025 the openage authors. See copying.md for legal info.
22

33
# finds the python interpreter, install destination and extension flags.
44

@@ -39,6 +39,19 @@ if(PYTHON_VER VERSION_GREATER_EQUAL 3.8 AND PYTHON_VERSION VERSION_LESS 3.9)
3939
endif()
4040

4141
set(PYEXT_LIBRARY "${PYTHON_LIBRARIES}")
42+
message("PYTHON_LIBRARIES: " "${PYTHON_LIBRARIES}")
43+
#Windows always uses optimized version of Python lib
44+
if(WIN32 AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
45+
#get index of string "optimized" and increment it by 1 so index points at the path of the optimized lib
46+
list (FIND PYEXT_LIBRARY "optimized" _index)
47+
if (${_index} GREATER -1)
48+
MATH(EXPR _index "${_index}+1")
49+
list(GET PYEXT_LIBRARY ${_index} PYEXT_LIBRARY)
50+
endif()
51+
message("force linking to python release lib, instead of debug lib when cythonising")
52+
set(force_optimized_lib_flag "--force_optimized_lib")
53+
endif()
54+
4255
set(PYEXT_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS};${NUMPY_INCLUDE_DIR}")
4356

4457
if(NOT CMAKE_PY_INSTALL_PREFIX)

buildsystem/codecompliance/__main__.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2014-2024 the openage authors. See copying.md for legal info.
1+
# Copyright 2014-2025 the openage authors. See copying.md for legal info.
22

33
"""
44
Entry point for the code compliance checker.
@@ -18,16 +18,24 @@ def parse_args():
1818
""" Returns the raw argument namespace. """
1919

2020
cli = argparse.ArgumentParser()
21-
cli.add_argument("--fast", action="store_true",
22-
help="do all checks that can be performed quickly")
23-
cli.add_argument("--all", action="store_true",
24-
help="do all checks, even the really slow ones")
21+
check_types = cli.add_mutually_exclusive_group()
22+
check_types.add_argument("--fast", action="store_true",
23+
help="do all checks that can be performed quickly")
24+
check_types.add_argument("--merge", action="store_true",
25+
help="do all checks that are required before merges to master")
26+
check_types.add_argument("--all", action="store_true",
27+
help="do all checks, even the really slow ones")
28+
2529
cli.add_argument("--only-changed-files", metavar='GITREF',
2630
help=("slow checks are only done on files that have "
2731
"changed since GITREF."))
2832
cli.add_argument("--authors", action="store_true",
2933
help=("check whether all git authors are in copying.md. "
3034
"repo must be a git repository."))
35+
cli.add_argument("--clang-tidy", action="store_true",
36+
help=("Check the C++ code with clang-tidy. Make sure you have build the "
37+
"project with ./configure --clang-tidy or have set "
38+
"CMAKE_CXX_CLANG_TIDY for your CMake build."))
3139
cli.add_argument("--cppstyle", action="store_true",
3240
help="check the cpp code style")
3341
cli.add_argument("--cython", action="store_true",
@@ -76,7 +84,7 @@ def process_args(args, error):
7684
# set up log level
7785
log_setup(args.verbose - args.quiet)
7886

79-
if args.fast or args.all:
87+
if args.fast or args.merge or args.all:
8088
# enable "fast" tests
8189
args.authors = True
8290
args.cppstyle = True
@@ -86,16 +94,19 @@ def process_args(args, error):
8694
args.filemodes = True
8795
args.textfiles = True
8896

89-
if args.all:
90-
# enable tests that take a bit longer
91-
97+
if args.merge or args.all:
98+
# enable tests that are required before merging to master
9299
args.pystyle = True
93100
args.pylint = True
94101
args.test_git_change_years = True
95102

103+
if args.all:
104+
# enable tests that take a bit longer
105+
args.clang_tidy = True
106+
96107
if not any((args.headerguards, args.legal, args.authors, args.pystyle,
97108
args.cppstyle, args.cython, args.test_git_change_years,
98-
args.pylint, args.filemodes, args.textfiles)):
109+
args.pylint, args.filemodes, args.textfiles, args.clang_tidy)):
99110
error("no checks were specified")
100111

101112
has_git = bool(shutil.which('git'))
@@ -128,6 +139,10 @@ def process_args(args, error):
128139
if not importlib.util.find_spec('pylint'):
129140
error("pylint python module required for linting")
130141

142+
if args.clang_tidy:
143+
if not shutil.which('clang-tidy'):
144+
error("--clang-tidy requires clang-tidy to be installed")
145+
131146

132147
def get_changed_files(gitref):
133148
"""
@@ -264,6 +279,9 @@ def find_all_issues(args, check_files=None):
264279
from .modes import find_issues
265280
yield from find_issues(check_files, ('openage', 'buildsystem',
266281
'libopenage', 'etc/gdb_pretty'))
282+
if args.clang_tidy:
283+
from .clangtidy import find_issues
284+
yield from find_issues(check_files, ('libopenage', ))
267285

268286

269287
if __name__ == '__main__':
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Copyright 2024-2024 the openage authors. See copying.md for legal info.
2+
3+
"""
4+
Checks clang-tidy errors on cpp files
5+
"""
6+
7+
import subprocess
8+
from .cppstyle import filter_file_list
9+
from .util import findfiles
10+
11+
12+
def find_issues(check_files, dirnames):
13+
"""
14+
Invoke clang-tidy to check C++ files for issues.
15+
Yields issues found by clang-tidy in real-time.
16+
"""
17+
# Specify the checks to include
18+
# 4 checks we focus on
19+
checks_to_include = [
20+
'clang-analyzer-*',
21+
'bugprone-*',
22+
'concurrency-*',
23+
'performance-*'
24+
]
25+
# Create the checks string
26+
checks = ', '.join(checks_to_include)
27+
28+
# Invocation command
29+
invocation = ['clang-tidy', f'-checks=-*,{checks}']
30+
31+
# Use utility functions from util.py and cppstyle.py
32+
if check_files is not None:
33+
filenames = list(filter_file_list(check_files, dirnames))
34+
else:
35+
filenames = list(filter_file_list(findfiles(dirnames), dirnames))
36+
37+
if not filenames:
38+
print("No files to check.")
39+
return # No files to check
40+
41+
for filename in filenames:
42+
# Run clang-tidy for each file
43+
print(f"Starting clang-tidy check on file: {filename}")
44+
try:
45+
with subprocess.Popen(
46+
invocation + [filename],
47+
stdout=subprocess.PIPE,
48+
stderr=subprocess.PIPE,
49+
text=True
50+
) as process:
51+
# Stream output in real-time
52+
while True:
53+
output = process.stdout.readline()
54+
if output:
55+
yield ("clang-tidy output", output.strip(), None)
56+
elif process.poll() is not None:
57+
break
58+
59+
# Capture remaining errors (if any)
60+
for error_line in process.stderr:
61+
yield ("clang-tidy error", error_line.strip(), None)
62+
63+
# Handle exception
64+
except subprocess.SubprocessError as exc:
65+
yield (
66+
"clang-tidy error",
67+
f"An error occurred while running clang-tidy on {filename}: {str(exc)}",
68+
None
69+
)

0 commit comments

Comments
 (0)