diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 9807772..e774b56 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,80 +1,98 @@ name: CI + on: push: - branches: [ master ] + branches: [master] pull_request: schedule: - - cron: '30 13 * * 5' + - cron: "30 13 * * 5" + +permissions: + contents: read + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: - build-linux-amd64: - runs-on: ubuntu-latest + build-linux: + strategy: + fail-fast: false + matrix: + include: + - arch: amd64 + runner: ubuntu-latest + make_target: Linux_x86_64 + - arch: arm64 + runner: ubuntu-24.04-arm + make_target: Linux_aarch64 + runs-on: ${{ matrix.runner }} + env: + IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }} + timeout-minutes: 30 + permissions: + contents: read + pull-requests: write steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - id: time - run: | - time=nightly-$(date +'%Y/%m/%d') - echo "time=${time}" >> $GITHUB_OUTPUT - - uses: actions/checkout@v4 - - run: make + - run: make "${{ matrix.make_target }}" - name: Package tar.xz archive - run: tar -cf - -C ${GITHUB_WORKSPACE}/linux $(ls -A ${GITHUB_WORKSPACE}"/linux") | xz -c > PathOfBuilding.linux.amd64.tar.xz + run: tar -C "${GITHUB_WORKSPACE}/linux" -cJf "PathOfBuilding.linux.${{ matrix.arch }}.tar.xz" . - - name: Cheking GUI + - name: Checking GUI + if: github.event_name == 'pull_request' && env.IMGUR_CLIENT_ID != '' env: IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }} - GIT_TOKEN: ${{ secrets.GIT_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} DISPLAY: :10 - if: github.ref != 'refs/heads/master' run: | - pushd ${GITHUB_WORKSPACE}/linux - Xvfb :10 -screen 0 1024x768x24 & - sleep 15 - ./PathOfBuilding & - sleep 10 - xwd -root -silent -display :10 | convert xwd:- png:/tmp/sl.png - export IMG_URL=`curl -L -X POST https://api.imgur.com/3/image -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}" -F image=@/tmp/sl.png | jq '.data | .link' | tr -d '"'` - pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") - curl -X POST -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token ${GIT_TOKEN}" \ - https://api.github.com/repos/aspel/pobfrontend/issues/${pull_number}/comments \ - -d "{\"body\":\"![Screenshot Linux](${IMG_URL})\n${GITHUB_SHA} : Linux amd64\"}" - popd - echo $IMG_URL - - - run: tar -tvf PathOfBuilding.linux.amd64.tar.xz - - - name: Update release tag + set -euo pipefail + pushd "${GITHUB_WORKSPACE}/linux" + Xvfb :10 -screen 0 1024x768x24 & + sleep 15 + ./PathOfBuilding & + sleep 10 + xwd -root -silent -display :10 | convert xwd:- png:/tmp/sl.png + IMG_URL=$(curl -sS -L -X POST https://api.imgur.com/3/image \ + -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}" \ + -F image=@/tmp/sl.png | jq -r '.data.link') + curl -sS -X POST \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + "https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${{ github.event.pull_request.number }}/comments" \ + -d "{\"body\":\"![Screenshot Linux](${IMG_URL})\n${GITHUB_SHA} : Linux ${{ matrix.arch }}\"}" + popd + echo "${IMG_URL}" + + - run: tar -tvf "PathOfBuilding.linux.${{ matrix.arch }}.tar.xz" + + - name: Upload Linux artifact if: github.ref == 'refs/heads/master' - run: | - git config --local user.name "${GITHUB_ACTOR}" - git config --local user.email "aspellip@gmail.com" - git tag -f PathOfBuilding - git remote add gh https://$GITHUB_ACTOR:$GIT_TOKEN@github.com/$GITHUB_REPOSITORY.git - git push -f gh PathOfBuilding - git remote remove gh - - - name: Upload Linux artifacts into Github - if: github.ref == 'refs/heads/master' - uses: ncipollo/release-action@v1 + uses: actions/upload-artifact@v4 with: - artifacts: "PathOfBuilding.linux.amd64.tar.xz" - token: ${{ secrets.GITHUB_TOKEN }} - allowUpdates: true - tag: PathOfBuilding - body: "${{steps.time.outputs.time}}" - - build-macos-amd64: - runs-on: macos-13 + name: linux-${{ matrix.arch }}-dist + path: PathOfBuilding.linux.${{ matrix.arch }}.tar.xz + if-no-files-found: error + + build-macos: + strategy: + fail-fast: false + matrix: + include: + - arch: amd64 + runner: macos-15-intel + - arch: arm64 + runner: macos-15 + runs-on: ${{ matrix.runner }} + env: + IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }} + timeout-minutes: 40 + permissions: + contents: read + pull-requests: write steps: - - id: time - run: | - time=nightly-$(date +'%Y/%m/%d') - echo "time=${time}" >> $GITHUB_OUTPUT - - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v4 - run: brew install make @@ -83,86 +101,85 @@ jobs: - name: Package tar.xz archive run: | + set -euo pipefail rm -rf PathOfBuilding.app/Contents/MacOS/spec codesign --force --deep --sign - PathOfBuilding.app - tar -cf - PathOfBuilding.app | xz -c > PathOfBuilding.darwin.amd64.tar.xz + tar -cJf "PathOfBuilding.darwin.${{ matrix.arch }}.tar.xz" PathOfBuilding.app - - name: Cheking GUI + - name: Checking GUI + if: github.event_name == 'pull_request' && env.IMGUR_CLIENT_ID != '' env: IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }} - GIT_TOKEN: ${{ secrets.GIT_TOKEN }} - if: github.ref != 'refs/heads/master' + GITHUB_TOKEN: ${{ github.token }} run: | - ./PathOfBuilding.app/Contents/MacOS/pobWrapper.sh & - sleep 15 - screencapture /tmp/sl.png - export IMG_URL=`curl -L -X POST https://api.imgur.com/3/image -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}" -F image=@/tmp/sl.png | jq '.data | .link' | tr -d '"'` - pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") - curl -X POST -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token ${GIT_TOKEN}" \ - https://api.github.com/repos/aspel/pobfrontend/issues/${pull_number}/comments \ - -d "{\"body\":\"![Screenshot MacOS](${IMG_URL})\n${GITHUB_SHA} : MacOS amd64\"}" - echo $IMG_URL - - - run: tar -tvf PathOfBuilding.darwin.amd64.tar.xz - - - name: Upload MacOS artifacts into Github + set -euo pipefail + ./PathOfBuilding.app/Contents/MacOS/pobWrapper.sh & + sleep 15 + screencapture /tmp/sl.png + IMG_URL=$(curl -sS -L -X POST https://api.imgur.com/3/image \ + -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}" \ + -F image=@/tmp/sl.png | jq -r '.data.link') + curl -sS -X POST \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + "https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${{ github.event.pull_request.number }}/comments" \ + -d "{\"body\":\"![Screenshot MacOS](${IMG_URL})\n${GITHUB_SHA} : MacOS ${{ matrix.arch }}\"}" + echo "${IMG_URL}" + + - run: tar -tvf "PathOfBuilding.darwin.${{ matrix.arch }}.tar.xz" + + - name: Upload MacOS artifact if: github.ref == 'refs/heads/master' - uses: ncipollo/release-action@v1 + uses: actions/upload-artifact@v4 with: - artifacts: "PathOfBuilding.darwin.amd64.tar.xz" - token: ${{ secrets.GITHUB_TOKEN }} - allowUpdates: true - tag: PathOfBuilding - body: "${{steps.time.outputs.time}}" - - build-macos-arm64: - runs-on: macos-latest + name: macos-${{ matrix.arch }}-dist + path: PathOfBuilding.darwin.${{ matrix.arch }}.tar.xz + if-no-files-found: error + + release: + if: github.ref == 'refs/heads/master' + needs: + - build-linux + - build-macos + runs-on: ubuntu-latest + timeout-minutes: 20 + permissions: + contents: write steps: - id: time run: | time=nightly-$(date +'%Y/%m/%d') - echo "time=${time}" >> $GITHUB_OUTPUT - - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + echo "time=${time}" >> "$GITHUB_OUTPUT" + - uses: actions/checkout@v4 - - - run: brew install make - - - run: make + with: + fetch-depth: 0 - - name: Package tar.xz archive - run: | - rm -rf PathOfBuilding.app/Contents/MacOS/spec - codesign --force --deep --sign - PathOfBuilding.app - tar -cf - PathOfBuilding.app | xz -c > PathOfBuilding.darwin.arm64.tar.xz + - uses: actions/download-artifact@v4 + with: + pattern: "*-dist" + merge-multiple: true + + - name: Show release artifacts + run: ls -lh *.tar.xz - - name: Cheking GUI + - name: Update release tag env: - IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }} - GIT_TOKEN: ${{ secrets.GIT_TOKEN }} - if: github.ref != 'refs/heads/master' + GITHUB_TOKEN: ${{ github.token }} run: | - ./PathOfBuilding.app/Contents/MacOS/pobWrapper.sh & - sleep 15 - screencapture /tmp/sl.png - export IMG_URL=`curl -L -X POST https://api.imgur.com/3/image -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}" -F image=@/tmp/sl.png | jq '.data | .link' | tr -d '"'` - pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") - curl -X POST -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token ${GIT_TOKEN}" \ - https://api.github.com/repos/aspel/pobfrontend/issues/${pull_number}/comments \ - -d "{\"body\":\"![Screenshot MacOS](${IMG_URL})\n${GITHUB_SHA} : MacOS arm64\"}" - echo $IMG_URL - - - run: tar -tvf PathOfBuilding.darwin.arm64.tar.xz - - - name: Upload MacOS artifacts into Github - if: github.ref == 'refs/heads/master' + set -euo pipefail + git config --local user.name "${GITHUB_ACTOR}" + git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git tag -f PathOfBuilding "${GITHUB_SHA}" + git push --force origin refs/tags/PathOfBuilding + + - name: Upload release artifacts uses: ncipollo/release-action@v1 with: - artifacts: "PathOfBuilding.darwin.arm64.tar.xz" - token: ${{ secrets.GITHUB_TOKEN }} + artifacts: "*.tar.xz" + token: ${{ github.token }} allowUpdates: true + replacesArtifacts: true tag: PathOfBuilding - body: "${{steps.time.outputs.time}}" - \ No newline at end of file + body: "${{ steps.time.outputs.time }}" + diff --git a/.gitignore b/.gitignore index 6406b08..1ee9110 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,12 @@ lcurl.so Lua-cURLv3 PathOfBuilding +build +*.so +*.dll +*.dylib +*.exe +*.o +*.obj +*.a +*.log diff --git a/Makefile b/Makefile index 4b32a43..51bf376 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ Darwin_x86_64: pob meson setup --buildtype=release --prefix=${DIR}/PathOfBuilding.app --bindir=Contents/MacOS build meson compile -C build meson install -C build - /usr/local/opt/qt@5/bin/macdeployqt ${DIR}/PathOfBuilding.app -verbose=2 + /usr/local/opt/qt@5/bin/macdeployqt ${DIR}/PathOfBuilding.app -verbose=2 echo "Finished $(OS_NAME)" Linux_x86_64: pob @@ -35,11 +35,18 @@ Linux_x86_64: pob meson install -C build echo "Finished $(OS_NAME)" +# ARM64 Linux runners commonly report uname -m as aarch64. +Linux_aarch64: Linux_x86_64 +Linux_arm64: Linux_x86_64 + pob: clear tools_$(OS_NAME) load_pob luacurl pushd PathOfBuilding && \ - unzip runtime-win32.zip lua/xml.lua lua/base64.lua lua/sha1.lua && \ - mv lua/*.lua . && \ - rmdir lua && \ + unzip runtime-win32.zip 'lua/*' && \ + cp -R lua/. . && \ + rm -rf lua && \ + LJ_VER=$$(luajit -e 'print(_VERSION:match("%d+%.%d+"))') && \ + MOD_SO=$$(find "$${HOME}/.luarocks/lib/lua/$$LJ_VER" /usr/local/lib/lua/$$LJ_VER /opt/homebrew/lib/lua/$$LJ_VER -maxdepth 1 -type f -name 'lua-utf8.so' 2>/dev/null | head -n 1 || true) && \ + if [ -n "$$MOD_SO" ]; then cp "$$MOD_SO" .; fi && \ cp ../lcurl.so . && \ mv src/* . && \ rmdir src && \ @@ -63,9 +70,13 @@ clear: rm -rf PathOfBuilding PathOfBuilding.app Lua-cURLv3 lcurl.so build tools_Darwin: - brew install jq qt@5 luajit zlib meson curl dylibbundler + brew install jq qt@5 luajit zlib meson curl dylibbundler luarocks + LJ_VER=$$(luajit -e 'print(_VERSION:match("%d+%.%d+"))'); \ + luajit -e 'require("lua-utf8")' || luarocks --lua-version=$$LJ_VER install luautf8 tools_Linux: sudo apt update && sudo apt -y install qtbase5-dev qt5-qmake \ - qtcreator luajit libluajit-5.1-dev zlib1g zlib1g-dev meson \ - xvfb build-essential ninja-build x11-apps imagemagick libcurl4-openssl-dev \ No newline at end of file + luajit libluajit-5.1-dev zlib1g zlib1g-dev meson luarocks \ + xvfb build-essential ninja-build x11-apps imagemagick libcurl4-openssl-dev + LJ_VER=$$(luajit -e 'print(_VERSION:match("%d+%.%d+"))'); \ + luajit -e 'require("lua-utf8")' || sudo luarocks --lua-version=$$LJ_VER install luautf8 diff --git a/main.cpp b/main.cpp index 97b4233..c839853 100644 --- a/main.cpp +++ b/main.cpp @@ -576,6 +576,20 @@ static int l_GetScreenSize(lua_State* L) return 2; } +static int l_GetVirtualScreenSize(lua_State* L) +{ + // Compatibility shim for newer PoB scripts. + return l_GetScreenSize(L); +} + +static int l_GetVirtualScreenOffset(lua_State* L) +{ + // Single-window frontend: virtual origin is the primary screen origin. + lua_pushinteger(L, 0); + lua_pushinteger(L, 0); + return 2; +} + static int l_SetClearColor(lua_State* L) { int n = lua_gettop(L); @@ -1681,6 +1695,8 @@ int main(int argc, char **argv) // Rendering ADDFUNC(RenderInit); ADDFUNC(GetScreenSize); + ADDFUNC(GetVirtualScreenSize); + ADDFUNC(GetVirtualScreenOffset); ADDFUNC(SetClearColor); ADDFUNC(SetDrawLayer); ADDFUNC(SetViewport); @@ -1763,8 +1779,26 @@ int main(int argc, char **argv) std::string basePath = pobwindow->basePath.toStdString(); std::string extraPathCommand = "package.path = package.path .. \";" + basePath - + "/runtime/lua/?.lua\""; + + "/?.lua;" + + basePath + + "/?/init.lua;" + + basePath + + "/runtime/lua/?.lua;" + + basePath + + "/runtime/lua/?/init.lua\"; " + "package.cpath = package.cpath .. \";" + + basePath + + "/?.so;" + + basePath + + "/runtime/lua/?.so\""; luaL_dostring(L, extraPathCommand.c_str()); + luaL_dostring(L, + "if GetVirtualScreenSize == nil then " + " function GetVirtualScreenSize() return GetScreenSize() end " + "end " + "if GetVirtualScreenOffset == nil then " + " function GetVirtualScreenOffset() return 0, 0 end " + "end"); int result = luaL_dofile(L, "Launch.lua"); if (result != 0) { @@ -1783,4 +1817,3 @@ int main(int argc, char **argv) QFontDatabase::addApplicationFont("LiberationSans-Bold.ttf"); return app.exec(); } -