Skip to content

Commit 1b1e5fc

Browse files
committed
fix: tool header was incorrectly formatted for universal binary
1 parent 068573a commit 1b1e5fc

File tree

6 files changed

+28
-24
lines changed

6 files changed

+28
-24
lines changed

tools/include/dwarfs/tool/tool.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ using extra_deps_fn = std::function<void(library_dependencies&)>;
4747
std::string tool_header(std::string_view tool_name, std::string_view extra_info,
4848
extra_deps_fn const& extra_deps);
4949

50+
std::string tool_header_nodeps(std::string_view tool_name);
51+
5052
inline std::string
5153
tool_header(std::string_view tool_name, std::string_view extra_info = {}) {
5254
return tool_header(tool_name, extra_info, {});

tools/src/dwarfs_main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,6 @@ int op_rename(char const* from, char const* to, unsigned int flags) {
11611161
void usage(std::ostream& os, std::filesystem::path const& progname) {
11621162
os << tool::tool_header("dwarfs",
11631163
fmt::format(", fuse version {}", FUSE_USE_VERSION))
1164-
<< "\n\n"
11651164
#if !DWARFS_FUSE_LOWLEVEL
11661165
<< "USING HIGH-LEVEL FUSE API\n\n"
11671166
#endif

tools/src/dwarfsck_main.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,7 @@ int dwarfsck_main(int argc, sys_char** argv, iolayer const& iol) {
256256
auto constexpr usage = "Usage: dwarfsck [OPTIONS...]\n";
257257

258258
if (vm.contains("help") or !vm.contains("input")) {
259-
iol.out << tool::tool_header("dwarfsck") << "\n\n"
260-
<< usage << "\n"
261-
<< opts << "\n";
259+
iol.out << tool::tool_header("dwarfsck") << usage << "\n" << opts << "\n";
262260
return 0;
263261
}
264262

tools/src/dwarfsextract_main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ int dwarfsextract_main(int argc, sys_char** argv, iolayer const& iol) {
145145
utility::filesystem_extractor::add_library_dependencies(deps);
146146
};
147147

148-
iol.out << tool::tool_header("dwarfsextract", extra_deps) << "\n\n"
149-
<< usage << "\n"
148+
iol.out << tool::tool_header("dwarfsextract", extra_deps) << usage << "\n"
150149
<< opts << "\n";
151150
return 0;
152151
}

tools/src/mkdwarfs_main.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,7 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
716716

717717
std::string sep(30 + l_dc + l_sc + l_mc + l_or, '-');
718718

719-
iol.out << tool::tool_header("mkdwarfs") << "\n\n"
720-
<< usage << opts << "\n"
719+
iol.out << tool::tool_header("mkdwarfs") << usage << opts << "\n"
721720
<< "Compression level defaults:\n"
722721
<< " " << sep << "\n"
723722
<< fmt::format(" Level Block {:{}s} {:s} Inode\n",
@@ -769,8 +768,7 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
769768
if (vm.contains("help") or
770769
!(vm.contains("input") or vm.contains("input-list")) or
771770
(!vm.contains("output") and !vm.contains("debug-filter"))) {
772-
iol.out << tool::tool_header("mkdwarfs") << "\n\n"
773-
<< usage << "\n"
771+
iol.out << tool::tool_header("mkdwarfs") << usage << "\n"
774772
<< basic_opts << "\n";
775773
return 0;
776774
}

tools/src/tool/tool.cpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,29 @@ std::string get_jemalloc_version() {
7575
}
7676
#endif
7777

78-
} // namespace
79-
80-
std::string tool_header(std::string_view tool_name, std::string_view extra_info,
81-
extra_deps_fn const& extra_deps) {
78+
std::string
79+
tool_header_impl(std::string_view tool_name, std::string_view extra_info = {}) {
8280
std::string date;
8381

8482
if (DWARFS_GIT_DATE) {
8583
date = fmt::format(" [{}]", DWARFS_GIT_DATE);
8684
}
8785

86+
return fmt::format(
87+
// clang-format off
88+
R"( ___ ___ ___)""\n"
89+
R"( | \__ __ ____ _ _ _| __/ __| Deduplicating Warp-speed)""\n"
90+
R"( | |) \ V V / _` | '_| _|\__ \ Advanced Read-only File System)""\n"
91+
R"( |___/ \_/\_/\__,_|_| |_| |___/ by Marcus Holland-Moritz)""\n\n"
92+
// clang-format on
93+
"{} ({}{}{})\nbuilt for {}\n\n",
94+
tool_name, DWARFS_GIT_ID, date, extra_info, DWARFS_BUILD_ID);
95+
}
96+
97+
} // namespace
98+
99+
std::string tool_header(std::string_view tool_name, std::string_view extra_info,
100+
extra_deps_fn const& extra_deps) {
88101
library_dependencies deps;
89102
deps.add_common_libraries();
90103

@@ -96,16 +109,11 @@ std::string tool_header(std::string_view tool_name, std::string_view extra_info,
96109
extra_deps(deps);
97110
}
98111

99-
return fmt::format(
100-
// clang-format off
101-
R"( ___ ___ ___)""\n"
102-
R"( | \__ __ ____ _ _ _| __/ __| Deduplicating Warp-speed)""\n"
103-
R"( | |) \ V V / _` | '_| _|\__ \ Advanced Read-only File System)""\n"
104-
R"( |___/ \_/\_/\__,_|_| |_| |___/ by Marcus Holland-Moritz)""\n\n"
105-
// clang-format on
106-
"{} ({}{}{})\nbuilt for {}\n\n{}",
107-
tool_name, DWARFS_GIT_ID, date, extra_info, DWARFS_BUILD_ID,
108-
deps.as_string());
112+
return tool_header_impl(tool_name, extra_info) + deps.as_string() + "\n\n";
113+
}
114+
115+
std::string tool_header_nodeps(std::string_view tool_name) {
116+
return tool_header_impl(tool_name);
109117
}
110118

111119
void add_common_options(po::options_description& opts,

0 commit comments

Comments
 (0)