Skip to content

Commit

Permalink
Merge pull request #5114 from myk002/myk_pdb
Browse files Browse the repository at this point in the history
generate pdb files for windows builds
  • Loading branch information
myk002 authored Dec 24, 2024
2 parents 14a3f53 + 0376eba commit dab30e6
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }} \
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ 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
- name: Finalize cache
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
Expand Down Expand Up @@ -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
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion build/build-win64-from-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions library/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 4 additions & 0 deletions library/DFHackVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions library/include/DFHackVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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())
Expand Down
20 changes: 19 additions & 1 deletion library/modules/Persistence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit dab30e6

Please sign in to comment.