Files
open-im-server/scripts/build_all_service.sh
T

103 lines
2.8 KiB
Bash
Raw Normal View History

2023-06-30 23:22:58 +08:00
#!/usr/bin/env bash
2023-08-08 11:24:15 +08:00
2023-07-04 11:15:20 +08:00
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2023-07-10 14:56:52 +08:00
#Include shell font styles and some basic information
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
source $SCRIPTS_ROOT/path_info.sh
2023-08-08 17:34:06 +08:00
source $SCRIPTS_ROOT/lib/init.sh
2023-06-30 23:22:58 +08:00
2023-07-07 21:59:28 +08:00
bin_dir="$BIN_DIR"
2023-07-13 11:37:23 +08:00
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/db/sdk/"
2023-07-13 15:45:03 +08:00
echo "==> bin_dir=$bin_dir"
echo "==> logs_dir=$logs_dir"
echo "==> sdk_db_dir=$sdk_db_dir"
2023-07-07 18:20:08 +08:00
# Automatically created when there is no bin, logs folder
2023-06-30 23:22:58 +08:00
if [ ! -d $logs_dir ]; then
mkdir -p $logs_dir
fi
if [ ! -d $sdk_db_dir ]; then
mkdir -p $sdk_db_dir
fi
2023-07-07 18:20:08 +08:00
cd $OPENIM_ROOT
2023-07-13 17:07:42 +08:00
# CPU core number
# Check the system type
system_type=$(uname)
if [[ "$system_type" == "Darwin" ]]; then
# macOS (using sysctl)
cpu_count=$(sysctl -n hw.ncpu)
elif [[ "$system_type" == "Linux" ]]; then
# Linux (using lscpu)
cpu_count=$(lscpu --parse | grep -E '^([^#].*,){3}[^#]' | sort -u | wc -l)
else
echo "Unsupported operating system: $system_type"
exit 1
fi
2023-07-13 17:07:42 +08:00
echo -e "${GREEN_PREFIX}======> cpu_count=$cpu_count${COLOR_SUFFIX}"
# Count the number of concurrent compilations (half the number of cpus)
compile_count=$((cpu_count / 2))
# Execute 'make build' run the make command for concurrent compilation
make -j$compile_count build
2023-07-07 18:20:08 +08:00
2023-07-12 19:21:55 +08:00
if [ $? -ne 0 ]; then
echo "make build Error, script exits"
exit 1
fi
2023-08-08 22:44:15 +08:00
openim::util::gen_os_arch
2023-07-07 18:20:08 +08:00
# Determine if all scripts were successfully built
BUILD_SUCCESS=true
FAILED_SCRIPTS=()
for binary in $(find _output/bin/platforms/$REPO_DIR -type f); do
if [[ ! -x $binary ]]; then
FAILED_SCRIPTS+=("$binary")
BUILD_SUCCESS=false
fi
2023-06-30 23:22:58 +08:00
done
2023-07-07 18:20:08 +08:00
2023-07-09 14:16:19 +08:00
echo -e " "
2023-07-07 18:20:08 +08:00
echo -e "${BOLD_PREFIX}=====================> Build Results <=====================${COLOR_SUFFIX}"
2023-07-09 14:16:19 +08:00
echo -e " "
2023-07-07 18:20:08 +08:00
if [[ "$BUILD_SUCCESS" == true ]]; then
echo -e "${GREEN_PREFIX}All binaries built successfully.${COLOR_SUFFIX}"
else
echo -e "${RED_PREFIX}Some binary builds failed. Please check the following binary files:${COLOR_SUFFIX}"
for script in "${FAILED_SCRIPTS[@]}"; do
echo -e "${RED_PREFIX}$script${COLOR_SUFFIX}"
done
fi
2023-07-09 14:16:19 +08:00
echo -e " "
2023-07-07 18:20:08 +08:00
echo -e "${BOLD_PREFIX}============================================================${COLOR_SUFFIX}"
2023-07-09 14:16:19 +08:00
echo -e " "