mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-12 11:12:16 +00:00
Automatically integrates git build information into executables.
Usage:
func.exe -V
adnl-pong -V
validator-engine -V
and so on.
Result will be shown in the following format:
Func build information: [ Commit: d8b751d7a5
, Date: 2021-02-27 14:34:41 +0200]
This commit is contained in:
parent
41a3418b7b
commit
bab4c1637e
40 changed files with 492 additions and 78 deletions
|
@ -4,7 +4,15 @@ project(TON VERSION 0.5 LANGUAGES C CXX)
|
|||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
#set(OPENSSL_USE_STATIC_LIBS TRUE)
|
||||
|
||||
ADD_DEFINITIONS( -DBUILD_VERSION=\"3.0.0\" )
|
||||
# Define the two required variables before including the source code for watching a git repository.
|
||||
set(PRE_CONFIGURE_FILE "git.cc.in")
|
||||
set(POST_CONFIGURE_FILE "${CMAKE_CURRENT_BINARY_DIR}/git.cc")
|
||||
include(git_watcher.cmake)
|
||||
|
||||
# Create a library out of the compiled post-configure file.
|
||||
add_library(git STATIC ${POST_CONFIGURE_FILE})
|
||||
target_include_directories(git PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_dependencies(git check_git)
|
||||
|
||||
# Prevent in-source build
|
||||
get_filename_component(TON_REAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)
|
||||
|
|
|
@ -89,12 +89,12 @@ target_link_libraries(adnl PUBLIC tdactor ton_crypto tl_api tdnet tddb keys keyr
|
|||
add_executable(adnl-proxy ${ADNL_PROXY_SOURCE})
|
||||
target_include_directories(adnl-proxy PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
target_link_libraries(adnl-proxy PUBLIC tdactor ton_crypto tl_api tdnet common
|
||||
tl-utils)
|
||||
tl-utils git)
|
||||
|
||||
add_executable(adnl-pong adnl-pong.cpp)
|
||||
target_include_directories(adnl-pong PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
target_link_libraries(adnl-pong PUBLIC tdactor ton_crypto tl_api tdnet common
|
||||
tl-utils adnl dht)
|
||||
tl-utils adnl dht git)
|
||||
|
||||
add_library(adnltest STATIC ${ADNL_TEST_SOURCE})
|
||||
target_include_directories(adnltest PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
|
@ -105,4 +105,4 @@ endif()
|
|||
add_library(adnllite STATIC ${ADNL_LITE_SOURCE})
|
||||
|
||||
target_include_directories(adnllite PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
target_link_libraries(adnllite PUBLIC tdactor ton_crypto tl_lite_api tdnet keys )
|
||||
target_link_libraries(adnllite PUBLIC tdactor ton_crypto tl_lite_api tdnet keys)
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "auto/tl/ton_api_json.h"
|
||||
#include "adnl/adnl.h"
|
||||
#include <map>
|
||||
#include "git.h"
|
||||
|
||||
#if TD_DARWIN || TD_LINUX
|
||||
#include <unistd.h>
|
||||
|
@ -97,8 +98,8 @@ int main(int argc, char *argv[]) {
|
|||
int v = VERBOSITY_NAME(FATAL) + (td::to_integer<int>(arg));
|
||||
SET_VERBOSITY_LEVEL(v);
|
||||
});
|
||||
p.add_option('V', "version", "shows adnl-pong build version", [&]() {
|
||||
std::cout << "adnl-pong build version: [" << BUILD_VERSION << "]\n";
|
||||
p.add_option('V', "version", "shows adnl-pong build information", [&]() {
|
||||
std::cout << "adnl-pong build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
});
|
||||
p.add_option('h', "help", "prints_help", [&]() {
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "adnl-proxy-types.h"
|
||||
#include "adnl-received-mask.h"
|
||||
#include <map>
|
||||
#include "git.h"
|
||||
|
||||
#if TD_DARWIN || TD_LINUX
|
||||
#include <unistd.h>
|
||||
|
@ -303,8 +304,8 @@ int main(int argc, char *argv[]) {
|
|||
int v = VERBOSITY_NAME(FATAL) + (td::to_integer<int>(arg));
|
||||
SET_VERBOSITY_LEVEL(v);
|
||||
});
|
||||
p.add_option('V', "version", "shows adnl-proxy build version", [&]() {
|
||||
std::cout << "adnl-proxy build version: [" << BUILD_VERSION << "]\n";
|
||||
p.add_option('V', "version", "shows adnl-proxy build information", [&]() {
|
||||
std::cout << "adnl-proxy build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
});
|
||||
p.add_option('h', "help", "prints_help", [&]() {
|
||||
|
|
|
@ -12,6 +12,6 @@ set(CREATE_HARDFORK_SOURCE
|
|||
add_executable(create-hardfork ${CREATE_HARDFORK_SOURCE})
|
||||
target_link_libraries(create-hardfork overlay tdutils tdactor adnl tl_api dht
|
||||
rldp catchain validatorsession full-node validator-hardfork ton_validator
|
||||
validator-hardfork fift-lib memprof ${JEMALLOC_LIBRARIES})
|
||||
validator-hardfork fift-lib memprof git ${JEMALLOC_LIBRARIES})
|
||||
|
||||
install(TARGETS create-hardfork RUNTIME DESTINATION bin)
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#endif
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include "git.h"
|
||||
|
||||
int verbosity;
|
||||
|
||||
|
@ -263,8 +264,8 @@ int main(int argc, char *argv[]) {
|
|||
std::cout << sb.as_cslice().c_str();
|
||||
std::exit(2);
|
||||
});
|
||||
p.add_option('V', "version", "shows create-hardfork build version", [&]() {
|
||||
std::cout << "create-hardfork build version: [" << BUILD_VERSION << "]\n";
|
||||
p.add_option('V', "version", "shows create-hardfork build information", [&]() {
|
||||
std::cout << "create-hardfork build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
});
|
||||
p.add_option('D', "db", "root for dbs",
|
||||
|
|
|
@ -284,7 +284,7 @@ target_link_libraries(fift-lib PUBLIC ton_crypto ton_db tdutils ton_block)
|
|||
set_target_properties(fift-lib PROPERTIES OUTPUT_NAME fift)
|
||||
|
||||
add_executable(fift fift/fift-main.cpp)
|
||||
target_link_libraries(fift PUBLIC fift-lib)
|
||||
target_link_libraries(fift PUBLIC fift-lib git)
|
||||
if (WINGETOPT_FOUND)
|
||||
target_link_libraries_system(fift wingetopt)
|
||||
endif()
|
||||
|
@ -295,7 +295,7 @@ target_link_libraries(src_parser PUBLIC ton_crypto)
|
|||
|
||||
add_executable(func func/func.cpp ${FUNC_LIB_SOURCE})
|
||||
target_include_directories(func PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||
target_link_libraries(func PUBLIC ton_crypto src_parser)
|
||||
target_link_libraries(func PUBLIC ton_crypto src_parser git)
|
||||
if (WINGETOPT_FOUND)
|
||||
target_link_libraries_system(func wingetopt)
|
||||
endif()
|
||||
|
@ -312,10 +312,11 @@ target_include_directories(pow-miner-lib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURREN
|
|||
target_link_libraries(pow-miner-lib PUBLIC ton_crypto ton_block)
|
||||
|
||||
add_executable(pow-miner util/pow-miner.cpp)
|
||||
target_link_libraries(pow-miner PRIVATE ton_crypto ton_block pow-miner-lib)
|
||||
target_link_libraries(pow-miner PRIVATE ton_crypto ton_block pow-miner-lib git)
|
||||
|
||||
if (WINGETOPT_FOUND)
|
||||
target_link_libraries_system(fift wingetopt)
|
||||
target_link_libraries_system(pow-miner wingetopt)
|
||||
endif()
|
||||
|
||||
add_library(ton_block ${BLOCK_SOURCE})
|
||||
|
@ -404,12 +405,12 @@ add_executable(create-state block/create-state.cpp)
|
|||
target_include_directories(create-state PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
if (INTERNAL_COMPILE)
|
||||
target_link_libraries(create-state PUBLIC ton_crypto fift-lib ton_block tonlib)
|
||||
target_link_libraries(create-state PUBLIC ton_crypto fift-lib ton_block tonlib git)
|
||||
else()
|
||||
if (TONLIB_COMPILE)
|
||||
target_link_libraries(create-state PUBLIC ton_crypto fift-lib ton_block tonlib)
|
||||
target_link_libraries(create-state PUBLIC ton_crypto fift-lib ton_block tonlib git)
|
||||
else()
|
||||
target_link_libraries(create-state PUBLIC ton_crypto fift-lib ton_block)
|
||||
target_link_libraries(create-state PUBLIC ton_crypto fift-lib ton_block git)
|
||||
endif()
|
||||
endif()
|
||||
if (WINGETOPT_FOUND)
|
||||
|
@ -419,7 +420,7 @@ endif()
|
|||
add_executable(dump-block block/dump-block.cpp)
|
||||
target_include_directories(dump-block PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
target_link_libraries(dump-block PUBLIC ton_crypto fift-lib ton_block)
|
||||
target_link_libraries(dump-block PUBLIC ton_crypto fift-lib ton_block git)
|
||||
if (WINGETOPT_FOUND)
|
||||
target_link_libraries_system(dump-block wingetopt)
|
||||
endif()
|
||||
|
@ -427,15 +428,16 @@ endif()
|
|||
add_executable(adjust-block block/adjust-block.cpp)
|
||||
target_include_directories(adjust-block PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
target_link_libraries(adjust-block PUBLIC ton_crypto fift-lib ton_block)
|
||||
target_link_libraries(adjust-block PUBLIC ton_crypto fift-lib ton_block git)
|
||||
if (WINGETOPT_FOUND)
|
||||
target_link_libraries_system(dump-block wingetopt)
|
||||
target_link_libraries_system(adjust-block wingetopt)
|
||||
endif()
|
||||
|
||||
add_executable(test-weight-distr block/test-weight-distr.cpp)
|
||||
target_include_directories(test-weight-distr PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
target_link_libraries(test-weight-distr PUBLIC ton_crypto fift-lib ton_block)
|
||||
target_link_libraries(test-weight-distr PUBLIC ton_crypto fift-lib ton_block git)
|
||||
if (WINGETOPT_FOUND)
|
||||
target_link_libraries_system(test-weight-distr wingetopt)
|
||||
endif()
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "vm/cp0.h"
|
||||
#include "td/utils/crypto.h"
|
||||
#include <getopt.h>
|
||||
#include "git.h"
|
||||
|
||||
using td::Ref;
|
||||
using namespace std::literals::string_literals;
|
||||
|
@ -144,7 +145,7 @@ int main(int argc, char* const argv[]) {
|
|||
int i, vseqno_incr = 1;
|
||||
int new_verbosity_level = VERBOSITY_NAME(INFO);
|
||||
std::string in_fname, out_fname;
|
||||
while ((i = getopt(argc, argv, "hi:v:")) != -1) {
|
||||
while ((i = getopt(argc, argv, "hi:v:V")) != -1) {
|
||||
switch (i) {
|
||||
case 'h':
|
||||
usage();
|
||||
|
@ -156,6 +157,10 @@ int main(int argc, char* const argv[]) {
|
|||
case 'v':
|
||||
new_verbosity_level = VERBOSITY_NAME(FATAL) + (verbosity = td::to_integer<int>(td::Slice(optarg)));
|
||||
break;
|
||||
case 'V':
|
||||
std::cout << "adjust-block build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "block-parse.h"
|
||||
#include "block-auto.h"
|
||||
#include "mc-config.h"
|
||||
#include "git.h"
|
||||
|
||||
#if defined(_INTERNAL_COMPILE) || defined(_TONLIB_COMPILE)
|
||||
#define WITH_TONLIB
|
||||
|
@ -805,7 +806,7 @@ void usage(const char* progname) {
|
|||
"$FIFTPATH is used instead.\n"
|
||||
"\t-L<library-fif-file>\tPre-loads a library source file\n"
|
||||
"\t-v<verbosity-level>\tSet verbosity level\n"
|
||||
"\t-V<version>\tShow create-state build version\n";
|
||||
"\t-V<version>\tShow create-state build information\n";
|
||||
std::exit(2);
|
||||
}
|
||||
|
||||
|
@ -866,7 +867,7 @@ int main(int argc, char* const argv[]) {
|
|||
new_verbosity_level = VERBOSITY_NAME(FATAL) + (verbosity = td::to_integer<int>(td::Slice(optarg)));
|
||||
break;
|
||||
case 'V':
|
||||
std::cout << "create-state build version: [" << BUILD_VERSION << "]\n";
|
||||
std::cout << "create-state build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
break;
|
||||
case 'h':
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "mc-config.h"
|
||||
#include "vm/cp0.h"
|
||||
#include <getopt.h>
|
||||
#include "git.h"
|
||||
|
||||
using td::Ref;
|
||||
using namespace std::literals::string_literals;
|
||||
|
@ -247,7 +248,7 @@ void usage() {
|
|||
std::cout << "usage: dump-block [-t<typename>][-S][<boc-file>]\n\tor dump-block -h\n\tDumps specified blockchain "
|
||||
"block or state "
|
||||
"from <boc-file>, or runs some tests\n\t-S\tDump a blockchain state instead of a block\n"
|
||||
"\t-V<version>\tShow fift build version\n";
|
||||
"\t-V<version>\tShow fift build information\n";
|
||||
std::exit(2);
|
||||
}
|
||||
|
||||
|
@ -282,7 +283,7 @@ int main(int argc, char* const argv[]) {
|
|||
dump = 0;
|
||||
break;
|
||||
case 'V':
|
||||
std::cout << "dump-block build version: [" << BUILD_VERSION << "]\n";
|
||||
std::cout << "dump-block build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
break;
|
||||
case 'h':
|
||||
|
|
|
@ -53,6 +53,8 @@
|
|||
#include "td/utils/Parser.h"
|
||||
#include "td/utils/port/path.h"
|
||||
|
||||
#include "git.h"
|
||||
|
||||
void usage(const char* progname) {
|
||||
std::cerr << "A simple Fift interpreter. Type `bye` to quit, or `words` to get a list of all commands\n";
|
||||
std::cerr
|
||||
|
@ -66,7 +68,7 @@ void usage(const char* progname) {
|
|||
"\t-d<ton-db-path>\tUse a ton database\n"
|
||||
"\t-s\tScript mode: use first argument as a fift source file and import remaining arguments as $n)\n"
|
||||
"\t-v<verbosity-level>\tSet verbosity level\n"
|
||||
"\t-V<version>\tShow fift build version\n";
|
||||
"\t-V<version>\tShow fift build information\n";
|
||||
std::exit(2);
|
||||
}
|
||||
|
||||
|
@ -118,7 +120,7 @@ int main(int argc, char* const argv[]) {
|
|||
new_verbosity_level = VERBOSITY_NAME(FATAL) + td::to_integer<int>(td::Slice(optarg));
|
||||
break;
|
||||
case 'V':
|
||||
std::cout << "Fift build version: [" << BUILD_VERSION << "]\n";
|
||||
std::cout << "Fift build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
break;
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "parser/symtable.h"
|
||||
#include <getopt.h>
|
||||
#include <fstream>
|
||||
#include "git.h"
|
||||
|
||||
namespace funC {
|
||||
|
||||
|
@ -172,7 +173,7 @@ void usage(const char* progname) {
|
|||
"-R\tInclude operation rewrite comments in the output code\n"
|
||||
"-W<output-boc-file>\tInclude Fift code to serialize and save generated code into specified BoC file. Enables "
|
||||
"-A and -P.\n"
|
||||
"\t-V<version>\tShow func build version\n";
|
||||
"\t-V<version>\tShow func build information\n";
|
||||
std::exit(2);
|
||||
}
|
||||
|
||||
|
@ -215,7 +216,7 @@ int main(int argc, char* const argv[]) {
|
|||
funC::asm_preamble = funC::program_envelope = true;
|
||||
break;
|
||||
case 'V':
|
||||
std::cout << "Func build version: [" << BUILD_VERSION << "]\n";
|
||||
std::cout << "Func build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
break;
|
||||
case 'h':
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include <thread>
|
||||
#include <cstdlib>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "git.h"
|
||||
#include "Miner.h"
|
||||
|
||||
const char* progname;
|
||||
|
@ -46,7 +46,7 @@ int usage() {
|
|||
std::cerr
|
||||
<< "usage: " << progname
|
||||
<< " [-v][-B][-w<threads>] [-t<timeout>] <my-address> <pow-seed> <pow-complexity> <iterations> [<miner-addr> "
|
||||
"<output-ext-msg-boc>]\n"
|
||||
"<output-ext-msg-boc>] [-V]\n"
|
||||
"Outputs a valid <rdata> value for proof-of-work testgiver after computing at most <iterations> hashes "
|
||||
"or terminates with non-zero exit code\n";
|
||||
std::exit(2);
|
||||
|
@ -156,7 +156,7 @@ int main(int argc, char* const argv[]) {
|
|||
progname = argv[0];
|
||||
int i, threads = 0;
|
||||
bool bounce = false, benchmark = false;
|
||||
while ((i = getopt(argc, argv, "bnvw:t:Bh")) != -1) {
|
||||
while ((i = getopt(argc, argv, "bnvw:t:Bh:V")) != -1) {
|
||||
switch (i) {
|
||||
case 'v':
|
||||
++verbosity;
|
||||
|
@ -180,6 +180,10 @@ int main(int argc, char* const argv[]) {
|
|||
case 'n':
|
||||
bounce = false;
|
||||
break;
|
||||
case 'V':
|
||||
std::cout << "pow-miner build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
break;
|
||||
case 'h':
|
||||
return usage();
|
||||
default:
|
||||
|
|
|
@ -11,6 +11,6 @@ set (DHT_SERVER_SOURCE
|
|||
)
|
||||
|
||||
add_executable (dht-server ${DHT_SERVER_SOURCE})
|
||||
target_link_libraries(dht-server tdutils tdactor adnl tl_api dht memprof ${JEMALLOC_LIBRARIES})
|
||||
target_link_libraries(dht-server tdutils tdactor adnl tl_api dht memprof git ${JEMALLOC_LIBRARIES})
|
||||
|
||||
install(TARGETS dht-server RUNTIME DESTINATION bin)
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include <sstream>
|
||||
#include <cstdlib>
|
||||
#include <set>
|
||||
#include "git.h"
|
||||
|
||||
Config::Config() {
|
||||
out_port = 3278;
|
||||
|
@ -1182,8 +1183,8 @@ int main(int argc, char *argv[]) {
|
|||
int v = VERBOSITY_NAME(FATAL) + (td::to_integer<int>(arg));
|
||||
SET_VERBOSITY_LEVEL(v);
|
||||
});
|
||||
p.add_option('V', "version", "shows dht-server build version", [&]() {
|
||||
std::cout << "dht-server build version: [" << BUILD_VERSION << "]\n";
|
||||
p.add_option('V', "version", "shows dht-server build information", [&]() {
|
||||
std::cout << "dht-server build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
});
|
||||
p.add_option('h', "help", "prints_help", [&]() {
|
||||
|
|
29
git.cc.in
Normal file
29
git.cc.in
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include "git.h"
|
||||
|
||||
bool GitMetadata::Populated() {
|
||||
return @GIT_RETRIEVED_STATE@;
|
||||
}
|
||||
bool GitMetadata::AnyUncommittedChanges() {
|
||||
return @GIT_IS_DIRTY@;
|
||||
}
|
||||
std::string GitMetadata::AuthorName() {
|
||||
return "@GIT_AUTHOR_NAME@";
|
||||
}
|
||||
std::string GitMetadata::AuthorEmail() {
|
||||
return "@GIT_AUTHOR_EMAIL@";
|
||||
}
|
||||
std::string GitMetadata::CommitSHA1() {
|
||||
return "@GIT_HEAD_SHA1@";
|
||||
}
|
||||
std::string GitMetadata::CommitDate() {
|
||||
return "@GIT_COMMIT_DATE_ISO8601@";
|
||||
}
|
||||
std::string GitMetadata::CommitSubject() {
|
||||
return "@GIT_COMMIT_SUBJECT@";
|
||||
}
|
||||
std::string GitMetadata::CommitBody() {
|
||||
return @GIT_COMMIT_BODY@;
|
||||
}
|
||||
std::string GitMetadata::Describe() {
|
||||
return "@GIT_DESCRIBE@";
|
||||
}
|
29
git.h
Normal file
29
git.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
|
||||
class GitMetadata {
|
||||
public:
|
||||
// Is the metadata populated? We may not have metadata if
|
||||
// there wasn't a .git directory (e.g. downloaded source
|
||||
// code without revision history).
|
||||
static bool Populated();
|
||||
|
||||
// Were there any uncommitted changes that won't be reflected
|
||||
// in the CommitID?
|
||||
static bool AnyUncommittedChanges();
|
||||
|
||||
// The commit author's name.
|
||||
static std::string AuthorName();
|
||||
// The commit author's email.
|
||||
static std::string AuthorEmail();
|
||||
// The commit SHA1.
|
||||
static std::string CommitSHA1();
|
||||
// The ISO8601 commit date.
|
||||
static std::string CommitDate();
|
||||
// The commit subject.
|
||||
static std::string CommitSubject();
|
||||
// The commit body.
|
||||
static std::string CommitBody();
|
||||
// The commit describe.
|
||||
static std::string Describe();
|
||||
};
|
314
git_watcher.cmake
Normal file
314
git_watcher.cmake
Normal file
|
@ -0,0 +1,314 @@
|
|||
# git_watcher.cmake
|
||||
# https://raw.githubusercontent.com/andrew-hardin/cmake-git-version-tracking/master/git_watcher.cmake
|
||||
#
|
||||
# Released under the MIT License.
|
||||
# https://raw.githubusercontent.com/andrew-hardin/cmake-git-version-tracking/master/LICENSE
|
||||
|
||||
|
||||
# This file defines a target that monitors the state of a git repo.
|
||||
# If the state changes (e.g. a commit is made), then a file gets reconfigured.
|
||||
# Here are the primary variables that control script behavior:
|
||||
#
|
||||
# PRE_CONFIGURE_FILE (REQUIRED)
|
||||
# -- The path to the file that'll be configured.
|
||||
#
|
||||
# POST_CONFIGURE_FILE (REQUIRED)
|
||||
# -- The path to the configured PRE_CONFIGURE_FILE.
|
||||
#
|
||||
# GIT_STATE_FILE (OPTIONAL)
|
||||
# -- The path to the file used to store the previous build's git state.
|
||||
# Defaults to the current binary directory.
|
||||
#
|
||||
# GIT_WORKING_DIR (OPTIONAL)
|
||||
# -- The directory from which git commands will be run.
|
||||
# Defaults to the directory with the top level CMakeLists.txt.
|
||||
#
|
||||
# GIT_EXECUTABLE (OPTIONAL)
|
||||
# -- The path to the git executable. It'll automatically be set if the
|
||||
# user doesn't supply a path.
|
||||
#
|
||||
# DESIGN
|
||||
# - This script was designed similar to a Python application
|
||||
# with a Main() function. I wanted to keep it compact to
|
||||
# simplify "copy + paste" usage.
|
||||
#
|
||||
# - This script is invoked under two CMake contexts:
|
||||
# 1. Configure time (when build files are created).
|
||||
# 2. Build time (called via CMake -P).
|
||||
# The first invocation is what registers the script to
|
||||
# be executed at build time.
|
||||
#
|
||||
# MODIFICATIONS
|
||||
# You may wish to track other git properties like when the last
|
||||
# commit was made. There are two sections you need to modify,
|
||||
# and they're tagged with a ">>>" header.
|
||||
|
||||
# Short hand for converting paths to absolute.
|
||||
macro(PATH_TO_ABSOLUTE var_name)
|
||||
get_filename_component(${var_name} "${${var_name}}" ABSOLUTE)
|
||||
endmacro()
|
||||
|
||||
# Check that a required variable is set.
|
||||
macro(CHECK_REQUIRED_VARIABLE var_name)
|
||||
if(NOT DEFINED ${var_name})
|
||||
message(FATAL_ERROR "The \"${var_name}\" variable must be defined.")
|
||||
endif()
|
||||
PATH_TO_ABSOLUTE(${var_name})
|
||||
endmacro()
|
||||
|
||||
# Check that an optional variable is set, or, set it to a default value.
|
||||
macro(CHECK_OPTIONAL_VARIABLE var_name default_value)
|
||||
if(NOT DEFINED ${var_name})
|
||||
set(${var_name} ${default_value})
|
||||
endif()
|
||||
PATH_TO_ABSOLUTE(${var_name})
|
||||
endmacro()
|
||||
|
||||
CHECK_REQUIRED_VARIABLE(PRE_CONFIGURE_FILE)
|
||||
CHECK_REQUIRED_VARIABLE(POST_CONFIGURE_FILE)
|
||||
CHECK_OPTIONAL_VARIABLE(GIT_STATE_FILE "${CMAKE_BINARY_DIR}/git-state-hash")
|
||||
CHECK_OPTIONAL_VARIABLE(GIT_WORKING_DIR "${CMAKE_SOURCE_DIR}")
|
||||
|
||||
# Check the optional git variable.
|
||||
# If it's not set, we'll try to find it using the CMake packaging system.
|
||||
if(NOT DEFINED GIT_EXECUTABLE)
|
||||
find_package(Git QUIET REQUIRED)
|
||||
endif()
|
||||
CHECK_REQUIRED_VARIABLE(GIT_EXECUTABLE)
|
||||
|
||||
|
||||
set(_state_variable_names
|
||||
GIT_RETRIEVED_STATE
|
||||
GIT_HEAD_SHA1
|
||||
GIT_IS_DIRTY
|
||||
GIT_AUTHOR_NAME
|
||||
GIT_AUTHOR_EMAIL
|
||||
GIT_COMMIT_DATE_ISO8601
|
||||
GIT_COMMIT_SUBJECT
|
||||
GIT_COMMIT_BODY
|
||||
GIT_DESCRIBE
|
||||
# >>>
|
||||
# 1. Add the name of the additional git variable you're interested in monitoring
|
||||
# to this list.
|
||||
)
|
||||
|
||||
|
||||
|
||||
# Macro: RunGitCommand
|
||||
# Description: short-hand macro for calling a git function. Outputs are the
|
||||
# "exit_code" and "output" variables.
|
||||
macro(RunGitCommand)
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}" ${ARGV}
|
||||
WORKING_DIRECTORY "${_working_dir}"
|
||||
RESULT_VARIABLE exit_code
|
||||
OUTPUT_VARIABLE output
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT exit_code EQUAL 0)
|
||||
set(ENV{GIT_RETRIEVED_STATE} "false")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
|
||||
# Function: GetGitState
|
||||
# Description: gets the current state of the git repo.
|
||||
# Args:
|
||||
# _working_dir (in) string; the directory from which git commands will be executed.
|
||||
function(GetGitState _working_dir)
|
||||
|
||||
# This is an error code that'll be set to FALSE if the
|
||||
# RunGitCommand ever returns a non-zero exit code.
|
||||
set(ENV{GIT_RETRIEVED_STATE} "true")
|
||||
|
||||
# Get whether or not the working tree is dirty.
|
||||
RunGitCommand(status --porcelain)
|
||||
if(NOT exit_code EQUAL 0)
|
||||
set(ENV{GIT_IS_DIRTY} "false")
|
||||
else()
|
||||
if(NOT "${output}" STREQUAL "")
|
||||
set(ENV{GIT_IS_DIRTY} "true")
|
||||
else()
|
||||
set(ENV{GIT_IS_DIRTY} "false")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# There's a long list of attributes grabbed from git show.
|
||||
set(object HEAD)
|
||||
RunGitCommand(show -s "--format=%H" ${object})
|
||||
if(exit_code EQUAL 0)
|
||||
set(ENV{GIT_HEAD_SHA1} ${output})
|
||||
endif()
|
||||
|
||||
RunGitCommand(show -s "--format=%an" ${object})
|
||||
if(exit_code EQUAL 0)
|
||||
set(ENV{GIT_AUTHOR_NAME} "${output}")
|
||||
endif()
|
||||
|
||||
RunGitCommand(show -s "--format=%ae" ${object})
|
||||
if(exit_code EQUAL 0)
|
||||
set(ENV{GIT_AUTHOR_EMAIL} "${output}")
|
||||
endif()
|
||||
|
||||
RunGitCommand(show -s "--format=%ci" ${object})
|
||||
if(exit_code EQUAL 0)
|
||||
set(ENV{GIT_COMMIT_DATE_ISO8601} "${output}")
|
||||
endif()
|
||||
|
||||
RunGitCommand(show -s "--format=%s" ${object})
|
||||
if(exit_code EQUAL 0)
|
||||
# Escape quotes
|
||||
string(REPLACE "\"" "\\\"" output "${output}")
|
||||
set(ENV{GIT_COMMIT_SUBJECT} "${output}")
|
||||
endif()
|
||||
|
||||
RunGitCommand(show -s "--format=%b" ${object})
|
||||
if(exit_code EQUAL 0)
|
||||
if(output)
|
||||
# Escape quotes
|
||||
string(REPLACE "\"" "\\\"" output "${output}")
|
||||
# Escape line breaks in the commit message.
|
||||
string(REPLACE "\r\n" "\\r\\n\\\r\n" safe "${output}")
|
||||
if(safe STREQUAL output)
|
||||
# Didn't have windows lines - try unix lines.
|
||||
string(REPLACE "\n" "\\n\\\n" safe "${output}")
|
||||
endif()
|
||||
else()
|
||||
# There was no commit body - set the safe string to empty.
|
||||
set(safe "")
|
||||
endif()
|
||||
set(ENV{GIT_COMMIT_BODY} "\"${safe}\"")
|
||||
else()
|
||||
set(ENV{GIT_COMMIT_BODY} "\"\"") # empty string.
|
||||
endif()
|
||||
|
||||
# Get output of git describe
|
||||
RunGitCommand(describe --always ${object})
|
||||
if(NOT exit_code EQUAL 0)
|
||||
set(ENV{GIT_DESCRIBE} "unknown")
|
||||
else()
|
||||
set(ENV{GIT_DESCRIBE} "${output}")
|
||||
endif()
|
||||
|
||||
# >>>
|
||||
# 2. Additional git properties can be added here via the
|
||||
# "execute_process()" command. Be sure to set them in
|
||||
# the environment using the same variable name you added
|
||||
# to the "_state_variable_names" list.
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
# Function: GitStateChangedAction
|
||||
# Description: this function is executed when the state of the git
|
||||
# repository changes (e.g. a commit is made).
|
||||
function(GitStateChangedAction)
|
||||
foreach(var_name ${_state_variable_names})
|
||||
set(${var_name} $ENV{${var_name}})
|
||||
endforeach()
|
||||
configure_file("${PRE_CONFIGURE_FILE}" "${POST_CONFIGURE_FILE}" @ONLY)
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
# Function: HashGitState
|
||||
# Description: loop through the git state variables and compute a unique hash.
|
||||
# Args:
|
||||
# _state (out) string; a hash computed from the current git state.
|
||||
function(HashGitState _state)
|
||||
set(ans "")
|
||||
foreach(var_name ${_state_variable_names})
|
||||
string(SHA256 ans "${ans}$ENV{${var_name}}")
|
||||
endforeach()
|
||||
set(${_state} ${ans} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
# Function: CheckGit
|
||||
# Description: check if the git repo has changed. If so, update the state file.
|
||||
# Args:
|
||||
# _working_dir (in) string; the directory from which git commands will be ran.
|
||||
# _state_changed (out) bool; whether or no the state of the repo has changed.
|
||||
function(CheckGit _working_dir _state_changed)
|
||||
|
||||
# Get the current state of the repo.
|
||||
GetGitState("${_working_dir}")
|
||||
|
||||
# Convert that state into a hash that we can compare against
|
||||
# the hash stored on-disk.
|
||||
HashGitState(state)
|
||||
|
||||
# Issue 14: post-configure file isn't being regenerated.
|
||||
#
|
||||
# Update the state to include the SHA256 for the pre-configure file.
|
||||
# This forces the post-configure file to be regenerated if the
|
||||
# pre-configure file has changed.
|
||||
file(SHA256 ${PRE_CONFIGURE_FILE} preconfig_hash)
|
||||
string(SHA256 state "${preconfig_hash}${state}")
|
||||
|
||||
# Check if the state has changed compared to the backup on disk.
|
||||
if(EXISTS "${GIT_STATE_FILE}")
|
||||
file(READ "${GIT_STATE_FILE}" OLD_HEAD_CONTENTS)
|
||||
if(OLD_HEAD_CONTENTS STREQUAL "${state}")
|
||||
# State didn't change.
|
||||
set(${_state_changed} "false" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# The state has changed.
|
||||
# We need to update the state file on disk.
|
||||
# Future builds will compare their state to this file.
|
||||
file(WRITE "${GIT_STATE_FILE}" "${state}")
|
||||
set(${_state_changed} "true" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
# Function: SetupGitMonitoring
|
||||
# Description: this function sets up custom commands that make the build system
|
||||
# check the state of git before every build. If the state has
|
||||
# changed, then a file is configured.
|
||||
function(SetupGitMonitoring)
|
||||
add_custom_target(check_git
|
||||
ALL
|
||||
DEPENDS ${PRE_CONFIGURE_FILE}
|
||||
BYPRODUCTS
|
||||
${POST_CONFIGURE_FILE}
|
||||
${GIT_STATE_FILE}
|
||||
COMMENT "Checking the git repository for changes..."
|
||||
COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-D_BUILD_TIME_CHECK_GIT=TRUE
|
||||
-DGIT_WORKING_DIR=${GIT_WORKING_DIR}
|
||||
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
|
||||
-DGIT_STATE_FILE=${GIT_STATE_FILE}
|
||||
-DPRE_CONFIGURE_FILE=${PRE_CONFIGURE_FILE}
|
||||
-DPOST_CONFIGURE_FILE=${POST_CONFIGURE_FILE}
|
||||
-P "${CMAKE_CURRENT_LIST_FILE}")
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
# Function: Main
|
||||
# Description: primary entry-point to the script. Functions are selected based
|
||||
# on whether it's configure or build time.
|
||||
function(Main)
|
||||
if(_BUILD_TIME_CHECK_GIT)
|
||||
# Check if the repo has changed.
|
||||
# If so, run the change action.
|
||||
CheckGit("${GIT_WORKING_DIR}" changed)
|
||||
if(changed OR NOT EXISTS "${POST_CONFIGURE_FILE}")
|
||||
GitStateChangedAction()
|
||||
endif()
|
||||
else()
|
||||
# >> Executes at configure time.
|
||||
SetupGitMonitoring()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# And off we go...
|
||||
Main()
|
|
@ -22,4 +22,4 @@ target_link_libraries(tonhttp PUBLIC tdactor ton_crypto tl_api tdnet )
|
|||
|
||||
add_executable(http-proxy http-proxy.cpp)
|
||||
target_include_directories(http-proxy PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
target_link_libraries(http-proxy PRIVATE tonhttp)
|
||||
target_link_libraries(http-proxy PRIVATE tonhttp git)
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include "git.h"
|
||||
|
||||
#if TD_DARWIN || TD_LINUX
|
||||
#include <unistd.h>
|
||||
|
@ -265,7 +266,7 @@ int main(int argc, char *argv[]) {
|
|||
SET_VERBOSITY_LEVEL(v);
|
||||
});
|
||||
p.add_option('V', "version", "shows http-proxy build version", [&]() {
|
||||
std::cout << "http-proxy build version: [" << BUILD_VERSION << "]\n";
|
||||
std::cout << "http-proxy build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
});
|
||||
p.add_option('h', "help", "prints_help", [&]() {
|
||||
|
|
|
@ -5,6 +5,6 @@ target_link_libraries(lite-client-common PUBLIC tdutils tdactor adnllite tl_api
|
|||
|
||||
add_executable(lite-client lite-client.cpp lite-client.h)
|
||||
target_link_libraries(lite-client tdutils tdactor adnllite tl_api tl_lite_api tl-lite-utils ton_crypto ton_block
|
||||
terminal lite-client-common)
|
||||
terminal lite-client-common git)
|
||||
|
||||
install(TARGETS lite-client RUNTIME DESTINATION bin)
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
#endif
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include "git.h"
|
||||
|
||||
using namespace std::literals::string_literals;
|
||||
using td::Ref;
|
||||
|
@ -4200,8 +4201,9 @@ int main(int argc, char* argv[]) {
|
|||
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(FATAL) + verbosity);
|
||||
return (verbosity >= 0 && verbosity <= 9) ? td::Status::OK() : td::Status::Error("verbosity must be 0..9");
|
||||
});
|
||||
p.add_option('V', "version", "shows lite-client build version", [&]() {
|
||||
std::cout << "lite-client build version: [" << BUILD_VERSION << "]\n";
|
||||
p.add_option('V', "version", "shows lite-client build information", [&]() {
|
||||
std::cout << "lite-client build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
|
||||
std::exit(0);
|
||||
});
|
||||
p.add_option('i', "idx", "set liteserver idx", [&](td::Slice arg) {
|
||||
|
|
|
@ -2,4 +2,4 @@ cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
|||
|
||||
add_executable(rldp-http-proxy rldp-http-proxy.cpp)
|
||||
target_include_directories(rldp-http-proxy PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
target_link_libraries(rldp-http-proxy PRIVATE tonhttp rldp dht tonlib)
|
||||
target_link_libraries(rldp-http-proxy PRIVATE tonhttp rldp dht tonlib git)
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include "git.h"
|
||||
|
||||
#if TD_DARWIN || TD_LINUX
|
||||
#include <unistd.h>
|
||||
|
@ -1133,8 +1134,8 @@ int main(int argc, char *argv[]) {
|
|||
int v = VERBOSITY_NAME(FATAL) + (td::to_integer<int>(arg));
|
||||
SET_VERBOSITY_LEVEL(v);
|
||||
});
|
||||
p.add_option('V', "version", "shows rldp-http-proxy build version", [&]() {
|
||||
std::cout << "rldp-http-proxy build version: [" << BUILD_VERSION << "]\n";
|
||||
p.add_option('V', "version", "shows rldp-http-proxy build information", [&]() {
|
||||
std::cout << "rldp-http-proxy build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
});
|
||||
p.add_option('h', "help", "prints a help message", [&]() {
|
||||
|
|
|
@ -278,7 +278,7 @@ void RldpConnection::receive_raw_obj(ton::ton_api::rldp2_messagePart &part) {
|
|||
return;
|
||||
}
|
||||
|
||||
auto r_total_size = td::narrow_cast_safe<td::size_t>(part.total_size_);
|
||||
auto r_total_size = td::narrow_cast_safe<std::size_t>(part.total_size_);
|
||||
if (r_total_size.is_error()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ target_include_directories(storage PUBLIC
|
|||
add_executable(storage-cli ${STORAGE_CLI_SOURCE})
|
||||
target_link_libraries(storage-cli storage overlay tdutils tdactor adnl tl_api dht
|
||||
rldp rldp2 catchain validatorsession full-node validator ton_validator validator
|
||||
fift-lib memprof terminal ${JEMALLOC_LIBRARIES})
|
||||
fift-lib memprof terminal git ${JEMALLOC_LIBRARIES})
|
||||
|
||||
set(STORAGE_TEST_SOURCE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/storage.cpp
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "td/utils/format.h"
|
||||
|
||||
namespace ton {
|
||||
void LoadSpeed::add(td::size_t size, td::Timestamp now) {
|
||||
void LoadSpeed::add(std::size_t size, td::Timestamp now) {
|
||||
total_size_ += size;
|
||||
events_.push(Event{size, now});
|
||||
update(now);
|
||||
|
|
|
@ -26,17 +26,17 @@
|
|||
namespace ton {
|
||||
class LoadSpeed {
|
||||
public:
|
||||
void add(td::size_t size, td::Timestamp now);
|
||||
void add(std::size_t size, td::Timestamp now);
|
||||
double speed(td::Timestamp now = td::Timestamp::now()) const;
|
||||
friend td::StringBuilder &operator<<(td::StringBuilder &sb, const LoadSpeed &speed);
|
||||
|
||||
private:
|
||||
struct Event {
|
||||
td::size_t size;
|
||||
std::size_t size;
|
||||
td::Timestamp at;
|
||||
};
|
||||
mutable td::VectorQueue<Event> events_;
|
||||
mutable td::size_t total_size_{0};
|
||||
mutable std::size_t total_size_{0};
|
||||
|
||||
double duration() const;
|
||||
void update(td::Timestamp now) const;
|
||||
|
|
|
@ -138,7 +138,7 @@ void MerkleTree::init_finish() {
|
|||
CHECK(root_hash_);
|
||||
}
|
||||
|
||||
void MerkleTree::remove_chunk(td::size_t index) {
|
||||
void MerkleTree::remove_chunk(std::size_t index) {
|
||||
CHECK(index < n_);
|
||||
index += n_;
|
||||
while (proof_[index].not_null()) {
|
||||
|
@ -147,13 +147,13 @@ void MerkleTree::remove_chunk(td::size_t index) {
|
|||
}
|
||||
}
|
||||
|
||||
bool MerkleTree::has_chunk(td::size_t index) const {
|
||||
bool MerkleTree::has_chunk(std::size_t index) const {
|
||||
CHECK(index < n_);
|
||||
index += n_;
|
||||
return proof_[index].not_null();
|
||||
}
|
||||
|
||||
void MerkleTree::add_chunk(td::size_t index, td::Slice hash) {
|
||||
void MerkleTree::add_chunk(std::size_t index, td::Slice hash) {
|
||||
CHECK(hash.size() == 32);
|
||||
CHECK(index < n_);
|
||||
index += n_;
|
||||
|
|
|
@ -39,7 +39,7 @@ class MerkleTree {
|
|||
MerkleTree(size_t chunks_count, td::Ref<vm::Cell> root_proof);
|
||||
|
||||
struct Chunk {
|
||||
td::size_t index{0};
|
||||
std::size_t index{0};
|
||||
td::Bits256 hash;
|
||||
};
|
||||
|
||||
|
@ -47,7 +47,7 @@ class MerkleTree {
|
|||
|
||||
MerkleTree() = default;
|
||||
void init_begin(size_t chunks_count);
|
||||
void init_add_chunk(td::size_t index, td::Slice hash);
|
||||
void init_add_chunk(std::size_t index, td::Slice hash);
|
||||
void init_finish();
|
||||
|
||||
// merge external proof with an existing proof
|
||||
|
@ -70,20 +70,20 @@ class MerkleTree {
|
|||
|
||||
private:
|
||||
td::uint64 total_blocks_;
|
||||
td::size_t n_; // n = 2^log_n
|
||||
std::size_t n_; // n = 2^log_n
|
||||
td::uint32 log_n_;
|
||||
td::size_t mark_id_{0};
|
||||
std::vector<td::size_t> mark_; // n_ * 2
|
||||
std::size_t mark_id_{0};
|
||||
std::vector<std::size_t> mark_; // n_ * 2
|
||||
std::vector<td::Ref<vm::Cell>> proof_; // n_ * 2
|
||||
|
||||
td::optional<td::Bits256> root_hash_;
|
||||
td::Ref<vm::Cell> root_proof_;
|
||||
|
||||
td::Status validate_proof(td::Ref<vm::Cell> new_root);
|
||||
bool has_chunk(td::size_t index) const;
|
||||
void remove_chunk(td::size_t index);
|
||||
bool has_chunk(std::size_t index) const;
|
||||
void remove_chunk(std::size_t index);
|
||||
|
||||
void add_chunk(td::size_t index, td::Slice hash);
|
||||
void add_chunk(std::size_t index, td::Slice hash);
|
||||
void init_proof();
|
||||
|
||||
td::Ref<vm::Cell> merge(td::Ref<vm::Cell> root, size_t index);
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include <limits>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include "git.h"
|
||||
|
||||
namespace ton_rldp = ton::rldp2;
|
||||
|
||||
|
@ -749,7 +750,7 @@ class StorageCli : public td::actor::Actor {
|
|||
auto file_id_str = parser.read_word();
|
||||
size_t file_id = std::numeric_limits<size_t>::max();
|
||||
if (file_id_str != "*") {
|
||||
TRY_RESULT_PROMISE_ASSIGN(promise, file_id, td::to_integer_safe<td::size_t>(file_id_str));
|
||||
TRY_RESULT_PROMISE_ASSIGN(promise, file_id, td::to_integer_safe<std::size_t>(file_id_str));
|
||||
}
|
||||
TRY_RESULT_PROMISE(promise, priority, td::to_integer_safe<td::uint8>(parser.read_word()));
|
||||
if (priority == 255) {
|
||||
|
@ -837,6 +838,10 @@ int main(int argc, char *argv[]) {
|
|||
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(FATAL) + verbosity);
|
||||
return (verbosity >= 0 && verbosity <= 20) ? td::Status::OK() : td::Status::Error("verbosity must be 0..20");
|
||||
});
|
||||
p.add_option('V', "version", "shows storage-cli build information", [&]() {
|
||||
std::cout << "storage-cli build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
});
|
||||
p.add_option('C', "config", "set ton config", [&](td::Slice arg) { options.config = arg.str(); });
|
||||
p.add_option('D', "db", "root for dbs", [&](td::Slice fname) { options.db_root = fname.str(); });
|
||||
p.add_checked_option('I', "ip", "set ip:port", [&](td::Slice arg) {
|
||||
|
|
|
@ -69,7 +69,7 @@ if (TONLIB_ENABLE_JNI AND NOT ANDROID) # jni is available by default on Android
|
|||
endif()
|
||||
|
||||
add_executable(tonlib-cli tonlib/tonlib-cli.cpp)
|
||||
target_link_libraries(tonlib-cli tonlib tdactor tdutils terminal pow-miner-lib)
|
||||
target_link_libraries(tonlib-cli tonlib tdactor tdutils terminal pow-miner-lib git)
|
||||
|
||||
if (NOT CMAKE_CROSSCOMPILING)
|
||||
if (TONLIB_ENABLE_JNI)
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include <cinttypes>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include "git.h"
|
||||
|
||||
using tonlib_api::make_object;
|
||||
|
||||
|
@ -2308,8 +2309,8 @@ int main(int argc, char* argv[]) {
|
|||
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(FATAL) + verbosity);
|
||||
return (verbosity >= 0 && verbosity <= 20) ? td::Status::OK() : td::Status::Error("verbosity must be 0..20");
|
||||
});
|
||||
p.add_option('V', "version", "show tonlib-cli build version", [&]() {
|
||||
std::cout << "Fift build version: [" << BUILD_VERSION << "]\n";
|
||||
p.add_option('V', "version", "show tonlib-cli build information", [&]() {
|
||||
std::cout << "tonlib-cli build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
});
|
||||
p.add_checked_option('C', "config-force", "set lite server config, drop config related blockchain cache",
|
||||
|
|
|
@ -5,18 +5,18 @@ if (NOT OPENSSL_FOUND)
|
|||
endif()
|
||||
|
||||
add_executable(generate-random-id generate-random-id.cpp )
|
||||
target_link_libraries(generate-random-id tl_api ton_crypto keys adnl)
|
||||
target_link_libraries(generate-random-id tl_api ton_crypto keys adnl git)
|
||||
|
||||
target_include_directories(generate-random-id PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/..)
|
||||
|
||||
add_executable(json2tlo json2tlo.cpp )
|
||||
target_link_libraries(json2tlo tl_api ton_crypto keys )
|
||||
target_link_libraries(json2tlo tl_api ton_crypto keys git)
|
||||
target_include_directories(json2tlo PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/..)
|
||||
|
||||
add_executable(pack-viewer pack-viewer.cpp )
|
||||
target_link_libraries(pack-viewer tl_api ton_crypto keys validator tddb )
|
||||
target_link_libraries(pack-viewer tl_api ton_crypto keys validator tddb)
|
||||
target_include_directories(pack-viewer PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/..)
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "td/utils/filesystem.h"
|
||||
#include "keys/encryptor.h"
|
||||
#include "keys/keys.hpp"
|
||||
#include "git.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
ton::PrivateKey pk;
|
||||
|
@ -59,8 +60,8 @@ int main(int argc, char *argv[]) {
|
|||
std::cout << sb.as_cslice().c_str();
|
||||
std::exit(2);
|
||||
});
|
||||
p.add_option('V', "version", "shows generate-random-id build version", [&]() {
|
||||
std::cout << "generate-random-id build version: [" << BUILD_VERSION << "]\n";
|
||||
p.add_option('V', "version", "shows generate-random-id build information", [&]() {
|
||||
std::cout << "generate-random-id build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
});
|
||||
p.add_option('n', "name", "path to save private keys to", [&](td::Slice arg) { name = arg.str(); });
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "tl/tl_json.h"
|
||||
#include "auto/tl/ton_api.h"
|
||||
#include "auto/tl/ton_api_json.h"
|
||||
#include "git.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
std::string in_f;
|
||||
|
@ -51,8 +52,8 @@ int main(int argc, char *argv[]) {
|
|||
p.add_option('i', "in", "input", [&](td::Slice key) { in_f = key.str(); });
|
||||
p.add_option('o', "out", "output", [&](td::Slice key) { out_f = key.str(); });
|
||||
p.add_option('r', "reverse", "read tlo, print json", [&]() { reverse_ = !reverse_; });
|
||||
p.add_option('V', "version", "shows json2tlo build version", [&]() {
|
||||
std::cout << "json2tlo build version: [" << BUILD_VERSION << "]\n";
|
||||
p.add_option('V', "version", "shows json2tlo build information", [&]() {
|
||||
std::cout << "json2tlo build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
});
|
||||
p.add_option('h', "help", "prints_help", [&]() {
|
||||
|
|
|
@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
|||
add_executable (validator-engine-console validator-engine-console.cpp
|
||||
validator-engine-console.h validator-engine-console-query.cpp
|
||||
validator-engine-console-query.h )
|
||||
target_link_libraries(validator-engine-console tdutils tdactor adnllite tl_api tl_lite_api tl-lite-utils ton_crypto ton_block terminal)
|
||||
target_link_libraries(validator-engine-console tdutils tdactor adnllite tl_api tl_lite_api tl-lite-utils ton_crypto ton_block terminal git)
|
||||
|
||||
install(TARGETS validator-engine-console RUNTIME DESTINATION bin)
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#endif
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include "git.h"
|
||||
|
||||
int verbosity;
|
||||
|
||||
|
@ -256,8 +257,8 @@ int main(int argc, char* argv[]) {
|
|||
std::cout << sb.as_cslice().c_str();
|
||||
std::exit(2);
|
||||
});
|
||||
p.add_option('V', "version", "shows validator-engine-console build version", [&]() {
|
||||
std::cout << "validator-engine-console build version: [" << BUILD_VERSION << "]\n";
|
||||
p.add_option('V', "version", "shows validator-engine-console build information", [&]() {
|
||||
std::cout << "validator-engine-console build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
});
|
||||
p.add_checked_option('a', "address", "server address", [&](td::Slice arg) {
|
||||
|
|
|
@ -13,6 +13,6 @@ set(VALIDATOR_ENGINE_SOURCE
|
|||
add_executable(validator-engine ${VALIDATOR_ENGINE_SOURCE})
|
||||
target_link_libraries(validator-engine overlay tdutils tdactor adnl tl_api dht
|
||||
rldp catchain validatorsession full-node validator ton_validator validator
|
||||
fift-lib memprof ${JEMALLOC_LIBRARIES})
|
||||
fift-lib memprof git ${JEMALLOC_LIBRARIES})
|
||||
|
||||
install(TARGETS validator-engine RUNTIME DESTINATION bin)
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include <sstream>
|
||||
#include <cstdlib>
|
||||
#include <set>
|
||||
#include "git.h"
|
||||
|
||||
Config::Config() {
|
||||
out_port = 3278;
|
||||
|
@ -3286,8 +3287,8 @@ int main(int argc, char *argv[]) {
|
|||
int v = VERBOSITY_NAME(FATAL) + (td::to_integer<int>(arg));
|
||||
SET_VERBOSITY_LEVEL(v);
|
||||
});
|
||||
p.add_option('V', "version", "shows validator-engine build version", [&]() {
|
||||
std::cout << "validator-engine build version: [" << BUILD_VERSION << "]\n";
|
||||
p.add_option('V', "version", "shows validator-engine build information", [&]() {
|
||||
std::cout << "validator-engine build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
|
||||
std::exit(0);
|
||||
});
|
||||
p.add_option('h', "help", "prints_help", [&]() {
|
||||
|
|
Loading…
Reference in a new issue