forked from NMAAHC/mkvnote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·59 lines (49 loc) · 1.68 KB
/
Copy pathbuild
File metadata and controls
executable file
·59 lines (49 loc) · 1.68 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
# build script for mkvnote-gui
# Usage: ./build [clean]
SCRIPT_NAME="$(basename "${0}")"
SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)"
BUILD_DIR="${SCRIPT_DIR}/_build"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RESET='\033[0m'
_log(){ echo -e "${1}${2}${RESET}" ; }
_ohno(){ _log "${RED}" "${1}" ; exit 1 ; }
# check for cmake and Qt6
if ! command -v cmake &>/dev/null ; then
_ohno "cmake not found. Install with: brew install cmake"
fi
QT6_PREFIX="$(brew --prefix qt@6 2>/dev/null)"
if [[ -z "${QT6_PREFIX}" || ! -d "${QT6_PREFIX}" ]] ; then
_ohno "Qt6 not found. Install with: brew install qt@6"
fi
# clean up process
if [[ "${1}" == "clean" ]] ; then
_log "${YELLOW}" "Cleanup time! ..."
rm -rf "${BUILD_DIR}"
_log "${GREEN}" "Done cleaning up around here."
exit 0
fi
# build process
_log "${GREEN}" "Getting ready :) ..."
if [[ ! -d "${BUILD_DIR}" ]] ; then
mkdir -p "${BUILD_DIR}"
fi
# clear cache if it exists and is stale
if [[ -f "${BUILD_DIR}/CMakeCache.txt" ]] ; then
_log "${YELLOW}" "Clearing stale CMake cache..."
rm -f "${BUILD_DIR}/CMakeCache.txt"
rm -rf "${BUILD_DIR}/CMakeFiles"
fi
cmake -S "${SCRIPT_DIR}" -B "${BUILD_DIR}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="${QT6_PREFIX}" -DCMAKE_OSX_ARCHITECTURES=arm64 || _ohno "cmake configure failed"
_log "${GREEN}" "Building it..."
cmake --build "${BUILD_DIR}" --parallel "$(sysctl -n hw.logicalcpu)" || _ohno "cmake build failed"
#
BINARY="${BUILD_DIR}/mkvnote-gui"
if [[ -f "${BINARY}" ]] ; then
_log "${GREEN}" "Built it: ${BINARY}"
_log "${GREEN}" "Run like: ${BINARY} /path/to/file.mkv"
else
_ohno "Build finished but it's not at ${BINARY}. Hmmm."
fi