From 45ad9a0168536880ce5244f7b392d9cd46fff4af Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 22 Nov 2024 08:25:15 +0100 Subject: [PATCH] Replace release.mk by release scripts Since commit 2687d202809dfaafe8f40f613aec131ad9501433, the Makefile named release.mk stopped handling dependencies between recipes, because they have to be executed separately (from different Github Actions jobs). There is no real benefit using a Makefile anymore. Replace them by several individual release scripts for simplicity and readability. Refs #5306 --- .github/workflows/release.yml | 46 ++++++----- release.mk | 141 ---------------------------------- release.sh | 2 - release/.gitignore | 2 + release/build_common | 5 ++ release/build_server.sh | 14 ++++ release/build_windows.sh | 51 ++++++++++++ release/generate_checksums.sh | 10 +++ release/package_client.sh | 33 ++++++++ release/package_server.sh | 10 +++ release/release.sh | 22 ++++++ release/test_client.sh | 12 +++ release/test_server.sh | 9 +++ 13 files changed, 193 insertions(+), 164 deletions(-) delete mode 100644 release.mk delete mode 100755 release.sh create mode 100644 release/.gitignore create mode 100644 release/build_common create mode 100755 release/build_server.sh create mode 100755 release/build_windows.sh create mode 100755 release/generate_checksums.sh create mode 100755 release/package_client.sh create mode 100755 release/package_server.sh create mode 100755 release/release.sh create mode 100755 release/test_client.sh create mode 100755 release/test_server.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e67c1c2120..7a589f120b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: build-scrcpy-server: runs-on: ubuntu-latest env: - GRADLE: gradle # use native gradle instead of ./gradlew in release.mk + GRADLE: gradle # use native gradle instead of ./gradlew in scripts steps: - name: Checkout code uses: actions/checkout@v4 @@ -22,16 +22,16 @@ jobs: java-version: '17' - name: Test scrcpy-server - run: make -f release.mk test-server + run: release/test_server.sh - name: Build scrcpy-server - run: make -f release.mk build-server + run: release/build_server.sh - name: Upload scrcpy-server artifact uses: actions/upload-artifact@v4 with: name: scrcpy-server - path: build-server/server/scrcpy-server + path: release/work/build-server/server/scrcpy-server test-client: runs-on: ubuntu-latest @@ -46,13 +46,8 @@ jobs: libsdl2-dev libavcodec-dev libavdevice-dev libavformat-dev \ libavutil-dev libswresample-dev libusb-1.0-0 libusb-1.0-0-dev - - name: Build - run: | - meson setup d -Db_sanitize=address,undefined - - name: Test - run: | - meson test -Cd + run: release/test_client.sh build-win32: runs-on: ubuntu-latest @@ -72,13 +67,13 @@ jobs: run: sed -i 's/^pkg-config/pkgconfig/' cross_win32.txt - name: Build scrcpy win32 - run: make -f release.mk build-win32 + run: release/build_windows.sh 32 - name: Upload build-win32 artifact uses: actions/upload-artifact@v4 with: name: build-win32-intermediate - path: build-win32/dist/ + path: release/work/build-win32/dist/ build-win64: runs-on: ubuntu-latest @@ -98,13 +93,13 @@ jobs: run: sed -i 's/^pkg-config/pkgconfig/' cross_win64.txt - name: Build scrcpy win64 - run: make -f release.mk build-win64 + run: release/build_windows.sh 64 - name: Upload build-win64 artifact uses: actions/upload-artifact@v4 with: name: build-win64-intermediate - path: build-win64/dist/ + path: release/work/build-win64/dist/ package: needs: @@ -113,7 +108,7 @@ jobs: - build-win64 runs-on: ubuntu-latest env: - # $VERSION is used by release.mk + # $VERSION is used by release scripts VERSION: ${{ github.event.inputs.name || github.ref_name }} steps: - name: Checkout code @@ -123,25 +118,34 @@ jobs: uses: actions/download-artifact@v4 with: name: scrcpy-server - path: build-server/server/ + path: release/work/build-server/server/ - name: Download build-win32 uses: actions/download-artifact@v4 with: name: build-win32-intermediate - path: build-win32/dist/ + path: release/work/build-win32/dist/ - name: Download build-win64 uses: actions/download-artifact@v4 with: name: build-win64-intermediate - path: build-win64/dist/ + path: release/work/build-win64/dist/ + + - name: Package server + run: release/package_server.sh + + - name: Package win32 + run: release/package_client.sh win32 + + - name: Package win64 + run: release/package_client.sh win64 - - name: Package - run: make -f release.mk package + - name: Generate checksums + run: release/generate_checksums.sh - name: Upload release artifact uses: actions/upload-artifact@v4 with: name: scrcpy-release-${{ env.VERSION }} - path: release-${{ env.VERSION }} + path: release/output diff --git a/release.mk b/release.mk deleted file mode 100644 index 6114500275..0000000000 --- a/release.mk +++ /dev/null @@ -1,141 +0,0 @@ -# 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 -# locations (e.g. /usr/bin/scrcpy and /usr/share/scrcpy/scrcpy-server). -# -# In particular, this implies to change the location from where the client push -# the server to the device. - -.PHONY: default clean \ - test test-client test-server \ - build-server \ - prepare-deps-win32 prepare-deps-win64 \ - build-win32 build-win64 \ - zip-win32 zip-win64 \ - package release - -GRADLE ?= ./gradlew - -TEST_BUILD_DIR := build-test -SERVER_BUILD_DIR := build-server -WIN32_BUILD_DIR := build-win32 -WIN64_BUILD_DIR := build-win64 - -VERSION ?= $(shell git describe --tags --exclude='*install-release' --always) - -ZIP := zip -WIN32_TARGET_DIR := scrcpy-win32-$(VERSION) -WIN64_TARGET_DIR := scrcpy-win64-$(VERSION) -WIN32_TARGET := $(WIN32_TARGET_DIR).zip -WIN64_TARGET := $(WIN64_TARGET_DIR).zip - -RELEASE_DIR := release-$(VERSION) - -release: clean test build-server build-win32 build-win64 package - -clean: - $(GRADLE) clean - rm -rf "$(ZIP)" "$(TEST_BUILD_DIR)" "$(SERVER_BUILD_DIR)" \ - "$(WIN32_BUILD_DIR)" "$(WIN64_BUILD_DIR)" - -test-client: - [ -d "$(TEST_BUILD_DIR)" ] || ( mkdir "$(TEST_BUILD_DIR)" && \ - meson setup "$(TEST_BUILD_DIR)" -Db_sanitize=address ) - ninja -C "$(TEST_BUILD_DIR)" - -test-server: - $(GRADLE) -p server check - -test: test-client test-server - -build-server: - $(GRADLE) -p server assembleRelease - mkdir -p "$(SERVER_BUILD_DIR)/server" - cp server/build/outputs/apk/release/server-release-unsigned.apk \ - "$(SERVER_BUILD_DIR)/server/scrcpy-server" - -prepare-deps-win32: - @app/deps/adb.sh win32 - @app/deps/sdl.sh win32 - @app/deps/ffmpeg.sh win32 - @app/deps/libusb.sh win32 - -prepare-deps-win64: - @app/deps/adb.sh win64 - @app/deps/sdl.sh win64 - @app/deps/ffmpeg.sh win64 - @app/deps/libusb.sh win64 - -build-win32: prepare-deps-win32 - rm -rf "$(WIN32_BUILD_DIR)" - mkdir -p "$(WIN32_BUILD_DIR)/local" - meson setup "$(WIN32_BUILD_DIR)" \ - --pkg-config-path="app/deps/work/install/win32/lib/pkgconfig" \ - -Dc_args="-I$(PWD)/app/deps/work/install/win32/include" \ - -Dc_link_args="-L$(PWD)/app/deps/work/install/win32/lib" \ - --cross-file=cross_win32.txt \ - --buildtype=release --strip -Db_lto=true \ - -Dcompile_server=false \ - -Dportable=true - ninja -C "$(WIN32_BUILD_DIR)" - # Group intermediate outputs into a 'dist' directory - mkdir -p "$(WIN32_BUILD_DIR)/dist" - cp "$(WIN32_BUILD_DIR)"/app/scrcpy.exe "$(WIN32_BUILD_DIR)/dist/" - cp app/data/scrcpy-console.bat "$(WIN32_BUILD_DIR)/dist/" - cp app/data/scrcpy-noconsole.vbs "$(WIN32_BUILD_DIR)/dist/" - cp app/data/icon.png "$(WIN32_BUILD_DIR)/dist/" - cp app/data/open_a_terminal_here.bat "$(WIN32_BUILD_DIR)/dist/" - cp app/deps/work/install/win32/bin/*.dll "$(WIN32_BUILD_DIR)/dist/" - cp app/deps/work/install/win32/bin/adb.exe "$(WIN32_BUILD_DIR)/dist/" - -build-win64: prepare-deps-win64 - rm -rf "$(WIN64_BUILD_DIR)" - mkdir -p "$(WIN64_BUILD_DIR)/local" - meson setup "$(WIN64_BUILD_DIR)" \ - --pkg-config-path="app/deps/work/install/win64/lib/pkgconfig" \ - -Dc_args="-I$(PWD)/app/deps/work/install/win64/include" \ - -Dc_link_args="-L$(PWD)/app/deps/work/install/win64/lib" \ - --cross-file=cross_win64.txt \ - --buildtype=release --strip -Db_lto=true \ - -Dcompile_server=false \ - -Dportable=true - ninja -C "$(WIN64_BUILD_DIR)" - # Group intermediate outputs into a 'dist' directory - mkdir -p "$(WIN64_BUILD_DIR)/dist" - cp "$(WIN64_BUILD_DIR)"/app/scrcpy.exe "$(WIN64_BUILD_DIR)/dist/" - cp app/data/scrcpy-console.bat "$(WIN64_BUILD_DIR)/dist/" - cp app/data/scrcpy-noconsole.vbs "$(WIN64_BUILD_DIR)/dist/" - cp app/data/icon.png "$(WIN64_BUILD_DIR)/dist/" - cp app/data/open_a_terminal_here.bat "$(WIN64_BUILD_DIR)/dist/" - cp app/deps/work/install/win64/bin/*.dll "$(WIN64_BUILD_DIR)/dist/" - cp app/deps/work/install/win64/bin/adb.exe "$(WIN64_BUILD_DIR)/dist/" - -zip-win32: - mkdir -p "$(ZIP)/$(WIN32_TARGET_DIR)" - cp -r "$(WIN32_BUILD_DIR)/dist/." "$(ZIP)/$(WIN32_TARGET_DIR)/" - cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(ZIP)/$(WIN32_TARGET_DIR)/" - cd "$(ZIP)"; \ - zip -r "$(WIN32_TARGET)" "$(WIN32_TARGET_DIR)" - rm -rf "$(ZIP)/$(WIN32_TARGET_DIR)" - -zip-win64: - mkdir -p "$(ZIP)/$(WIN64_TARGET_DIR)" - cp -r "$(WIN64_BUILD_DIR)/dist/." "$(ZIP)/$(WIN64_TARGET_DIR)/" - cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(ZIP)/$(WIN64_TARGET_DIR)/" - cd "$(ZIP)"; \ - zip -r "$(WIN64_TARGET)" "$(WIN64_TARGET_DIR)" - rm -rf "$(ZIP)/$(WIN64_TARGET_DIR)" - -package: zip-win32 zip-win64 - mkdir -p "$(RELEASE_DIR)" - cp "$(SERVER_BUILD_DIR)/server/scrcpy-server" \ - "$(RELEASE_DIR)/scrcpy-server-$(VERSION)" - cp "$(ZIP)/$(WIN32_TARGET)" "$(RELEASE_DIR)" - cp "$(ZIP)/$(WIN64_TARGET)" "$(RELEASE_DIR)" - cd "$(RELEASE_DIR)" && \ - sha256sum "scrcpy-server-$(VERSION)" \ - "scrcpy-win32-$(VERSION).zip" \ - "scrcpy-win64-$(VERSION).zip" > SHA256SUMS.txt - @echo "Release generated in $(RELEASE_DIR)/" diff --git a/release.sh b/release.sh deleted file mode 100755 index 51ce2e3867..0000000000 --- a/release.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -make -f release.mk diff --git a/release/.gitignore b/release/.gitignore new file mode 100644 index 0000000000..ed363cdfb1 --- /dev/null +++ b/release/.gitignore @@ -0,0 +1,2 @@ +/work +/output diff --git a/release/build_common b/release/build_common new file mode 100644 index 0000000000..199a80b600 --- /dev/null +++ b/release/build_common @@ -0,0 +1,5 @@ +# This file must be sourced from the release scripts directory +WORK_DIR="$PWD/work" +OUTPUT_DIR="$PWD/output" + +VERSION="${VERSION:-$(git describe --tags --always)}" diff --git a/release/build_server.sh b/release/build_server.sh new file mode 100755 index 0000000000..f52672de33 --- /dev/null +++ b/release/build_server.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -ex +cd "$(dirname ${BASH_SOURCE[0]})" +. build_common +cd .. # root project dir + +GRADLE="${GRADLE:-./gradlew}" +SERVER_BUILD_DIR="$WORK_DIR/build-server" + +rm -rf "$SERVER_BUILD_DIR" +"$GRADLE" -p server assembleRelease +mkdir -p "$SERVER_BUILD_DIR/server" +cp server/build/outputs/apk/release/server-release-unsigned.apk \ + "$SERVER_BUILD_DIR/server/scrcpy-server" diff --git a/release/build_windows.sh b/release/build_windows.sh new file mode 100755 index 0000000000..74bd32fceb --- /dev/null +++ b/release/build_windows.sh @@ -0,0 +1,51 @@ +#!/bin/bash +set -ex + +case "$1" in + 32) + WINXX=win32 + ;; + 64) + WINXX=win64 + ;; + *) + echo "ERROR: $0 must be called with one argument: 32 or 64" >&2 + exit 1 + ;; +esac + +cd "$(dirname ${BASH_SOURCE[0]})" +. build_common +cd .. # root project dir + +WINXX_BUILD_DIR="$WORK_DIR/build-$WINXX" + +app/deps/adb.sh $WINXX +app/deps/sdl.sh $WINXX +app/deps/ffmpeg.sh $WINXX +app/deps/libusb.sh $WINXX + +DEPS_INSTALL_DIR="$PWD/app/deps/work/install/$WINXX" + +rm -rf "$WINXX_BUILD_DIR" +meson setup "$WINXX_BUILD_DIR" \ + --pkg-config-path="$DEPS_INSTALL_DIR/lib/pkgconfig" \ + -Dc_args="-I$DEPS_INSTALL_DIR/include" \ + -Dc_link_args="-L$DEPS_INSTALL_DIR/lib" \ + --cross-file=cross_$WINXX.txt \ + --buildtype=release \ + --strip \ + -Db_lto=true \ + -Dcompile_server=false \ + -Dportable=true +ninja -C "$WINXX_BUILD_DIR" + +# Group intermediate outputs into a 'dist' directory +mkdir -p "$WINXX_BUILD_DIR/dist" +cp "$WINXX_BUILD_DIR"/app/scrcpy.exe "$WINXX_BUILD_DIR/dist/" +cp app/data/scrcpy-console.bat "$WINXX_BUILD_DIR/dist/" +cp app/data/scrcpy-noconsole.vbs "$WINXX_BUILD_DIR/dist/" +cp app/data/icon.png "$WINXX_BUILD_DIR/dist/" +cp app/data/open_a_terminal_here.bat "$WINXX_BUILD_DIR/dist/" +cp "$DEPS_INSTALL_DIR"/bin/*.dll "$WINXX_BUILD_DIR/dist/" +cp "$DEPS_INSTALL_DIR"/bin/adb.exe "$WINXX_BUILD_DIR/dist/" diff --git a/release/generate_checksums.sh b/release/generate_checksums.sh new file mode 100755 index 0000000000..ccb1ba1c00 --- /dev/null +++ b/release/generate_checksums.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -ex +cd "$(dirname ${BASH_SOURCE[0]})" +. build_common + +cd "$OUTPUT_DIR" +sha256sum "scrcpy-server-$VERSION" \ + "scrcpy-win32-$VERSION.zip" \ + "scrcpy-win64-$VERSION.zip" | tee SHA256SUMS.txt +echo "Release checksums generated in $PWD/SHA256SUMS.txt" diff --git a/release/package_client.sh b/release/package_client.sh new file mode 100755 index 0000000000..bbc7c6dbe2 --- /dev/null +++ b/release/package_client.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -ex +cd "$(dirname ${BASH_SOURCE[0]})" +. build_common +cd .. # root project dir + +if [[ $# != 1 ]] +then + # : for example win64 + echo "Syntax: $0 " >&2 + exit 1 + +fi + +BUILD_DIR="$WORK_DIR/build-$1" +ZIP_DIR="$BUILD_DIR/zip" +TARGET="scrcpy-$1-$VERSION" + +rm -rf "$ZIP_DIR/$TARGET" +mkdir -p "$ZIP_DIR/$TARGET" + +cp -r "$BUILD_DIR/dist/." "$ZIP_DIR/$TARGET/" +cp "$WORK_DIR/build-server/server/scrcpy-server" "$ZIP_DIR/$TARGET/" + +mkdir -p "$OUTPUT_DIR" +rm -f "$OUTPUT_DIR/$TARGET.zip" + +cd "$ZIP_DIR" +rm -f "$OUTPUT_DIR/$TARGET.zip" +zip -r "$OUTPUT_DIR/$TARGET.zip" "$TARGET" +rm -rf "$TARGET" +cd - +echo "Generated '$OUTPUT_DIR/$TARGET.zip'" diff --git a/release/package_server.sh b/release/package_server.sh new file mode 100755 index 0000000000..a856cebb3f --- /dev/null +++ b/release/package_server.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -ex +cd "$(dirname ${BASH_SOURCE[0]})" +OUTPUT_DIR="$PWD/output" +. build_common +cd .. # root project dir + +mkdir -p "$OUTPUT_DIR" +cp "$WORK_DIR/build-server/server/scrcpy-server" "$OUTPUT_DIR/scrcpy-server-$VERSION" +echo "Generated '$OUTPUT_DIR/scrcpy-server-$VERSION'" diff --git a/release/release.sh b/release/release.sh new file mode 100755 index 0000000000..0760089f62 --- /dev/null +++ b/release/release.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# To customize the version name: +# VERSION=myversion ./release.sh +set -e + +cd "$(dirname ${BASH_SOURCE[0]})" +rm -rf output + +./test_server.sh +./test_client.sh + +./build_server.sh +./build_windows.sh 32 +./build_windows.sh 64 + +./package_server.sh +./package_client.sh win32 +./package_client.sh win64 + +./generate_checksums.sh + +echo "Release generated in $PWD/output" diff --git a/release/test_client.sh b/release/test_client.sh new file mode 100755 index 0000000000..6059541d0c --- /dev/null +++ b/release/test_client.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -ex +cd "$(dirname ${BASH_SOURCE[0]})" +. build_common +cd .. # root project dir + +TEST_BUILD_DIR="$WORK_DIR/build-test" + +rm -rf "$TEST_BUILD_DIR" +meson setup "$TEST_BUILD_DIR" -Dcompile_server=false \ + -Db_sanitize=address,undefined +ninja -C "$TEST_BUILD_DIR" test diff --git a/release/test_server.sh b/release/test_server.sh new file mode 100755 index 0000000000..940e8c1a97 --- /dev/null +++ b/release/test_server.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -ex +cd "$(dirname ${BASH_SOURCE[0]})" +. build_common +cd .. # root project dir + +GRADLE="${GRADLE:-./gradlew}" + +"$GRADLE" -p server check