diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 3d3f6f7c6f..c7fcdccef3 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -135,6 +135,7 @@ jobs: -G Ninja \ -DCMAKE_INSTALL_PREFIX=build/image \ -DCMAKE_BUILD_TYPE=Release \ + -DDFHACK_RUN_URL='https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' \ ${{ inputs.platform-files && '-DCMAKE_C_COMPILER_LAUNCHER=ccache' || '' }} \ ${{ inputs.platform-files && '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache' || '' }} \ -DBUILD_LIBRARY:BOOL=${{ inputs.platform-files }} \ diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 24306b72f9..b4e1e8b539 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -107,7 +107,7 @@ jobs: win-msvc - name: Cross-compile env: - CMAKE_EXTRA_ARGS: -DBUILD_LIBRARY=${{ inputs.platform-files }} -DBUILD_PLUGINS:BOOL=${{ inputs.platform-files && inputs.plugins }} -DBUILD_STONESENSE:BOOL=${{ inputs.stonesense }} -DBUILD_DOCS:BOOL=${{ inputs.docs }} -DBUILD_DOCS_NO_HTML:BOOL=${{ !inputs.html }} -DINSTALL_DATA_FILES:BOOL=${{ inputs.common-files }} -DINSTALL_SCRIPTS:BOOL=${{ inputs.common-files }} -DBUILD_DFLAUNCH:BOOL=${{ inputs.launchdf }} -DBUILD_TESTS:BOOL=${{ inputs.tests }} -DBUILD_XMLDUMP:BOOL=${{ inputs.xml-dump-type-sizes }} ${{ inputs.xml-dump-type-sizes && '-DINSTALL_XMLDUMP:BOOL=1' || '' }} + CMAKE_EXTRA_ARGS: -DBUILD_PDBS:BOOL=${{ inputs.cache-id == 'release' }} -DDFHACK_RUN_URL='https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' -DBUILD_LIBRARY=${{ inputs.platform-files }} -DBUILD_PLUGINS:BOOL=${{ inputs.platform-files && inputs.plugins }} -DBUILD_STONESENSE:BOOL=${{ inputs.stonesense }} -DBUILD_DOCS:BOOL=${{ inputs.docs }} -DBUILD_DOCS_NO_HTML:BOOL=${{ !inputs.html }} -DINSTALL_DATA_FILES:BOOL=${{ inputs.common-files }} -DINSTALL_SCRIPTS:BOOL=${{ inputs.common-files }} -DBUILD_DFLAUNCH:BOOL=${{ inputs.launchdf }} -DBUILD_TESTS:BOOL=${{ inputs.tests }} -DBUILD_XMLDUMP:BOOL=${{ inputs.xml-dump-type-sizes }} ${{ inputs.xml-dump-type-sizes && '-DINSTALL_XMLDUMP:BOOL=1' || '' }} run: | cd build bash -x build-win64-from-linux.sh @@ -115,9 +115,9 @@ jobs: run: | cd build ccache -d win64-cross/ccache --show-stats --verbose - ccache -d win64-cross/ccache --max-size 150M + ccache -d win64-cross/ccache --max-size ${{ inputs.cache-id == 'release' && '500M' || '150M' }} ccache -d win64-cross/ccache --cleanup - ccache -d win64-cross/ccache --max-size 500M + ccache -d win64-cross/ccache --max-size ${{ inputs.cache-id == 'release' && '2G' || '500M' }} ccache -d win64-cross/ccache --zero-stats - name: Save ccache if: inputs.platform-files && !inputs.cache-readonly @@ -145,3 +145,9 @@ jobs: with: name: ${{ steps.artifactname.outputs.name }} path: ${{ steps.artifactname.outputs.name }}.tar.bz2 + - name: Upload PDBs + if: inputs.artifact-name && inputs.cache-id == 'release' + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.artifactname.outputs.name }}_pdb + path: build/win64-cross/pdb diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d09cf448b..d340d5c8ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,6 +271,13 @@ elseif(MSVC) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od") string(REPLACE "/O2" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") string(REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + + option(BUILD_PDBS "Build PDB debug symbol files." OFF) + if(BUILD_PDBS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Z7") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /DEBUG") + endif() endif() # use shared libraries for protobuf diff --git a/build/build-win64-from-linux.sh b/build/build-win64-from-linux.sh index 0fdc3bb756..7f878ef1c6 100755 --- a/build/build-win64-from-linux.sh +++ b/build/build-win64-from-linux.sh @@ -13,6 +13,7 @@ builder_uid=$(id -u) mkdir -p win64-cross mkdir -p win64-cross/output +mkdir -p win64-cross/pdb mkdir -p win64-cross/ccache # Check for sudo; we want to use the real user @@ -43,7 +44,7 @@ if ! docker run --rm -i -v "$srcdir":/src -v "$srcdir/build/win64-cross/":/src/b -e steam_password \ --name dfhack-win \ ghcr.io/dfhack/build-env:master \ - bash -c "cd /src/build && dfhack-configure windows 64 Release -DCMAKE_INSTALL_PREFIX=/src/build/output -DBUILD_DOCS=1 $CMAKE_EXTRA_ARGS && dfhack-make -j$jobs install" \ + bash -c "cd /src/build && dfhack-configure windows 64 Release -DCMAKE_INSTALL_PREFIX=/src/build/output -DBUILD_DOCS=1 $CMAKE_EXTRA_ARGS && dfhack-make -j$jobs install && find depends library plugins -iname '*.pdb' -exec cp '{}' pdb/ \;" \ ; then echo echo "Build failed" diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index c43772af58..df64de3bd7 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -346,6 +346,7 @@ set_property(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS DF_VERSION="${DF_VERSION}" DFHACK_RELEASE="${DFHACK_RELEASE}" DFHACK_ABI_VERSION=${DFHACK_ABI_VERSION} + DFHACK_RUN_URL="${DFHACK_RUN_URL}" ) if(DFHACK_PRERELEASE) set_property(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS diff --git a/library/Core.cpp b/library/Core.cpp index 22c6139b13..951fb62f3a 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -1547,8 +1547,11 @@ bool Core::InitMainThread() { if (!freopen("stderr.log", "w", stderr)) std::cerr << "Could not redirect stderr to stderr.log" << std::endl; - std::cerr << "DFHack build: " << Version::git_description() << "\n" - << "Starting with working directory: " << Filesystem::getcwd() << std::endl; + std::cerr << "DFHack build: " << Version::git_description() << std::endl; + if (strlen(Version::dfhack_run_url())) { + std::cerr << "Build url: " << Version::dfhack_run_url() << std::endl; + } + std::cerr << "Starting with working directory: " << Filesystem::getcwd() << std::endl; std::cerr << "Binding to SDL.\n"; if (!DFSDL::init(con)) { diff --git a/library/DFHackVersion.cpp b/library/DFHackVersion.cpp index 42aac251ee..4fb8883432 100644 --- a/library/DFHackVersion.cpp +++ b/library/DFHackVersion.cpp @@ -25,6 +25,10 @@ namespace DFHack { { return DFHACK_BUILD_ID; } + const char *dfhack_run_url() + { + return DFHACK_RUN_URL; + } const char *git_description() { return DFHACK_GIT_DESCRIPTION; diff --git a/library/include/DFHackVersion.h b/library/include/DFHackVersion.h index fbf2539bf9..f4ab705e0c 100644 --- a/library/include/DFHackVersion.h +++ b/library/include/DFHackVersion.h @@ -5,6 +5,7 @@ namespace DFHack { const char *dfhack_version(); const char *dfhack_release(); const char *dfhack_build_id(); + const char *dfhack_run_url(); int dfhack_abi_version(); const char *git_description(); @@ -23,6 +24,7 @@ namespace DFHack { #define DFHACK_VERSION (DFHack::Version::dfhack_version()) #define DFHACK_RELEASE (DFHack::Version::dfhack_release()) #define DFHACK_BUILD_ID (DFHack::Version::dfhack_build_id()) + #define DFHACK_RUN_URL (DFHack::Version::dfhack_run_url()) #define DFHACK_ABI_VERSION (DFHack::Version::dfhack_abi_version()) #define DFHACK_GIT_DESCRIPTION (DFHack::Version::git_description()) diff --git a/library/modules/Persistence.cpp b/library/modules/Persistence.cpp index 54d2c1a9f2..6b5e494a6e 100644 --- a/library/modules/Persistence.cpp +++ b/library/modules/Persistence.cpp @@ -23,9 +23,11 @@ distribution. */ #include "Core.h" +#include "DFHackVersion.h" #include "Debug.h" #include "Internal.h" #include "LuaTools.h" +#include "MemAccess.h" #include "modules/Filesystem.h" #include "modules/Gui.h" @@ -186,11 +188,26 @@ static std::string getSaveFilePath(const std::string &world, const std::string & } void Persistence::Internal::save(color_ostream& out) { - if (!Core::getInstance().isWorldLoaded()) + Core &core = Core::getInstance(); + + if (!core.isWorldLoaded()) return; CoreSuspender suspend; + // write status + { + auto file = std::ofstream(getSaveFilePath("current", "status")); + file << "DF version: " << core.p->getDescriptor()->getVersion() << std::endl; + file << "DFHack version: " << Version::dfhack_version() << " (" << Version::git_commit(true) << ")" << std::endl; + file << "Tagged release: " << (Version::is_release() ? "yes" : "no") << std::endl; + file << "Pre-release: " << (Version::is_prerelease() ? "yes" : "no") << std::endl; + if (strlen(Version::dfhack_run_url())) { + file << "Build url: " << Version::dfhack_run_url() << std::endl; + } + } + + // write entity data for (auto & entity_store_entry : store) { int entity_id = entity_store_entry.first; Json::Value json(Json::arrayValue); @@ -205,6 +222,7 @@ void Persistence::Internal::save(color_ostream& out) { file << json; } + // write perf counters { auto file = std::ofstream(getSaveFilePath("current", "perf-counters")); color_ostream_wrapper wrapper(file);