Makefile.CrossWindows 4.5 KB
Newer Older
1 2 3 4 5
# This makefile provides recipes to build a "portable" version of scrcpy for
# Windows.
#
# Here, "portable" means that the client and server binaries are expected to be
# anywhere, but in the same directory, instead of well-defined separate
6
# locations (e.g. /usr/bin/scrcpy and /usr/share/scrcpy/scrcpy-server).
7 8 9 10 11 12 13
#
# In particular, this implies to change the location from where the client push
# the server to the device.

.PHONY: default clean \
	build-server \
	prepare-deps-win32 prepare-deps-win64 \
14
	build-win32 build-win64 \
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
	dist-win32 dist-win64 \
	zip-win32 zip-win64 \
	sums release

GRADLE ?= ./gradlew

SERVER_BUILD_DIR := build-server
WIN32_BUILD_DIR := build-win32
WIN64_BUILD_DIR := build-win64

DIST := dist
WIN32_TARGET_DIR := scrcpy-win32
WIN64_TARGET_DIR := scrcpy-win64

VERSION := $(shell git describe --tags --always)
WIN32_TARGET := $(WIN32_TARGET_DIR)-$(VERSION).zip
WIN64_TARGET := $(WIN64_TARGET_DIR)-$(VERSION).zip

release: clean zip-win32 zip-win64 sums
R
Romain Vimont 已提交
34
	@echo "Windows archives generated in $(DIST)/"
35 36 37

clean:
	$(GRADLE) clean
38
	rm -rf "$(SERVER_BUILD_DIR)" "$(WIN32_BUILD_DIR)" "$(WIN64_BUILD_DIR)" \
39
		   "$(DIST)"
40 41 42 43

build-server:
	[ -d "$(SERVER_BUILD_DIR)" ] || ( mkdir "$(SERVER_BUILD_DIR)" && \
		meson "$(SERVER_BUILD_DIR)" \
R
Romain Vimont 已提交
44
			--buildtype release -Dcompile_app=false )
45 46 47 48 49 50 51 52 53 54
		ninja -C "$(SERVER_BUILD_DIR)"

prepare-deps-win32:
	-$(MAKE) -C prebuilt-deps prepare-win32

build-win32: prepare-deps-win32
	[ -d "$(WIN32_BUILD_DIR)" ] || ( mkdir "$(WIN32_BUILD_DIR)" && \
		meson "$(WIN32_BUILD_DIR)" \
			--cross-file cross_win32.txt \
			--buildtype release --strip -Db_lto=true \
55
			-Dcrossbuild_windows=true \
R
Romain Vimont 已提交
56
			-Dcompile_server=false \
57
			-Dportable=true )
58 59 60 61 62 63 64 65 66 67
	ninja -C "$(WIN32_BUILD_DIR)"

prepare-deps-win64:
	-$(MAKE) -C prebuilt-deps prepare-win64

build-win64: prepare-deps-win64
	[ -d "$(WIN64_BUILD_DIR)" ] || ( mkdir "$(WIN64_BUILD_DIR)" && \
		meson "$(WIN64_BUILD_DIR)" \
			--cross-file cross_win64.txt \
			--buildtype release --strip -Db_lto=true \
68
			-Dcrossbuild_windows=true \
R
Romain Vimont 已提交
69
			-Dcompile_server=false \
70
			-Dportable=true )
71 72
	ninja -C "$(WIN64_BUILD_DIR)"

73
dist-win32: build-server build-win32
74
	mkdir -p "$(DIST)/$(WIN32_TARGET_DIR)"
75
	cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN32_TARGET_DIR)/"
76
	cp "$(WIN32_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
77
	cp data/scrcpy-console.bat "$(DIST)/$(WIN32_TARGET_DIR)"
78
	cp data/scrcpy-noconsole.vbs "$(DIST)/$(WIN32_TARGET_DIR)"
79 80 81 82 83
	cp prebuilt-deps/ffmpeg-4.3.1-win32-shared/bin/avutil-56.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
	cp prebuilt-deps/ffmpeg-4.3.1-win32-shared/bin/avcodec-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
	cp prebuilt-deps/ffmpeg-4.3.1-win32-shared/bin/avformat-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
	cp prebuilt-deps/ffmpeg-4.3.1-win32-shared/bin/swresample-3.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
	cp prebuilt-deps/ffmpeg-4.3.1-win32-shared/bin/swscale-5.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
84 85 86
	cp prebuilt-deps/platform-tools/adb.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
	cp prebuilt-deps/platform-tools/AdbWinApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
	cp prebuilt-deps/platform-tools/AdbWinUsbApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
R
Romain Vimont 已提交
87
	cp prebuilt-deps/SDL2-2.0.12/i686-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
88

89
dist-win64: build-server build-win64
90
	mkdir -p "$(DIST)/$(WIN64_TARGET_DIR)"
91
	cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN64_TARGET_DIR)/"
92
	cp "$(WIN64_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
93
	cp data/scrcpy-console.bat "$(DIST)/$(WIN64_TARGET_DIR)"
94
	cp data/scrcpy-noconsole.vbs "$(DIST)/$(WIN64_TARGET_DIR)"
95 96 97 98 99
	cp prebuilt-deps/ffmpeg-4.3.1-win64-shared/bin/avutil-56.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
	cp prebuilt-deps/ffmpeg-4.3.1-win64-shared/bin/avcodec-58.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
	cp prebuilt-deps/ffmpeg-4.3.1-win64-shared/bin/avformat-58.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
	cp prebuilt-deps/ffmpeg-4.3.1-win64-shared/bin/swresample-3.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
	cp prebuilt-deps/ffmpeg-4.3.1-win64-shared/bin/swscale-5.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
100 101 102
	cp prebuilt-deps/platform-tools/adb.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
	cp prebuilt-deps/platform-tools/AdbWinApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
	cp prebuilt-deps/platform-tools/AdbWinUsbApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
R
Romain Vimont 已提交
103
	cp prebuilt-deps/SDL2-2.0.12/x86_64-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
104 105

zip-win32: dist-win32
106 107
	cd "$(DIST)/$(WIN32_TARGET_DIR)"; \
		zip -r "../$(WIN32_TARGET)" .
108 109

zip-win64: dist-win64
110 111
	cd "$(DIST)/$(WIN64_TARGET_DIR)"; \
		zip -r "../$(WIN64_TARGET)" .
112 113 114

sums:
	cd "$(DIST)"; \
R
Romain Vimont 已提交
115
		sha256sum *.zip > SHA256SUMS.txt