chore: check dependenies before building on Mac OSX

This commit is contained in:
Shawn 2022-05-07 21:43:06 +08:00
parent dc1cd3b34e
commit d80b7c720b
4 changed files with 47 additions and 3 deletions

View File

@ -139,7 +139,7 @@ jobs:
- name: prepare
run: |
brew update
brew install curl zip unzip gnu-sed kerl unixodbc freetds automake bison
brew install curl zip unzip kerl
echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH
echo "/usr/local/bin" >> $GITHUB_PATH
git config --global credential.helper store

View File

@ -151,7 +151,7 @@ jobs:
- name: prepare
run: |
brew update
brew install curl zip unzip gnu-sed kerl unixodbc freetds automake bison
brew install curl zip unzip kerl
echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH
echo "/usr/local/bin" >> $GITHUB_PATH
echo "EMQX_NAME=${{ matrix.profile }}" >> $GITHUB_ENV

View File

@ -111,7 +111,7 @@ cover: $(REBAR)
coveralls: $(REBAR)
@ENABLE_COVER_COMPILE=1 $(REBAR) as test coveralls send
COMMON_DEPS := $(REBAR) get-dashboard conf-segs
COMMON_DEPS := $(REBAR) prepare-build-deps get-dashboard conf-segs
ELIXIR_COMMON_DEPS := ensure-hex ensure-mix-rebar3 ensure-mix-rebar
.PHONY: $(REL_PROFILES)
@ -219,6 +219,9 @@ conf-segs:
@scripts/merge-config.escript
@scripts/merge-i18n.escript
prepare-build-deps:
@scripts/prepare-build-deps.sh
## elixir target is to create release packages using Elixir's Mix
.PHONY: $(REL_PROFILES:%=%-elixir) $(PKG_PROFILES:%=%-elixir)
$(REL_PROFILES:%=%-elixir) $(PKG_PROFILES:%=%-elixir): $(COMMON_DEPS) $(ELIXIR_COMMON_DEPS) mix-deps-get

41
scripts/prepare-build-deps.sh Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail
AUTO_INSTALL_BUILD_DEPS="${AUTO_INSTALL_BUILD_DEPS:-0}"
required_packages_mac_osx="freetds unixodbc"
required_cmds_mac_osx="curl zip unzip autoconf automake bison cmake openssl"
dependency_missing() {
echo "error: $1 is not found in the system"
if [ "${AUTO_INSTALL_BUILD_DEPS}" = "1" ]; then
echo "brew install $1"
brew install $1
else
echo "You can install it by running:"
echo " brew install $1"
exit 1
fi
}
prepare_mac_osx() {
current_packages=$(brew list)
for package in ${required_packages_mac_osx}
do
if ! echo ${current_packages} | grep -q "${package}"; then
dependency_missing ${package}
fi
done
for cmd in ${required_cmds_mac_osx}
do
if ! command -v "${cmd}" &> /dev/null; then
dependency_missing ${cmd}
fi
done
}
case $(uname) in
*Darwin*) prepare_mac_osx;;
*) exit 0;;
esac