From b257abac7d26538ca47f328f2488963405fa17a5 Mon Sep 17 00:00:00 2001 From: Abhinay Agarwal Date: Mon, 2 Sep 2024 23:18:13 +0530 Subject: [PATCH] Add release for supported platforms (#2) --- .github/workflows/release.yml | 179 +++++++++++++++++++++++++++++++++- .gitignore | 3 + Makefile | 38 ++++++-- 3 files changed, 209 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f27b08f..317e643 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,6 +28,7 @@ jobs: name: vmone-android-linux-aarch64 path: lib/android/staticjdk/lib/ retention-days: 1 + build-ios: runs-on: macos-14 steps: @@ -50,8 +51,132 @@ jobs: name: vmone-ios-macos-aarch64 path: lib/ios/staticjdk/lib/ retention-days: 1 + + build-linux-x64: + runs-on: ubuntu-22.04 + steps: + - name: 'Checkout the JDK source' + uses: actions/checkout@v4 + - name: 'Download libjdk.a' + uses: robinraju/release-downloader@v1 + with: + repository: 'gluonhq/mobile' + latest: true + fileName: 'linux-x64.zip' + - name: 'Build' + run: | + unzip linux-x64.zip -d /tmp/ + mv /tmp/linux-x64/libjdk.a /tmp/ + make clean all + - name: 'Upload static image artifact' + uses: actions/upload-artifact@v4 + with: + name: vmone-linux-x64 + path: lib/linux/staticjdk/lib/ + retention-days: 1 + + build-macos-x64: + runs-on: macos-14 + steps: + - name: 'Checkout the JDK source' + uses: actions/checkout@v4 + - name: 'Download libjdk.a' + uses: robinraju/release-downloader@v1 + with: + repository: 'gluonhq/mobile' + latest: true + fileName: 'macos-x64.zip' + - name: 'Build' + run: | + unzip macos-x64.zip -d /tmp/ + mv /tmp/macos-x64/libjdk.a /tmp/ + make clean all + - name: 'Upload static image artifact' + uses: actions/upload-artifact@v4 + with: + name: vmone-macos-x64 + path: lib/macosx/staticjdk/lib/ + retention-days: 1 + + build-macos-aarch64: + runs-on: macos-14 + steps: + - name: 'Checkout the JDK source' + uses: actions/checkout@v4 + - name: 'Download libjdk.a' + uses: robinraju/release-downloader@v1 + with: + repository: 'gluonhq/mobile' + latest: true + fileName: 'macos-aarch64.zip' + - name: 'Build' + run: | + unzip macos-aarch64.zip -d /tmp/ + mv /tmp/macos-aarch64/libjdk.a /tmp/ + make clean all + - name: 'Upload static image artifact' + uses: actions/upload-artifact@v4 + with: + name: vmone-macos-aarch64 + path: lib/macosx/staticjdk/lib/ + retention-days: 1 + + build-windows-x64: + runs-on: windows-latest + steps: + - name: 'Checkout the JDK source' + uses: actions/checkout@v4 + - name: 'Download libjdk.lib' + uses: robinraju/release-downloader@v1 + with: + repository: 'gluonhq/mobile' + latest: true + fileName: 'windows-x64.zip' + - name: 'Build' + run: | + powershell -Command "Expand-Archive -Path windows-x64.zip -DestinationPath C:\temp\" + powershell -Command "Move-Item -Path C:\temp\windows-x64\libjdk.lib -Destination C:\temp\" + cd C:\temp + make clean all + - name: 'Upload static image artifact' + uses: actions/upload-artifact@v4 + with: + name: vmone-windows-x64 + path: C:\temp\lib\windows\x64\staticjdk\lib\ + retention-days: 1 + + build-windows-aarch64: + runs-on: windows-latest + steps: + - name: 'Checkout the JDK source' + uses: actions/checkout@v4 + - name: 'Download libjdk.lib' + uses: robinraju/release-downloader@v1 + with: + repository: 'gluonhq/mobile' + latest: true + fileName: 'windows-aarch64.zip' + - name: 'Build' + run: | + powershell -Command "Expand-Archive -Path windows-aarch64.zip -DestinationPath C:\temp\" + powershell -Command "Move-Item -Path C:\temp\windows-aarch64\libjdk.lib -Destination C:\temp\" + cd C:\temp + make clean all + - name: 'Upload static image artifact' + uses: actions/upload-artifact@v4 + with: + name: vmone-windows-aarch64 + path: C:\temp\lib\windows\aarch64\staticjdk\lib\ + retention-days: 1 + release: - needs: [ build-android, build-ios ] + needs: [ + build-android, build-ios, + build-linux-x64, + # build-macos-x64, + build-macos-aarch64, + # build-windows-x64, build-windows-aarch64 + ] runs-on: ubuntu-22.04 steps: - name: Download android artifacts @@ -59,21 +184,67 @@ jobs: with: name: vmone-android-linux-aarch64 path: ./dist/android-linux-aarch64/lib/ + - name: Download ios artifacts uses: actions/download-artifact@v4 with: name: vmone-ios-macos-aarch64 path: ./dist/ios-macos-aarch64/lib/ - - name: Zip downloaded artifact + + - name: Download linux x64 artifacts + uses: actions/download-artifact@v4 + with: + name: vmone-linux-x64 + path: ./dist/linux-x64/lib/ + + - name: Download macos x64 artifacts + uses: actions/download-artifact@v4 + with: + name: vmone-macos-x64 + path: ./dist/macos-x64/lib/ + if: false + + - name: Download macos aarch64 artifacts + uses: actions/download-artifact@v4 + with: + name: vmone-macos-aarch64 + path: ./dist/macos-aarch64/lib/ + + - name: Download windows x64 artifacts + uses: actions/download-artifact@v4 + with: + name: vmone-windows-x64 + path: ./dist/windows-x64/lib/ + if: false + + - name: Download windows aarch64 artifacts + uses: actions/download-artifact@v4 + with: + name: vmone-windows-aarch64 + path: ./dist/windows-aarch64/lib/ + if: false + + - name: Zip downloaded artifacts run: | cd $GITHUB_WORKSPACE/dist/android-linux-aarch64/ zip -r ../vmone-android-linux-aarch64.zip lib/ cd $GITHUB_WORKSPACE/dist/ios-macos-aarch64/ zip -r ../vmone-ios-macos-aarch64.zip lib/ - - name: Check downloads + cd $GITHUB_WORKSPACE/dist/linux-x64/ + zip -r ../vmone-linux-x64.zip lib/ + # cd $GITHUB_WORKSPACE/dist/macos-x64/ + # zip -r ../vmone-macos-x64.zip lib/ + cd $GITHUB_WORKSPACE/dist/macos-aarch64/ + zip -r ../vmone-macos-aarch64.zip lib/ + # cd $GITHUB_WORKSPACE/dist/windows-x64/ + # zip -r ../vmone-windows-x64.zip lib/ + # cd $GITHUB_WORKSPACE/dist/windows-aarch64/ + # zip -r ../vmone-windows-aarch64.zip lib/ + + - name: Check zip files run: | - pwd ls -R ./dist/ + - name: Release uses: softprops/action-gh-release@v2 with: diff --git a/.gitignore b/.gitignore index 1224622..6896b53 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ lib/ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* replay_pid* + +# Mac +.DS_Store diff --git a/Makefile b/Makefile index dcfeb25..39e07e1 100644 --- a/Makefile +++ b/Makefile @@ -16,8 +16,10 @@ else ifeq ($(shell uname), Darwin) OS := macosx CC = gcc CFLAGS = -DDARWIN $(INCLUDE_FLAGS) -else - OS := Unknown +else ifeq ($(shell uname), MINGW32_NT) + OS := windows + CC = gcc + CFLAGS = -DWIN32 -I$(JAVA)/include -I$(JAVA)/include/win32 endif ifeq ($(TARGET), ios) @@ -37,7 +39,7 @@ else ifeq ($(TARGET), android) CC = $(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/linux-x86_64/bin/clang CFLAGS = -target aarch64-linux-android \ -DANDROID -else +else endif @@ -68,22 +70,44 @@ OBJS = $(OBJS_C) $(OBJS_M) JDKLIB = /tmp/libjdk.a TEMP_DIR = /tmp/extractdir -LIB = $(LIBDIR)/$(OS)/staticjdk/lib/libvmone.a +ifeq ($(OS), windows) + JDKLIB := C:/path/to/libjdk.lib + LIB = $(LIBDIR)/windows/staticjdk/lib/libvmone.lib + AR = lib + ARFLAGS = /OUT: +else + LIB = $(LIBDIR)/$(OS)/staticjdk/lib/libvmone.a + AR = ar + ARFLAGS = rcs +endif all: $(LIB) $(LIB): $(OBJS) @mkdir -p $(LIBDIR)/$(OS)/staticjdk/lib +ifeq ($(OS), windows) + if [ -s $(JDKLIB) ]; then \ + echo "Including $(JDKLIB) in lib"; \ + TMPDIR=$(LIBDIR)/$(OS)/temp_objs; \ + mkdir -p $$TMPDIR; \ + (cd $$TMPDIR && $(AR) x $(JDKLIB)); \ + $(AR) $(ARFLAGS) $@ $$TMPDIR/*.o $^; \ + else \ + echo "Existing library not found. Creating static library with object files only."; \ + $(AR) $(ARFLAGS) $@ $^; \ + fi +else if [ -s $(JDKLIB) ]; then \ echo "Including $(JDKLIB) in lib"; \ TMPDIR=$(LIBDIR)/$(OS)/temp_objs; \ mkdir -p $$TMPDIR; \ (cd $$TMPDIR && ar x $(JDKLIB)); \ - ar rcs $@ $$TMPDIR/*.o $^; \ + ar $(ARFLAGS) $@ $$TMPDIR/*.o $^; \ else \ echo "Existing library not found. Creating static library with object files only."; \ - ar rcs $@ $^; \ + ar $(ARFLAGS) $@ $^; \ fi +endif debug: @echo "OS: $(OS)" @@ -106,4 +130,4 @@ $(OBJDIR)/$(OS)/%.o: $(SRCDIR)/darwin/%.m #$(CC) $(CFLAGS) -c $< -o $@ clean: - rm -rf $(OBJDIR) $(LIBDIR) + rm -rf $(OBJDIR) $(LIBDIR)