Skip to content

Commit b56c536

Browse files
author
yangxingxiang
committed
Add build.sh surpport Ubuntu 22.04 Docker build, Ubuntu 20.04 Docker build、CentOS 9 Docker build,Default local build
1 parent b22f715 commit b56c536

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed

build.sh

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Default build config
5+
BUILD_TYPE="local"
6+
OS_TYPE="ubuntu2204"
7+
BUILD_DIR="build-local"
8+
9+
# Parse arguments
10+
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
11+
cat <<EOF
12+
HF3FS Build System
13+
14+
Usage: $0 [OPTION]
15+
16+
Options:
17+
docker-ubuntu2204 Build using Ubuntu 22.04 Docker container
18+
docker-ubuntu2004 Build using Ubuntu 20.04 Docker container
19+
docker-centos9 Build using CentOS 9 Docker container
20+
-h, --help Show this help message
21+
22+
Environment:
23+
- Local builds use host system tools with clang-14
24+
- Docker builds create isolated environments with version-specific toolchains
25+
- Build artifacts are stored in separate directories:
26+
- build-local/ : Default local build
27+
- build-docker-ubuntu2204/ : Ubuntu 22.04 Docker build
28+
- build-docker-ubuntu2004/ : Ubuntu 20.04 Docker build
29+
- build-docker-centos9/ : CentOS 9 Docker build
30+
31+
Examples:
32+
./build.sh # Local build with clang-14
33+
./build.sh docker-ubuntu2204 # Docker build with Ubuntu 22.04
34+
./build.sh docker-ubuntu2004 # Docker build with Ubuntu 20.04
35+
./build.sh docker-centos9 # Docker build with CentOS 9
36+
37+
EOF
38+
exit 0
39+
elif [[ "$1" == "docker-ubuntu2204" ]]; then
40+
BUILD_TYPE="docker"
41+
OS_TYPE="ubuntu2204"
42+
BUILD_DIR="build-docker-ubuntu2204"
43+
elif [[ "$1" == "docker-ubuntu2004" ]]; then
44+
BUILD_TYPE="docker"
45+
OS_TYPE="ubuntu2004"
46+
BUILD_DIR="build-docker-ubuntu2004"
47+
elif [[ "$1" == "docker-centos9" ]]; then
48+
BUILD_TYPE="docker"
49+
OS_TYPE="centos9"
50+
BUILD_DIR="build-docker-centos9"
51+
elif [[ -n "$1" ]]; then
52+
echo "Error: Invalid option '$1'"
53+
echo "Try './build.sh --help' for usage information"
54+
exit 1
55+
fi
56+
57+
# Common build parameters
58+
CPU_CORES=$(nproc)
59+
CMAKE_FLAGS=(
60+
-DCMAKE_CXX_COMPILER=clang++-14
61+
-DCMAKE_C_COMPILER=clang-14
62+
-DCMAKE_BUILD_TYPE=RelWithDebInfo
63+
)
64+
65+
local_build() {
66+
echo "Starting local build..."
67+
mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
68+
CC=clang-14 CXX=clang++-14 cmake "${CMAKE_FLAGS[@]}" ..
69+
make -j${CPU_CORES}
70+
}
71+
72+
docker_build() {
73+
echo "Starting Docker build for ${OS_TYPE}..."
74+
DOCKER_IMAGE="hf3fs-dev-${OS_TYPE}"
75+
docker build -t ${DOCKER_IMAGE} -f dockerfile/dev.${OS_TYPE}.dockerfile .
76+
docker run --rm \
77+
-v "${PWD}:/build/src" \
78+
--cpus="${CPU_CORES}" \
79+
-e BUILD_JOBS="${CPU_CORES}" \
80+
${DOCKER_IMAGE} /bin/bash -c "
81+
set -e
82+
cd /build/src
83+
mkdir -p ${BUILD_DIR}
84+
cd ${BUILD_DIR}
85+
cmake .. ${CMAKE_FLAGS[@]}
86+
make -j\${BUILD_JOBS}
87+
"
88+
}
89+
90+
# Execute build
91+
if [[ "${BUILD_TYPE}" == "docker" ]]; then
92+
docker_build
93+
else
94+
local_build
95+
fi
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
FROM ubuntu:20.04
2+
3+
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
4+
RUN apt-get update &&\
5+
apt-get install -y --no-install-recommends \
6+
git wget ca-certificates \
7+
clang-format-14 clang-14 clang-tidy-14 lld-14 \
8+
build-essential meson libclang-rt-14-dev gcc-10 g++-10 cmake rustc cargo \
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+
libssl-dev \
22+
libunwind-dev \
23+
libuv1-dev &&\
24+
apt-get clean &&\
25+
rm -rf /var/lib/apt/lists/*
26+
27+
ARG FDB_VERSION=7.3.63
28+
RUN FDB_ARCH_SUFFIX=$(dpkg --print-architecture) && \
29+
case "${FDB_ARCH_SUFFIX}" in \
30+
amd64) ;; \
31+
arm64) FDB_ARCH_SUFFIX="aarch64" ;; \
32+
*) echo "Unsupported architecture: ${FDB_ARCH_SUFFIX}"; exit 1 ;; \
33+
esac && \
34+
FDB_CLIENT_URL="https://github.com/apple/foundationdb/releases/download/${FDB_VERSION}/foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH_SUFFIX}.deb" && \
35+
FDB_SERVER_URL="https://github.com/apple/foundationdb/releases/download/${FDB_VERSION}/foundationdb-server_${FDB_VERSION}-1_${FDB_ARCH_SUFFIX}.deb" && \
36+
wget -q "${FDB_CLIENT_URL}" && \
37+
wget -q "${FDB_SERVER_URL}" && \
38+
dpkg -i foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH_SUFFIX}.deb && \
39+
# dpkg -i foundationdb-server_${FDB_VERSION}-1_${FDB_ARCH_SUFFIX}.deb && \
40+
rm foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH_SUFFIX}.deb foundationdb-server_${FDB_VERSION}-1_${FDB_ARCH_SUFFIX}.deb
41+
42+
ARG LIBFUSE_VERSION=3.16.2
43+
ARG LIBFUSE_DOWNLOAD_URL=https://github.com/libfuse/libfuse/releases/download/fuse-${LIBFUSE_VERSION}/fuse-${LIBFUSE_VERSION}.tar.gz
44+
RUN wget -O- ${LIBFUSE_DOWNLOAD_URL} |\
45+
tar -xzvf - -C /tmp &&\
46+
cd /tmp/fuse-${LIBFUSE_VERSION} &&\
47+
mkdir build && cd build &&\
48+
meson setup .. && meson configure -D default_library=both &&\
49+
ninja && ninja install &&\
50+
rm -f -r /tmp/fuse-${LIBFUSE_VERSION}*

0 commit comments

Comments
 (0)