Skip to content

Commit d08747c

Browse files
committedSep 22, 2021
Make build easier for macOS
1 parent 9e89724 commit d08747c

File tree

2 files changed

+64
-6
lines changed

2 files changed

+64
-6
lines changed
 

‎README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@ $ git clone https://github.com/buffrr/fingertip
3636

3737
### MacOS
3838

39-
Follow [hnsd](https://github.com/handshake-org/hnsd) build instructions for MacOS.
40-
41-
Move hnsd binary to `builds/macos/Fingertip.app/Contents/MacOS/`
39+
```
40+
$ brew install dylibbundler git automake autoconf libtool unbound
41+
$ git clone https://github.com/imperviousinc/fingertip
42+
$ cd fingertip && ./builds/macos/build.sh
43+
```
4244

45+
For development, you can run fingertip from the following path:
4346
```
44-
$ brew install dylibbundler
45-
$ dylibbundler -od -b -x ./builds/macos/Fingertip.app/Contents/MacOS/hnsd -d ./builds/macos/Fingertip.app/Contents/Frameworks/ -p @executable_path/../Frameworks/
46-
$ go build -trimpath -o ./builds/macos/Fingertip.app/Contents/MacOS/fingertip
47+
$ ./builds/macos/Fingertip.app/Contents/MacOS/fingertip
4748
```
49+
50+
Configure your IDE to output to this directory or continue to use `build.sh` when making changes (it will only build hnsd once).
4851

4952
### Windows
5053

‎builds/macos/build.sh

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
# make sure path is correct
4+
# so that pwd points to main repo directory
5+
[[ -e builds/macos/build.sh ]] || { echo >&2 "Please cd into fingertip repo before running this script."; exit 1; }
6+
7+
min_macos_version="10.13"
8+
cflags="-mmacosx-version-min="${min_macos_version}
9+
working_dir=$(pwd)
10+
bundle_path="${working_dir}/builds/macos/Fingertip.app/Contents/"
11+
hnsd_path=${bundle_path}/MacOS/hnsd
12+
fingertip_path=${bundle_path}/MacOS/fingertip
13+
lib_dir=${bundle_path}/Frameworks/
14+
15+
if [ ! -e "$hnsd_path" ]; then
16+
17+
echo "Cloning hnsd ..."
18+
tmp_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'fingertip_hnsd')
19+
git clone https://github.com/handshake-org/hnsd "$tmp_dir"
20+
cd "$tmp_dir" || exit
21+
22+
echo "Building hnsd ..."
23+
./autogen.sh && ./configure
24+
make CFLAGS=$cflags -j 10
25+
cp "${tmp_dir}/hnsd" "$hnsd_path"
26+
27+
cd "$working_dir" || exit
28+
29+
# bundle libs
30+
dylibbundler -od -b -x "$hnsd_path" -d "$lib_dir" -p @executable_path/../Frameworks/
31+
32+
fi
33+
34+
# build fingertip
35+
CGO_CFLAGS=$cflags CGO_LDFLAGS=$cflags go build -trimpath -o "$fingertip_path"
36+
37+
get_min_version() {
38+
otool -l $1 | grep LC_VERSION_MIN_MACOSX -A3 | grep version | xargs | sed s/version// | xargs
39+
}
40+
41+
check_min_version() {
42+
min=$(get_min_version "$1")
43+
name=$(basename "$1")
44+
if [ "$min" != "$min_macos_version" ] ; then
45+
echo "Warning: ${name} got min version = ${min}, want $min_macos_version"
46+
fi
47+
}
48+
49+
check_min_version "$fingertip_path"
50+
check_min_version "$hnsd_path"
51+
52+
for file in "${lib_dir}"/*
53+
do
54+
check_min_version "$file"
55+
done

0 commit comments

Comments
 (0)
Please sign in to comment.