Skip to content

Commit 19b5c0f

Browse files
authored
Merge pull request #2369 from joto/version-cmd
Reorganize the way we are printing version numbers
2 parents 7d1e06d + 8feb76a commit 19b5c0f

File tree

6 files changed

+37
-24
lines changed

6 files changed

+37
-24
lines changed

src/command-line-parser.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "command-line-parser.hpp"
1111

1212
#include "command-line-app.hpp"
13-
#include "format.hpp"
1413
#include "logging.hpp"
1514
#include "options.hpp"
1615
#include "pgsql.hpp"
@@ -20,12 +19,9 @@
2019
#include "version.hpp"
2120

2221
#include <osmium/util/string.hpp>
23-
#include <osmium/version.hpp>
2422

2523
#include <CLI/CLI.hpp>
2624

27-
#include <lua.hpp>
28-
2925
#include <algorithm>
3026
#include <cmath>
3127
#include <cstdio>
@@ -254,20 +250,6 @@ void check_options_expire(options_t *options) {
254250

255251
} // anonymous namespace
256252

257-
void print_version()
258-
{
259-
fmt::print(stderr, "osm2pgsql version {}\n", get_osm2pgsql_version());
260-
fmt::print(stderr, "Build: {}\n", get_build_type());
261-
fmt::print(stderr, "Compiled using the following library versions:\n");
262-
fmt::print(stderr, "Libosmium {}\n", LIBOSMIUM_VERSION_STRING);
263-
fmt::print(stderr, "Proj {}\n", get_proj_version());
264-
#ifdef HAVE_LUAJIT
265-
fmt::print(stderr, "{} ({})\n", LUA_RELEASE, LUAJIT_VERSION);
266-
#else
267-
fmt::print(stderr, "{}\n", LUA_RELEASE);
268-
#endif
269-
}
270-
271253
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
272254
options_t parse_command_line(int argc, char *argv[])
273255
{

src/command-line-parser.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,4 @@
1515
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
1616
options_t parse_command_line(int argc, char *argv[]);
1717

18-
void print_version();
19-
2018
#endif // OSM2PGSQL_COMMAND_LINE_PARSER_HPP

src/gen/osm2pgsql-gen.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242

4343
#include <lua.hpp>
4444

45+
#include <potracelib.h>
46+
47+
#include <opencv2/core/version.hpp>
48+
4549
#include <algorithm>
4650
#include <atomic>
4751
#include <chrono>
@@ -685,13 +689,16 @@ int main(int argc, char *argv[])
685689
return 0;
686690
}
687691

688-
log_info("osm2pgsql-gen version {}", get_osm2pgsql_version());
689-
log_warn("This is an EXPERIMENTAL extension to osm2pgsql.");
690-
691692
if (app.want_version()) {
693+
print_version("osm2pgsql-gen");
694+
fmt::print(stderr, "OpenCV {}\n", CV_VERSION);
695+
fmt::print(stderr, "{}\n", potrace_version());
692696
return 0;
693697
}
694698

699+
log_info("osm2pgsql-gen version {}", get_osm2pgsql_version());
700+
log_warn("This is an EXPERIMENTAL extension to osm2pgsql.");
701+
695702
if (dbschema.empty()) {
696703
log_error("Schema must not be empty");
697704
return 2;

src/osm2pgsql.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ int main(int argc, char *argv[])
339339
}
340340

341341
if (options.command == command_t::version) {
342-
print_version();
342+
print_version("osm2pgsql");
343343
return 0;
344344
}
345345

src/version.cpp.in

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@
77
* For a full list of authors see the git log.
88
*/
99

10+
#include "format.hpp"
11+
#include "reprojection.hpp"
1012
#include "version.hpp"
1113

14+
#include <osmium/version.hpp>
15+
16+
#include <lua.hpp>
17+
18+
#include <nlohmann/json.hpp>
19+
1220
char const *get_build_type() noexcept
1321
{
1422
return "@CMAKE_BUILD_TYPE@";
@@ -34,3 +42,18 @@ uint32_t get_minimum_postgresql_server_version_num() noexcept
3442
return @MINIMUM_POSTGRESQL_SERVER_VERSION_NUM@;
3543
}
3644

45+
void print_version(std::string const &command)
46+
{
47+
fmt::print(stderr, "{} version {}\n", command, get_osm2pgsql_version());
48+
fmt::print(stderr, "Build: {}\n", get_build_type());
49+
fmt::print(stderr, "Compiled using the following library versions:\n");
50+
fmt::print(stderr, "Libosmium {}\n", LIBOSMIUM_VERSION_STRING);
51+
fmt::print(stderr, "Proj {}\n", get_proj_version());
52+
fmt::print(stderr, "nlohmann JSON {}.{}.{}\n", NLOHMANN_JSON_VERSION_MAJOR,
53+
NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH);
54+
#ifdef HAVE_LUAJIT
55+
fmt::print(stderr, "{} ({})\n", LUA_RELEASE, LUAJIT_VERSION);
56+
#else
57+
fmt::print(stderr, "{}\n", LUA_RELEASE);
58+
#endif
59+
}

src/version.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
*/
1212

1313
#include <cstdint>
14+
#include <string>
1415

1516
char const *get_build_type() noexcept;
1617
char const *get_osm2pgsql_version() noexcept;
1718
char const *get_osm2pgsql_short_version() noexcept;
1819
char const *get_minimum_postgresql_server_version() noexcept;
1920
uint32_t get_minimum_postgresql_server_version_num() noexcept;
2021

22+
void print_version(std::string const &command);
23+
2124
#endif // OSM2PGSQL_VERSION_HPP

0 commit comments

Comments
 (0)