Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
169 lines (144 loc) · 7.44 KB
/
Copy pathMakefile
File metadata and controls
169 lines (144 loc) · 7.44 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
PREFIX ?= $(HOME)/.local
CARGO ?= cargo
CODESIGN_IDENTITY ?= -
BINARY := undefined-player
DESKTOP_FILE := data/undefined-player.desktop
VERSION := $(shell awk -F'"' '/^version = / { print $$2; exit }' Cargo.toml)
ARCH ?= $(shell uname -m)
TARBALL_NAME := $(BINARY)-$(VERSION)-linux-$(ARCH)
TARBALL_BINARY ?= target/release/$(BINARY)
DMG_NAME := $(BINARY)-$(VERSION)-macos-$(ARCH).dmg
HOST_OS := $(shell uname -s)
.PHONY: all build check check-native check-metal check-upscale app dmg deb tarball install uninstall clean
all: build
build:
$(CARGO) build --release
app: build
python3 packaging/macos/bundle.py --identity "$(CODESIGN_IDENTITY)"
dmg: app
@set -eu; \
stage=$$(mktemp -d target/dist/dmg.XXXXXX); \
trap 'rm -rf "$$stage"' EXIT HUP INT TERM; \
mkdir "$$stage/root"; \
ditto "target/dist/Undefined Player.app" "$$stage/root/Undefined Player.app"; \
ln -s /Applications "$$stage/root/Applications"; \
hdiutil create -volname "Undefined Player" -srcfolder "$$stage/root" \
-fs HFS+ -format UDZO "$$stage/image.dmg"; \
hdiutil verify "$$stage/image.dmg"; \
if [ "$(CODESIGN_IDENTITY)" != "-" ]; then \
codesign --force --sign "$(CODESIGN_IDENTITY)" --timestamp "$$stage/image.dmg"; \
codesign --verify --strict "$$stage/image.dmg"; \
fi; \
mv -f "$$stage/image.dmg" "target/dist/$(DMG_NAME)"; \
echo "Built target/dist/$(DMG_NAME)"
check: check-native
$(CARGO) fmt --check
$(CARGO) test
$(CARGO) clippy --all-targets -- -D warnings
ifneq ($(HOST_OS),Darwin)
desktop-file-validate $(DESKTOP_FILE)
endif
ifeq ($(HOST_OS),Darwin)
target/tests/video_color_macos_shader.h: native/video_color_macos.metal
mkdir -p target/tests
python3 -c 'import json; print("static const char video_color_shader[] = " + json.dumps(open("native/video_color_macos.metal").read()) + ";")' > $@
target/tests/video-color.o: native/video_color_macos.m native/video_color_macos.h target/tests/video_color_macos_shader.h
$(CC) -std=c11 -O2 -Wall -Wextra -Werror -fobjc-arc -Itarget/tests \
$(shell pkg-config --cflags sdl3 libavutil libswscale) -c $< -o $@
target/tests/video-upscaler.o: native/video_upscaler_macos.m native/video_upscaler_macos.h
mkdir -p target/tests
$(CC) -std=c11 -O2 -Wall -Wextra -Werror -fobjc-arc \
$(shell pkg-config --cflags sdl3 libavutil libswscale) -c $< -o $@
target/tests/playback-macos.o: native/playback_macos.m native/playback_macos.h
mkdir -p target/tests
$(CC) -std=c11 -O2 -Wall -Wextra -Werror -fobjc-arc \
$(shell pkg-config --cflags sdl3) -c $< -o $@
target/tests/video-renderer: native/video_renderer_macos_tests.c native/video_renderer_macos.c native/video_renderer.h native/window_shape.h native/ffmpeg_luma.h native/ffmpeg_compat.h target/tests/video-color.o target/tests/video-upscaler.o target/tests/playback-macos.o
$(CC) -std=c11 -O2 -Wall -Wextra -Werror \
$(shell pkg-config --cflags sdl3 pangocairo libavutil libswscale) \
native/video_renderer_macos_tests.c target/tests/video-color.o target/tests/video-upscaler.o target/tests/playback-macos.o -o $@ \
$(shell pkg-config --libs sdl3 pangocairo libavutil libswscale) \
-framework VideoToolbox -framework CoreVideo -framework CoreMedia -framework Metal \
-framework QuartzCore -framework Foundation -framework AVFoundation -framework AppKit -Wl,-dead_strip
target/tests/media-controls: native/media_controls_macos_tests.m native/media_controls_macos.m native/media_controls_macos.h
mkdir -p target/tests
$(CC) -std=c11 -O2 -Wall -Wextra -Werror -fobjc-arc $< -o $@ \
-framework AppKit -framework MediaPlayer -framework Foundation
target/tests/video-upscaler: native/video_upscaler_macos_tests.m native/video_upscaler_macos.m native/video_upscaler_macos.h native/macos_logging.h
mkdir -p target/tests
$(CC) -std=c11 -O2 -Wall -Wextra -Werror -fobjc-arc \
$(shell pkg-config --cflags sdl3 libavutil libswscale) $< -o $@ \
$(shell pkg-config --libs sdl3 libavutil libswscale) \
-framework Foundation -framework VideoToolbox -framework CoreVideo -framework CoreMedia
target/tests/video-decoder: native/video_decoder_macos_tests.m native/video_decoder_macos.m native/video_decoder_macos.h
mkdir -p target/tests
$(CC) -std=c11 -O2 -Wall -Wextra -Werror -fobjc-arc \
$(shell pkg-config --cflags libavformat libavcodec libavutil) $< -o $@ \
$(shell pkg-config --libs libavformat libavcodec libavutil) \
-framework Foundation -framework VideoToolbox -framework CoreVideo -framework CoreMedia
check-native: target/tests/video-renderer target/tests/media-controls target/tests/video-upscaler target/tests/video-decoder
target/tests/video-renderer
target/tests/media-controls
target/tests/video-upscaler
target/tests/video-decoder
# Requires a desktop/Metal GPU. Kept separate from CPU-only CI checks.
target/tests/playback-macos: native/playback_macos_tests.m native/playback_macos.m native/playback_macos.h
mkdir -p target/tests
$(CC) -std=c11 -O2 -Wall -Wextra -Werror -fobjc-arc \
$(shell pkg-config --cflags sdl3) $< -o $@ \
$(shell pkg-config --libs sdl3) \
-framework AVFoundation -framework AppKit -framework QuartzCore -framework CoreMedia
target/tests/native-playback.mp4:
mkdir -p target/tests
ffmpeg -v error -f lavfi -i testsrc2=size=160x90:rate=30 -t 2 \
-c:v libx264 -pix_fmt yuv420p -y $@
check-metal: target/tests/video-renderer target/tests/playback-macos target/tests/native-playback.mp4
target/tests/video-renderer --metal
target/tests/playback-macos target/tests/native-playback.mp4
check-upscale: target/tests/video-upscaler
target/tests/video-upscaler --apple-ml
else
check-native:
mkdir -p target/tests
$(CC) -std=c11 -O2 -Wall -Wextra -Werror -ffunction-sections -fdata-sections \
$(shell pkg-config --cflags libplacebo sdl3 pangocairo) \
$(if $(FFMPEG_DIR),-I"$(FFMPEG_DIR)",$(shell pkg-config --cflags libavutil)) \
native/video_renderer_tests.c -o target/tests/video-renderer \
$(shell pkg-config --libs libplacebo sdl3 pangocairo) -lm -Wl,--gc-sections
target/tests/video-renderer
endif
deb:
dpkg-buildpackage --build=binary --no-sign
tarball: build
rm -rf target/dist/$(TARBALL_NAME)
install -Dm755 $(TARBALL_BINARY) target/dist/$(TARBALL_NAME)/bin/$(BINARY)
install -Dm644 $(DESKTOP_FILE) target/dist/$(TARBALL_NAME)/share/applications/$(BINARY).desktop
install -Dm644 README.md target/dist/$(TARBALL_NAME)/README.md
install -m644 USAGE.md CONFIGURATION.md DEVELOPMENT.md target/dist/$(TARBALL_NAME)/
install -Dm644 LICENSE target/dist/$(TARBALL_NAME)/LICENSE
install -Dm644 debian/copyright target/dist/$(TARBALL_NAME)/COPYRIGHT
install -Dm644 packaging/tarball/INSTALL.txt target/dist/$(TARBALL_NAME)/INSTALL.txt
install -Dm755 packaging/tarball/install.sh target/dist/$(TARBALL_NAME)/install.sh
tar -C target/dist -czf target/dist/$(TARBALL_NAME).tar.gz $(TARBALL_NAME)
@echo "Built target/dist/$(TARBALL_NAME).tar.gz"
install: build
ifeq ($(HOST_OS),Darwin)
install -d $(DESTDIR)$(PREFIX)/bin
install -m755 target/release/$(BINARY) $(DESTDIR)$(PREFIX)/bin/$(BINARY)
else
install -Dm755 target/release/$(BINARY) $(DESTDIR)$(PREFIX)/bin/$(BINARY)
install -Dm644 $(DESKTOP_FILE) $(DESTDIR)$(PREFIX)/share/applications/$(BINARY).desktop
@if command -v update-desktop-database >/dev/null 2>&1; then \
update-desktop-database $(DESTDIR)$(PREFIX)/share/applications; \
fi
endif
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(BINARY)
ifneq ($(HOST_OS),Darwin)
rm -f $(DESTDIR)$(PREFIX)/share/applications/$(BINARY).desktop
@if command -v update-desktop-database >/dev/null 2>&1; then \
update-desktop-database $(DESTDIR)$(PREFIX)/share/applications; \
fi
endif
clean:
$(CARGO) clean