mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-11 04:25:59 +08:00
feat: option scripts and docs
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright © 2023 OpenIM. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -18,9 +17,9 @@
|
||||
# The command compiles all Makefile configs.
|
||||
# Args:
|
||||
# WHAT: Directory names to build. If any of these directories has a 'main'
|
||||
# package, the build will produce executable files under $(OUT_DIR)/go/bin.
|
||||
# package, the build will produce executable files under $(OUT_DIR)/bin/platforms OR $(OUT_DIR)/bin—tools/platforms.
|
||||
# If not specified, "everything" will be built.
|
||||
# Usage: `hack/build-go.sh`.
|
||||
# Usage: `scripts/build_all_server.sh`.
|
||||
# Example: `hack/build-go.sh WHAT=cmd/kubelet`.
|
||||
|
||||
set -o errexit
|
||||
@@ -30,21 +29,6 @@ set -o pipefail
|
||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
source "${OPENIM_ROOT}/scripts/lib/init.sh"
|
||||
|
||||
source $SCRIPTS_ROOT/lib/init.sh
|
||||
|
||||
bin_dir="$BIN_DIR"
|
||||
logs_dir="$OPENIM_ROOT/logs"
|
||||
|
||||
echo "==> bin_dir=$bin_dir"
|
||||
echo "==> logs_dir=$logs_dir"
|
||||
|
||||
# Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
|
||||
cd $OPENIM_ROOT
|
||||
|
||||
# CPU core number
|
||||
# Check the system type
|
||||
system_type=$(uname)
|
||||
@@ -61,47 +45,30 @@ else
|
||||
fi
|
||||
echo -e "${GREEN_PREFIX}======> cpu_count=$cpu_count${COLOR_SUFFIX}"
|
||||
|
||||
# Count the number of concurrent compilations (half the number of cpus)
|
||||
openim::log::status "Building OpenIM, Parallel compilation compile=$cpu_count"
|
||||
compile_count=$((cpu_count / 2))
|
||||
|
||||
# Execute 'make build' run the make command for concurrent compilation
|
||||
make -j$compile_count build
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "make build Error, script exits"
|
||||
exit 1
|
||||
# For help output
|
||||
ARGHELP=""
|
||||
if [[ "$#" -gt 0 ]]; then
|
||||
ARGHELP="'$*'"
|
||||
fi
|
||||
|
||||
openim::util::gen_os_arch
|
||||
openim::color::echo $COLOR_CYAN "NOTE: $0 has been replaced by 'make multiarch' or 'make build'"
|
||||
echo
|
||||
echo "The equivalent of this invocation is: "
|
||||
echo " make build ${ARGHELP}"
|
||||
echo
|
||||
echo " Example: "
|
||||
echo " Print a single binary:"
|
||||
echo " make build BINS=openim-api"
|
||||
echo " Print : Enable debugging and logging"
|
||||
echo " make build BINS=openim-api V=1 DEBUG=1"
|
||||
echo
|
||||
make --no-print-directory -C "${OPENIM_ROOT}" -j$compile_count build "$*"
|
||||
|
||||
# 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
|
||||
done
|
||||
|
||||
echo -e " "
|
||||
|
||||
echo -e "${BOLD_PREFIX}=====================> Build Results <=====================${COLOR_SUFFIX}"
|
||||
|
||||
echo -e " "
|
||||
|
||||
if [[ "$BUILD_SUCCESS" == true ]]; then
|
||||
echo -e "${GREEN_PREFIX}All binaries built successfully.${COLOR_SUFFIX}"
|
||||
if [ $? -eq 0 ]; then
|
||||
openim::log::success "all service build success, run 'make start' or './scripts/start_all.sh'"
|
||||
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
|
||||
openim::log::error "make build Error, script exits"
|
||||
fi
|
||||
|
||||
echo -e " "
|
||||
|
||||
echo -e "${BOLD_PREFIX}============================================================${COLOR_SUFFIX}"
|
||||
|
||||
echo -e " "
|
||||
|
||||
Reference in New Issue
Block a user