refactor: Move license info into new module

This commit is contained in:
Hennadii Stepanov
2026-03-30 16:34:48 +01:00
parent eb750d277b
commit 6953363be8
15 changed files with 70 additions and 40 deletions

View File

@@ -209,7 +209,7 @@ fi
if [[ "${RUN_IWYU}" == true ]]; then
# TODO: Consider enforcing IWYU across the entire codebase.
FILES_WITH_ENFORCED_IWYU="/src/((crypto|index|kernel|primitives|univalue/(lib|test)|zmq)/.*\\.cpp|node/blockstorage\\.cpp|node/utxo_snapshot\\.cpp|core_io\\.cpp|signet\\.cpp)"
FILES_WITH_ENFORCED_IWYU="/src/(((crypto|index|kernel|primitives|univalue/(lib|test)|zmq)/.*|common/license_info|node/blockstorage|node/utxo_snapshot|clientversion|core_io|signet)\\.cpp)"
jq --arg patterns "$FILES_WITH_ENFORCED_IWYU" 'map(select(.file | test($patterns)))' "${BASE_BUILD_DIR}/compile_commands.json" > "${BASE_BUILD_DIR}/compile_commands_iwyu_errors.json"
jq --arg patterns "$FILES_WITH_ENFORCED_IWYU" 'map(select(.file | test($patterns) | not))' "${BASE_BUILD_DIR}/compile_commands.json" > "${BASE_BUILD_DIR}/compile_commands_iwyu_warnings.json"

View File

@@ -97,6 +97,7 @@ add_library(bitcoin_common STATIC EXCLUDE_FROM_ALL
common/config.cpp
common/init.cpp
common/interfaces.cpp
common/license_info.cpp
common/messages.cpp
common/netif.cpp
common/pcp.cpp

View File

@@ -8,6 +8,7 @@
#include <chainparamsbase.h>
#include <clientversion.h>
#include <common/args.h>
#include <common/license_info.h>
#include <common/system.h>
#include <compat/compat.h>
#include <compat/stdin.h>

View File

@@ -8,6 +8,7 @@
#include <clientversion.h>
#include <coins.h>
#include <common/args.h>
#include <common/license_info.h>
#include <common/system.h>
#include <compat/compat.h>
#include <consensus/amount.h>

View File

@@ -10,6 +10,7 @@
#include <chainparamsbase.h>
#include <clientversion.h>
#include <common/args.h>
#include <common/license_info.h>
#include <common/system.h>
#include <compat/compat.h>
#include <core_io.h>

View File

@@ -8,6 +8,7 @@
#include <chainparamsbase.h>
#include <clientversion.h>
#include <common/args.h>
#include <common/license_info.h>
#include <common/system.h>
#include <compat/compat.h>
#include <interfaces/init.h>

View File

@@ -6,6 +6,7 @@
#include <clientversion.h>
#include <common/args.h>
#include <common/license_info.h>
#include <common/system.h>
#include <util/fs.h>
#include <util/exec.h>

View File

@@ -9,6 +9,7 @@
#include <clientversion.h>
#include <common/args.h>
#include <common/init.h>
#include <common/license_info.h>
#include <common/system.h>
#include <compat/compat.h>
#include <init.h>

View File

@@ -6,10 +6,8 @@
#include <clientversion.h>
#include <util/string.h>
#include <util/translation.h>
#include <tinyformat.h>
#include <util/string.h>
#include <string>
#include <vector>
@@ -70,34 +68,3 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const
if (!comments.empty()) comments_str = strprintf("(%s)", Join(comments, "; "));
return strprintf("/%s:%s%s/", name, FormatVersion(nClientVersion), comments_str);
}
std::string CopyrightHolders(const std::string& strPrefix)
{
const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS), COPYRIGHT_HOLDERS_SUBSTITUTION).translated;
std::string strCopyrightHolders = strPrefix + copyright_devs;
// Make sure Bitcoin Core copyright is not removed by accident
if (copyright_devs.find("Bitcoin Core") == std::string::npos) {
strCopyrightHolders += "\n" + strPrefix + "The Bitcoin Core developers";
}
return strCopyrightHolders;
}
std::string LicenseInfo()
{
const std::string URL_SOURCE_CODE = "<https://github.com/bitcoin/bitcoin>";
return CopyrightHolders(strprintf(_("Copyright (C) %i-%i"), 2009, COPYRIGHT_YEAR).translated + " ") + "\n" +
"\n" +
strprintf(_("Please contribute if you find %s useful. "
"Visit %s for further information about the software."),
CLIENT_NAME, "<" CLIENT_URL ">")
.translated +
"\n" +
strprintf(_("The source code is available from %s."), URL_SOURCE_CODE).translated +
"\n" +
"\n" +
_("This is experimental software.") + "\n" +
strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s"), "COPYING", "<https://opensource.org/license/MIT>").translated +
"\n";
}

View File

@@ -34,11 +34,6 @@ extern const std::string UA_NAME;
std::string FormatFullVersion();
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
std::string CopyrightHolders(const std::string& strPrefix);
/** Returns licensing information (for -version) */
std::string LicenseInfo();
#endif // RC_INVOKED
#endif // BITCOIN_CLIENTVERSION_H

View File

@@ -0,0 +1,43 @@
// Copyright (c) The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://opensource.org/license/mit/.
#include <bitcoin-build-config.h> // IWYU pragma: keep
#include <common/license_info.h>
#include <tinyformat.h>
#include <util/translation.h>
#include <string>
std::string CopyrightHolders(const std::string& strPrefix)
{
const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS), COPYRIGHT_HOLDERS_SUBSTITUTION).translated;
std::string strCopyrightHolders = strPrefix + copyright_devs;
// Make sure Bitcoin Core copyright is not removed by accident
if (copyright_devs.find("Bitcoin Core") == std::string::npos) {
strCopyrightHolders += "\n" + strPrefix + "The Bitcoin Core developers";
}
return strCopyrightHolders;
}
std::string LicenseInfo()
{
const std::string URL_SOURCE_CODE = "<https://github.com/bitcoin/bitcoin>";
return CopyrightHolders(strprintf(_("Copyright (C) %i-%i"), 2009, COPYRIGHT_YEAR).translated + " ") + "\n" +
"\n" +
strprintf(_("Please contribute if you find %s useful. "
"Visit %s for further information about the software."),
CLIENT_NAME, "<" CLIENT_URL ">")
.translated +
"\n" +
strprintf(_("The source code is available from %s."), URL_SOURCE_CODE).translated +
"\n" +
"\n" +
_("This is experimental software.") + "\n" +
strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s"), "COPYING", "<https://opensource.org/license/MIT>").translated +
"\n";
}

15
src/common/license_info.h Normal file
View File

@@ -0,0 +1,15 @@
// Copyright (c) The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://opensource.org/license/mit/.
#ifndef BITCOIN_COMMON_LICENSE_INFO_H
#define BITCOIN_COMMON_LICENSE_INFO_H
#include <string>
std::string CopyrightHolders(const std::string& strPrefix);
/** Returns licensing information (for -version) */
std::string LicenseInfo();
#endif // BITCOIN_COMMON_LICENSE_INFO_H

View File

@@ -7,6 +7,7 @@
#include <qt/splashscreen.h>
#include <clientversion.h>
#include <common/license_info.h>
#include <common/system.h>
#include <interfaces/handler.h>
#include <interfaces/node.h>

View File

@@ -12,6 +12,7 @@
#include <clientversion.h>
#include <common/args.h>
#include <common/license_info.h>
#include <init.h>
#include <util/strencodings.h>

View File

@@ -5,6 +5,7 @@
#include <blockfilter.h>
#include <clientversion.h>
#include <common/args.h>
#include <common/license_info.h>
#include <common/messages.h>
#include <common/settings.h>
#include <common/system.h>