-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
105 lines (77 loc) · 2.73 KB
/
Copy pathMakefile
File metadata and controls
105 lines (77 loc) · 2.73 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
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
PLATFORM ?= web
SERVER_URL ?= http://localhost:8080
BUNDLE_ARGS ?=
PACKAGES ?=
PACKAGE_FLAGS := $(foreach b,$(PACKAGES),--package-types $(b))
PACKAGE_NAME = roommates
ifdef VERBOSE
BUNDLE_ARGS += --verbose --trace
endif
ifdef HOTPATCH
HOT_PATCH_FLAG := --hot-patch
endif
ifeq ($(PLATFORM), android)
BUNDLE_ARGS += --target aarch64-linux-android
endif
.PHONY: dependencies assets bundle bundle-no-deps bundle-android dev-server tests format clean
all: bundle
################### ASSETS ###################
FRONTEND_DIR := packages/frontend
DIST_DIR := dist
ASSETS_DIR := $(FRONTEND_DIR)/assets
GENERATED_ASSETS_DIR := $(ASSETS_DIR)/dist
APP_ICONS_DIR := $(GENERATED_ASSETS_DIR)/app_icons
APP_ICON_STAMP := $(APP_ICONS_DIR)/.stamp
ASSET_DEPS = $(GENERATED_ASSETS_DIR)/tailwind.css
ifneq ($(PLATFORM), web)
ASSET_DEPS += $(APP_ICON_STAMP)
endif
NPM_DEPS = package.json package-lock.json
NODE_MODULES_STAMP = node_modules/.stamp
$(NODE_MODULES_STAMP): $(NPM_DEPS)
npm ci
touch $(NODE_MODULES_STAMP)
dependencies: $(NODE_MODULES_STAMP)
$(APP_ICON_STAMP): $(ASSETS_DIR)/roommatesicon.png dependencies
npx @tauri-apps/cli icon $(ASSETS_DIR)/roommatesicon.png -o $(APP_ICONS_DIR)
touch $(APP_ICON_STAMP)
$(GENERATED_ASSETS_DIR)/tailwind.css: $(FRONTEND_DIR)/tailwind.css dependencies
npx @tailwindcss/cli -i $(FRONTEND_DIR)/tailwind.css -o $(GENERATED_ASSETS_DIR)/tailwind.css --minify --map
assets: $(ASSET_DEPS)
################# BUNDLING #################
KEYSTORE_PATH ?= $(HOME)/.android/keystore.jks
KEYSTORE_PASSWORD ?=
ANDROID_PROJECT_DIR := target/dx/$(PACKAGE_NAME)/release/android/app
bundle-android:
@echo "Running custom Android bundle process"
@KEYSTORE_PASSWORD=$(KEYSTORE_PASSWORD) ./scripts/bundle_android.sh $(ANDROID_PROJECT_DIR) $(DIST_DIR)/android $(APP_ICONS_DIR) $(KEYSTORE_PATH)
bundle-no-deps:
SERVER_URL=$(SERVER_URL) dx bundle \
--release \
--package $(PACKAGE_NAME) \
--$(PLATFORM) \
--debug-symbols=false \
--out-dir $(DIST_DIR)/$(PLATFORM) $(PACKAGE_FLAGS) $(BUNDLE_ARGS)
bundle: assets
@echo "Building for platform: $(PLATFORM)"
ifeq ($(PLATFORM),android)
rm -r $(ANDROID_PROJECT_DIR)/app/src/main/res/*
endif
@set -e; \
tmpfile=$$(mktemp); \
mv $(FRONTEND_DIR)/tailwind.css $$tmpfile; \
trap '[ -e $$tmpfile ] && mv $$tmpfile $(FRONTEND_DIR)/tailwind.css' INT TERM EXIT; \
$(MAKE) bundle-no-deps
ifeq ($(PLATFORM),android)
$(MAKE) bundle-android
endif
########################## UTILS ##########################
dev-server: dependencies
dx serve --package $(PACKAGE_NAME) --platform $(PLATFORM) --addr 0.0.0.0 $(BUNDLE_ARGS) $(HOT_PATCH_FLAG)
tests: dependencies
cargo test --workspace --all-features --no-fail-fast
format:
@./scripts/format.sh
clean:
rm -rf $(DIST_DIR)
rm -rf $(GENERATED_ASSETS_DIR)