Skip to content

Commit d664107

Browse files
authored
Merge pull request #692 from howetuft/pointers-squash
Pointers and memory handling modernization This merge is mainly about modernizing memory and pointers handling, by implementing smart pointers. Smart pointers have many advantages compared to raw pointers, among them clarifying object ownership, automating memory release at object end-of-life (even on exception), avoiding leaks, double-free and other pointer pathologies, allowing RAII etc. (have a look on the web for more) At this stage, not all the eligible pointers have been treated, as this is quite a huge job. Other work will come in the future. This big overhaul was also the opportunity to fix some bugs, enhance some capabilities (especially on build system) and upgrade some deps (among them Python v3.14)
2 parents d6a8c92 + 322e11c commit d664107

File tree

583 files changed

+18296
-13053
lines changed

Some content is hidden

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

583 files changed

+18296
-13053
lines changed

.github/workflows/wheel-builder.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ jobs:
8282

8383
- name: Checkout main repository (standard context)
8484
if: ${{ !env.ACT }}
85-
uses: actions/checkout@v4
85+
uses: actions/checkout@v6
8686
with:
8787
repository: ${{ inputs.repository }}
8888
ref: ${{ inputs.ref }}
8989

9090
- name: Checkout main repository (act context)
9191
if: env.ACT
92-
uses: actions/checkout@v4
92+
uses: actions/checkout@v6
9393

9494
- name: Get current commit
9595
id: current-commit
@@ -119,7 +119,7 @@ jobs:
119119
echo "CONAN_HOME=${_conan_home}" >> $GITHUB_ENV
120120
121121
- name: Configure ccache
122-
uses: actions/github-script@v7
122+
uses: actions/github-script@v8
123123
with:
124124
script: |
125125
const workspace = String.raw`${{ github.workspace }}`;
@@ -146,7 +146,7 @@ jobs:
146146
sudo apt-get update -y
147147
148148
- name: ccache
149-
uses: hendrikmuhs/ccache-action@v1.2
149+
uses: hendrikmuhs/ccache-action@v1
150150
with:
151151
create-symlink: false
152152
variant: ${{ env.cache-variant }}
@@ -174,7 +174,7 @@ jobs:
174174
175175
- name: Set MacOS deployment target and other set-ups
176176
if: runner.os == 'macOS'
177-
uses: actions/github-script@v7
177+
uses: actions/github-script@v8
178178
with:
179179
# Minimum targets driven by:
180180
# Intel: libomp
@@ -230,7 +230,7 @@ jobs:
230230
# I found to pass a calculated environment var to CMake build step
231231
- name: Set M4 env var
232232
if: runner.os != 'Windows'
233-
uses: actions/github-script@v7
233+
uses: actions/github-script@v8
234234
with:
235235
script: |
236236
if ('${{ runner.arch }}' == 'X64') {
@@ -271,7 +271,7 @@ jobs:
271271
272272
# Build wheel
273273
- name: Build wheels
274-
uses: pypa/cibuildwheel@v3.3.1
274+
uses: pypa/cibuildwheel@v3.1.1
275275
env:
276276
CIBW_BUILD_FRONTEND: build
277277
CIBW_BUILD_VERBOSITY: 1
@@ -392,7 +392,7 @@ jobs:
392392
- name: Save dependency cache
393393
if: always()
394394
id: cache-deps-save
395-
uses: actions/cache/save@v4
395+
uses: actions/cache/save@v5
396396
with:
397397
path: conan-cache
398398
key: deps-${{ matrix.os }}-${{ matrix.python-minor}}-${{ hashFiles('**/conan-cache') }}
@@ -402,7 +402,7 @@ jobs:
402402
#uses: mxschmitt/action-tmate@v3
403403

404404
# Upload artifacts
405-
- uses: actions/upload-artifact@v4
405+
- uses: actions/upload-artifact@v5
406406
id: upload
407407
with:
408408
name: cibw-wheels-${{ matrix.os }}-${{ matrix.python-minor }}
@@ -418,7 +418,7 @@ jobs:
418418
attestation-url: ${{ steps.attestation-step.outputs.attestation-url }}
419419

420420
steps:
421-
- uses: actions/download-artifact@v4
421+
- uses: actions/download-artifact@v7
422422
if: ${{ !env.ACT }}
423423
with:
424424
pattern: cibw-wheels-*
@@ -428,6 +428,6 @@ jobs:
428428
- name: Generate artifact attestations
429429
id: attestation-step
430430
if: ${{ !env.ACT }}
431-
uses: actions/attest-build-provenance@v2
431+
uses: actions/attest-build-provenance@v3
432432
with:
433433
subject-path: ${{ github.workspace }}/dist/*

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ doc/
99
generated/
1010
lib/
1111
nbproject/
12+
.cache/
1213
deps/perceptualdiff-master/libpdiff.a
1314
samples/(benchsimple|smallluxgpu)/(Debug|Release)/
1415
samples/luxcoreui/deps/glfw-3.1.1/src/glfw_config.h
@@ -99,3 +100,4 @@ CMakeUserPresets.json
99100
# Visual Studio (Code)
100101
.vs/
101102
.vscode/
103+
tags

CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
MESSAGE(STATUS "CMake version " ${CMAKE_VERSION} " detected")
2020

21-
2221
################################################################################
2322
#
2423
# Check and configure cmake
@@ -85,10 +84,19 @@ OPTION(LUXRAYS_ENABLE_OPENCL "Enable to use OpenCL" ON)
8584
OPTION(LUXRAYS_ENABLE_CUDA "Enable to use CUDA" ON)
8685
OPTION(LUXRAYS_ENABLE_OPTIX "Enable to use Optix" ON)
8786

87+
# Sanitization (optional)
8888
IF(DEFINED ENV{LUX_SANITIZE})
8989
MESSAGE(STATUS "Compiling with sanitizer (ASAN)")
90-
add_compile_options(-fsanitize=undefined -fno-omit-frame-pointer)
91-
add_link_options(-fsanitize=undefined)
90+
add_compile_options(-fsanitize=address)
91+
add_link_options(-fsanitize=address)
92+
IF(UNIX)
93+
add_compile_options(-fsanitize=undefined -fno-omit-frame-pointer)
94+
add_link_options(-fsanitize=undefined)
95+
ENDIF()
96+
IF(MSVC)
97+
add_compile_definitions(_DISABLE_VECTOR_ANNOTATION)
98+
add_compile_definitions(_DISABLE_STRING_ANNOTATION)
99+
ENDIF()
92100
ENDIF()
93101

94102
# Fundamental settings

build-system/build-settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"Dependencies": {
99
"user": "LuxCoreRender",
10-
"release": "2.0.0"
10+
"release": "2.0.1"
1111
},
1212
"Build": {
1313
"gcc": "14",
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# From https://stackoverflow.com/questions/60038427/cmake-get-runtime-dependencies-couldnt-find-dll-library-when-it-is-linked-throu
2+
# Thanks to author Franck Dana
3+
4+
#[=======================================================================[.rst:
5+
IMPLIB_UTILS
6+
------------
7+
8+
Tools for CMake on WIN32 to associate IMPORTED_IMPLIB paths (as discovered
9+
by the :command:`find_library` command) with their IMPORTED_LOCATION DLLs.
10+
11+
Writing Find modules that create ``SHARED IMPORTED`` targets with the
12+
correct ``IMPORTED_IMPLIB`` and ``IMPORTED_LOCATION`` properties is a
13+
requirement for ``$<TARGET_RUNTIME_DLLS>`` to work correctly. (Probably
14+
``IMPORTED_RUNTIME_DEPENDENCIES`` as well.)
15+
16+
Macros Provided
17+
^^^^^^^^^^^^^^^
18+
19+
Currently the only tool here is ``implib_to_dll``. It takes a single
20+
argument, the __name__ (_not_ value!) of a prefixed ``<prefix>_IMPLIB``
21+
variable (containing the path to a ``.lib`` or ``.dll.a`` import library).
22+
23+
``implib_to_dll`` will attempt to locate the corresponding ``.dll`` file
24+
for that import library, and set the variable ``<prefix>_LIBRARY``
25+
to its location.
26+
27+
``implib_to_dll`` relies on the ``dlltool.exe`` utility. The path can
28+
be set by defining ``DLLTOOL_EXECUTABLE`` in the cache prior to
29+
including this module, if it is not set implib_utils will attempt to locate
30+
``dlltool.exe`` using ``find_program()``.
31+
32+
Revision history
33+
^^^^^^^^^^^^^^^^
34+
2021-11-18 - Updated docs to remove CACHE mentions, fixed formatting
35+
2021-10-14 - Initial version
36+
37+
Author: FeRD (Frank Dana) <ferdnyc@gmail.com>
38+
License: CC0-1.0 (Creative Commons Universal Public Domain Dedication)
39+
#]=======================================================================]
40+
include_guard(DIRECTORY)
41+
42+
if (NOT WIN32)
43+
# Nothing to do here!
44+
return()
45+
endif()
46+
47+
if (NOT DEFINED DLLTOOL_EXECUTABLE)
48+
find_program(DLLTOOL_EXECUTABLE
49+
NAMES dlltool dlltool.exe
50+
DOC "The path to the DLLTOOL utility"
51+
)
52+
if (DLLTOOL_EXECUTABLE STREQUAL "DLLTOOL_EXECUTABLE-NOTFOUND")
53+
message(WARNING "DLLTOOL not available, cannot continue")
54+
return()
55+
endif()
56+
message(DEBUG "Found dlltool at ${DLLTOOL_EXECUTABLE}")
57+
endif()
58+
59+
#
60+
### Macro: implib_to_dll
61+
#
62+
# (Win32 only)
63+
# Uses dlltool.exe to find the name of the dll associated with the
64+
# supplied import library.
65+
macro(implib_to_dll _implib_var)
66+
set(_implib ${${_implib_var}})
67+
set(_library_var "${_implib_var}")
68+
# Automatically update the name, assuming it's in the correct format
69+
string(REGEX REPLACE
70+
[[_IMPLIBS$]] [[_LIBRARIES]]
71+
_library_var "${_library_var}")
72+
string(REGEX REPLACE
73+
[[_IMPLIB$]] [[_LIBRARY]]
74+
_library_var "${_library_var}")
75+
# We can't use the input variable name without blowing away the
76+
# previously-discovered contents, so that's a non-starter
77+
if ("${_implib_var}" STREQUAL "${_library_var}")
78+
message(ERROR "Name collision! You probably didn't pass "
79+
"implib_to_dll() a correctly-formatted variable name. "
80+
"Only <prefix>_IMPLIB or <prefix>_IMPLIBS is supported.")
81+
return()
82+
endif()
83+
84+
if(EXISTS "${_implib}")
85+
message(DEBUG "Looking up dll name for import library ${_implib}")
86+
execute_process(COMMAND
87+
"${DLLTOOL_EXECUTABLE}" -I "${_implib}"
88+
OUTPUT_VARIABLE _dll_name
89+
OUTPUT_STRIP_TRAILING_WHITESPACE
90+
)
91+
message(DEBUG "DLLTOOL returned ${_dll_name}, finding...")
92+
93+
# Check the directory where the import lib is found
94+
get_filename_component(_implib_dir ".." REALPATH
95+
BASE_DIR "${_implib}")
96+
message(DEBUG "Checking import lib directory ${_implib_dir}")
97+
98+
# Add a check in ../../bin/, relative to the import library
99+
get_filename_component(_bindir "../../bin" REALPATH
100+
BASE_DIR "${_implib}")
101+
message(DEBUG "Also checking ${_bindir}")
102+
103+
find_program(${_library_var}
104+
NAMES ${_dll_name}
105+
HINTS
106+
${_bindir}
107+
${_implib_dir}
108+
PATHS
109+
ENV PATH
110+
)
111+
set(${_library_var} "${${_library_var}}" PARENT_SCOPE)
112+
message(DEBUG "Set ${_library_var} to ${${_library_var}}")
113+
endif()
114+
endmacro()

build-system/conan/conanfile.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,22 @@ class LuxCore(ConanFile):
2929
user = "luxcore"
3030
channel = "luxcore"
3131

32-
requires = f"luxcoredeps/{LUXDEPS_VERSION}@luxcore/luxcore"
3332
tool_requires = "ninja/[*]", "doxygen/[*]"
3433
settings = "os", "compiler", "build_type", "arch"
3534

35+
options = {
36+
"deps_version": ["ANY"] # Override json file (for tests)
37+
}
38+
default_options = {
39+
"deps_version": ""
40+
}
41+
42+
def requirements(self):
43+
luxversion = self.options.deps_version or LUXDEPS_VERSION
44+
self.requires(
45+
f"luxcoredeps/{luxversion}@luxcore/luxcore"
46+
)
47+
3648
def _generate_oidn(self, toolchain):
3749
"""Generate toolchain part related to oidn."""
3850
self_settings_os = self.settings.os # pylint: disable=no-member

build-system/debug/debug_wheels.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
#export CIBW_DEBUG_KEEP_CONTAINER=TRUE
1212

1313
python_version_minor=$(python -c 'import sys; print(sys.version_info[1])')
14-
python_version_minor=12
14+
python_version_minor=14
1515

1616
act workflow_dispatch \
17+
-P ubuntu-latest=catthehacker/ubuntu:act-latest \
1718
--pull \
1819
--action-offline-mode \
1920
--workflows ".github/workflows/wheel-builder.yml" \

build-system/luxmake/config.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
"""Config command."""
5+
"""Config command.
6+
7+
This command has also been extended to export compile commands for CMake
8+
(`compile_commands.json` file), mainly for syntaxic checkers.
9+
"""
610

711
from .constants import INSTALL_DIR, SOURCE_DIR, BINARY_DIR
8-
from .utils import run_cmake, fail
12+
from .utils import run_cmake, fail, logger
913

1014

1115
def config(
12-
_,
16+
args,
1317
):
1418
"""CMake config."""
1519
# Check whether presets exist
@@ -21,10 +25,17 @@ def config(
2125
str(presets.absolute()),
2226
)
2327

24-
# Run command
28+
# Prepare and run command
2529
cmd = [
2630
"--preset conan-default",
2731
f"-DCMAKE_INSTALL_PREFIX={str(INSTALL_DIR)}",
32+
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
2833
f"-S {str(SOURCE_DIR)}",
2934
]
3035
run_cmake(cmd)
36+
37+
# Info
38+
compile_commands_file = BINARY_DIR / "build" / "compile_commands.json"
39+
logger.info(
40+
"Compile commands file generated at: '%s'", compile_commands_file
41+
)

0 commit comments

Comments
 (0)