From c1c91bb78d7267f01ee3a3c156c218b46a92cd39 Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Thu, 21 Feb 2019 14:00:33 +0100 Subject: [build] detect std::system or ::wsystem --- configure.ac | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/configure.ac b/configure.ac index 5e1a5e14a1..c67448c963 100644 --- a/configure.ac +++ b/configure.ac @@ -925,6 +925,29 @@ if test x$use_reduce_exports = xyes; then [AC_MSG_ERROR([Cannot set default symbol visibility. Use --disable-reduce-exports.])]) fi +AC_MSG_CHECKING([for std::system]) +AC_LINK_IFELSE( + [ AC_LANG_PROGRAM( + [[ #include ]], + [[ int nErr = std::system(""); ]] + )], + [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STD__SYSTEM, 1, Define to 1 if you have the `std::system' function.)], + [ AC_MSG_RESULT(no) ] +) + +AC_MSG_CHECKING([for ::_wsystem]) +AC_LINK_IFELSE( + [ AC_LANG_PROGRAM( + [[ ]], + [[ int nErr = ::_wsystem(""); ]] + )], + [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_WSYSTEM, 1, Define to 1 if you have the `::wsystem' function.)], + [ AC_MSG_RESULT(no) ] +) + +# Define to 1 if std::system or ::wsystem (Windows) is available +AC_DEFINE([HAVE_SYSTEM], [HAVE_STD__SYSTEM || HAVE_WSYSTEM], [HAVE_WSYSTEM]) + LEVELDB_CPPFLAGS= LIBLEVELDB= LIBMEMENV= -- cgit v1.2.3 From cc3ad56ff2bc2583fe68c4a9e0b41072a47c0b07 Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Fri, 15 Mar 2019 10:43:35 +0100 Subject: [build] MSVC: set HAVE_SYSTEM for desktop apps --- build_msvc/bitcoin_config.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build_msvc/bitcoin_config.h b/build_msvc/bitcoin_config.h index ab13f73539..66cc1208a1 100644 --- a/build_msvc/bitcoin_config.h +++ b/build_msvc/bitcoin_config.h @@ -421,4 +421,14 @@ /* Define for large files, on AIX-style hosts. */ /* #undef _LARGE_FILES */ +/* Windows Universal Platform constraints */ +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) +/* Either a desktop application without API restrictions, or and older system + before these macros were defined. */ + +/* ::wsystem is available */ +#define HAVE_SYSTEM 1 + +#endif // !WINAPI_FAMILY || WINAPI_FAMILY_DESKTOP_APP + #endif //BITCOIN_BITCOIN_CONFIG_H -- cgit v1.2.3 From f874e14cd3c84cd412bd3fb42b3ee1706ca6a267 Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Thu, 14 Mar 2019 11:30:37 +0100 Subject: [build]: check std::system for -[alert|block|wallet]notify Platforms such as iOs do not support launching a process through system(). --- configure.ac | 2 +- src/init.cpp | 8 ++++++++ src/util/system.cpp | 2 ++ src/util/system.h | 2 ++ src/validation.cpp | 2 ++ src/wallet/init.cpp | 2 ++ src/wallet/wallet.cpp | 2 ++ 7 files changed, 19 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index c67448c963..1d5a41ab9a 100644 --- a/configure.ac +++ b/configure.ac @@ -946,7 +946,7 @@ AC_LINK_IFELSE( ) # Define to 1 if std::system or ::wsystem (Windows) is available -AC_DEFINE([HAVE_SYSTEM], [HAVE_STD__SYSTEM || HAVE_WSYSTEM], [HAVE_WSYSTEM]) +AC_DEFINE([HAVE_SYSTEM], [HAVE_STD__SYSTEM || HAVE_WSYSTEM], [std::system or ::wsystem]) LEVELDB_CPPFLAGS= LIBLEVELDB= diff --git a/src/init.cpp b/src/init.cpp index f9723196b0..e6e85b66a1 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -378,10 +378,14 @@ void SetupServerArgs() "-allowselfsignedrootcertificates", "-choosedatadir", "-lang=", "-min", "-resetguisettings", "-rootcertificates=", "-splash", "-uiplatform"}; gArgs.AddArg("-version", "Print version and exit", false, OptionsCategory::OPTIONS); +#if defined(HAVE_SYSTEM) gArgs.AddArg("-alertnotify=", "Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)", false, OptionsCategory::OPTIONS); +#endif gArgs.AddArg("-assumevalid=", strprintf("If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all, default: %s, testnet: %s)", defaultChainParams->GetConsensus().defaultAssumeValid.GetHex(), testnetChainParams->GetConsensus().defaultAssumeValid.GetHex()), false, OptionsCategory::OPTIONS); gArgs.AddArg("-blocksdir=", "Specify directory to hold blocks subdirectory for *.dat files (default: )", false, OptionsCategory::OPTIONS); +#if defined(HAVE_SYSTEM) gArgs.AddArg("-blocknotify=", "Execute command when the best block changes (%s in cmd is replaced by block hash)", false, OptionsCategory::OPTIONS); +#endif gArgs.AddArg("-blockreconstructionextratxn=", strprintf("Extra transactions to keep in memory for compact block reconstructions (default: %u)", DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN), false, OptionsCategory::OPTIONS); gArgs.AddArg("-blocksonly", strprintf("Whether to reject transactions from network peers. Transactions from the wallet or RPC are not affected. (default: %u)", DEFAULT_BLOCKSONLY), false, OptionsCategory::OPTIONS); gArgs.AddArg("-conf=", strprintf("Specify configuration file. Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME), false, OptionsCategory::OPTIONS); @@ -582,6 +586,7 @@ std::string LicenseInfo() "\n"; } +#if defined(HAVE_SYSTEM) static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex) { if (initialSync || !pBlockIndex) @@ -594,6 +599,7 @@ static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex t.detach(); // thread runs free } } +#endif static bool fHaveGenesis = false; static Mutex g_genesis_wait_mutex; @@ -1726,8 +1732,10 @@ bool AppInitMain(InitInterfaces& interfaces) fHaveGenesis = true; } +#if defined(HAVE_SYSTEM) if (gArgs.IsArgSet("-blocknotify")) uiInterface.NotifyBlockTip_connect(BlockNotifyCallback); +#endif std::vector vImportFiles; for (const std::string& strFile : gArgs.GetArgs("-loadblock")) { diff --git a/src/util/system.cpp b/src/util/system.cpp index 6925bda4ef..86606ea446 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -1122,6 +1122,7 @@ fs::path GetSpecialFolderPath(int nFolder, bool fCreate) } #endif +#if defined(HAVE_SYSTEM) void runCommand(const std::string& strCommand) { if (strCommand.empty()) return; @@ -1133,6 +1134,7 @@ void runCommand(const std::string& strCommand) if (nErr) LogPrintf("runCommand error: system(%s) returned %d\n", strCommand, nErr); } +#endif void SetupEnvironment() { diff --git a/src/util/system.h b/src/util/system.h index 1a83cb67b1..6677e52b83 100644 --- a/src/util/system.h +++ b/src/util/system.h @@ -90,7 +90,9 @@ fs::path GetConfigFile(const std::string& confPath); #ifdef WIN32 fs::path GetSpecialFolderPath(int nFolder, bool fCreate = true); #endif +#if defined(HAVE_SYSTEM) void runCommand(const std::string& strCommand); +#endif /** * Most paths passed as configuration arguments are treated as relative to diff --git a/src/validation.cpp b/src/validation.cpp index 6fd7964647..8ac9b1dfef 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1054,6 +1054,7 @@ CBlockIndex *pindexBestForkTip = nullptr, *pindexBestForkBase = nullptr; static void AlertNotify(const std::string& strMessage) { uiInterface.NotifyAlertChanged(); +#if defined(HAVE_SYSTEM) std::string strCmd = gArgs.GetArg("-alertnotify", ""); if (strCmd.empty()) return; @@ -1067,6 +1068,7 @@ static void AlertNotify(const std::string& strMessage) std::thread t(runCommand, strCmd); t.detach(); // thread runs free +#endif } static void CheckForkWarningConditions() EXCLUSIVE_LOCKS_REQUIRED(cs_main) diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index 0b8afd5a5d..240c5112fc 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -62,7 +62,9 @@ void WalletInit::AddWalletOptions() const gArgs.AddArg("-wallet=", "Specify wallet database path. Can be specified multiple times to load multiple wallets. Path is interpreted relative to if it is not absolute, and will be created if it does not exist (as a directory containing a wallet.dat file and log files). For backwards compatibility this will also accept names of existing data files in .)", false, OptionsCategory::WALLET); gArgs.AddArg("-walletbroadcast", strprintf("Make the wallet broadcast transactions (default: %u)", DEFAULT_WALLETBROADCAST), false, OptionsCategory::WALLET); gArgs.AddArg("-walletdir=", "Specify directory to hold wallets (default: /wallets if it exists, otherwise )", false, OptionsCategory::WALLET); +#if defined(HAVE_SYSTEM) gArgs.AddArg("-walletnotify=", "Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)", false, OptionsCategory::WALLET); +#endif gArgs.AddArg("-walletrbf", strprintf("Send transactions with full-RBF opt-in enabled (RPC only, default: %u)", DEFAULT_WALLET_RBF), false, OptionsCategory::WALLET); gArgs.AddArg("-zapwallettxes=", "Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup" " (1 = keep tx meta data e.g. payment request information, 2 = drop tx meta data)", false, OptionsCategory::WALLET); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index e86147b5d0..3f7cf5cab8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1008,6 +1008,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose) // Notify UI of new or updated transaction NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED); +#if defined(HAVE_SYSTEM) // notify an external script when a wallet transaction comes in or is updated std::string strCmd = gArgs.GetArg("-walletnotify", ""); @@ -1017,6 +1018,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose) std::thread t(runCommand, strCmd); t.detach(); // thread runs free } +#endif return true; } -- cgit v1.2.3