Merge pull request #7896 from terry-xiaoyu/compile_mac_osx

chore: check dependenies before building on Mac OSX
This commit is contained in:
Xinyu Liu 2022-05-08 14:30:24 +08:00 committed by GitHub
commit d2c55ec194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 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
@ -167,6 +167,8 @@ jobs:
- name: build
working-directory: source
env:
AUTO_INSTALL_BUILD_DEPS: 1
run: |
. $HOME/.kerl/${{ matrix.otp }}/activate
make ensure-rebar3

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
@ -172,6 +172,8 @@ jobs:
kerl install ${{ matrix.otp }} $HOME/.kerl/${{ matrix.otp }}
- name: Get deps git refs for cache
id: deps-refs
env:
AUTO_INSTALL_BUILD_DEPS: 1
run: |
. $HOME/.kerl/${{ matrix.otp }}/activate
make ensure-rebar3
@ -184,6 +186,8 @@ jobs:
path: _build/default/lib/quicer/
key: ${{ matrix.macos }}-${{ matrix.otp }}-macos-${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
- name: build ${{ matrix.profile }}
env:
AUTO_INSTALL_BUILD_DEPS: 1
run: |
. $HOME/.kerl/${{ matrix.otp }}/activate
make ensure-rebar3

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 bison"
required_cmds_mac_osx="curl zip unzip autoconf automake 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