-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile
84 lines (61 loc) · 2.74 KB
/
Makefile
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
BUILD_FOLDER = "$(shell pwd)/build"
ASSETS_FOLDER = "$(shell pwd)/assets"
FLAGS_LINUX = GOOS=linux
FLAGS_DARWIN = GOOS=darwin
FLAGS_WINDOWS = GOOS=windows GOARCH=amd64 CC=i686-w64-mingw32-gcc CGO_ENABLED=1
PLATFORMTOOLS_URL = https://dl.google.com/android/repository/
PLATFORMTOOLS_WINDOWS = platform-tools-latest-windows.zip
PLATFORMTOOLS_DARWIN = platform-tools-latest-darwin.zip
PLATFORMTOOLS_LINUX = platform-tools-latest-linux.zip
PLATFORMTOOLS_FOLDER = /tmp/platform-tools
lint:
@echo "[lint] Running linter on codebase"
@golint ./...
deps:
@echo "[deps] Installing dependencies..."
go mod download
go mod tidy
@echo "[deps] Dependencies installed."
windows:
@mkdir -p $(BUILD_FOLDER)
@if [ ! -f /tmp/$(PLATFORMTOOLS_WINDOWS) ]; then \
echo "Downloading Windows Android Platform Tools..."; \
wget $(PLATFORMTOOLS_URL)$(PLATFORMTOOLS_WINDOWS) -O /tmp/$(PLATFORMTOOLS_WINDOWS); \
fi
@rm -rf $(PLATFORMTOOLS_FOLDER)
@cd /tmp && unzip -u $(PLATFORMTOOLS_WINDOWS)
@cp $(PLATFORMTOOLS_FOLDER)/AdbWinApi.dll $(ASSETS_FOLDER)
@cp $(PLATFORMTOOLS_FOLDER)/AdbWinUsbApi.dll $(ASSETS_FOLDER)
@cp $(PLATFORMTOOLS_FOLDER)/adb.exe $(ASSETS_FOLDER)
@echo "[builder] Building Windows binary for amd64"
$(FLAGS_WINDOWS) go build --ldflags '-s -w -extldflags "-static"' -o $(BUILD_FOLDER)/androidqf_windows_amd64.exe .
@echo "[builder] Done!"
darwin:
@mkdir -p $(BUILD_FOLDER)
@if [ ! -f /tmp/$(PLATFORMTOOLS_DARWIN) ]; then \
echo "Downloading Darwin Android Platform Tools..."; \
wget $(PLATFORMTOOLS_URL)$(PLATFORMTOOLS_DARWIN) -O /tmp/$(PLATFORMTOOLS_DARWIN); \
fi
@rm -rf $(PLATFORMTOOLS_FOLDER)
@cd /tmp && unzip -u $(PLATFORMTOOLS_DARWIN)
@cp $(PLATFORMTOOLS_FOLDER)/adb $(ASSETS_FOLDER)
@echo "[builder] Building Darwin binary for amd64"
$(FLAGS_DARWIN) GOARCH=amd64 go build --ldflags '-s -w' -o $(BUILD_FOLDER)/androidqf_darwin_amd64 .
$(FLAGS_DARWIN) GOARCH=arm64 go build --ldflags '-s -w' -o $(BUILD_FOLDER)/androidqf_darwin_arm64 .
@echo "[builder] Done!"
linux:
@mkdir -p $(BUILD_FOLDER)
@if [ ! -f /tmp/$(PLATFORMTOOLS_LINUX) ]; then \
echo "Downloading Linux Android Platform Tools..."; \
wget $(PLATFORMTOOLS_URL)$(PLATFORMTOOLS_LINUX) -O /tmp/$(PLATFORMTOOLS_LINUX); \
fi
@rm -rf $(PLATFORMTOOLS_FOLDER)
@cd /tmp && unzip -u $(PLATFORMTOOLS_LINUX)
@cp $(PLATFORMTOOLS_FOLDER)/adb $(ASSETS_FOLDER)
@echo "[builder] Building Linux binary for amd64"
@$(FLAGS_LINUX) GOARCH=amd64 go build --ldflags '-s -w' -o $(BUILD_FOLDER)/androidqf_linux_amd64 .
@$(FLAGS_LINUX) GOARCH=arm64 go build --ldflags '-s -w' -o $(BUILD_FOLDER)/androidqf_linux_arm64 .
@echo "[builder] Done!"
clean:
rm -rf $(BUILD_FOLDER)
rm -f $(ASSETS_FOLDER)/adb $(ASSETS_FOLDER)/adb.exe $(ASSETS_FOLDER)/AdbWinApi.dll $(ASSETS_FOLDER)/AdbWinUsbApi.dll