release.mk 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. # This makefile provides recipes to build a "portable" version of scrcpy for
  2. # Windows.
  3. #
  4. # Here, "portable" means that the client and server binaries are expected to be
  5. # 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. # In particular, this implies to change the location from where the client push
  9. # the server to the device.
  10. .PHONY: default clean \
  11. test \
  12. build-server \
  13. prepare-deps-win32 prepare-deps-win64 \
  14. build-win32 build-win64 \
  15. dist-win32 dist-win64 \
  16. zip-win32 zip-win64 \
  17. release
  18. GRADLE ?= ./gradlew
  19. TEST_BUILD_DIR := build-test
  20. SERVER_BUILD_DIR := build-server
  21. WIN32_BUILD_DIR := build-win32
  22. WIN64_BUILD_DIR := build-win64
  23. VERSION := $(shell git describe --tags --always)
  24. DIST := dist
  25. WIN32_TARGET_DIR := scrcpy-win32-$(VERSION)
  26. WIN64_TARGET_DIR := scrcpy-win64-$(VERSION)
  27. WIN32_TARGET := $(WIN32_TARGET_DIR).zip
  28. WIN64_TARGET := $(WIN64_TARGET_DIR).zip
  29. RELEASE_DIR := release-$(VERSION)
  30. release: clean test build-server zip-win32 zip-win64
  31. mkdir -p "$(RELEASE_DIR)"
  32. cp "$(SERVER_BUILD_DIR)/server/scrcpy-server" \
  33. "$(RELEASE_DIR)/scrcpy-server-$(VERSION)"
  34. cp "$(DIST)/$(WIN32_TARGET)" "$(RELEASE_DIR)"
  35. cp "$(DIST)/$(WIN64_TARGET)" "$(RELEASE_DIR)"
  36. cd "$(RELEASE_DIR)" && \
  37. sha256sum "scrcpy-server-$(VERSION)" \
  38. "scrcpy-win32-$(VERSION).zip" \
  39. "scrcpy-win64-$(VERSION).zip" > SHA256SUMS.txt
  40. @echo "Release generated in $(RELEASE_DIR)/"
  41. clean:
  42. $(GRADLE) clean
  43. rm -rf "$(DIST)" "$(TEST_BUILD_DIR)" "$(SERVER_BUILD_DIR)" \
  44. "$(WIN32_BUILD_DIR)" "$(WIN64_BUILD_DIR)"
  45. test:
  46. [ -d "$(TEST_BUILD_DIR)" ] || ( mkdir "$(TEST_BUILD_DIR)" && \
  47. meson setup "$(TEST_BUILD_DIR)" -Db_sanitize=address )
  48. ninja -C "$(TEST_BUILD_DIR)"
  49. $(GRADLE) -p server check
  50. build-server:
  51. [ -d "$(SERVER_BUILD_DIR)" ] || ( mkdir "$(SERVER_BUILD_DIR)" && \
  52. meson setup "$(SERVER_BUILD_DIR)" --buildtype release -Dcompile_app=false )
  53. ninja -C "$(SERVER_BUILD_DIR)"
  54. prepare-deps-win32:
  55. @app/prebuilt-deps/prepare-adb.sh
  56. @app/prebuilt-deps/prepare-sdl.sh
  57. @app/prebuilt-deps/prepare-ffmpeg-win32.sh
  58. @app/prebuilt-deps/prepare-libusb.sh
  59. prepare-deps-win64:
  60. @app/prebuilt-deps/prepare-adb.sh
  61. @app/prebuilt-deps/prepare-sdl.sh
  62. @app/prebuilt-deps/prepare-ffmpeg-win64.sh
  63. @app/prebuilt-deps/prepare-libusb.sh
  64. build-win32: prepare-deps-win32
  65. [ -d "$(WIN32_BUILD_DIR)" ] || ( mkdir "$(WIN32_BUILD_DIR)" && \
  66. meson setup "$(WIN32_BUILD_DIR)" \
  67. --cross-file cross_win32.txt \
  68. --buildtype release --strip -Db_lto=true \
  69. -Dcompile_server=false \
  70. -Dportable=true )
  71. ninja -C "$(WIN32_BUILD_DIR)"
  72. build-win64: prepare-deps-win64
  73. [ -d "$(WIN64_BUILD_DIR)" ] || ( mkdir "$(WIN64_BUILD_DIR)" && \
  74. meson setup "$(WIN64_BUILD_DIR)" \
  75. --cross-file cross_win64.txt \
  76. --buildtype release --strip -Db_lto=true \
  77. -Dcompile_server=false \
  78. -Dportable=true )
  79. ninja -C "$(WIN64_BUILD_DIR)"
  80. dist-win32: build-server build-win32
  81. mkdir -p "$(DIST)/$(WIN32_TARGET_DIR)"
  82. cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN32_TARGET_DIR)/"
  83. cp "$(WIN32_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
  84. cp app/data/scrcpy-console.bat "$(DIST)/$(WIN32_TARGET_DIR)"
  85. cp app/data/scrcpy-noconsole.vbs "$(DIST)/$(WIN32_TARGET_DIR)"
  86. cp app/data/icon.png "$(DIST)/$(WIN32_TARGET_DIR)"
  87. cp app/data/open_a_terminal_here.bat "$(DIST)/$(WIN32_TARGET_DIR)"
  88. cp app/prebuilt-deps/data/ffmpeg-win32-4.3.1/bin/avutil-56.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
  89. cp app/prebuilt-deps/data/ffmpeg-win32-4.3.1/bin/avcodec-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
  90. cp app/prebuilt-deps/data/ffmpeg-win32-4.3.1/bin/avformat-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
  91. cp app/prebuilt-deps/data/ffmpeg-win32-4.3.1/bin/swresample-3.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
  92. cp app/prebuilt-deps/data/ffmpeg-win32-4.3.1/bin/swscale-5.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
  93. cp app/prebuilt-deps/data/platform-tools-33.0.3/adb.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
  94. cp app/prebuilt-deps/data/platform-tools-33.0.3/AdbWinApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
  95. cp app/prebuilt-deps/data/platform-tools-33.0.3/AdbWinUsbApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
  96. cp app/prebuilt-deps/data/SDL2-2.26.1/i686-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
  97. cp app/prebuilt-deps/data/libusb-1.0.26/MinGW-Win32/msys-usb-1.0.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
  98. dist-win64: build-server build-win64
  99. mkdir -p "$(DIST)/$(WIN64_TARGET_DIR)"
  100. cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN64_TARGET_DIR)/"
  101. cp "$(WIN64_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
  102. cp app/data/scrcpy-console.bat "$(DIST)/$(WIN64_TARGET_DIR)"
  103. cp app/data/scrcpy-noconsole.vbs "$(DIST)/$(WIN64_TARGET_DIR)"
  104. cp app/data/icon.png "$(DIST)/$(WIN64_TARGET_DIR)"
  105. cp app/data/open_a_terminal_here.bat "$(DIST)/$(WIN64_TARGET_DIR)"
  106. cp app/prebuilt-deps/data/ffmpeg-win64-5.1.2/bin/avutil-57.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
  107. cp app/prebuilt-deps/data/ffmpeg-win64-5.1.2/bin/avcodec-59.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
  108. cp app/prebuilt-deps/data/ffmpeg-win64-5.1.2/bin/avformat-59.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
  109. cp app/prebuilt-deps/data/ffmpeg-win64-5.1.2/bin/swresample-4.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
  110. cp app/prebuilt-deps/data/ffmpeg-win64-5.1.2/bin/swscale-6.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
  111. cp app/prebuilt-deps/data/platform-tools-33.0.3/adb.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
  112. cp app/prebuilt-deps/data/platform-tools-33.0.3/AdbWinApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
  113. cp app/prebuilt-deps/data/platform-tools-33.0.3/AdbWinUsbApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
  114. cp app/prebuilt-deps/data/SDL2-2.26.1/x86_64-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
  115. cp app/prebuilt-deps/data/libusb-1.0.26/MinGW-x64/msys-usb-1.0.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
  116. zip-win32: dist-win32
  117. cd "$(DIST)"; \
  118. zip -r "$(WIN32_TARGET)" "$(WIN32_TARGET_DIR)"
  119. zip-win64: dist-win64
  120. cd "$(DIST)"; \
  121. zip -r "$(WIN64_TARGET)" "$(WIN64_TARGET_DIR)"