forked from goweiwen/Allium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
176 lines (147 loc) · 7.53 KB
/
Copy pathMakefile
File metadata and controls
176 lines (147 loc) · 7.53 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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
ROOT_DIR := $(shell pwd)
BUILD_DIR := target/armv7-unknown-linux-gnueabihf/release
DIST_DIR := dist
RETROARCH := third-party/RetroArch-patch
TOOLCHAIN := mholdg16/miyoomini-toolchain:latest
TARGET_TRIPLE := armv7-unknown-linux-gnueabihf
GLIBC_VERSION := 2.28
comma := ,
FEATURES ?=
-include local.mk
.PHONY: all
all: dist build package-build $(DIST_DIR)/RetroArch/retroarch $(DIST_DIR)/.allium/bin/dufs $(DIST_DIR)/.allium/bin/syncthing $(DIST_DIR)/.allium/cores/drastic/drastic $(DIST_DIR)/Themes migrations strip-all
.PHONY: clean
clean:
rm -r $(DIST_DIR) || true
cd $(RETROARCH) && make clean || true
simulator-env: simulator/Themes
mkdir -p simulator
rsync -ar static/ simulator/
simulator/Themes:
TEMP_DIR=$$(mktemp -d) && \
git clone --depth 1 "$(THEMES_URL)" "$$TEMP_DIR" && \
rsync -a "$$TEMP_DIR/Themes/" "simulator/Themes/" && \
rm -rf "$$TEMP_DIR"
.PHONY: simulator
simulator: simulator-env
RUST_LOG=debug RUST_BACKTRACE=1 ALLIUM_DATABASE=$(ROOT_DIR)/simulator/allium.db ALLIUM_BASE_DIR=$(ROOT_DIR)/simulator/.allium ALLIUM_SD_ROOT=$(ROOT_DIR)/simulator cargo run --bin $(bin) --features=simulator$(if $(FEATURES),$(comma)$(FEATURES)) $(args)
.PHONY: dist
dist:
mkdir -p $(DIST_DIR)
rsync -a --exclude='.gitkeep' static/. $(DIST_DIR)
third-party/my283:
wget -O third-party/my283.tar.xz https://github.com/shauninman/miyoomini-toolchain-buildroot/raw/main/support/my283.tar.xz
cd third-party/ && tar xf my283.tar.xz
rm third-party/my283.tar.xz
.PHONY: build
build: third-party/my283
cargo zigbuild --release --target=$(TARGET_TRIPLE).$(GLIBC_VERSION) --features=miyoo --bin=alliumd --bin=allium-launcher --bin=activity-tracker --bin=screenshot-viewer --bin=screenshot --bin=say --bin=show --bin=myctl
patchelf \
--replace-needed third-party/my283/usr/lib/libcam_os_wrapper.so libcam_os_wrapper.so \
--replace-needed third-party/my283/usr/lib/libmi_sys.so libmi_sys.so \
target/$(TARGET_TRIPLE)/release/myctl
.PHONY: debug
debug: third-party/my283
cargo zigbuild --target=$(TARGET_TRIPLE).$(GLIBC_VERSION) --features=miyoo --bin=alliumd --bin=allium-launcher --bin=activity-tracker --bin=screenshot-viewer --bin=screenshot --bin=say --bin=show --bin=myctl
.PHONY: strip-all
strip-all:
docker run --rm -i -v $(ROOT_DIR):/root/workspace $(TOOLCHAIN) \
find dist \
-type f \
-not -path "dist/.tmp_update/8188fu.ko" \
-exec sh -c 'file "{}" | grep "not stripped"' \; \
-exec /opt/miyoomini-toolchain/usr/bin/arm-linux-gnueabihf-strip -s {} \;
.PHONY: package-build
package-build:
mkdir -p $(DIST_DIR)/.allium/bin
rsync -a $(BUILD_DIR)/alliumd $(DIST_DIR)/.allium/bin/
rsync -a $(BUILD_DIR)/allium-launcher $(DIST_DIR)/.allium/bin/
rsync -a $(BUILD_DIR)/screenshot $(DIST_DIR)/.tmp_update/bin/
rsync -a $(BUILD_DIR)/say $(DIST_DIR)/.tmp_update/bin/
rsync -a $(BUILD_DIR)/show $(DIST_DIR)/.tmp_update/bin/
rsync -a $(BUILD_DIR)/activity-tracker "$(DIST_DIR)/Apps/Activity Tracker.pak/"
rsync -a $(BUILD_DIR)/screenshot-viewer "$(DIST_DIR)/Apps/Screenshot Viewer.pak/"
rsync -a $(BUILD_DIR)/myctl $(DIST_DIR)/.tmp_update/bin/
@# Write version.txt: use git tag if available, otherwise nightly-<hash>
@TAG=$$(git describe --exact-match --tags HEAD 2>/dev/null | grep -v '^nightly$$'); \
if [ -n "$$TAG" ]; then \
echo "$$TAG" > $(DIST_DIR)/.allium/version.txt; \
else \
echo "nightly-$$(git rev-parse --short HEAD)" > $(DIST_DIR)/.allium/version.txt; \
fi
MIGRATIONS_DIR := $(DIST_DIR)/.allium/migrations
.PHONY: migrations
migrations: $(MIGRATIONS_DIR)/0000-retroarch-config/retroarch-config.zip $(MIGRATIONS_DIR)/0001-retroarch-core-overrides/retroarch-core-overrides.zip
$(MIGRATIONS_DIR)/0000-retroarch-config/retroarch-config.zip:
migrations/0000-retroarch-config/package.sh
$(MIGRATIONS_DIR)/0001-retroarch-core-overrides/retroarch-core-overrides.zip:
migrations/0001-retroarch-core-overrides/package.sh
.PHONY: retroarch
retroarch: $(RETROARCH)/retroarch
$(DIST_DIR)/RetroArch/retroarch: $(RETROARCH)/bin/retroarch_miyoo354
cp "$(RETROARCH)/bin/retroarch_miyoo354" "$(DIST_DIR)/RetroArch/retroarch"
$(RETROARCH)/bin/retroarch_miyoo354:
docker run --rm -v /$(ROOT_DIR)/$(RETROARCH):/root/workspace $(TOOLCHAIN) bash -c "source /root/.bashrc; make all; chown -R \$$(stat -c '%u:%g' /root/workspace) /root/workspace"
$(DIST_DIR)/.allium/bin/dufs:
cd third-party/dufs && LZMA_API_STATIC=1 cargo zigbuild --release --target=$(TARGET_TRIPLE).$(GLIBC_VERSION)
cp "third-party/dufs/target/$(TARGET_TRIPLE)/release/dufs" "$(DIST_DIR)/.allium/bin/"
SYNCTHING_VERSION := "v2.0.10"
SYNCTHING_URL := "https://github.com/syncthing/syncthing/releases/download/$(SYNCTHING_VERSION)/syncthing-linux-arm-$(SYNCTHING_VERSION).tar.gz"
$(DIST_DIR)/.allium/bin/syncthing:
TEMP_DIR=$$(mktemp --directory) && \
wget "$(SYNCTHING_URL)" -O "$$TEMP_DIR/syncthing.tar.gz" && \
tar xf "$$TEMP_DIR/syncthing.tar.gz" --directory="$$TEMP_DIR" && \
mv "$$TEMP_DIR/syncthing-linux-arm-$(SYNCTHING_VERSION)/syncthing" "$(DIST_DIR)/.allium/bin/syncthing"
DRASTIC_URL := https://github.com/steward-fu/nds/releases/download/v1.8/drastic-v1.8_miyoo.zip
$(DIST_DIR)/.allium/cores/drastic/drastic:
wget "$(DRASTIC_URL)" -O /tmp/drastic.zip
mkdir -p $(DIST_DIR)/.allium/cores/drastic
unzip -o /tmp/drastic.zip -d $(DIST_DIR)/.allium/cores/drastic
rm /tmp/drastic.zip
THEMES_URL := https://github.com/goweiwen/Allium-Themes.git
$(DIST_DIR)/Themes:
TEMP_DIR=$$(mktemp -d) && \
git clone --depth 1 "$(THEMES_URL)" "$$TEMP_DIR" && \
rsync -a "$$TEMP_DIR/Themes/" "$(DIST_DIR)/Themes/" && \
rm -rf "$$TEMP_DIR"
.PHONY: lint
lint:
cargo clippy --fix --allow-dirty --allow-staged --all-targets -- -D warnings
cargo fmt --all
.PHONY: bump-version
bump-version: lint
sed -i'' -e "s/^version = \".*\"/version = \"$(version)\"/" crates/allium-launcher/Cargo.toml
sed -i'' -e "s/^version = \".*\"/version = \"$(version)\"/" crates/allium-menu/Cargo.toml
sed -i'' -e "s/^version = \".*\"/version = \"$(version)\"/" crates/alliumd/Cargo.toml
sed -i'' -e "s/^version = \".*\"/version = \"$(version)\"/" crates/activity-tracker/Cargo.toml
sed -i'' -e "s/^version = \".*\"/version = \"$(version)\"/" crates/screenshot-viewer/Cargo.toml
sed -i'' -e "s/^version = \".*\"/version = \"$(version)\"/" crates/common/Cargo.toml
cargo check
git add crates/allium-launcher/Cargo.toml
git add crates/allium-menu/Cargo.toml
git add crates/alliumd/Cargo.toml
git add crates/activity-tracker/Cargo.toml
git add crates/screenshot-viewer/Cargo.toml
git add crates/common/Cargo.toml
git add Cargo.lock
git commit -m "chore: bump version to v$(version)"
git tag "v$(version)" -a
.PHONY: deploy
deploy:
ifndef SDCARD_PATH
$(error SDCARD_PATH is not set. Create a local.mk file with SDCARD_PATH=/path/to/sdcard or set it as an environment variable)
endif
@echo "Deploying to $(SDCARD_PATH)..."
rsync --progress --modify-window=1 --update --recursive --times --verbose $(DIST_DIR)/.allium $(DIST_DIR)/.tmp_update $(DIST_DIR)/Apps $(DIST_DIR)/RetroArch $(DIST_DIR)/Themes $(SDCARD_PATH)/
@echo "Deployment complete! Remember to eject your SD card properly."
.PHONY: deploy-all
deploy-all:
ifndef SDCARD_PATH
$(error SDCARD_PATH is not set. Create a local.mk file with SDCARD_PATH=/path/to/sdcard or set it as an environment variable)
endif
@echo "Deploying full dist to $(SDCARD_PATH)..."
rsync --progress --modify-window=1 --update --recursive --times --verbose --delete $(DIST_DIR)/.allium $(DIST_DIR)/.tmp_update $(DIST_DIR)/Apps $(DIST_DIR)/Themes $(SDCARD_PATH)/
@echo "Full deployment complete! Remember to eject your SD card properly."
.PHONY: toolchain
toolchain:
docker run --rm -it -v $(ROOT_DIR):/root/workspace $(TOOLCHAIN) bash