Skip to content

Commit 968af71

Browse files
committed
write build url to stderr and status file
1 parent 0ebd92b commit 968af71

7 files changed

Lines changed: 33 additions & 4 deletions

File tree

.github/workflows/build-linux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ jobs:
135135
-G Ninja \
136136
-DCMAKE_INSTALL_PREFIX=build/image \
137137
-DCMAKE_BUILD_TYPE=Release \
138+
-DDFHACK_RUN_URL='https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
138139
${{ inputs.platform-files && '-DCMAKE_C_COMPILER_LAUNCHER=ccache' || '' }} \
139140
${{ inputs.platform-files && '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache' || '' }} \
140141
-DBUILD_LIBRARY:BOOL=${{ inputs.platform-files }} \

.github/workflows/build-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110
win-msvc
111111
- name: Cross-compile
112112
env:
113-
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' || '' }}
113+
CMAKE_EXTRA_ARGS: -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' || '' }}
114114
run: |
115115
cd build
116116
bash -x build-win64-from-linux.sh

library/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ set_property(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS
346346
DF_VERSION="${DF_VERSION}"
347347
DFHACK_RELEASE="${DFHACK_RELEASE}"
348348
DFHACK_ABI_VERSION=${DFHACK_ABI_VERSION}
349+
DFHACK_RUN_URL="${DFHACK_RUN_URL}"
349350
)
350351
if(DFHACK_PRERELEASE)
351352
set_property(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS

library/Core.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,8 +1547,11 @@ bool Core::InitMainThread() {
15471547
if (!freopen("stderr.log", "w", stderr))
15481548
std::cerr << "Could not redirect stderr to stderr.log" << std::endl;
15491549

1550-
std::cerr << "DFHack build: " << Version::git_description() << "\n"
1551-
<< "Starting with working directory: " << Filesystem::getcwd() << std::endl;
1550+
std::cerr << "DFHack build: " << Version::git_description() << std::endl;
1551+
if (strlen(Version::dfhack_run_url())) {
1552+
std::cerr << "Build url: " << Version::dfhack_run_url() << std::endl;
1553+
}
1554+
std::cerr << "Starting with working directory: " << Filesystem::getcwd() << std::endl;
15521555

15531556
std::cerr << "Binding to SDL.\n";
15541557
if (!DFSDL::init(con)) {

library/DFHackVersion.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ namespace DFHack {
2525
{
2626
return DFHACK_BUILD_ID;
2727
}
28+
const char *dfhack_run_url()
29+
{
30+
return DFHACK_RUN_URL;
31+
}
2832
const char *git_description()
2933
{
3034
return DFHACK_GIT_DESCRIPTION;

library/include/DFHackVersion.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace DFHack {
55
const char *dfhack_version();
66
const char *dfhack_release();
77
const char *dfhack_build_id();
8+
const char *dfhack_run_url();
89
int dfhack_abi_version();
910

1011
const char *git_description();
@@ -23,6 +24,7 @@ namespace DFHack {
2324
#define DFHACK_VERSION (DFHack::Version::dfhack_version())
2425
#define DFHACK_RELEASE (DFHack::Version::dfhack_release())
2526
#define DFHACK_BUILD_ID (DFHack::Version::dfhack_build_id())
27+
#define DFHACK_RUN_URL (DFHack::Version::dfhack_run_url())
2628
#define DFHACK_ABI_VERSION (DFHack::Version::dfhack_abi_version())
2729

2830
#define DFHACK_GIT_DESCRIPTION (DFHack::Version::git_description())

library/modules/Persistence.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ distribution.
2323
*/
2424

2525
#include "Core.h"
26+
#include "DFHackVersion.h"
2627
#include "Debug.h"
2728
#include "Internal.h"
2829
#include "LuaTools.h"
30+
#include "MemAccess.h"
2931

3032
#include "modules/Filesystem.h"
3133
#include "modules/Gui.h"
@@ -186,11 +188,26 @@ static std::string getSaveFilePath(const std::string &world, const std::string &
186188
}
187189

188190
void Persistence::Internal::save(color_ostream& out) {
189-
if (!Core::getInstance().isWorldLoaded())
191+
Core &core = Core::getInstance();
192+
193+
if (!core.isWorldLoaded())
190194
return;
191195

192196
CoreSuspender suspend;
193197

198+
// write status
199+
{
200+
auto file = std::ofstream(getSaveFilePath("current", "status"));
201+
file << "DF version: " << core.p->getDescriptor()->getVersion() << std::endl;
202+
file << "DFHack version: " << Version::dfhack_version() << " (" << Version::git_commit(true) << ")" << std::endl;
203+
file << "Tagged release: " << (Version::is_release() ? "yes" : "no") << std::endl;
204+
file << "Pre-release: " << (Version::is_prerelease() ? "yes" : "no") << std::endl;
205+
if (strlen(Version::dfhack_run_url())) {
206+
file << "Build url: " << Version::dfhack_run_url() << std::endl;
207+
}
208+
}
209+
210+
// write entity data
194211
for (auto & entity_store_entry : store) {
195212
int entity_id = entity_store_entry.first;
196213
Json::Value json(Json::arrayValue);
@@ -205,6 +222,7 @@ void Persistence::Internal::save(color_ostream& out) {
205222
file << json;
206223
}
207224

225+
// write perf counters
208226
{
209227
auto file = std::ofstream(getSaveFilePath("current", "perf-counters"));
210228
color_ostream_wrapper wrapper(file);

0 commit comments

Comments
 (0)