Skip to content

Commit 85c21fa

Browse files
author
yangxingxiang
committed
Add build.sh,surpport docker-ubuntu2204 docker-ubuntu2004 docker-centos9, default docker-ubuntu2204
1 parent dfadd59 commit 85c21fa

File tree

3 files changed

+134
-0
lines changed

3 files changed

+134
-0
lines changed

build.sh

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Default build config
5+
OS_TYPE="ubuntu2204"
6+
7+
# Parse arguments
8+
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
9+
cat <<EOF
10+
HF3FS Build System
11+
12+
Usage: $0 [OPTION]
13+
14+
Options:
15+
docker-ubuntu2204 Build using Ubuntu 22.04 Docker container (default)
16+
docker-ubuntu2004 Build using Ubuntu 20.04 Docker container
17+
docker-centos9 Build using CentOS 9 Docker container
18+
-h, --help Show this help message
19+
20+
Environment:
21+
- Docker builds create isolated environments with version-specific toolchains
22+
- Build artifacts are stored in: build/
23+
24+
Examples:
25+
./build.sh # Default Docker build with Ubuntu 22.04
26+
./build.sh docker-ubuntu2004 # Docker build with Ubuntu 20.04
27+
28+
EOF
29+
exit 0
30+
31+
elif [[ "$1" == "docker-ubuntu2204" ]]; then
32+
OS_TYPE="ubuntu2204"
33+
elif [[ "$1" == "docker-ubuntu2004" ]]; then
34+
OS_TYPE="ubuntu2004"
35+
elif [[ "$1" == "docker-centos9" ]]; then
36+
OS_TYPE="centos9"
37+
elif [[ -n "$1" ]]; then
38+
echo "Error: Invalid option '$1'"
39+
echo "Try './build.sh --help' for usage information"
40+
exit 1
41+
fi
42+
43+
# Common build parameters
44+
CPU_CORES=$(nproc)
45+
CMAKE_FLAGS=(
46+
-DCMAKE_CXX_COMPILER=clang++-14
47+
-DCMAKE_C_COMPILER=clang-14
48+
-DCMAKE_BUILD_TYPE=RelWithDebInfo
49+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
50+
)
51+
52+
docker_build() {
53+
echo "Starting Docker build for ${OS_TYPE}..."
54+
DOCKER_IMAGE="${OS_TYPE}-3fs-builder"
55+
docker build -t "${DOCKER_IMAGE}" -f "dockerfile/dev.${OS_TYPE}.dockerfile" . && \
56+
docker run --rm \
57+
-v "${PWD}:/build/src" \
58+
--cpus="${CPU_CORES}" \
59+
-e BUILD_JOBS="${CPU_CORES}" \
60+
"${DOCKER_IMAGE}" /bin/bash -c "
61+
set -ex
62+
cd /build/src
63+
cmake -S . -B build ${CMAKE_FLAGS[*]}
64+
cmake --build build -j\${BUILD_JOBS}
65+
"
66+
}
67+
68+
69+
# Execute build
70+
docker_build || echo "Docker build failed"

dockerfile/dev.ubuntu2004.dockerfile

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
FROM ubuntu:20.04
2+
3+
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
RUN apt-get update &&\
6+
apt-get install -y --no-install-recommends \
7+
git wget ca-certificates software-properties-common \
8+
build-essential meson cmake \
9+
google-perftools \
10+
libaio-dev \
11+
libboost1.71-all-dev \
12+
libdouble-conversion-dev \
13+
libdwarf-dev \
14+
libgflags-dev \
15+
libgmock-dev \
16+
libgoogle-glog-dev \
17+
libgoogle-perftools-dev \
18+
libgtest-dev \
19+
liblz4-dev \
20+
liblzma-dev \
21+
libunwind-dev \
22+
libuv1-dev \
23+
libssl-dev \
24+
gnupg &&\
25+
apt-get clean &&\
26+
rm -rf /var/lib/apt/lists/*
27+
28+
RUN wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key |tee /etc/apt/trusted.gpg.d/llvm.asc &&\
29+
add-apt-repository -y "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" &&\
30+
apt-get update && apt-get install -y clang-format-14 clang-14 clang-tidy-14 lld-14 libclang-rt-14-dev gcc-10 g++-10 &&\
31+
apt-get clean &&\
32+
rm -rf /var/lib/apt/lists/*
33+
34+
ARG FDB_VERSION=7.3.63
35+
RUN FDB_ARCH_SUFFIX=$(dpkg --print-architecture) && \
36+
case "${FDB_ARCH_SUFFIX}" in \
37+
amd64) ;; \
38+
arm64) FDB_ARCH_SUFFIX="aarch64" ;; \
39+
*) echo "Unsupported architecture: ${FDB_ARCH_SUFFIX}"; exit 1 ;; \
40+
esac && \
41+
FDB_CLIENT_URL="https://github.com/apple/foundationdb/releases/download/${FDB_VERSION}/foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH_SUFFIX}.deb" && \
42+
FDB_SERVER_URL="https://github.com/apple/foundationdb/releases/download/${FDB_VERSION}/foundationdb-server_${FDB_VERSION}-1_${FDB_ARCH_SUFFIX}.deb" && \
43+
wget -q "${FDB_CLIENT_URL}" && \
44+
# wget -q "${FDB_SERVER_URL}" && \
45+
dpkg -i foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH_SUFFIX}.deb && \
46+
# dpkg -i foundationdb-server_${FDB_VERSION}-1_${FDB_ARCH_SUFFIX}.deb && \
47+
rm foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH_SUFFIX}.deb
48+
# foundationdb-server_${FDB_VERSION}-1_${FDB_ARCH_SUFFIX}.deb
49+
50+
ARG LIBFUSE_VERSION=3.16.2
51+
ARG LIBFUSE_DOWNLOAD_URL=https://github.com/libfuse/libfuse/releases/download/fuse-${LIBFUSE_VERSION}/fuse-${LIBFUSE_VERSION}.tar.gz
52+
RUN wget -O- ${LIBFUSE_DOWNLOAD_URL} |\
53+
tar -xzvf - -C /tmp &&\
54+
cd /tmp/fuse-${LIBFUSE_VERSION} &&\
55+
mkdir build && cd build &&\
56+
meson setup .. && meson configure -D default_library=both &&\
57+
ninja && ninja install &&\
58+
rm -f -r /tmp/fuse-${LIBFUSE_VERSION}*
59+
60+
# Install Rust
61+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
62+
ENV PATH="/root/.cargo/bin:${PATH}"
63+
64+
File renamed without changes.

0 commit comments

Comments
 (0)