ClickHouse/docker/packager/binary/build.sh

162 lines
5.8 KiB
Bash
Raw Normal View History

2019-04-25 12:29:28 +00:00
#!/usr/bin/env bash
exec &> >(ts)
2019-04-25 12:29:28 +00:00
set -x -e
2022-02-08 18:12:04 +00:00
cache_status () {
ccache --show-config ||:
ccache --show-stats ||:
}
2022-04-13 19:33:34 +00:00
git config --global --add safe.directory /build
2021-09-04 13:09:12 +00:00
mkdir -p build/cmake/toolchain/darwin-x86_64
tar xJf MacOSX11.0.sdk.tar.xz -C build/cmake/toolchain/darwin-x86_64 --strip-components=1
ln -sf darwin-x86_64 build/cmake/toolchain/darwin-aarch64
2021-04-01 12:12:30 +00:00
# Uncomment to debug ccache. Don't put ccache log in /output right away, or it
# will be confusingly packed into the "performance" package.
2021-04-07 20:38:48 +00:00
# export CCACHE_LOGFILE=/build/ccache.log
# export CCACHE_DEBUG=1
2021-03-31 15:38:36 +00:00
2022-04-13 19:33:34 +00:00
2019-04-25 12:29:28 +00:00
mkdir -p build/build_docker
cd build/build_docker
rm -f CMakeCache.txt
2020-10-05 07:06:38 +00:00
# Read cmake arguments into array (possibly empty)
2020-10-04 10:23:25 +00:00
read -ra CMAKE_FLAGS <<< "${CMAKE_FLAGS:-}"
env
2022-04-13 15:45:15 +00:00
2022-04-21 11:43:24 +00:00
if [ -n "$MAKE_DEB" ]; then
rm -rf /build/packages/root
fi
2022-04-13 19:33:34 +00:00
2022-04-21 15:18:43 +00:00
cache_status
# clear cache stats
ccache --zero-stats ||:
2022-04-13 15:45:15 +00:00
if [ "$BUILD_MUSL_KEEPER" == "1" ]
then
2022-04-21 12:15:24 +00:00
# build keeper with musl separately
2022-04-21 11:43:24 +00:00
cmake --debug-trycompile --verbose=1 -DBUILD_STANDALONE_KEEPER=1 -DENABLE_CLICKHOUSE_KEEPER=1 -DCMAKE_VERBOSE_MAKEFILE=1 -DUSE_MUSL=1 -LA -DCMAKE_TOOLCHAIN_FILE=/build/cmake/linux/toolchain-x86_64-musl.cmake "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" "-DSANITIZE=$SANITIZER" -DENABLE_CHECK_HEAVY_BUILDS=1 "${CMAKE_FLAGS[@]}" ..
2022-04-13 15:45:15 +00:00
# shellcheck disable=SC2086 # No quotes because I want it to expand to nothing if empty.
ninja $NINJA_FLAGS clickhouse-keeper
2022-04-14 13:43:36 +00:00
2022-04-14 10:23:09 +00:00
ls -la ./programs/
ldd ./programs/clickhouse-keeper
2022-04-14 13:43:36 +00:00
if [ -n "$MAKE_DEB" ]; then
# No quotes because I want it to expand to nothing if empty.
# shellcheck disable=SC2086
2022-04-21 14:11:43 +00:00
DESTDIR=/build/packages/root ninja $NINJA_FLAGS programs/keeper/install
2022-04-14 13:43:36 +00:00
fi
2022-04-21 12:15:24 +00:00
rm -f CMakeCache.txt
2022-04-13 15:45:15 +00:00
2022-04-21 12:15:24 +00:00
# Build the rest of binaries
2022-04-20 10:11:55 +00:00
cmake --debug-trycompile --verbose=1 -DBUILD_STANDALONE_KEEPER=0 -DCREATE_KEEPER_SYMLINK=0 -DCMAKE_VERBOSE_MAKEFILE=1 -LA "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" "-DSANITIZE=$SANITIZER" -DENABLE_CHECK_HEAVY_BUILDS=1 "${CMAKE_FLAGS[@]}" ..
2022-04-14 13:44:09 +00:00
else
2022-04-21 12:15:24 +00:00
# Build everything
2022-04-20 20:42:26 +00:00
cmake --debug-trycompile --verbose=1 -DCMAKE_VERBOSE_MAKEFILE=1 -LA "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" "-DSANITIZE=$SANITIZER" -DENABLE_CHECK_HEAVY_BUILDS=1 "${CMAKE_FLAGS[@]}" ..
2022-04-14 13:43:36 +00:00
fi
2021-03-30 11:31:39 +00:00
if [ "coverity" == "$COMBINED_OUTPUT" ]
then
2022-04-07 16:21:13 +00:00
mkdir -p /opt/cov-analysis
wget --post-data "token=$COVERITY_TOKEN&project=ClickHouse%2FClickHouse" -qO- https://scan.coverity.com/download/linux64 | tar xz -C /opt/cov-analysis --strip-components 1
export PATH=$PATH:/opt/cov-analysis/bin
cov-configure --config ./coverity.config --template --comptype clangcc --compiler "$CC"
SCAN_WRAPPER="cov-build --config ./coverity.config --dir cov-int"
fi
2022-02-08 18:12:04 +00:00
# No quotes because I want it to expand to nothing if empty.
# shellcheck disable=SC2086 # No quotes because I want it to expand to nothing if empty.
$SCAN_WRAPPER ninja $NINJA_FLAGS clickhouse-bundle
2021-03-31 15:43:31 +00:00
2022-04-14 10:23:09 +00:00
ls -la ./programs
2022-02-08 18:12:04 +00:00
cache_status
if [ -n "$MAKE_DEB" ]; then
# No quotes because I want it to expand to nothing if empty.
# shellcheck disable=SC2086
DESTDIR=/build/packages/root ninja $NINJA_FLAGS install
bash -x /build/packages/build
fi
2021-03-31 15:43:31 +00:00
mv ./programs/clickhouse* /output
2020-09-17 14:01:48 +00:00
mv ./src/unit_tests_dbms /output ||: # may not exist for some binary builds
find . -name '*.so' -print -exec mv '{}' /output \;
find . -name '*.so.*' -print -exec mv '{}' /output \;
2019-09-20 20:15:42 +00:00
2019-12-25 16:08:44 +00:00
# Different files for performance test.
if [ "performance" == "$COMBINED_OUTPUT" ]
then
cp -r ../tests/performance /output
cp -r ../tests/config/top_level_domains /output
2020-02-25 13:12:12 +00:00
cp -r ../docker/test/performance-comparison/config /output ||:
2019-12-25 16:08:44 +00:00
rm /output/unit_tests_dbms ||:
rm /output/clickhouse-odbc-bridge ||:
2020-03-11 14:29:34 +00:00
cp -r ../docker/test/performance-comparison /output/scripts ||:
# We have to know the revision that corresponds to this binary build.
# It is not the nominal SHA from pull/*/head, but the pull/*/merge, which is
# head merged to master by github, at some point after the PR is updated.
# There are some quirks to consider:
# - apparently the real SHA is not recorded in system.build_options;
# - it can change at any time as github pleases, so we can't just record
# the SHA and use it later, it might become inaccessible;
# - CI has an immutable snapshot of repository that it uses for all checks
# for a given nominal SHA, but it is not accessible outside Yandex.
# This is why we add this repository snapshot from CI to the performance test
# package.
mkdir /output/ch
git -C /output/ch init --bare
2020-07-14 21:56:35 +00:00
git -C /output/ch remote add origin /build
git -C /output/ch fetch --no-tags --depth 50 origin HEAD:pr
git -C /output/ch fetch --no-tags --depth 50 origin master:master
git -C /output/ch reset --soft pr
git -C /output/ch log -5
2019-12-25 16:08:44 +00:00
fi
# May be set for split build or for performance test.
if [ "" != "$COMBINED_OUTPUT" ]
2019-09-20 20:15:42 +00:00
then
2019-09-23 12:20:08 +00:00
mkdir -p /output/config
cp ../programs/server/config.xml /output/config
cp ../programs/server/users.xml /output/config
cp -r --dereference ../programs/server/config.d /output/config
2021-04-01 17:00:08 +00:00
tar -cv -I pigz -f "$COMBINED_OUTPUT.tgz" /output
2019-09-20 20:15:42 +00:00
rm -r /output/*
mv "$COMBINED_OUTPUT.tgz" /output
2019-09-20 20:15:42 +00:00
fi
2021-03-31 15:43:31 +00:00
if [ "coverity" == "$COMBINED_OUTPUT" ]
then
tar -cv -I pigz -f "coverity-scan.tgz" cov-int
mv "coverity-scan.tgz" /output
fi
2021-08-24 00:09:19 +00:00
# Also build fuzzers if any sanitizer specified
2021-11-10 11:38:26 +00:00
# if [ -n "$SANITIZER" ]
# then
# # Currently we are in build/build_docker directory
# ../docker/packager/other/fuzzer.sh
# fi
2021-08-24 00:09:19 +00:00
2022-02-08 18:12:04 +00:00
cache_status
2021-08-24 00:09:19 +00:00
2021-03-31 23:51:47 +00:00
if [ "${CCACHE_DEBUG:-}" == "1" ]
2021-03-31 21:54:45 +00:00
then
2021-04-01 12:46:55 +00:00
find . -name '*.ccache-*' -print0 \
2021-04-01 18:02:35 +00:00
| tar -c -I pixz -f /output/ccache-debug.txz --null -T -
2021-03-31 21:54:45 +00:00
fi
2021-03-31 15:43:31 +00:00
2021-04-01 12:12:30 +00:00
if [ -n "$CCACHE_LOGFILE" ]
2021-03-31 21:54:45 +00:00
then
# Compress the log as well, or else the CI will try to compress all log
# files in place, and will fail because this directory is not writable.
2021-04-01 17:00:08 +00:00
tar -cv -I pixz -f /output/ccache.log.txz "$CCACHE_LOGFILE"
2021-03-31 21:54:45 +00:00
fi