Skip to content

Commit 97562ca

Browse files
committed
extended --version output to include 3rd party, incremented version to
0.9.5
1 parent eb1e85a commit 97562ca

7 files changed

Lines changed: 138 additions & 40 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if(NOT CMAKE_C_COMPILER AND NOT CMAKE_CXX_COMPILER)
3333
endif()
3434
endif()
3535

36-
project(zelph VERSION 0.9.4 LANGUAGES C CXX)
36+
project(zelph VERSION 0.9.5 LANGUAGES C CXX)
3737

3838
include(GNUInstallDirs)
3939

@@ -79,4 +79,4 @@ endif()
7979
if(PROJECT_IS_TOP_LEVEL)
8080
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE
8181
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/licenses/${PROJECT_NAME})
82-
endif()
82+
endif()

‎src/app/main.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ along with zelph. If not, see <https://www.gnu.org/licenses/>.
2424
*/
2525

2626
#include "interactive.hpp"
27+
#include "versions.hpp"
2728

2829
#ifdef _WIN32
2930
#include <Windows.h> // for SetConsoleOutputCP
@@ -104,8 +105,7 @@ int main(int argc, char** argv)
104105

105106
if (show_version)
106107
{
107-
interactive.out("zelph " + zelph::console::Interactive::get_version());
108-
108+
std::cout << zelph::get_version_description() << std::endl;
109109
return 0;
110110
}
111111

‎src/lib/CMakeLists.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ add_library(zelph_lib SHARED
233233
repl_state.hpp
234234
script_engine.cpp
235235
script_engine.hpp
236+
versions.cpp
237+
versions.hpp
236238

237239
chrono/stopwatch.cpp
238240
chrono/stopwatch.hpp

‎src/lib/command_executor.cpp‎

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,10 @@ along with zelph. If not, see <https://www.gnu.org/licenses/>.
3434
#include "script_engine.hpp"
3535
#include "string/node_to_string.hpp"
3636
#include "string/string_utils.hpp"
37+
#include "versions.hpp"
3738
#include "wikidata/wikidata.hpp"
3839
#include "wikidata/wikidata_text_compressor.hpp"
3940

40-
// for 3rd party versions
41-
#if __has_include(<mimalloc.h>)
42-
#include "mimalloc.h"
43-
#endif
44-
#include <ankerl/unordered_dense.h>
45-
#include <bzlib.h>
46-
#include <capnp/common.h>
47-
4841
#include <fstream>
4942
#include <iomanip>
5043
#include <map>
@@ -1537,34 +1530,15 @@ class console::CommandExecutor::Impl
15371530
{
15381531
if (cmd.size() != 1) throw std::runtime_error("Command .licenses takes no arguments");
15391532

1540-
_n->out("zelph incorporates the following third-party software:", true);
1541-
_n->out("------------------------------------------------------", true);
1542-
1543-
_n->out("Janet (v" + ScriptEngine::get_janet_version() + ") - MIT License", true);
1544-
1545-
std::string ud_version = std::to_string(ANKERL_UNORDERED_DENSE_VERSION_MAJOR) + "." + std::to_string(ANKERL_UNORDERED_DENSE_VERSION_MINOR) + "." + std::to_string(ANKERL_UNORDERED_DENSE_VERSION_PATCH);
1546-
_n->out("unordered_dense (v" + ud_version + ") - MIT License", true);
1547-
1548-
std::string capnp_version = std::to_string(CAPNP_VERSION_MAJOR) + "." + std::to_string(CAPNP_VERSION_MINOR) + "." + std::to_string(CAPNP_VERSION_MICRO);
1549-
_n->out("Cap'n Proto (v" + capnp_version + ") - MIT License", true);
1550-
1551-
std::string bz2_full = BZ2_bzlibVersion();
1552-
size_t bz2_comma_pos = bz2_full.find(',');
1553-
std::string bz2_version = (bz2_comma_pos != std::string::npos) ? bz2_full.substr(0, bz2_comma_pos) : bz2_full;
1554-
_n->out("bzip2 (v" + bz2_version + ") - bzip2 License (BSD-style)", true);
1533+
std::istringstream stream(zelph::get_version_description());
1534+
std::string line;
15551535

1556-
// 5. mimalloc (nur einkompiliert, wenn das Makro existiert)
1557-
#if defined(MI_MALLOC_VERSION)
1558-
int mi_major = MI_MALLOC_VERSION / 1000;
1559-
int mi_minor = (MI_MALLOC_VERSION / 100) % 10;
1560-
int mi_patch = MI_MALLOC_VERSION % 100;
1561-
std::string mi_version = std::to_string(mi_major) + "." + std::to_string(mi_minor) + "." + std::to_string(mi_patch);
1562-
_n->out("mimalloc (v" + mi_version + ") - MIT License", true);
1563-
#endif
1564-
1565-
_n->out("------------------------------------------------------", true);
1566-
_n->out("For full license texts and copyright notices, please refer to the", true);
1567-
_n->out("documentation or the source code repositories.", true);
1536+
while (std::getline(stream, line))
1537+
{
1538+
// Wir überspringen leere Zeilen am Ende nicht,
1539+
// aber std::getline verwirft das '\n'.
1540+
_n->out(line, true);
1541+
}
15681542
}
15691543
void cmd_log(const std::vector<std::string>& cmd)
15701544
{

‎src/lib/network/zelph.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ using namespace zelph::network;
3939

4040
std::string Zelph::get_version()
4141
{
42-
return "0.9.4";
42+
return "0.9.5";
4343
}
4444

4545
Zelph::Zelph(const io::OutputHandler& output)

‎src/lib/versions.cpp‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
Copyright (c) 2025, 2026 acrion innovations GmbH
3+
Authors: Stefan Zipproth, s.zipproth@acrion.ch
4+
5+
This file is part of zelph, see https://github.com/acrion/zelph and https://zelph.org
6+
7+
zelph is offered under a commercial and under the AGPL license.
8+
For commercial licensing, contact us at https://acrion.ch/sales. For AGPL licensing, see below.
9+
10+
AGPL licensing:
11+
12+
zelph is free software: you can redistribute it and/or modify
13+
it under the terms of the GNU Affero General Public License as published by
14+
the Free Software Foundation, either version 3 of the License, or
15+
(at your option) any later version.
16+
17+
zelph is distributed in the hope that it will be useful,
18+
but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
GNU Affero General Public License for more details.
21+
22+
You should have received a copy of the GNU Affero General Public License
23+
along with zelph. If not, see <https://www.gnu.org/licenses/>.
24+
*/
25+
26+
#include "versions.hpp"
27+
28+
#include "interactive.hpp"
29+
#include "script_engine.hpp"
30+
31+
#include <ankerl/unordered_dense.h>
32+
#include <bzlib.h>
33+
#include <capnp/common.h>
34+
35+
#if __has_include(<mimalloc.h>)
36+
#include <mimalloc.h>
37+
#endif
38+
39+
#include <sstream>
40+
41+
namespace zelph
42+
{
43+
std::string get_version_description()
44+
{
45+
std::ostringstream oss;
46+
47+
// 1. zelph Version
48+
oss << "zelph " << console::Interactive::get_version() << "\n\n";
49+
50+
// 2. Third-party software
51+
oss << "zelph incorporates the following third-party software:\n";
52+
oss << "------------------------------------------------------\n";
53+
54+
// Janet
55+
oss << "Janet (v" << ScriptEngine::get_janet_version() << ") - MIT License\n";
56+
57+
// unordered_dense
58+
oss << "unordered_dense (v"
59+
<< ANKERL_UNORDERED_DENSE_VERSION_MAJOR << "."
60+
<< ANKERL_UNORDERED_DENSE_VERSION_MINOR << "."
61+
<< ANKERL_UNORDERED_DENSE_VERSION_PATCH << ") - MIT License\n";
62+
63+
// Cap'n Proto
64+
oss << "Cap'n Proto (v"
65+
<< CAPNP_VERSION_MAJOR << "."
66+
<< CAPNP_VERSION_MINOR << "."
67+
<< CAPNP_VERSION_MICRO << ") - MIT License\n";
68+
69+
// bzip2
70+
std::string bz2_full = BZ2_bzlibVersion();
71+
size_t bz2_comma_pos = bz2_full.find(',');
72+
std::string bz2_version = (bz2_comma_pos != std::string::npos) ? bz2_full.substr(0, bz2_comma_pos) : bz2_full;
73+
oss << "bzip2 (v" << bz2_version << ") - bzip2 License (BSD-style)\n";
74+
75+
// mimalloc
76+
#if defined(MI_MALLOC_VERSION)
77+
int mi_major = MI_MALLOC_VERSION / 1000;
78+
int mi_minor = (MI_MALLOC_VERSION / 100) % 10;
79+
int mi_patch = MI_MALLOC_VERSION % 100;
80+
oss << "mimalloc (v" << mi_major << "." << mi_minor << "." << mi_patch << ") - MIT License\n";
81+
#endif
82+
83+
oss << "------------------------------------------------------\n";
84+
oss << "For full license texts and copyright notices, please refer to the\n";
85+
oss << "documentation or the source code repositories.";
86+
87+
return oss.str();
88+
}
89+
}

‎src/lib/versions.hpp‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright (c) 2025, 2026 acrion innovations GmbH
3+
Authors: Stefan Zipproth, s.zipproth@acrion.ch
4+
5+
This file is part of zelph, see https://github.com/acrion/zelph and https://zelph.org
6+
7+
zelph is offered under a commercial and under the AGPL license.
8+
For commercial licensing, contact us at https://acrion.ch/sales. For AGPL licensing, see below.
9+
10+
AGPL licensing:
11+
12+
zelph is free software: you can redistribute it and/or modify
13+
it under the terms of the GNU Affero General Public License as published by
14+
the Free Software Foundation, either version 3 of the License, or
15+
(at your option) any later version.
16+
17+
zelph is distributed in the hope that it will be useful,
18+
but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
GNU Affero General Public License for more details.
21+
22+
You should have received a copy of the GNU Affero General Public License
23+
along with zelph. If not, see <https://www.gnu.org/licenses/>.
24+
*/
25+
26+
#pragma once
27+
28+
#include <string>
29+
30+
namespace zelph
31+
{
32+
std::string get_version_description();
33+
}

0 commit comments

Comments
 (0)