-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.sh
executable file
·42 lines (36 loc) · 1.06 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
set -euo pipefail
PKGNAME="$(./pkgname.sh)"
if [ "${BUILD_RELEASE:-}" != 1 ] && [ -n "$PKGNAME" ]; then
if ./download.sh "$PKGNAME"; then
echo "JQ: done_dowloading_jq_build_cache"
exit 0
else
echo "JQ: failed_to_download_jq_build_cache, continue to build from source"
fi
fi
# default: 4 concurrent jobs
JOBS=4
if [ "$(uname -s)" = 'Darwin' ]; then
JOBS="$(sysctl -n hw.ncpu)"
else
JOBS="$(nproc)"
fi
make -j "$JOBS" -C c_src
if [ "${BUILD_RELEASE:-}" = 1 ]; then
if [ -z "$PKGNAME" ]; then
echo "JQ: unable_to_resolve_release_package_name"
exit 1
fi
mkdir -p _packages
TARGET="_packages/${PKGNAME}"
cp c_src/libs/jqc/COPYING priv/
tar -czf "$TARGET" ./priv
# use openssl but not sha256sum command because in some macos env it does not exist
if command -v openssl; then
openssl dgst -sha256 "${TARGET}" | cut -d ' ' -f 2 > "${TARGET}.sha256"
else
sha256sum "${TARGET}" | cut -d ' ' -f 1 > "${TARGET}.sha256"
fi
echo "JQ: built $TARGET"
fi