Skip to content

Commit 502d472

Browse files
committed
Merge bitcoin/bitcoin#31161: cmake: Set top-level target output locations
568fcdd scripted-diff: Adjust documentation per top-level target output location (Hennadii Stepanov) 026bb22 cmake: Set top-level target output locations (Hennadii Stepanov) Pull request description: This PR sets the target output locations to the `bin` and `lib` subdirectories within the build tree, creating a directory structure that mirrors that of the installed targets. This approach is widely adopted by the large projects, such as [LLVM](https://github.com/llvm/llvm-project/blob/e146c1867e8decfd423034f63a3a863733e03f04/lldb/cmake/modules/LLDBStandalone.cmake#L128-L130): ```cmake set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}) ``` The `libsecp256k1` project has also recently [adopted](bitcoin-core/secp256k1#1553) this approach. With this PR, all binaries are conveniently located. For example, run: ``` $ ./build/bin/fuzz ``` instead of: ``` $ ./build/src/test/fuzz/fuzz ``` On Windows, all required DLLs are now located in the same directory as the executables, allowing to run `bitcoin-chainstate.exe` (which loads `bitcoinkernel.dll`) without the need to copy DLLs or modify the `PATH` variable. The idea was briefly discussed among the build team during the recent CoreDev meeting. --- **Warning**: This PR changes build locations of newly built executables like `bitcoind` and `test_bitcoin` from `src/` to `bin/` without deleting previously built executables. A clean build is recommended to avoid accidentally running old binaries. ACKs for top commit: theStack: Light re-ACK 568fcdd ryanofsky: Code review ACK 568fcdd. Only change since last review was rebasing. I'm ok with this PR in its current form if other developers are happy with it. I just personally think it is inappropriate to \*silently\* break an everyday developer workflow like `git pull; make bitcoind`. I wouldn't have a problem with this PR if it triggered an explicit error, or if the problem was limited to less common workflows like changing cmake options in an existing build. TheCharlatan: Re-ACK 568fcdd theuni: ACK 568fcdd Tree-SHA512: 1aa5ecd3cd49bd82f1dcc96c8e171d2d19c58aec8dade4bc329df89311f9e50cbf6cf021d004c58a0e1016c375b0fa348ccd52761bcdd179c2d1e61c105e3b9f
2 parents e38f09b + 568fcdd commit 502d472

27 files changed

+164
-145
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ jobs:
238238
if: matrix.job-type == 'standard'
239239
working-directory: build
240240
env:
241-
BITCOIND: '${{ github.workspace }}\build\src\Release\bitcoind.exe'
242-
BITCOINCLI: '${{ github.workspace }}\build\src\Release\bitcoin-cli.exe'
243-
BITCOINUTIL: '${{ github.workspace }}\build\src\Release\bitcoin-util.exe'
244-
BITCOINWALLET: '${{ github.workspace }}\build\src\Release\bitcoin-wallet.exe'
241+
BITCOIND: '${{ github.workspace }}\build\bin\Release\bitcoind.exe'
242+
BITCOINCLI: '${{ github.workspace }}\build\bin\Release\bitcoin-cli.exe'
243+
BITCOINUTIL: '${{ github.workspace }}\build\bin\Release\bitcoin-util.exe'
244+
BITCOINWALLET: '${{ github.workspace }}\build\bin\Release\bitcoin-wallet.exe'
245245
TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }}
246246
shell: cmd
247247
run: py -3 test\functional\test_runner.py --jobs %NUMBER_OF_PROCESSORS% --ci --quiet --tmpdirprefix=%RUNNER_TEMP% --combinedlogslen=99999999 --timeout-factor=%TEST_RUNNER_TIMEOUT_FACTOR% %TEST_RUNNER_EXTRA%
@@ -258,7 +258,7 @@ jobs:
258258
if: matrix.job-type == 'fuzz'
259259
working-directory: build
260260
env:
261-
BITCOINFUZZ: '${{ github.workspace }}\build\src\test\fuzz\Release\fuzz.exe'
261+
BITCOINFUZZ: '${{ github.workspace }}\build\bin\Release\fuzz.exe'
262262
shell: cmd
263263
run: |
264264
py -3 test\fuzz\test_runner.py --par %NUMBER_OF_PROCESSORS% --loglevel DEBUG %RUNNER_TEMP%\qa-assets\fuzz_corpora

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,6 @@ endif()
615615
add_subdirectory(test)
616616
add_subdirectory(doc)
617617

618-
include(cmake/crc32c.cmake)
619-
include(cmake/leveldb.cmake)
620-
include(cmake/minisketch.cmake)
621618
add_subdirectory(src)
622619

623620
include(cmake/tests.cmake)

contrib/devtools/check-deps.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ declare -A LIBS
88
LIBS[cli]="libbitcoin_cli.a"
99
LIBS[common]="libbitcoin_common.a"
1010
LIBS[consensus]="libbitcoin_consensus.a"
11-
LIBS[crypto]="crypto/libbitcoin_crypto.a"
11+
LIBS[crypto]="libbitcoin_crypto.a"
1212
LIBS[node]="libbitcoin_node.a"
13-
LIBS[util]="util/libbitcoin_util.a"
14-
LIBS[wallet]="wallet/libbitcoin_wallet.a"
13+
LIBS[util]="libbitcoin_util.a"
14+
LIBS[wallet]="libbitcoin_wallet.a"
1515

1616
# Declare allowed dependencies "X Y" where X is allowed to depend on Y. This
1717
# list is taken from doc/design/libraries.md.
@@ -187,7 +187,7 @@ fi
187187
# shellcheck disable=SC2046
188188
cmake --build "$BUILD_DIR" -j"$(nproc)" -t $(lib_targets)
189189
TEMP_DIR="$(mktemp -d)"
190-
cd "$BUILD_DIR/src"
190+
cd "$BUILD_DIR/lib"
191191
extract_symbols "$TEMP_DIR"
192192
if check_libraries "$TEMP_DIR"; then
193193
echo "Success! No unexpected dependencies were detected."

contrib/devtools/gen-bitcoin-conf.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
export LC_ALL=C
77
TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)}
88
BUILDDIR=${BUILDDIR:-$TOPDIR/build}
9-
BINDIR=${BINDIR:-$BUILDDIR/src}
9+
BINDIR=${BINDIR:-$BUILDDIR/bin}
1010
BITCOIND=${BITCOIND:-$BINDIR/bitcoind}
1111
SHARE_EXAMPLES_DIR=${SHARE_EXAMPLES_DIR:-$TOPDIR/share/examples}
1212
EXAMPLE_CONF_FILE=${EXAMPLE_CONF_FILE:-$SHARE_EXAMPLES_DIR/bitcoin.conf}

contrib/devtools/gen-manpages.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
import argparse
1010

1111
BINARIES = [
12-
'src/bitcoind',
13-
'src/bitcoin-cli',
14-
'src/bitcoin-tx',
15-
'src/bitcoin-wallet',
16-
'src/bitcoin-util',
17-
'src/qt/bitcoin-qt',
12+
'bin/bitcoind',
13+
'bin/bitcoin-cli',
14+
'bin/bitcoin-tx',
15+
'bin/bitcoin-wallet',
16+
'bin/bitcoin-util',
17+
'bin/bitcoin-qt',
1818
]
1919

2020
parser = argparse.ArgumentParser(

contrib/signet/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ miner
2424
You will first need to pick a difficulty target. Since signet chains are primarily protected by a signature rather than proof of work, there is no need to spend as much energy as possible mining, however you may wish to choose to spend more time than the absolute minimum. The calibrate subcommand can be used to pick a target appropriate for your hardware, eg:
2525

2626
MINER="./contrib/signet/miner"
27-
GRIND="./build/src/bitcoin-util grind"
27+
GRIND="./build/bin/bitcoin-util grind"
2828
$MINER calibrate --grind-cmd="$GRIND"
2929
nbits=1e00f403 for 25s average mining time
3030

3131
It defaults to estimating an nbits value resulting in 25s average time to find a block, but the --seconds parameter can be used to pick a different target, or the --nbits parameter can be used to estimate how long it will take for a given difficulty.
3232

3333
To mine the first block in your custom chain, you can run:
3434

35-
CLI="./build/src/bitcoin-cli -conf=mysignet.conf"
35+
CLI="./build/bin/bitcoin-cli -conf=mysignet.conf"
3636
ADDR=$($CLI -signet getnewaddress)
3737
NBITS=1e00f403
3838
$MINER --cli="$CLI" generate --grind-cmd="$GRIND" --address="$ADDR" --nbits=$NBITS

contrib/tracing/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ In a different terminal, starting Bitcoin Core in SigNet mode and with
188188
re-indexing enabled.
189189

190190
```
191-
$ ./build/src/bitcoind -signet -reindex
191+
$ ./build/bin/bitcoind -signet -reindex
192192
```
193193

194194
This produces the following output.

contrib/tracing/connectblock_benchmark.bt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
This script requires a 'bitcoind' binary compiled with eBPF support and the
1818
'validation:block_connected' USDT. By default, it's assumed that 'bitcoind' is
19-
located in './build/src/bitcoind'. This can be modified in the script below.
19+
located in './build/bin/bitcoind'. This can be modified in the script below.
2020

2121
EXAMPLES:
2222

@@ -67,7 +67,7 @@ BEGIN
6767
connected block is between the start and end height (or the end height is
6868
unset).
6969
*/
70-
usdt:./build/src/bitcoind:validation:block_connected /arg1 >= $1 && (arg1 <= $2 || $2 == 0 )/
70+
usdt:./build/bin/bitcoind:validation:block_connected /arg1 >= $1 && (arg1 <= $2 || $2 == 0 )/
7171
{
7272
$height = arg1;
7373
$transactions = arg2;
@@ -102,7 +102,7 @@ usdt:./build/src/bitcoind:validation:block_connected /arg1 >= $1 && (arg1 <= $2
102102
blocks where the time it took to connect the block is above the
103103
<logging threshold in ms>.
104104
*/
105-
usdt:./build/src/bitcoind:validation:block_connected / (uint64) arg5 / 1e6 > $3 /
105+
usdt:./build/bin/bitcoind:validation:block_connected / (uint64) arg5 / 1e6 > $3 /
106106
{
107107
$hash = arg0;
108108
$height = (int32) arg1;

contrib/tracing/log_p2p_connections.bt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ BEGIN
55
printf("Logging opened, closed, misbehaving, and evicted P2P connections\n")
66
}
77

8-
usdt:./build/src/bitcoind:net:inbound_connection
8+
usdt:./build/bin/bitcoind:net:inbound_connection
99
{
1010
$id = (int64) arg0;
1111
$addr = str(arg1);
@@ -15,7 +15,7 @@ usdt:./build/src/bitcoind:net:inbound_connection
1515
printf("INBOUND conn from %s: id=%ld, type=%s, network=%d, total=%d\n", $addr, $id, $conn_type, $network, $existing);
1616
}
1717

18-
usdt:./build/src/bitcoind:net:outbound_connection
18+
usdt:./build/bin/bitcoind:net:outbound_connection
1919
{
2020
$id = (int64) arg0;
2121
$addr = str(arg1);
@@ -25,7 +25,7 @@ usdt:./build/src/bitcoind:net:outbound_connection
2525
printf("OUTBOUND conn to %s: id=%ld, type=%s, network=%d, total=%d\n", $addr, $id, $conn_type, $network, $existing);
2626
}
2727

28-
usdt:./build/src/bitcoind:net:closed_connection
28+
usdt:./build/bin/bitcoind:net:closed_connection
2929
{
3030
$id = (int64) arg0;
3131
$addr = str(arg1);
@@ -34,7 +34,7 @@ usdt:./build/src/bitcoind:net:closed_connection
3434
printf("CLOSED conn to %s: id=%ld, type=%s, network=%d, established=%ld\n", $addr, $id, $conn_type, $network, arg4);
3535
}
3636

37-
usdt:./build/src/bitcoind:net:evicted_inbound_connection
37+
usdt:./build/bin/bitcoind:net:evicted_inbound_connection
3838
{
3939
$id = (int64) arg0;
4040
$addr = str(arg1);
@@ -43,7 +43,7 @@ usdt:./build/src/bitcoind:net:evicted_inbound_connection
4343
printf("EVICTED conn to %s: id=%ld, type=%s, network=%d, established=%ld\n", $addr, $id, $conn_type, $network, arg4);
4444
}
4545

46-
usdt:./build/src/bitcoind:net:misbehaving_connection
46+
usdt:./build/bin/bitcoind:net:misbehaving_connection
4747
{
4848
$id = (int64) arg0;
4949
$message = str(arg1);

contrib/tracing/log_p2p_traffic.bt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ BEGIN
55
printf("Logging P2P traffic\n")
66
}
77

8-
usdt:./build/src/bitcoind:net:inbound_message
8+
usdt:./build/bin/bitcoind:net:inbound_message
99
{
1010
$peer_id = (int64) arg0;
1111
$peer_addr = str(arg1);
@@ -15,7 +15,7 @@ usdt:./build/src/bitcoind:net:inbound_message
1515
printf("inbound '%s' msg from peer %d (%s, %s) with %d bytes\n", $msg_type, $peer_id, $peer_type, $peer_addr, $msg_len);
1616
}
1717

18-
usdt:./build/src/bitcoind:net:outbound_message
18+
usdt:./build/bin/bitcoind:net:outbound_message
1919
{
2020
$peer_id = (int64) arg0;
2121
$peer_addr = str(arg1);

0 commit comments

Comments
 (0)