-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathMakefile
135 lines (100 loc) · 4.09 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
PLATFORM := $(shell uname -s)
ARCH ?= x86_64
# Check if variable contains string https://stackoverflow.com/a/2741747
ifneq (,$(findstring CYGWIN,$(PLATFORM)))
PLATFORM := "windows"
endif
ifneq (,$(findstring MINGW,$(PLATFORM)))
PLATFORM := "windows"
endif
ifneq (,$(findstring MSYS,$(PLATFORM)))
PLATFORM := "windows"
endif
$(warning PLATFORM is $(PLATFORM))
ifeq "$(PLATFORM)" "Darwin"
# Add brew executables to PATH
export PATH := /opt/homebrew/bin:/opt/homebrew/sbin:$(PATH)
endif
# Add cargo executables to PATH
export PATH := $(HOME)/.cargo/bin:$(PATH)
SHELL := env PATH=$(PATH) /bin/bash
# Check if cargo exists
CARGO := $(shell command -v cargo 2> /dev/null)
ifndef CARGO
$(error "cargo is not in PATH $(PATH)")
endif
MAKE_DIR ?= $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
TARGET_DIR ?= $(shell cargo metadata --format-version 1 | jq -r .target_directory)
BUILT_PRODUCTS_DIR ?= $(MAKE_DIR)/build
OUT_DIR := $(BUILT_PRODUCTS_DIR)
$(shell mkdir -p $(OUT_DIR))
CARGO_OPTIONS ?= --locked --release
BINARY_NAME ?= fig_desktop
CRATE_NAME ?= fig_desktop
### Build for each platform
ifeq "$(PLATFORM)" "Darwin"
all: macos
endif
ifeq "$(PLATFORM)" "Linux"
all: linux
endif
ifeq "$(PLATFORM)" "windows"
all: windows
endif
macos: $(BINARY_NAME)-darwin-universal
install $(OUT_DIR)/$< $(OUT_DIR)/$(BINARY_NAME)
$(BINARY_NAME)-x86_64-apple-darwin:
cargo build --target=x86_64-apple-darwin $(CARGO_OPTIONS)
install $(TARGET_DIR)/x86_64-apple-darwin/release/$(CRATE_NAME) $(OUT_DIR)/$@
$(BINARY_NAME)-aarch64-apple-darwin:
cargo build --target=aarch64-apple-darwin $(CARGO_OPTIONS)
install $(TARGET_DIR)/aarch64-apple-darwin/release/$(CRATE_NAME) $(OUT_DIR)/$@
$(BINARY_NAME)-darwin-universal:
cargo build --target=x86_64-apple-darwin --target=aarch64-apple-darwin $(CARGO_OPTIONS)
install $(TARGET_DIR)/x86_64-apple-darwin/release/$(CRATE_NAME) $(OUT_DIR)/$(BINARY_NAME)-x86_64-apple-darwin
install $(TARGET_DIR)/aarch64-apple-darwin/release/$(CRATE_NAME) $(OUT_DIR)/$(BINARY_NAME)-aarch64-apple-darwin
lipo -create -output $(OUT_DIR)/$@ $(OUT_DIR)/$(BINARY_NAME)-x86_64-apple-darwin $(OUT_DIR)/$(BINARY_NAME)-aarch64-apple-darwin
linux: $(BINARY_NAME)-$(ARCH)-unknown-linux-gnu
install $(OUT_DIR)/$< $(OUT_DIR)/$(BINARY_NAME)
$(BINARY_NAME)-x86_64-unknown-linux-gnu:
cargo build --target=x86_64-unknown-linux-gnu $(CARGO_OPTIONS)
install $(TARGET_DIR)/x86_64-unknown-linux-gnu/release/$(CRATE_NAME) $(OUT_DIR)/$@
$(BINARY_NAME)-aarch64-unknown-linux-gnu:
cargo build --target=aarch64-unknown-linux-gnu $(CARGO_OPTIONS)
install $(TARGET_DIR)/aarch64-unknown-linux-gnu/release/$(CRATE_NAME) $(OUT_DIR)/$@
windows: $(BINARY_NAME)-x86_64-pc-windows-gnu
install $(OUT_DIR)/$< $(OUT_DIR)/$(BINARY_NAME)
$(BINARY_NAME)-x86_64-pc-windows-gnu:
cargo build --target x86_64-pc-windows-gnu $(CARGO_OPTIONS)
install $(TARGET_DIR)/x86_64-pc-windows-gnu/release/$(CRATE_NAME).exe $(OUT_DIR)/$@
### Build and Install for local dev
build-native:
cargo build
build-native-release:
cargo build --release
install-native-usr: build-native
sudo install $(TARGET_DIR)/debug/$(CRATE_NAME) /usr/bin/$(BINARY_NAME)
install-native-usr-release: build-native-release
sudo install $(TARGET_DIR)/release/$(CRATE_NAME) /usr/bin/$(BINARY_NAME)
install-macos-bundle: build-native
mkdir -p /Applications/Amazon\ Q.app/Contents/MacOS/
install $(TARGET_DIR)/debug/$(CRATE_NAME) /Applications/Amazon\ Q.app/Contents/MacOS/fig_desktop
### Convert icons
icons:
echo $(MAKE_DIR)
for res in 16 22 24 32 48 64 128 256 512; do \
convert -resize "$${res}x$${res}" "icons/icon.png" "icons/$${res}x$${res}.png" ; \
done
convert -resize "32x32" "icons/icon.png" "icons/icon.ico"
cargo tauri icon icons/icon.png
cargo tauri icon -o volume-icons icons/VolumeIcon.png
mv volume-icons/icon.icns $(MAKE_DIR)/../bundle/dmg/VolumeIcon.icns
mv icons/256x256.png $(MAKE_DIR)/../extensions/vscode/images/icon.png
# Clean up unused output from tauri icon cli.
rm icons/Square* icons/StoreLogo.png
rm -rf volume-icons
### Clean the project
clean:
command -v cargo &>/dev/null && cargo clean
rm -rf $(BUILT_PRODUCTS_DIR)
.PHONY: clean icons