From 103c30125f3ba7be0c0f70a3ff5450a33454f566 Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 3 Mar 2025 12:27:54 +0000 Subject: [PATCH 1/5] chore: add `sentry-crashpad` dependency --- endstone/_internal/bootstrap/base.py | 5 +++++ endstone/_internal/bootstrap/linux.py | 1 + pyproject.toml | 1 + src/endstone/core/crash_handler.cpp | 16 ++-------------- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/endstone/_internal/bootstrap/base.py b/endstone/_internal/bootstrap/base.py index a944cb71f..a3051faf9 100644 --- a/endstone/_internal/bootstrap/base.py +++ b/endstone/_internal/bootstrap/base.py @@ -3,6 +3,7 @@ import logging import os import platform +import shutil import subprocess import sys import tempfile @@ -12,6 +13,7 @@ import click import requests +import sentry_crashpad from packaging.version import Version from rich.progress import BarColumn, DownloadColumn, Progress, TextColumn, TimeRemainingColumn @@ -135,6 +137,9 @@ def _download(self, dst: Union[str, os.PathLike]) -> None: def _prepare(self) -> None: self.plugin_path.mkdir(parents=True, exist_ok=True) + shutil.copytree( + Path(sentry_crashpad._get_executable("crashpad_handler")).parent, self.server_path, dirs_exist_ok=True + ) def _install(self) -> None: """ diff --git a/endstone/_internal/bootstrap/linux.py b/endstone/_internal/bootstrap/linux.py index e6ba27b7f..cd957ecbc 100644 --- a/endstone/_internal/bootstrap/linux.py +++ b/endstone/_internal/bootstrap/linux.py @@ -27,6 +27,7 @@ def _prepare(self) -> None: super()._prepare() st = os.stat(self.executable_path) os.chmod(self.executable_path, st.st_mode | stat.S_IEXEC) + os.chmod(self.server_path / "crashpad_handler", st.st_mode | stat.S_IEXEC) def _create_process(self, *args, **kwargs) -> None: env = os.environ.copy() diff --git a/pyproject.toml b/pyproject.toml index a5e6bf10d..37286e085 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ dependencies = [ "pyyaml", "requests", "rich", + "sentry-crashpad==0.7.17.1", "tomlkit", "typing-extensions", ] diff --git a/src/endstone/core/crash_handler.cpp b/src/endstone/core/crash_handler.cpp index 7eb7440f3..1a2d708a7 100644 --- a/src/endstone/core/crash_handler.cpp +++ b/src/endstone/core/crash_handler.cpp @@ -47,10 +47,7 @@ struct exception_slot { const char *description; }; -#define EXCEPTION_DEF(code, desc) \ - { \ - code, #code, desc \ - } +#define EXCEPTION_DEF(code, desc) {code, #code, desc} const exception_slot EXCEPTION_DEFINITIONS[] = { EXCEPTION_DEF(EXCEPTION_ACCESS_VIOLATION, "AccessViolation"), @@ -83,10 +80,7 @@ struct signal_slot { const char *description; }; -#define SIGNAL_DEF(sig, desc) \ - { \ - sig, #sig, desc \ - } +#define SIGNAL_DEF(sig, desc) {sig, #sig, desc} const signal_slot SIGNAL_DEFINITIONS[] = {SIGNAL_DEF(SIGILL, "IllegalInstruction"), SIGNAL_DEF(SIGTRAP, "Trap"), @@ -199,18 +193,12 @@ CrashHandler::CrashHandler() { constexpr auto dsn = "https://69c28eeaef4651abcf0bbeace6a1175c@o4508553519431680.ingest.de.sentry.io/4508569040519248"; -#ifdef _WIN32 - fs::path handler_path = (fs::path{detail::get_module_pathname()}.parent_path()) / "crashpad_handler.exe"; -#else - fs::path handler_path = (fs::path{detail::get_module_pathname()}.parent_path()) / "crashpad_handler"; -#endif constexpr std::string_view release = "endstone@" ENDSTONE_VERSION; constexpr bool is_dev = release.find("dev") != std::string_view::npos; sentry_options_t *options = sentry_options_new(); sentry_options_set_dsn(options, dsn); sentry_options_set_database_path(options, ".sentry-native"); - sentry_options_set_handler_path(options, handler_path.string().c_str()); sentry_options_set_release(options, std::string(release).c_str()); sentry_options_set_on_crash(options, on_crash, nullptr); sentry_options_set_environment(options, is_dev ? "development" : "production"); From cc2850faf8c3bcb4db6cc7628aebc2287cd2ed29 Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 3 Mar 2025 12:28:16 +0000 Subject: [PATCH 2/5] chore: change build type to `RelWithDebInfo` for wheels --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 37286e085..d706e2cee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ endstone = "endstone._internal.bootstrap:cli" [tool.scikit-build] build-dir = "build/{wheel_tag}" cmake.args = ["-G Ninja"] -cmake.build-type = "Release" +cmake.build-type = "RelWithDebInfo" cmake.define = { BUILD_TESTING = "OFF" } wheel.packages = ["endstone"] wheel.license-files = ["LICENSE"] From 0511c706b576478c996440781e92db98f17587cc Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 3 Mar 2025 12:36:04 +0000 Subject: [PATCH 3/5] refactor: do not include `crashpad_handler` directly with endstone --- src/endstone/core/CMakeLists.txt | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/endstone/core/CMakeLists.txt b/src/endstone/core/CMakeLists.txt index 1954a99d6..6b8ad2ccd 100644 --- a/src/endstone/core/CMakeLists.txt +++ b/src/endstone/core/CMakeLists.txt @@ -131,23 +131,9 @@ if (DEFINED SKBUILD_PROJECT_VERSION_FULL) target_compile_definitions(endstone_core PUBLIC ENDSTONE_VERSION="${SKBUILD_PROJECT_VERSION_FULL}") endif () -# The crashpad handler executable must be shipped alongside our shared library -add_custom_target( - copy_crashpad_handler - ALL - COMMAND ${CMAKE_COMMAND} -E copy_directory ${sentry_INCLUDE_DIRS}/../bin/ ${CMAKE_BINARY_DIR}/crashpad - COMMENT "Copying crashpad_handler${CMAKE_EXECUTABLE_SUFFIX}" -) -add_dependencies(copy_crashpad_handler endstone_runtime) include(GNUInstallDirs) install(TARGETS endstone_core ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(DIRECTORY ${CMAKE_BINARY_DIR}/crashpad/ DESTINATION "endstone/_internal/" COMPONENT endstone_wheel OPTIONAL - FILE_PERMISSIONS - OWNER_READ OWNER_EXECUTE OWNER_WRITE - GROUP_READ GROUP_EXECUTE - WORLD_READ WORLD_EXECUTE -) \ No newline at end of file From a83cc4ee3d5721d7bc755afb573d782e2bd4f2de Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 3 Mar 2025 14:04:32 +0000 Subject: [PATCH 4/5] refactor: simplify CMakeLists.txt --- src/endstone/python/CMakeLists.txt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/endstone/python/CMakeLists.txt b/src/endstone/python/CMakeLists.txt index 49a0d34f4..223b7daef 100644 --- a/src/endstone/python/CMakeLists.txt +++ b/src/endstone/python/CMakeLists.txt @@ -4,7 +4,7 @@ project(endstone_python LANGUAGES CXX) find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) find_package(pybind11 REQUIRED) -add_library(endstone_python MODULE +pybind11_add_module(endstone_python MODULE actor.cpp ban.cpp block.cpp @@ -25,15 +25,9 @@ add_library(endstone_python MODULE util.cpp ) target_link_libraries(endstone_python PRIVATE endstone::endstone pybind11::module) -pybind11_extension(endstone_python) -set_target_properties(endstone_python PROPERTIES CXX_VISIBILITY_PRESET "hidden") target_compile_definitions(endstone_python PUBLIC PYBIND11_DETAILED_ERROR_MESSAGES) -if (NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION) - target_link_libraries(endstone_python PRIVATE pybind11::lto) -endif () if (MSVC) - target_link_libraries(endstone_python PRIVATE pybind11::windows_extras) target_link_options(endstone_python PRIVATE /DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF) target_compile_options(endstone_python PRIVATE /O2 /DNDEBUG /Zi /Gy) endif () From a4e9823878b1a8b01d4ae4c9a25661fe2e6973f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 14:32:21 +0000 Subject: [PATCH 5/5] chore(deps): bump pypa/cibuildwheel from 2.22.0 to 2.23.0 Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.22.0 to 2.23.0. - [Release notes](https://github.com/pypa/cibuildwheel/releases) - [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md) - [Commits](https://github.com/pypa/cibuildwheel/compare/v2.22.0...v2.23.0) --- updated-dependencies: - dependency-name: pypa/cibuildwheel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/wheel.yml | 2 +- .github/workflows/windows-portable.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index ae9c8fa9d..a477b6ab4 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -55,7 +55,7 @@ jobs: run: echo "CONAN_HOME=/host${HOME}/.conan2" >> $GITHUB_ENV - name: Build wheels - uses: pypa/cibuildwheel@v2.22.0 + uses: pypa/cibuildwheel@v2.23.0 env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} CIBW_BUILD: ${{ matrix.python-tag }}-${{ matrix.platform }} diff --git a/.github/workflows/windows-portable.yml b/.github/workflows/windows-portable.yml index 45c104455..fd532972b 100644 --- a/.github/workflows/windows-portable.yml +++ b/.github/workflows/windows-portable.yml @@ -43,7 +43,7 @@ jobs: uses: lukka/get-cmake@latest - name: Build wheels - uses: pypa/cibuildwheel@v2.22.0 + uses: pypa/cibuildwheel@v2.23.0 env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} CIBW_BUILD: cp312-win_amd64