-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathMakefile
154 lines (124 loc) · 5.32 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
PREFIX ?= $(HOME)/.local
ROOTFS ?= .rootfs
GODOT_VERSION ?= 4.0
GODOT_RELEASE ?= stable
GODOT_REVISION := $(GODOT_VERSION).$(GODOT_RELEASE)
GODOT ?= /usr/bin/godot4
GAMESCOPE ?= /usr/bin/gamescope
EXPORT_TEMPLATE := $(HOME)/.local/share/godot/export_templates/$(GODOT_REVISION)/linux_debug.x86_64
EXPORT_TEMPLATE_URL ?= https://downloads.tuxfamily.org/godotengine/$(GODOT_VERSION)/Godot_v$(GODOT_VERSION)-$(GODOT_RELEASE)_export_templates.tpz
ALL_GDSCRIPT := $(shell find ./ -name '*.gd')
ALL_SCENES := $(shell find ./ -name '*.tscn')
# Remote debugging variables
SSH_USER ?= deck
SSH_HOST ?= 192.168.0.65
SSH_MOUNT_PATH ?= /tmp/remote
SSH_DATA_PATH ?= /home/$(SSH_USER)/Projects
# Include any user defined settings
-include settings.mk
##@ General
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: install
install: rootfs ## Install OpenGamepadUI (default: ~/.local)
cd $(ROOTFS) && make install PREFIX=$(PREFIX)
.PHONY: uninstall
uninstall: ## Uninstall OpenGamepadUI
cd $(ROOTFS) && make uninstall PREFIX=$(PREFIX)
##@ Development
.PHONY: build
build: addons build/opengamepad-ui.x86_64 ## Build and export the project
build/opengamepad-ui.x86_64: $(ALL_GDSCRIPT) $(ALL_SCENES) $(EXPORT_TEMPLATE)
mkdir -p build
$(GODOT) --headless --export-debug "Linux/X11"
.PHONY: plugins
plugins: addons build/plugins.zip ## Build and export plugins
build/plugins.zip: $(ALL_GDSCRIPT) $(ALL_SCENES) $(EXPORT_TEMPLATE)
mkdir -p build
$(GODOT) --headless --export-pack "Linux/X11 (Plugins)" $@
.PHONY: import
import: ## Import project assets
@echo "Importing project assets. This will take some time..."
timeout --foreground 60 $(GODOT) --headless --editor . || echo "Finished"
.PHONY: addons
addons: ## Build GDExtension add-ons
@echo "Building gdnative addons"
cd ./addons/godot-xlib && make build
cd ./addons/godot-evdev && make build
cd ./addons/godot-pty && make build
.PHONY: edit
edit: ## Open the project in the Godot editor
$(GODOT) --editor .
.PHONY: clean
clean: ## Remove build artifacts
rm -rf build
rm -rf $(ROOTFS)
rm -rf dist
cd ./addons/godot-xlib && make clean
cd ./addons/godot-evdev && make clean
cd ./addons/godot-pty && make clean
.PHONY: run run-force
run: addons build/opengamepad-ui.x86_64 run-force ## Run the project in gamescope
run-force:
$(GAMESCOPE) -w 1920 -h 1080 -f -e \
--xwayland-count 2 -- ./build/opengamepad-ui.x86_64
$(EXPORT_TEMPLATE):
mkdir -p $(HOME)/.local/share/godot/export_templates
@echo "Downloading export templates"
wget $(EXPORT_TEMPLATE_URL) -O $(HOME)/.local/share/godot/export_templates/templates.zip
@echo "Extracting export templates"
unzip $(HOME)/.local/share/godot/export_templates/templates.zip -d $(HOME)/.local/share/godot/export_templates/
rm $(HOME)/.local/share/godot/export_templates/templates.zip
mv $(HOME)/.local/share/godot/export_templates/templates $(@D)
.PHONY: debug
debug: addons ## Run the project in debug mode in gamescope
$(GAMESCOPE) -e --xwayland-count 2 -- \
$(GODOT) --path $(PWD) --remote-debug tcp://127.0.0.1:6007 \
--position 320,140 res://entrypoint.tscn
.PHONY: inspect
inspect: addons ## Launch Gamescope inspector
$(GODOT) --path $(PWD) res://core/ui/menu/debug/gamescope_inspector.tscn
##@ Remote Debugging
.PHONY: deploy
deploy: dist $(SSH_MOUNT_PATH)/.mounted ## Build, deploy, and tunnel to a remote device
cp dist/opengamepadui.tar.gz $(SSH_MOUNT_PATH)
cd $(SSH_MOUNT_PATH) && tar xvfz opengamepadui.tar.gz
.PHONY: tunnel
tunnel: ## Create an SSH tunnel to allow remote debugging
ssh $(SSH_USER)@$(SSH_HOST) -N -f -R 6007:localhost:6007
# Mounts the remote device and creates an SSH tunnel for remote debugging
$(SSH_MOUNT_PATH)/.mounted:
mkdir -p $(SSH_MOUNT_PATH)
sshfs -o default_permissions $(SSH_USER)@$(SSH_HOST):$(SSH_DATA_PATH) $(SSH_MOUNT_PATH)
$(MAKE) tunnel
touch $(SSH_MOUNT_PATH)/.mounted
##@ Distribution
.PHONY: rootfs
rootfs: ## Build the archive structure
rm -rf $(ROOTFS)
mkdir -p $(ROOTFS)
cp -r rootfs/* $(ROOTFS)
mkdir -p $(ROOTFS)/usr/share/opengamepadui
cp -r build/*.so $(ROOTFS)/usr/share/opengamepadui
cp -r build/opengamepad-ui.x86_64 $(ROOTFS)/usr/share/opengamepadui
touch $(ROOTFS)/.gdignore
.PHONY: dist
dist: dist/opengamepadui.tar.gz ## Create an archive distribution of the project
dist/opengamepadui.tar.gz: build rootfs
mv $(ROOTFS) opengamepadui
tar cvfz opengamepadui.tar.gz opengamepadui
mkdir -p dist
mv opengamepadui.tar.gz dist
mv opengamepadui $(ROOTFS)
cd dist && sha256sum opengamepadui.tar.gz > sha256sum.txt