diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml deleted file mode 100644 index 6594508df8dd..000000000000 --- a/.github/workflows/android.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: android - -on: - push: - branches: - - dev - - paths-ignore: - - '**.md' - - '**/*.md.in' - - 'docs/**' -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - GH_OS_NAME: linux - BUILD_TARGET: android - BUILD_TYPE: Release - -jobs: - build: - if: ${{ !startsWith(github.event.commits[0].message, 'Merge pull request') }} - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: ubuntu-latest - - strategy: - matrix: - arch: - - armv7 - - arm64 - - x86 - - x64 - env: - BUILD_ARCH: ${{ matrix.arch }} - - steps: - - uses: actions/checkout@v3 - with: - submodules: 'recursive' - - - uses: actions/setup-java@v3 - with: - distribution: 'microsoft' # See 'Supported distributions' for available options - java-version: '17' - - - name: Build - # Execute the build. You can specify a specific target with "--target " - shell: pwsh - run: | - $AX_ROOT = $(Get-Location).Path - ./build.ps1 -p android -a $env:BUILD_ARCH - - - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.arch }} - path: | - templates/**/*.apk - tests/**/*.apk diff --git a/.github/workflows/windows.yml b/.github/workflows/build.yml similarity index 51% rename from .github/workflows/windows.yml rename to .github/workflows/build.yml index 91d6213d26e2..34d796fffcfe 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: windows +name: build on: push: @@ -9,13 +9,11 @@ on: - '**.md' - '**/*.md.in' - 'docs/**' + - '.github/workflows/publish.yml' + - 'tools/ci/make-pkg.ps1' jobs: win32: - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix runs-on: windows-latest steps: - uses: actions/checkout@v3 @@ -29,10 +27,6 @@ jobs: shell: pwsh run: .\build.ps1 -p win32 -a x64 win32-dll: - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix runs-on: windows-latest steps: - uses: actions/checkout@v3 @@ -46,10 +40,6 @@ jobs: shell: pwsh run: .\build.ps1 -p win32 -a x64 -dll true winuwp: - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix # build uwp debug avoid github CI fail with memory issue runs-on: windows-latest steps: @@ -70,10 +60,6 @@ jobs: path: | build_*/tests/**/AppPackages/**/*.msix win32-clang: - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix runs-on: windows-latest env: # Test winsdk < 10.0.22000.0 (missing C11 standard stdalign.h), axmol will auto fallback to C99 for resolving compiling issue. @@ -91,3 +77,84 @@ jobs: - name: Build shell: pwsh run: .\build.ps1 -p win32 -a 'x64' -cc clang -winsdk $env:WINSDK_VER + linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - name: Install dependencies + run: | + AX_ROOT=`pwd` + echo -e "y" | pwsh $AX_ROOT/setup.ps1 + + - name: Build + shell: pwsh + run: ./build.ps1 -p linux -a x64 + osx: + runs-on: macos-latest + strategy: + matrix: + arch: + - x64 + - arm64 + env: + BUILD_ARCH: ${{ matrix.arch }} + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + - name: Build + shell: pwsh + run: ./build.ps1 -p osx -a $env:BUILD_ARCH + android: + runs-on: ubuntu-latest + strategy: + matrix: + arch: + - armv7 + - arm64 + - x86 + - x64 + env: + BUILD_ARCH: ${{ matrix.arch }} + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + - uses: actions/setup-java@v3 + with: + distribution: 'microsoft' # See 'Supported distributions' for available options + java-version: '17' + - name: Build + shell: pwsh + run: | + $AX_ROOT = $(Get-Location).Path + ./build.ps1 -p android -a $env:BUILD_ARCH + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.arch }} + path: | + templates/**/*.apk + tests/**/*.apk + ios: + runs-on: macos-latest + strategy: + matrix: + target_os: + - ios + - tvos + env: + TARGET_OS: ${{ matrix.target_os }} + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '14.2' + + - name: Build + shell: pwsh + run: ./build.ps1 -p $env:TARGET_OS -a 'x64' diff --git a/.github/workflows/forward-push.yml b/.github/workflows/forward-push.yml index eda8a6d01c39..d3d8106a183f 100644 --- a/.github/workflows/forward-push.yml +++ b/.github/workflows/forward-push.yml @@ -6,15 +6,15 @@ on: push: branches: - dev + paths-ignore: + - '.github/workflows/publish.yml' + - 'tools/ci/make-pkg.ps1' jobs: - build-site: + forward-push: runs-on: ubuntu-latest + if: ${{ github.repository == 'axmolengine/axmol' }} steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Repository Dispatch uses: peter-evans/repository-dispatch@v2 with: diff --git a/.github/workflows/genbindings.yml b/.github/workflows/genbindings.yml index cb260f3ac202..da189987d0de 100644 --- a/.github/workflows/genbindings.yml +++ b/.github/workflows/genbindings.yml @@ -8,6 +8,8 @@ on: - '**.md' - '**/*.md.in' - 'docs/**' + - '.github/workflows/publish.yml' + - 'tools/ci/make-pkg.ps1' workflow_dispatch: jobs: diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml deleted file mode 100644 index 5ea9b949418b..000000000000 --- a/.github/workflows/ios.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: ios - -on: - push: - branches: - - dev - - paths-ignore: - - '**.md' - - '**/*.md.in' - - 'docs/**' -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - GH_OS_NAME: osx - BUILD_TARGET: ios - BUILD_TYPE: Release - -jobs: - build: - if: ${{ !startsWith(github.event.commits[0].message, 'Merge pull request') }} - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: macos-latest - - steps: - - uses: actions/checkout@v3 - with: - submodules: 'recursive' - - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: '14.2' - - - name: Build - # Execute the build. You can specify a specific target with "--target " - shell: pwsh - run: ./build.ps1 -p ios -a 'x64' diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml deleted file mode 100644 index d6d575bdc03f..000000000000 --- a/.github/workflows/linux.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: linux - -on: - push: - branches: - - dev - - paths-ignore: - - '**.md' - - '**/*.md.in' - - 'docs/**' - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - GH_OS_NAME: linux - BUILD_TARGET: linux - BUILD_TYPE: Release - -jobs: - build: - if: ${{ !startsWith(github.event.commits[0].message, 'Merge pull request') }} - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - with: - submodules: 'recursive' - - - name: Install dependencies - # Some projects don't allow in-source building, so create a separate build directory - # We'll use this as our working directory for all subsequent commands - run: | - AX_ROOT=`pwd` - echo -e "y" | pwsh $AX_ROOT/setup.ps1 - - - name: Build - # Execute the build. You can specify a specific target with "--target " - shell: pwsh - run: ./build.ps1 -p linux -a x64 diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml deleted file mode 100644 index 1cfc2cdc5f78..000000000000 --- a/.github/workflows/osx.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: osx - -on: - push: - branches: - - dev - - paths-ignore: - - '**.md' - - '**/*.md.in' - - 'docs/**' - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - GH_OS_NAME: osx - BUILD_TARGET: osx - BUILD_TYPE: Release - -jobs: - build: - if: ${{ !startsWith(github.event.commits[0].message, 'Merge pull request') }} - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: macos-latest - - strategy: - matrix: - arch: - - x64 - - arm64 - env: - BUILD_ARCH: ${{ matrix.arch }} - - steps: - - uses: actions/checkout@v3 - with: - submodules: 'recursive' - - - name: Build - # Execute the build. You can specify a specific target with "--target " - shell: pwsh - run: ./build.ps1 -p osx -a $env:BUILD_ARCH diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 14b502b0e800..8fde324d66cb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,46 +1,81 @@ name: publish on: + workflow_run: + workflows: [build] + types: [completed] workflow_dispatch: # Inputs the workflow accepts. inputs: version: # actions run ID - description: 'Please input release version' + description: 'Please input release version, example: 2.1.0' # Default value if no value is explicitly provided - default: '' + default: 'auto' # Input has to be provided for the workflow to run required: false jobs: publish: - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: submodules: 'recursive' + - name: Check release ver from input + if: ${{ github.event.inputs.version != '' }} + id: check_ver + shell: pwsh + run: | + $release_ver = '${{ github.event.inputs.version }}' + echo "release_ver=$release_ver" >> ${env:GITHUB_OUTPUT} + echo "release_ver=$release_ver" >> ${env:GITHUB_ENV} + + - name: Check release ver from commits + if: ${{ github.event.workflow_run.conclusion == 'success' && steps.check_ver.outputs.release_ver == '' }} + shell: pwsh + run: | + # commit message template: xxxx [release 2.1.0] + $commit_msg = "$(git show -s --format=%s)" + echo "commit_msg: $commit_msg" + $matchInfo = [Regex]::Match($commit_msg, '\[release\s(\d+\.)+(-)?(\*|\d+)\]') + if ($matchInfo.Success) { $matchInfo = [Regex]::Match($matchInfo.Value, '(\d+\.)+(-)?(\*|\d+)') } + $release_ver = if($matchInfo.Success) { $matchInfo.Value } + echo "release_ver=$release_ver" >> ${env:GITHUB_ENV} + + - name: Forward release ver to step make_pkg + id: forward_ver + shell: pwsh + run: | + echo "Forwarding release_ver=$env:release_ver ..." + echo "release_ver=$env:release_ver" >> ${env:GITHUB_OUTPUT} + + - name: Install linux dependencies + if: ${{ steps.forward_ver.outputs.release_ver != '' }} + run: | + AX_ROOT=`pwd` + echo -e "y" | pwsh $AX_ROOT/setup.ps1 + - name: Make package + if: ${{ steps.forward_ver.outputs.release_ver != '' }} id: make_pkg - # Some projects don't allow in-source building, so create a separate build directory # We'll use this as our working directory for all subsequent commands shell: pwsh run: | - .\build.ps1 -p win32 -xc '-DAX_WITH_LZ4=ON,-DAX_WITH_CARES=ON,-DAX_WITH_YAML_CPP=ON,-DAX_WITH_KCP=ON,-DAX_WITH_OBOE=ON' -c - .\tools\ci\make-pkg.ps1 -version "${{ github.event.inputs.version }}" - ls + $AX_ROOT = $(pwd).Path + ./1k/fetch.ps1 -name 'oboe' -dest $(Join-Path $AX_ROOT 'cache/oboe') -cfg $(Join-Path $AX_ROOT 'manifest.json') + ./build.ps1 -xc '-DAX_WITH_LZ4=ON,-DAX_WITH_CARES=ON,-DAX_WITH_YAML_CPP=ON,-DAX_WITH_KCP=ON' -c + ./tools/ci/make-pkg.ps1 -version "${{ steps.forward_ver.outputs.release_ver }}" - name: Publish to github release page + if: ${{ steps.make_pkg.outputs.release_tag != '' }} uses: softprops/action-gh-release@v1 with: tag_name: ${{ steps.make_pkg.outputs.release_tag }} name: ${{ steps.make_pkg.outputs.release_tag }} files: ${{ steps.make_pkg.outputs.release_pkg }} + body_path: ${{ steps.make_pkg.outputs.release_note }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_REPOSITORY: simdsoft/axmol \ No newline at end of file diff --git a/.github/workflows/tvos.yml b/.github/workflows/tvos.yml deleted file mode 100644 index 95086466df15..000000000000 --- a/.github/workflows/tvos.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: tvos - -on: - push: - branches: - - dev - - paths-ignore: - - '**.md' - - '**/*.md.in' - - 'docs/**' -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - GH_OS_NAME: osx - BUILD_TARGET: tvos - BUILD_TYPE: Release - -jobs: - build: - if: ${{ !startsWith(github.event.commits[0].message, 'Merge pull request') }} - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: macos-latest - - steps: - - uses: actions/checkout@v3 - with: - submodules: 'recursive' - - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: '14.2' - - - name: Build - # Execute the build. You can specify a specific target with "--target " - shell: pwsh - run: ./build.ps1 -p tvos -a 'x64' diff --git a/.gitignore b/.gitignore index 81f812261066..f293e1377019 100644 --- a/.gitignore +++ b/.gitignore @@ -227,3 +227,4 @@ tests/live2d-tests/Content cache .gitee +release_note_draft.txt diff --git a/1k/build.ps1 b/1k/build.ps1 index 6e4ddb2a4be1..a97f31c1d255 100644 --- a/1k/build.ps1 +++ b/1k/build.ps1 @@ -193,7 +193,7 @@ $manifest = @{ cmake = '3.27.7+'; ninja = '1.11.1+'; jdk = '17.0.3+'; - emsdk = '3.1.50'; + emsdk = '3.1.51'; cmdlinetools = '7.0+'; # android cmdlinetools } diff --git a/1k/fetch.cmake b/1k/fetch.cmake index 54dc3c0d76d0..33b207558869 100644 --- a/1k/fetch.cmake +++ b/1k/fetch.cmake @@ -26,10 +26,10 @@ endfunction() function(_1kfetch_dist package_name) set(_prebuilt_root ${CMAKE_CURRENT_LIST_DIR}/_d) if(NOT IS_DIRECTORY ${_prebuilt_root}) - set (package_url "${_1kdist_base_url}/${package_name}.zip") set (package_store "${_1kfetch_cache_dir}/1kdist/v${_1kdist_ver}/${package_name}.zip") - message(AUTHOR_WARNING "Downloading ${package_url}") if (NOT EXISTS ${package_store}) + set (package_url "${_1kdist_base_url}/${package_name}.zip") + message(AUTHOR_WARNING "Downloading ${package_url}") file(DOWNLOAD ${package_url} ${package_store} STATUS _status LOG _logs SHOW_PROGRESS) list(GET _status 0 status_code) list(GET _status 1 status_string) @@ -56,7 +56,12 @@ function(_1kfetch name) execute_process(COMMAND ${PWSH_COMMAND} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/fetch.ps1 -name "${name}" -dest "${_pkg_store}" - -cfg ${_1kfetch_manifest}) + -cfg ${_1kfetch_manifest} + RESULT_VARIABLE _errorcode + ) + if (_errorcode) + message(FATAL_ERROR "aborted") + endif() set(${name}_SOURCE_DIR ${_pkg_store} PARENT_SCOPE) endfunction() diff --git a/1k/fetch.ps1 b/1k/fetch.ps1 index a292fb0286a4..a5e41ad68d48 100644 --- a/1k/fetch.ps1 +++ b/1k/fetch.ps1 @@ -21,15 +21,21 @@ if ($pkg_ver) { } $url = "$url_base/$url_path" - if (Test-Path $dest -PathType Container) { - if (!(Test-Path $(Join-Path $dest '.git') -PathType Container)) { + + $sentry = Join-Path $dest '_1kiss' + # if sentry file missing, re-clone + if (!(Test-Path $sentry -PathType Leaf)) { + if (Test-Path $dest -PathType Container) { Remove-Item $dest -Recurse -Force - git clone $url $dest } - } - else { git clone $url $dest + if ($? -and (Test-Path $(Join-Path $dest '.git') -PathType Container)) { + [System.IO.File]::WriteAllText($sentry, "$(git -C $dest rev-parse HEAD)") + } else { + throw "fetch.ps1: execute git clone $url failed" + } } + $pkg_ver = $pkg_ver.Split('-') $use_hash = $pkg_ver.Count -gt 1 $revision = $pkg_ver[$use_hash].Trim() diff --git a/README.md b/README.md index c89dbacfa151..e75fd4cf6639 100644 --- a/README.md +++ b/README.md @@ -4,32 +4,33 @@ ## A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0) -[![dev](https://img.shields.io/github/v/release/axmolengine/axmol?include_prereleases&label=release)](https://github.com/axmolengine/axmol/releases) +[![Latest Release](https://img.shields.io/github/v/release/axmolengine/axmol?include_prereleases&label=release)](https://github.com/axmolengine/axmol/releases) [![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/axmolengine/axmol/blob/master/LICENSE) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/81fa1aba09ab41a98b949064b928d06e)](https://www.codacy.com/gh/axmolengine/axmol/dashboard?utm_source=github.com&utm_medium=referral&utm_content=axmolengine/axmol&utm_campaign=Badge_Grade) -[![cxxstd](https://img.shields.io/badge/cxxstd-c++20-8A2BE2.svg)](https://github.com/axmolengine/axmol) -[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/axmolengine/axmol/pulls) -[![Discord](https://img.shields.io/discord/1099599084895088670?label=discord)](https://discord.com/channels/1099599084895088670) - +[![cxxstd](https://img.shields.io/badge/cxxstd-c++20-8A2BE2.svg)](https://github.com/axmolengine/axmol) + +[![Build Status](https://github.com/axmolengine/axmol/workflows/build/badge.svg)](https://github.com/axmolengine/axmol/actions?query=workflow%3Abuild) +[![WASM Build Status](https://ci.appveyor.com/api/projects/status/4slq965fwhbaidnc?svg=true&passingText=wasm%20-%20passing)](https://ci.appveyor.com/project/halx99/axmol) + ![issues](https://img.shields.io/github/issues/axmolengine/axmol?style=plastic) ![forks](https://img.shields.io/github/forks/axmolengine/axmol?style=plastic) ![stars](https://img.shields.io/github/stars/axmolengine/axmol?style=plastic) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/axmolengine/axmol?style=plastic) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/axmolengine/axmol/pulls) +[![Discord](https://img.shields.io/discord/1099599084895088670?label=discord)](https://discord.com/channels/1099599084895088670) + **[简体中文](README_CN.md)** ## Supported Platforms -| Build | Status (github) | -|-------|-----------------| -| Windows(win32,winuwp,win32-clang)|[![Win32 CI](https://github.com/axmolengine/axmol/actions/workflows/windows.yml/badge.svg)](https://github.com/axmolengine/axmol/actions/workflows/windows.yml)| -| Android | [![Android Build Status](https://github.com/axmolengine/axmol/workflows/android/badge.svg)](https://github.com/axmolengine/axmol/actions?query=workflow%3Aandroid)| -| iOS |[![iOS Build Status](https://github.com/axmolengine/axmol/workflows/ios/badge.svg)](https://github.com/axmolengine/axmol/actions?query=workflow%3Aios)| -| tvOS |[![tvOS Build Status](https://github.com/axmolengine/axmol/workflows/tvos/badge.svg)](https://github.com/axmolengine/axmol/actions?query=workflow%3Atvos)| -| Linux |[![Linux Build Status](https://github.com/axmolengine/axmol/workflows/linux/badge.svg)](https://github.com/axmolengine/axmol/actions?query=workflow%3Alinux)| -| macOS |[![macOS Build Status](https://github.com/axmolengine/axmol/workflows/osx/badge.svg)](https://github.com/axmolengine/axmol/actions?query=workflow%3Aosx)| -| WASM(experimental) |[![WASM Build Status](https://ci.appveyor.com/api/projects/status/4slq965fwhbaidnc?svg=true&passingText=wasm%20-%20passing)](https://ci.appveyor.com/project/halx99/axmol)| +- Windows(win32,winuwp,win32-clang) +- Linux +- macOS +- Android +- iOS/tvOS +- WASM `experimental` ## Building diff --git a/README_CN.md b/README_CN.md index ccaf1dc37c67..a7592b32b328 100644 --- a/README_CN.md +++ b/README_CN.md @@ -4,10 +4,20 @@ ## A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0) -[![dev](https://img.shields.io/github/v/release/axmolengine/axmol?include_prereleases&label=release)](https://github.com/axmolengine/axmol/releases) + +[![Latest Release](https://img.shields.io/github/v/release/axmolengine/axmol?include_prereleases&label=release)](https://github.com/axmolengine/axmol/releases) [![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/axmolengine/axmol/blob/master/LICENSE) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/81fa1aba09ab41a98b949064b928d06e)](https://www.codacy.com/gh/axmolengine/axmol/dashboard?utm_source=github.com&utm_medium=referral&utm_content=axmolengine/axmol&utm_campaign=Badge_Grade) -[![cxxstd](https://img.shields.io/badge/cxxstd-c++20-8A2BE2.svg)](https://github.com/axmolengine/axmol) +[![cxxstd](https://img.shields.io/badge/cxxstd-c++20-8A2BE2.svg)](https://github.com/axmolengine/axmol) + +[![Build Status](https://github.com/axmolengine/axmol/workflows/build/badge.svg)](https://github.com/axmolengine/axmol/actions?query=workflow%3Abuild) +[![WASM Build Status](https://ci.appveyor.com/api/projects/status/4slq965fwhbaidnc?svg=true&passingText=wasm%20-%20passing)](https://ci.appveyor.com/project/halx99/axmol) + +![issues](https://img.shields.io/github/issues/axmolengine/axmol?style=plastic) +![forks](https://img.shields.io/github/forks/axmolengine/axmol?style=plastic) +![stars](https://img.shields.io/github/stars/axmolengine/axmol?style=plastic) +![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/axmolengine/axmol?style=plastic) + [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/axmolengine/axmol/pulls) [![QQ Group](https://img.shields.io/badge/QQGroup-join-green.svg)](https://jq.qq.com/?_wv=1027&k=nvNmzOIY) @@ -15,16 +25,13 @@ **[English](README.md)** ## 支持平台列表 -| Build | Status (github) | -|-------|-----------------| -| Windows(win32,winuwp,win32-clang)|[![Win32 CI](https://github.com/axmolengine/axmol/actions/workflows/windows.yml/badge.svg)](https://github.com/axmolengine/axmol/actions/workflows/windows.yml)| -| Android | [![Android Build Status](https://github.com/axmolengine/axmol/workflows/android/badge.svg)](https://github.com/axmolengine/axmol/actions?query=workflow%3Aandroid)| -| iOS |[![iOS Build Status](https://github.com/axmolengine/axmol/workflows/ios/badge.svg)](https://github.com/axmolengine/axmol/actions?query=workflow%3Aios)| -| tvOS |[![tvOS Build Status](https://github.com/axmolengine/axmol/workflows/tvos/badge.svg)](https://github.com/axmolengine/axmol/actions?query=workflow%3Atvos)| -| Linux |[![Linux Build Status](https://github.com/axmolengine/axmol/workflows/linux/badge.svg)](https://github.com/axmolengine/axmol/actions?query=workflow%3Alinux)| -| macOS |[![macOS Build Status](https://github.com/axmolengine/axmol/workflows/osx/badge.svg)](https://github.com/axmolengine/axmol/actions?query=workflow%3Aosx)| -| WASM(experimental) |[![WASM Build Status](https://ci.appveyor.com/api/projects/status/4slq965fwhbaidnc?svg=true&passingText=wasm%20-%20passing)](https://ci.appveyor.com/project/halx99/axmol)| +- Windows(win32,winuwp,win32-clang) +- Linux +- macOS +- Android +- iOS/tvOS +- WASM `experimental` ## 构建 diff --git a/cmake/Modules/AXBuildHelpers.cmake b/cmake/Modules/AXBuildHelpers.cmake index 4265b18a4bba..af341e150630 100644 --- a/cmake/Modules/AXBuildHelpers.cmake +++ b/cmake/Modules/AXBuildHelpers.cmake @@ -489,7 +489,6 @@ macro (ax_setup_app_props app_name) ) target_link_libraries(${APP_NAME} ${CMAKE_BINARY_DIR}/packages/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.targets) elseif(WASM) - message(STATUS "#### AX_WASM_EXPORTS=${AX_WASM_EXPORTS}") get_target_property(_APP_SOURCE_DIR ${app_name} SOURCE_DIR) set(CMAKE_EXECUTABLE_SUFFIX ".html") target_link_options(${app_name} PRIVATE diff --git a/cmake/Modules/AXConfigDefine.cmake b/cmake/Modules/AXConfigDefine.cmake index e78278eaa9de..2f6dde47016a 100644 --- a/cmake/Modules/AXConfigDefine.cmake +++ b/cmake/Modules/AXConfigDefine.cmake @@ -103,6 +103,10 @@ if(WINDOWS) endif() endif() +if(EMSCRIPTEN_VERSION) + message(STATUS "Using emsdk generate axmol project, EMSCRIPTEN_VERSION: ${EMSCRIPTEN_VERSION}") +endif() + if (FUZZ_MSVC) add_compile_options(/GF) endif() diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index e6c0737fadde..aae8924183b1 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -246,6 +246,13 @@ list(APPEND _AX_SRC ${_AX_HEADER}) add_library(${_AX_CORE_LIB} ${_AX_SRC}) +if(WASM) + if(${EMSCRIPTEN_VERSION} VERSION_GREATER_EQUAL "3.1.51") + target_link_options(${_AX_CORE_LIB} PUBLIC -sGL_ENABLE_GET_PROC_ADDRESS) + endif() + target_link_options(${_AX_CORE_LIB} PUBLIC -lwebsocket.js) +endif() + ax_find_shaders(${_AX_ROOT}/core/renderer/shaders BUILTIN_SHADER_SOURCES) set(ax_builtin_shaders ${BUILTIN_SHADER_SOURCES} CACHE STATIC "" FORCE) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index de7e1725df67..6fa92328ec36 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -250,13 +250,13 @@ ax_add_3rd(fmt EXCLUDE_FROM_ALL TARGETS fmt-header-only) # bellow are non header only libs # cpufeatures -if(ANDROID) +if(ANDROID) add_subdirectory(android-specific/cpufeatures) endif() if(NOT EMSCRIPTEN) ax_add_3rd(zlib) -endif(NOT EMSCRIPTEN) +endif() # libpng ax_add_3rd(png) @@ -269,7 +269,7 @@ if(AX_WITH_BOX2D) else() ax_add_3rd(box2d OPTIONS ${box2d_opts}) endif() -endif(AX_WITH_BOX2D) +endif() if(AX_WITH_CHIPMUNK) ax_add_3rd(chipmunk OPTIONS @@ -285,7 +285,7 @@ if(AX_WITH_CHIPMUNK) # !important axmol not use double precision target_compile_definitions(chipmunk PUBLIC CP_USE_CGTYPES=0) target_compile_definitions(chipmunk PUBLIC CP_USE_DOUBLES=0) -endif(AX_WITH_CHIPMUNK) +endif() ax_add_3rd(freetype OPTIONS "FT_WITH_ZLIB ON" @@ -302,11 +302,11 @@ target_include_directories(thirdparty INTERFACE "freetype/include") if(AX_WITH_RECAST) ax_add_3rd(recast) -endif(AX_WITH_RECAST) +endif() if(AX_WITH_BULLET) ax_add_3rd(bullet) -endif(AX_WITH_BULLET) +endif() if(AX_WITH_JPEG AND NOT WINRT AND NOT EMSCRIPTEN) ax_add_3rd(jpeg-turbo) @@ -325,7 +325,7 @@ target_compile_definitions(thirdparty INTERFACE OPENSSL_SUPPRESS_DEPRECATED=1) if(AX_WITH_WEBP) ax_add_3rd(webp) -endif(AX_WITH_WEBP) +endif() ax_add_3rd(pugixml) ax_add_3rd(xxhash) @@ -349,18 +349,18 @@ endif() if(AX_WITH_CLIPPER2) ax_add_3rd(clipper2) -endif(AX_WITH_CLIPPER2) +endif() ax_add_3rd(ConvertUTF) if(AX_WITH_POLY2TRI) ax_add_3rd(poly2tri) target_compile_definitions(poly2tri PUBLIC P2T_STATIC_EXPORTS) -endif(AX_WITH_POLY2TRI) +endif() if(AX_WITH_ASTCENC) ax_add_3rd(astcenc) -endif(AX_WITH_ASTCENC) +endif() # use lua/js specific libs by property to prevent conflict if(AX_ENABLE_EXT_LUA) @@ -432,12 +432,12 @@ endif() # unzip depend on zlib if(AX_WITH_UNZIP) ax_add_3rd(unzip) -endif(AX_WITH_UNZIP) +endif() if(AX_WITH_CARES) ax_add_3rd(c-ares) target_compile_definitions(thirdparty INTERFACE YASIO_USE_CARES=1) -endif(AX_WITH_CARES) +endif() ax_add_3rd(llhttp) diff --git a/tools/ci/make-pkg.ps1 b/tools/ci/make-pkg.ps1 index 0f6a8361e4c8..ef86aca766da 100644 --- a/tools/ci/make-pkg.ps1 +++ b/tools/ci/make-pkg.ps1 @@ -1,9 +1,12 @@ param( $version = $null ) -$AX_ROOT = (Resolve-Path $PSScriptRoot/../../).Path -if(!$version) { +Write-Host "Creating package $pkg_file_path ..." + +$AX_ROOT = (Resolve-Path $PSScriptRoot/../..).Path + +if(!$version -or ($version -eq 'auto')) { $axver_file = (Resolve-Path $AX_ROOT/core/axmolver.h.in).Path $axver_content = $(Get-Content -Path $axver_file) function parse_axver($part) { @@ -14,7 +17,6 @@ if(!$version) { $git_prog = (Get-Command 'git' -ErrorAction SilentlyContinue).Source if($git_prog) { - Write-Host "Found git: $git_prog" $branchName = $(git -C $AX_ROOT branch --show-current) if ($branchName -eq 'dev') { $commitHash = $(git -C $AX_ROOT rev-parse --short=7 HEAD) @@ -35,37 +37,145 @@ $excludes = @( '.vscode' 'build_*' 'build' + 'core/axmolver.h' + 'core/renderer/RenderConsts.h' '.github' 'tmp' 'temp' - 'tools' - '*.zip' + 'tools/external' + 'axmol-*.zip' 'out' + '*/_d/*' ) -$axmol_files = Get-ChildItem $AX_ROOT -Exclude $excludes - -# $tools_files = Get-ChildItem $(Join-Path $AX_ROOT 'tools') -Exclude 'external' -# $axmol_files += $tools_files - -# $tools_external_files = Get-ChildItem $(Join-Path $AX_ROOT 'tools/external') -Exclude '*.zip' -# $axmol_files += $tools_external_files - $pkg_file_name = "axmol-$version.zip" $pkg_file_path = $(Join-Path $AX_ROOT $pkg_file_name) -$compress = @{ - Path = $axmol_files - CompressionLevel = "Optimal" +$compress_args = @{ + Path = $AX_ROOT + CompressionLevel = 'Optimal' DestinationPath = $pkg_file_path + RelativeBasePath = $AX_ROOT + Exclude = $excludes + Prefix = "axmol-$version" } -Write-Host "Creating package $pkg_file_path ..." -Compress-Archive @compress -PassThru +# Compress-Archive @compress -PassThru + +function Compress-ArchiveEx() { + param( + $Path, + $CompressionLevel = 'Optimal', + $DestinationPath, + $Exclude, + $Prefix = '', + $RelativeBasePath = '', + [switch]$Force + ) + + if($RelativeBasePath) { + Push-Location $RelativeBasePath + } + + # remove old zip file + if ((Test-Path $DestinationPath) -and $Force) { Remove-Item $DestinationPath -ErrorAction Stop } + + #create zip file + if (!([System.Management.Automation.PSTypeName]'System.IO.Compression').Type) { + Add-Type -AssemblyName System.IO.Compression + Add-Type -AssemblyName System.IO.Compression.FileSystem + } + $archive = [System.IO.Compression.ZipFile]::Open($DestinationPath, [System.IO.Compression.ZipArchiveMode]::Create) + + $compressionLevelValue = @{ + 'Optimal' = [System.IO.Compression.CompressionLevel]::Optimal + 'Fastest' = [System.IO.Compression.CompressionLevel]::Fastest + 'NoCompression' = [System.IO.Compression.CompressionLevel]::NoCompression + }[$CompressionLevel] + + [array]$Excludes = $Exclude + [array]$Paths = $Path + $_is_exclude = { + param($uxpath) + foreach($exclude in $Excludes) { + if($uxpath -like $exclude) { + return $true + } + } + return $false + } + + $Script:total = 0 + + $_zip_add = { + param($archive, $path, $compressionLevel, $prefix) + if(!$path.LinkType) { + # -RelativeBasePath add in powershell 7.4 which github ci is 7.2 not support + $rname = $(Resolve-Path -Path $path -Relative).Replace('\', '/') + if ($rname.StartsWith('./')) { $rname = $rname.TrimStart('./') } + $excluded = (&$_is_exclude -uxpath $rname) + if(!$excluded) { + if($prefix) { $rname = Join-Path $prefix $rname } + + if (!$path.PSIsContainer) { + ++$Script:total + $zentry = $archive.CreateEntry($rname) + if ($path.UnixStat) { + # when run on unix, set permissions same with origin file + # refer https://github.com/PowerShell/Microsoft.PowerShell.Archive/pull/146/files + $zentry.ExternalAttributes = ((0x8000 -bor $path.UnixStat.Mode) -shl 16) + } + $zentryWriter = New-Object -TypeName System.IO.BinaryWriter $zentry.Open() + $zentryWriter.Write([System.IO.File]::ReadAllBytes($path)) + $zentryWriter.Flush() + $zentryWriter.Close() + } else { + $sub_paths = Get-ChildItem $path + foreach($sub_path in $sub_paths) { + &$_zip_add $archive $sub_path $compressionLevel $prefix + } + } + } + else { + Write-Host "x` $path" + } + } + else { + Write-Host "x $path, LinkType=$($Path.LinkType)" + } + } + + # write entries with relative paths as names + foreach ($path in $Paths) { + if($path.GetType() -eq [string]) { + $path = Get-Item $path + } + &$_zip_add $archive $path $compressionLevelValue $Prefix + } + + # release zip file + $archive.Dispose() + + if($RelativeBasePath) { + Pop-Location + } + + return $Script:total +} + +# Compress-Archive @compress_args +$total = Compress-ArchiveEx @compress_args -Force + +$md5_digest = (Get-FileHash $pkg_file_path -Algorithm MD5).Hash + +Write-Host "Create package $pkg_file_path done, ${total} files found, MD5: $md5_digest" Pop-Location if($env:GITHUB_ACTIONS -eq 'true') { + $release_note = Join-Path $AX_ROOT "release_note_draft.txt" + [System.IO.File]::WriteAllText($release_note, "## MD5 Hash of the release artifacts`n - ``${pkg_file_name}``: $md5_digest") echo "release_tag=v$version" >> ${env:GITHUB_OUTPUT} echo "release_pkg=$pkg_file_name" >> ${env:GITHUB_OUTPUT} + echo "release_note=$release_note" >> ${env:GITHUB_OUTPUT} } diff --git a/tools/console/axmol.ps1 b/tools/console/axmol.ps1 index 6ed07fc0a56c..a40932c25986 100644 --- a/tools/console/axmol.ps1 +++ b/tools/console/axmol.ps1 @@ -22,9 +22,9 @@ $axmolVersion = "$(parse_axver 'MAJOR').$(parse_axver 'MINOR').$(parse_axver 'PA $git_prog = (Get-Command 'git' -ErrorAction SilentlyContinue).Source if ($git_prog) { - $branchName = $(git -C $AX_ROOT branch --show-current) + $branchName = $(git -C $AX_ROOT branch --show-current 2>$null) if ($branchName -eq 'dev') { - $commitHash = $(git -C $AX_ROOT rev-parse --short=7 HEAD) + $commitHash = $(git -C $AX_ROOT rev-parse --short=7 HEAD 2>$null) $axmolVersion += "-$commitHash" } }