From e2cfbdcf3f374f539e7901a5781a2ecb99eb601b Mon Sep 17 00:00:00 2001 From: SpaiR Date: Tue, 27 Dec 2022 10:50:09 +0200 Subject: [PATCH] [Build] Change comparison for binary libraries Instead of size we will compare hash of the `imgui-binding/src/main` folder. --- .github/workflows/ci.yml | 29 ++++++++++++++--------------- bin/README.md | 17 +++++++++++++++++ bin/README.txt | 13 ------------- buildSrc/scripts/equal_file_size.py | 8 -------- 4 files changed, 31 insertions(+), 36 deletions(-) create mode 100644 bin/README.md delete mode 100644 bin/README.txt delete mode 100644 buildSrc/scripts/equal_file_size.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce7a183..876cfa4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,11 +2,8 @@ name: CI on: [ push, pull_request ] jobs: build-java: - strategy: - matrix: - os: [ ubuntu-latest, macos-latest ] name: Build Java - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v3 @@ -33,6 +30,7 @@ jobs: imgui-lwjgl3/build/libs/*.jar build-natives: + name: Build Native (${{ matrix.type }}${{ matrix.freetype && ', freetype' || '' }}) strategy: matrix: os: [ ubuntu-latest, macos-latest ] @@ -52,7 +50,6 @@ jobs: type: windows - os: macos-latest type: linux - name: Build Native (${{ matrix.type }}${{ matrix.freetype && ', freetype' || '' }}) runs-on: ${{ matrix.os }} steps: - name: Checkout Repository and Submodules @@ -113,25 +110,27 @@ jobs: with: path: /tmp/artifacts - - name: Equal Artifacts - id: equal-artifacts + # Job compares sha1 hash of the imgui-binding/src/main directory. + # If there are any changes, then we update native libraries. + # We do not rely on git in terms of comparing binaries, + # since DLL files will always have versioning difference. + - name: Compare Binding Hash + id: cmp-binding-hash continue-on-error: true run: | - python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries/imgui-java64.dll bin/imgui-java64.dll - python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries/libimgui-java64.dylib bin/libimgui-java64.dylib - python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries/libimgui-java64.so bin/libimgui-java64.so - python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries-with-freetype/imgui-java64.dll bin/freetype/imgui-java64.dll - python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries-with-freetype/libimgui-java64.dylib bin/freetype/libimgui-java64.dylib - python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries-with-freetype/libimgui-java64.so bin/freetype/libimgui-java64.so + touch bin/binding.sha1 + cat bin/binding.sha1 > /tmp/hash + find imgui-binding/src/main -type f -print0 | xargs -0 sha1sum > bin/binding.sha1 + cmp /tmp/hash bin/binding.sha1 - name: Update - if: steps.equal-artifacts.outcome != 'success' + if: steps.cmp-binding-hash.outcome != 'success' run: | mv /tmp/artifacts/native-libraries/* bin/ mv /tmp/artifacts/native-libraries-with-freetype/* bin/freetype/ - name: Commit - if: steps.equal-artifacts.outcome != 'success' + if: steps.cmp-binding-hash.outcome != 'success' uses: EndBug/add-and-commit@v9 with: default_author: github_actions diff --git a/bin/README.md b/bin/README.md new file mode 100644 index 0000000..4038f32 --- /dev/null +++ b/bin/README.md @@ -0,0 +1,17 @@ +Folder contains libraries used by the binding and `binding.sha1` sum of the `imgui-binding/src/main` directory libraries has been built upon. + +Provide `imgui.library.path` (or `java.library.path`) VM option to the folder with one of those file (ex: `-Dimgui.library.path=./folder/path`). +In the same way you can use 'java.library.path' option instead. + +By default, binding expects `imgui-java64` file name. +You can change that by using `imgui.library.name` VM option (ex: `-Dimgui.library.name=custom-lib-name.dll`). + +| OS | Library | +|---------|-----------------------| +| Windows | imgui-java64.dll | +| Linux | libimgui-java64.so | +| macOS | libimgui-java64.dylib | + +Freetype directory contains same libraries, but with Freetype support. + +Hash sum in the `binding.sha1` file is used in CI to see, if there is a need to update native binaries. diff --git a/bin/README.txt b/bin/README.txt deleted file mode 100644 index c58aab1..0000000 --- a/bin/README.txt +++ /dev/null @@ -1,13 +0,0 @@ -Folder contains libraries used by the binding. - -Provide 'imgui.library.path' VM option to the folder with one of those file (ex: -Dimgui.library.path=./some/folder). -In the same way you can use 'java.library.path' option instead. - -By default binding expects 'imgui-java64' file name. -You can change that by using 'imgui.library.name' VM option (ex: -Dimgui.library.name=custom-lib-name). - -- imgui-java64.dll << Windows -- libimgui-java64.so << Linux -- libimgui-java64.dylib << MacOS - -Freetype folder contains same libraries, but with Freetype support. diff --git a/buildSrc/scripts/equal_file_size.py b/buildSrc/scripts/equal_file_size.py deleted file mode 100644 index 4a4323e..0000000 --- a/buildSrc/scripts/equal_file_size.py +++ /dev/null @@ -1,8 +0,0 @@ -import sys -import os - -# A python script to compare file size of two files. -# Used to compare sizes of binaries to see, if there is a difference between them. -# Shell scripts are not used, since Python is a more portable solution. - -os.path.getsize(sys.argv[1]) == os.path.getsize(sys.argv[2]) if sys.exit(0) else sys.exit(1)