diff --git a/.github/actions/godot-build/action.yml b/.github/actions/godot-build/action.yml new file mode 100644 index 00000000..bfb9ca15 --- /dev/null +++ b/.github/actions/godot-build/action.yml @@ -0,0 +1,51 @@ +name: Build Godot +description: Build Godot with the provided options. +inputs: + target: + description: The scons target (debug/release_debug/release). + default: debug + tools: + description: If tools are to be built. + default: false + tests: + description: If tests are to be built. + default: false + platform: + description: The Godot platform to build. + required: false + sconsflags: + default: '' + scons-cache: + description: The scons cache path. + default: ${{ github.workspace }}/.scons-cache/ + scons-cache-limit: + description: The scons cache size limit. + default: 4096 + shell: + description: the shell to run this under + default: sh +runs: + using: composite + steps: + - name: Scons Build + shell: sh + env: + SCONSFLAGS: ${{ inputs.sconsflags }} + SCONS_CACHE: ${{ inputs.scons-cache }} + SCONS_CACHE_LIMIT: ${{ inputs.scons-cache-limit }} + run: | + echo "Building with flags:" ${{ env.SCONSFLAGS }} + scons p=${{ inputs.platform }} target=${{ inputs.target }} tools=${{ inputs.tools }} tests=${{ inputs.tests }} --jobs=2 ${{ env.SCONSFLAGS }} + ls -l bin/ + if: inputs.shell == 'sh' + - name: Scons Build + shell: msys2 {0} + env: + SCONSFLAGS: ${{ inputs.sconsflags }} + SCONS_CACHE: ${{ inputs.scons-cache }} + SCONS_CACHE_LIMIT: ${{ inputs.scons-cache-limit }} + run: | + echo "Building with flags:" ${{ env.SCONSFLAGS }} + scons p=${{ inputs.platform }} target=${{ inputs.target }} tools=${{ inputs.tools }} tests=${{ inputs.tests }} --jobs=2 ${{ env.SCONSFLAGS }} + ls -l bin/ + if: inputs.shell == 'msys2 {0}' diff --git a/.github/actions/godot-cache/action.yml b/.github/actions/godot-cache/action.yml new file mode 100644 index 00000000..72ed281d --- /dev/null +++ b/.github/actions/godot-cache/action.yml @@ -0,0 +1,21 @@ +name: Setup Godot build cache +description: Setup Godot build cache. +inputs: + cache-name: + description: The cache base name (job name by default). + default: ${{github.job}} + scons-cache: + description: The scons cache path. + default: ${{github.workspace}}/.scons-cache/ +runs: + using: composite + steps: + - name: Load .scons_cache directory + uses: actions/cache@v2 + with: + path: ${{inputs.scons-cache}} + key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + restore-keys: | + ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} + ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}} + ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}} diff --git a/.github/actions/godot-deps/action.yml b/.github/actions/godot-deps/action.yml new file mode 100644 index 00000000..1d7347bc --- /dev/null +++ b/.github/actions/godot-deps/action.yml @@ -0,0 +1,34 @@ +name: Setup python and scons +description: Setup python, install the pip version of scons. +inputs: + python-version: + description: The python version to use. + default: 3.x + python-arch: + description: The python architecture. + default: x64 + shell: + description: the shell to run this under + default: sh +runs: + using: composite + steps: + - name: Set up Python 3.x + uses: actions/setup-python@v2 + with: + python-version: ${{ inputs.python-version }} + architecture: ${{ inputs.python-arch }} + - name: Setup scons + shell: sh + run: | + python -c "import sys; print(sys.version)" + python -m pip install scons + scons --version + if: inputs.shell == 'sh' + - name: Setup scons + shell: msys2 {0} + run: | + python -c "import sys; print(sys.version)" + python -m pip install scons + scons --version + if: inputs.shell == 'msys2 {0}' diff --git a/.github/actions/upload-artifact/action.yml b/.github/actions/upload-artifact/action.yml new file mode 100644 index 00000000..820273b1 --- /dev/null +++ b/.github/actions/upload-artifact/action.yml @@ -0,0 +1,19 @@ +name: Upload Godot artifact +description: Upload the Godot artifact. +inputs: + name: + description: The artifact name. + default: ${{ github.job }} + path: + description: The path to upload. + required: true + default: bin/* +runs: + using: composite + steps: + - name: Upload Godot Artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ inputs.name }} + path: ${{ inputs.path }} + retention-days: 14 diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml new file mode 100644 index 00000000..15a21290 --- /dev/null +++ b/.github/workflows/android_builds.yml @@ -0,0 +1,64 @@ +name: 🤖 Android Builds +'on': +- push +- pull_request +env: + GODOT_BASE_BRANCH: 3.4.4-stable + SCONSFLAGS: ' verbose=yes debug_symbols=no' +concurrency: + group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-android + cancel-in-progress: true +jobs: + android-template: + runs-on: ubuntu-20.04 + name: Template (target=release, tools=no) + steps: + - name: Checkout Godot + uses: actions/checkout@v2 + with: + repository: godotengine/godot + ref: ${{ env.GODOT_BASE_BRANCH }} + - name: Checkout ECMAScript + uses: actions/checkout@v2 + with: + path: ${{github.workspace}}/modules/ECMAScript/ + - name: Make apt sources.list use the default Ubuntu repositories + run: | + sudo rm -f /etc/apt/sources.list.d/* + sudo cp -f misc/ci/sources.list /etc/apt/sources.list + sudo apt-get update + - name: Set up Java 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Setup Godot build cache + uses: ./.github/actions/godot-cache + continue-on-error: true + - name: Setup python and scons + uses: ./modules/ECMAScript/.github/actions/godot-deps + with: + shell: sh + - name: Compilation (armv7) + uses: ./modules/ECMAScript/.github/actions/godot-build + with: + sconsflags: ${{ env.SCONSFLAGS }} android_arch=armv7 + platform: android + target: release + tools: false + shell: sh + - name: Compilation (arm64v8) + uses: ./modules/ECMAScript/.github/actions/godot-build + with: + sconsflags: ${{ env.SCONSFLAGS }} android_arch=arm64v8 + platform: android + target: release + tools: false + shell: sh + - name: Generate Godot templates + run: | + cd platform/android/java + ./gradlew generateGodotTemplates + cd ../../.. + ls -l bin/ + - name: Upload artifact + uses: ./.github/actions/upload-artifact diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 4d677309..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,494 +0,0 @@ -name: Build Godot with ECMAScript -# TODO: Investigate making this on tag instead of push since builds take so long -on: [push] - -# Global Cache Settings -env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - GODOT_BASE_BRANCH: '3.3-stable' - BASE_BRANCH: master - SCONS_CACHE_LIMIT: 4096 - -jobs: - android-template: - runs-on: ubuntu-latest - name: 🤖 Android Template - container: - # See how this image is built at https://github.com/Flux159/godot-docker - image: flux159/godot:1.0.0 - steps: - - name: Get dependencies - run: | - apt-get update - apt-get install -y openjdk-8-jdk curl unzip - echo "::set-env name=JAVA_HOME::/usr/lib/jvm/java-8-openjdk-amd64" - - - name: Checkout Godot - uses: actions/checkout@v2 - with: - repository: 'godotengine/godot' - ref: ${{ env.GODOT_BASE_BRANCH }} - - - name: Checkout ECMAScript - uses: actions/checkout@v2 - with: - path: ${{github.workspace}}/modules/ECMAScript/ - - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - id: android-template-cache - uses: actions/cache@v2 - with: - path: ${{github.workspace}}/.scons_cache/ - key: ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - restore-keys: | - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}} - ${{github.job}}-${{env.BASE_BRANCH}} - - - name: Install Android SDK and NDK - run: | - echo "::set-env name=PATH::/usr/lib/jvm/java-8-openjdk-amd64/jre/bin:$(pwd)/godot-dev/build-tools/android-sdk/tools:$(pwd)/godot-dev/build-tools/android-sdk/tools/bin:${PATH}" - echo "::set-env name=ANDROID_HOME::$(pwd)/godot-dev/build-tools/android-sdk" - echo "::set-env name=ANDROID_NDK_ROOT::$(pwd)/godot-dev/build-tools/android-ndk" - wget https://raw.githubusercontent.com/godotengine/godot/431930b/misc/ci/android-tools-linux.sh - chmod +x android-tools-linux.sh - ./android-tools-linux.sh - - - name: Build godot with ECMAScript module for Android (release) - run: | - scons p=android android_arch=armv7 tools=no target=release -j8 - scons p=android android_arch=arm64v8 tools=no target=release -j8 - scons p=android android_arch=x86 tools=no target=release -j8 - scons p=android android_arch=x86_64 tools=no target=release -j8 - cd platform/android/java - ./gradlew generateGodotTemplates - - - name: Publish artifact (release) - uses: actions/upload-artifact@v2 - with: - name: android_release - path: bin/ - - - name: Remove Previous Build - uses: JesseTG/rm@v1.0.2 - with: - path: ${{github.workspace}}/bin/ - - - name: Build godot with ECMAScript module for Android (debug) - run: | - scons p=android android_arch=armv7 tools=no target=release_debug -j8 - scons p=android android_arch=arm64v8 tools=no target=release_debug -j8 - scons p=android android_arch=x86 tools=no target=release_debug -j8 - scons p=android android_arch=x86_64 tools=no target=release_debug -j8 - cd platform/android/java - ./gradlew generateGodotTemplates - - - name: Publish artifact (debug) - uses: actions/upload-artifact@v2 - with: - name: android_debug - path: bin/ - - html5-template: - runs-on: ubuntu-latest - name: 🌐 HTML5 Template - container: - # See how this image is built at https://github.com/Flux159/godot-docker - image: flux159/godot:1.0.0 - steps: - - name: Checkout Godot - uses: actions/checkout@v2 - with: - repository: 'godotengine/godot' - ref: ${{ env.GODOT_BASE_BRANCH }} - - - name: Checkout ECMAScript - uses: actions/checkout@v2 - with: - path: ${{github.workspace}}/modules/ECMAScript/ - - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - id: html5-template-cache - uses: actions/cache@v2 - with: - path: ${{github.workspace}}/.scons_cache/ - key: ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - restore-keys: | - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}} - ${{github.job}}-${{env.BASE_BRANCH}} - - - name: Build godot with ECMAScript module for HTML5 platform - shell: bash - run: | - /emsdk/emsdk activate latest - source /emsdk/emsdk_env.sh - scons p=javascript tools=no target=release -j8 - - - name: Publish artifact (release) - uses: actions/upload-artifact@v2 - with: - name: webassembly_release - path: bin/godot.javascript.opt.zip - - # - name: Publish artifact (debug) - # uses: actions/upload-artifact@v2 - # with: - # name: webassembly_debug - # path: bin/godot.javascript.opt.debug.zip - - ios-template: - runs-on: macos-latest - name: 🍏 iOS Template - steps: - - name: Get dependencies - run: | - brew install scons yasm - - - name: Checkout Godot - uses: actions/checkout@v2 - with: - repository: 'godotengine/godot' - ref: ${{ env.GODOT_BASE_BRANCH }} - - - name: Checkout ECMAScript - uses: actions/checkout@v2 - with: - path: ${{github.workspace}}/modules/ECMAScript/ - - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - id: ios-template-cache - uses: actions/cache@v2 - with: - path: ${{github.workspace}}/.scons_cache/ - key: ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - restore-keys: | - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}} - ${{github.job}}-${{env.BASE_BRANCH}} - - - name: Build godot with ECMAScript module for iOS (release) - run: | - scons p=iphone arch=arm tools=no target=release -j8 - scons p=iphone arch=arm64 tools=no target=release -j8 - scons p=iphone arch=x86_64 tools=no target=release -j8 - lipo -create bin/libgodot.iphone.opt.arm.a bin/libgodot.iphone.opt.arm64.a bin/libgodot.iphone.opt.x86_64.a -output bin/libgodot.iphone.fat.a - lipo -create bin/libgodot_camera_module.iphone.opt.arm.a bin/libgodot_camera_module.iphone.opt.arm64.a bin/libgodot_camera_module.iphone.opt.x86_64.a -output bin/libgodot_camera_module.iphone.fat.a - lipo -create bin/libgodot_arkit_module.iphone.opt.arm.a bin/libgodot_arkit_module.iphone.opt.arm64.a bin/libgodot_arkit_module.iphone.opt.x86_64.a -output bin/libgodot_arkit_module.iphone.fat.a - - - name: Publish artifact (release) - uses: actions/upload-artifact@v2 - with: - name: iphone_release - path: bin/*.iphone.fat.a - - - name: Remove Previous Build - uses: JesseTG/rm@v1.0.2 - with: - path: ${{github.workspace}}/bin/ - - - name: Build godot with ECMAScript module for iOS (debug) - run: | - scons p=iphone arch=arm tools=no target=release_debug -j8 - scons p=iphone arch=arm64 tools=no target=release_debug -j8 - scons p=iphone arch=x86_64 tools=no target=release_debug -j8 - lipo -create bin/libgodot.iphone.opt.debug.arm.a bin/libgodot.iphone.opt.debug.arm64.a bin/libgodot.iphone.opt.debug.x86_64.a -output bin/libgodot.iphone.fat.a - lipo -create bin/libgodot_camera_module.iphone.opt.debug.arm.a bin/libgodot_camera_module.iphone.opt.debug.arm64.a bin/libgodot_camera_module.iphone.opt.debug.x86_64.a -output bin/libgodot_camera_module.iphone.fat.a - lipo -create bin/libgodot_arkit_module.iphone.opt.debug.arm.a bin/libgodot_arkit_module.iphone.opt.debug.arm64.a bin/libgodot_arkit_module.iphone.opt.debug.x86_64.a -output bin/libgodot_arkit_module.iphone.fat.a - - - name: Publish artifact (debug) - uses: actions/upload-artifact@v2 - with: - name: iphone_debug - path: bin/*.iphone.fat.a - - linux-editor: - runs-on: ubuntu-latest - name: 🐧 Linux Editor - container: - # See how this image is built at https://github.com/Flux159/godot-docker - image: flux159/godot:1.0.0 - steps: - - name: Checkout Godot - uses: actions/checkout@v2 - with: - repository: 'godotengine/godot' - ref: ${{ env.GODOT_BASE_BRANCH }} - - - name: Checkout ECMAScript - uses: actions/checkout@v2 - with: - path: ${{github.workspace}}/modules/ECMAScript/ - - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - id: linux-editor-cache - uses: actions/cache@v2 - with: - path: ${{github.workspace}}/.scons_cache/ - key: ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - restore-keys: | - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}} - ${{github.job}}-${{env.BASE_BRANCH}} - - - name: Build godot with ECMAScript module for Linux - run: | - scons p=x11 target=release_debug -j8 - strip bin/godot.x11.opt.tools.64 - - - name: Publish artifact - uses: actions/upload-artifact@v2 - with: - name: linux_x11_64_editor - path: bin/godot.x11.opt.tools.64 - - linux-template: - runs-on: ubuntu-latest - name: 🐧 Linux Template - container: - # See how this image is built at https://github.com/Flux159/godot-docker - image: flux159/godot:1.0.0 - steps: - - name: Checkout Godot - uses: actions/checkout@v2 - with: - repository: 'godotengine/godot' - ref: ${{ env.GODOT_BASE_BRANCH }} - - - name: Checkout ECMAScript - uses: actions/checkout@v2 - with: - path: ${{github.workspace}}/modules/ECMAScript/ - - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - id: linux-template-cache - uses: actions/cache@v2 - with: - path: ${{github.workspace}}/.scons_cache/ - key: ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - restore-keys: | - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}} - ${{github.job}}-${{env.BASE_BRANCH}} - - - name: Build godot with ECMAScript module for Linux - run: | - scons p=x11 bits=64 tools=no target=release -j8 - scons p=x11 bits=64 tools=no target=release_debug -j8 - strip bin/* - - - name: Publish artifact (release/64) - uses: actions/upload-artifact@v2 - with: - name: linux_x11_64_release - path: bin/godot.x11.opt.64 - - - name: Publish artifact (debug/64) - uses: actions/upload-artifact@v2 - with: - name: linux_x11_64_debug - path: bin/godot.x11.opt.debug.64 - - macos-editor: - runs-on: macos-latest - name: 🍎 macOS Editor - steps: - - name: Get dependencies - run: | - brew install scons yasm - - - name: Checkout Godot - uses: actions/checkout@v2 - with: - repository: 'godotengine/godot' - ref: ${{ env.GODOT_BASE_BRANCH }} - - - name: Checkout ECMAScript - uses: actions/checkout@v2 - with: - path: ${{github.workspace}}/modules/ECMAScript/ - - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - id: macos-editor-cache - uses: actions/cache@v2 - with: - path: ${{github.workspace}}/.scons_cache/ - key: ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - restore-keys: | - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}} - ${{github.job}}-${{env.BASE_BRANCH}} - - - name: Build godot with ECMAScript module for macOS - run: | - scons p=osx arch=x86_64 target=release_debug -j8 - strip bin/godot.osx.opt.tools.x86_64 - - - name: Publish artifact - uses: actions/upload-artifact@v2 - with: - name: osx_editor.64 - path: bin/godot.osx.opt.tools.x86_64 - - macos-template: - runs-on: macos-latest - name: 🍎 macOS Template - steps: - - name: Get dependencies - run: | - brew install scons yasm - - - name: Checkout Godot - uses: actions/checkout@v2 - with: - repository: 'godotengine/godot' - ref: ${{ env.GODOT_BASE_BRANCH }} - - - name: Checkout ECMAScript - uses: actions/checkout@v2 - with: - path: ${{github.workspace}}/modules/ECMAScript/ - - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - id: macos-template-cache - uses: actions/cache@v2 - with: - path: ${{github.workspace}}/.scons_cache/ - key: ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - restore-keys: | - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}} - ${{github.job}}-${{env.BASE_BRANCH}} - - - name: Build godot with ECMAScript module for macOS (release) - run: | - scons p=osx arch=x86_64 tools=no target=release -j8 - strip bin/godot.osx.opt.x86_64 - - - name: Publish artifact (release) - uses: actions/upload-artifact@v2 - with: - name: osx_release.64 - path: bin/godot.osx.opt.x86_64 - - - name: Build godot with ECMAScript module for macOS (debug) - run: | - scons p=osx arch=x86_64 tools=no target=release_debug -j8 - strip bin/godot.osx.opt.debug.x86_64 - - - name: Publish artifact (debug) - uses: actions/upload-artifact@v2 - with: - name: osx_debug.64 - path: bin/godot.osx.opt.debug.x86_64 - - windows-editor: - runs-on: ubuntu-latest - name: 🏁 Windows Editor - container: - # See how this image is built at https://github.com/Flux159/godot-docker - image: flux159/godot:1.0.0 - steps: - - name: Checkout Godot - uses: actions/checkout@v2 - with: - repository: 'godotengine/godot' - ref: ${{ env.GODOT_BASE_BRANCH }} - - - name: Checkout ECMAScript - uses: actions/checkout@v2 - with: - path: ${{github.workspace}}/modules/ECMAScript/ - - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - id: windows-editor-cache - uses: actions/cache@v2 - with: - path: ${{github.workspace}}/.scons_cache/ - key: ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - restore-keys: | - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}} - ${{github.job}}-${{env.BASE_BRANCH}} - - - name: Build godot with ECMAScript module for Windows - run: | - update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix - update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix - update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix - update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix - scons p=windows bits=64 target=release_debug -j8 - strip bin/godot.windows.opt.tools.64.exe - - - name: Publish artifact - uses: actions/upload-artifact@v2 - with: - name: windows_64_editor - path: bin/godot.windows.opt.tools.64.exe - - windows-template: - runs-on: ubuntu-latest - name: 🏁 Windows Template - container: - # See how this image is built at https://github.com/Flux159/godot-docker - image: flux159/godot:1.0.0 - steps: - - name: Checkout Godot - uses: actions/checkout@v2 - with: - repository: 'godotengine/godot' - ref: ${{ env.GODOT_BASE_BRANCH }} - - - name: Checkout ECMAScript - uses: actions/checkout@v2 - with: - path: ${{github.workspace}}/modules/ECMAScript/ - - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - id: windows-template-cache - uses: actions/cache@v2 - with: - path: ${{github.workspace}}/.scons_cache/ - key: ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - restore-keys: | - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - ${{github.job}}-${{env.BASE_BRANCH}}-${{github.ref}} - ${{github.job}}-${{env.BASE_BRANCH}} - - - name: Setup MinGW - run: | - update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix - update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix - update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix - update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix - - - name: Build godot with ECMAScript module for Windows (release) - run: | - scons p=windows bits=64 tools=no target=release -j8 - strip bin/godot.windows.opt.64.exe - - - name: Publish artifact (release) - uses: actions/upload-artifact@v2 - with: - name: windows_64_release - path: bin/godot.windows.opt.64.exe - - - name: Build godot with ECMAScript module for Windows (debug) - run: | - scons p=windows bits=64 tools=no target=release_debug -j8 - strip bin/godot.windows.opt.debug.64.exe - - - name: Publish artifact (debug) - uses: actions/upload-artifact@v2 - with: - name: windows_64_debug - path: bin/godot.windows.opt.debug.64.exe diff --git a/.github/workflows/ios_builds.yml b/.github/workflows/ios_builds.yml new file mode 100644 index 00000000..a6dbd71a --- /dev/null +++ b/.github/workflows/ios_builds.yml @@ -0,0 +1,41 @@ +name: 🍏 iOS Builds +'on': +- push +- pull_request +env: + GODOT_BASE_BRANCH: 3.4.4-stable + SCONSFLAGS: ' verbose=yes debug_symbols=no' +concurrency: + group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-ios + cancel-in-progress: true +jobs: + ios-template: + runs-on: macos-latest + name: Template (target=release, tools=no) + steps: + - name: Checkout Godot + uses: actions/checkout@v2 + with: + repository: godotengine/godot + ref: ${{ env.GODOT_BASE_BRANCH }} + - name: Checkout ECMAScript + uses: actions/checkout@v2 + with: + path: ${{github.workspace}}/modules/ECMAScript/ + - name: Setup Godot build cache + uses: ./.github/actions/godot-cache + continue-on-error: true + - name: Setup python and scons + uses: ./modules/ECMAScript/.github/actions/godot-deps + with: + shell: sh + - name: Compilation (armv7) + uses: ./modules/ECMAScript/.github/actions/godot-build + with: + sconsflags: ${{ env.SCONSFLAGS }} + platform: iphone + target: release + tools: false + shell: sh + - name: Upload artifact + uses: ./.github/actions/upload-artifact diff --git a/.github/workflows/javascript_builds.yml b/.github/workflows/javascript_builds.yml new file mode 100644 index 00000000..57298d69 --- /dev/null +++ b/.github/workflows/javascript_builds.yml @@ -0,0 +1,57 @@ +name: 🌐 JavaScript Builds +'on': +- push +- pull_request +env: + GODOT_BASE_BRANCH: 3.4.4-stable + SCONSFLAGS: ' verbose=yes debug_symbols=no' + EM_VERSION: 2.0.25 + EM_CACHE_FOLDER: emsdk-cache +concurrency: + group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-javascript + cancel-in-progress: true +jobs: + javascript-template: + runs-on: ubuntu-20.04 + name: Template (target=release, tools=no) + steps: + - name: Checkout Godot + uses: actions/checkout@v2 + with: + repository: godotengine/godot + ref: ${{ env.GODOT_BASE_BRANCH }} + - name: Checkout ECMAScript + uses: actions/checkout@v2 + with: + path: ${{github.workspace}}/modules/ECMAScript/ + - name: Load Emscripten cache + id: javascript-template-emscripten-cache + uses: actions/cache@v2 + with: + path: ${{env.EM_CACHE_FOLDER}} + key: ${{env.EM_VERSION}}-${{github.job}} + - name: Set up Emscripten latest + uses: mymindstorm/setup-emsdk@v10 + with: + version: ${{env.EM_VERSION}} + actions-cache-folder: ${{env.EM_CACHE_FOLDER}} + - name: Verify Emscripten setup + run: | + emcc -v + - name: Setup Godot build cache + uses: ./.github/actions/godot-cache + continue-on-error: true + - name: Setup python and scons + uses: ./modules/ECMAScript/.github/actions/godot-deps + with: + shell: sh + - name: Compilation + uses: ./modules/ECMAScript/.github/actions/godot-build + with: + sconsflags: ${{ env.SCONSFLAGS }} + platform: javascript + target: release + tools: false + shell: sh + - name: Upload artifact + uses: ./.github/actions/upload-artifact diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml new file mode 100644 index 00000000..1074d24a --- /dev/null +++ b/.github/workflows/linux_builds.yml @@ -0,0 +1,125 @@ +name: 🐧 Linux Builds +'on': +- push +- pull_request +env: + GODOT_BASE_BRANCH: 3.4.4-stable + SCONSFLAGS: ' verbose=yes ' +concurrency: + group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-linux + cancel-in-progress: true +jobs: + build-linux: + runs-on: ubuntu-20.04 + name: ${{ matrix.name }} + strategy: + fail-fast: false + matrix: + include: + - name: Editor w/ Mono (target=release_debug, tools=yes) + cache-name: linux-editor-mono + target: release_debug + tools: true + sconsflags: module_mono_enabled=yes mono_static=yes mono_glue=no + bin: ./bin/godot.x11.opt.tools.64.mono + build-mono: true + artifact: true + - name: Editor and sanitizers (target=debug, tools=yes) + cache-name: linux-editor-sanitizers + target: debug + tools: true + sconsflags: ' ' + test: true + bin: ./bin/godot.x11.tools.64s + build-mono: false + artifact: false + - name: Template w/ Mono (target=release, tools=no) + cache-name: linux-template-mono + target: release + tools: false + sconsflags: module_mono_enabled=yes mono_static=yes mono_glue=no debug_symbols=no + build-mono: false + artifact: true + steps: + - name: Checkout Godot + uses: actions/checkout@v2 + with: + repository: godotengine/godot + ref: ${{ env.GODOT_BASE_BRANCH }} + - name: Checkout ECMAScript + uses: actions/checkout@v2 + with: + path: ${{github.workspace}}/modules/ECMAScript/ + - name: Linux dependencies + shell: bash + run: | + # Azure repositories are not reliable, we need to prevent azure giving us packages. + sudo rm -f /etc/apt/sources.list.d/* + sudo cp -f misc/ci/sources.list /etc/apt/sources.list + sudo apt-get update + # The actual dependencies + sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \ + libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev \ + libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm xvfb wget unzip + - name: Setup Godot build cache + uses: ./.github/actions/godot-cache + with: + cache-name: ${{ matrix.cache-name }} + continue-on-error: true + - name: Setup python and scons + uses: ./modules/ECMAScript/.github/actions/godot-deps + with: + shell: sh + - name: Compilation + uses: ./modules/ECMAScript/.github/actions/godot-build + with: + sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} + platform: linuxbsd + target: ${{ matrix.target }} + tools: ${{ matrix.tools }} + shell: sh + - name: Generate Mono glue code + if: ${{ matrix.build-mono }} + run: | + DRI_PRIME=0 xvfb-run ${{ matrix.bin }} --generate-mono-glue modules/mono/glue || true + - name: Compilation (mono_glue=yes) + uses: ./modules/ECMAScript/.github/actions/godot-build + if: ${{ matrix.build-mono }} + with: + sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} mono_glue=yes + platform: linuxbsd + target: ${{ matrix.target }} + tools: ${{ matrix.tools }} + shell: sh + - name: Download test project + if: ${{ matrix.test }} + run: | + wget https://github.com/godotengine/regression-test-project/archive/3.4.zip + unzip 3.4.zip + mv "regression-test-project-3.4" "test_project" + - name: Open and close editor + if: ${{ matrix.test }} + run: | + DRI_PRIME=0 xvfb-run ${{ matrix.bin }} --audio-driver Dummy -e -q --path test_project 2>&1 | tee sanitizers_log.txt || true + misc/scripts/check_ci_log.py sanitizers_log.txt + - name: Run project + if: ${{ matrix.test }} + run: | + DRI_PRIME=0 xvfb-run ${{ matrix.bin }} 30 --video-driver GLES3 --audio-driver Dummy --path test_project 2>&1 | tee sanitizers_log.txt || true + misc/scripts/check_ci_log.py sanitizers_log.txt + - name: Check for class reference updates + if: ${{ matrix.test }} + run: | + echo "Running --doctool to see if this changes the public API without updating the documentation." + echo -e "If a diff is shown, it means that your code/doc changes are incomplete and you should update the class reference with --doctool.\n\n" + DRI_PRIME=0 xvfb-run ${{ matrix.bin }} --doctool . 2>&1 > /dev/null || true + git diff --color --exit-code && ! git ls-files --others --exclude-standard | sed -e 's/^/New doc file missing in PR: /' | grep 'xml$' + - name: Prepare artifact + if: ${{ matrix.artifact }} + run: | + strip bin/godot.* + - name: Upload artifact + uses: ./.github/actions/upload-artifact + if: ${{ matrix.artifact }} + with: + name: ${{ matrix.cache-name }} diff --git a/.github/workflows/macos_builds.yml b/.github/workflows/macos_builds.yml new file mode 100644 index 00000000..6bb69f3b --- /dev/null +++ b/.github/workflows/macos_builds.yml @@ -0,0 +1,58 @@ +name: 🍎 macOS Builds +'on': +- push +- pull_request +env: + GODOT_BASE_BRANCH: 3.4.4-stable + SCONSFLAGS: ' verbose=yes debug_symbols=no' +concurrency: + group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-macos + cancel-in-progress: true +jobs: + build-macos: + runs-on: macos-latest + name: ${{ matrix.name }} + strategy: + fail-fast: false + matrix: + include: + - name: Editor (target=release_debug, tools=yes) + cache-name: macos-editor + target: release_debug + tools: true + bin: ./bin/godot.osx.opt.tools.64 + - name: Template (target=release, tools=no) + cache-name: macos-template + target: release + tools: false + steps: + - name: Checkout Godot + uses: actions/checkout@v2 + with: + repository: godotengine/godot + ref: ${{ env.GODOT_BASE_BRANCH }} + - name: Checkout ECMAScript + uses: actions/checkout@v2 + with: + path: ${{github.workspace}}/modules/ECMAScript/ + - name: Setup Godot build cache + uses: ./.github/actions/godot-cache + with: + cache-name: ${{ matrix.cache-name }} + continue-on-error: true + - name: Setup python and scons + uses: ./modules/ECMAScript/.github/actions/godot-deps + with: + shell: sh + - name: Compilation + uses: ./modules/ECMAScript/.github/actions/godot-build + with: + sconsflags: ${{ env.SCONSFLAGS }} + platform: osx + target: ${{ matrix.target }} + tools: ${{ matrix.tools }} + shell: sh + - name: Upload artifact + uses: ./.github/actions/upload-artifact + with: + name: ${{ matrix.cache-name }} diff --git a/.github/workflows/on_tag.yml b/.github/workflows/on_tag.yml new file mode 100644 index 00000000..2f45a94c --- /dev/null +++ b/.github/workflows/on_tag.yml @@ -0,0 +1,73 @@ +name: 🚢 Publish release +'on': + push: + tags: + - '*' +jobs: + collect-template: + runs-on: ubuntu-latest + steps: + - name: download artifacts + uses: actions/github-script@v6 + if: startsWith(github.ref, 'refs/tags') + with: + script: |- + var total_slept = 0; + var downloaded_files = []; + var seen_completed_wfs = []; + var expected_to_see = 7; + while (total_slept < 3600000 && seen_completed_wfs.length < expected_to_see) { + var all_workflows = await github.rest.actions.listWorkflowRunsForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + }); + console.log("Expecting to download from " + expected_to_see + " workflows, currently at " + seen_completed_wfs.length + ". Have already downloaded " + downloaded_files.length + " files as " + downloaded_files); + for (const workflow of all_workflows.data.workflow_runs) { + if (workflow.head_sha == "${{ github.sha }}") { + console.log("found " + workflow.name + " " + workflow.status); + if (workflow.status == "completed") { + if (seen_completed_wfs.includes(workflow.name)) {continue;} + if (workflow.conclusion == "success") { + var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: workflow.id, + per_page: 100, + }); + for (const artifact of artifacts.data.artifacts) { + var fn = '${{github.workspace}}/' + artifact.name + '.zip'; + if (downloaded_files.includes(fn)) {continue;} + var download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: artifact.id, + archive_format: 'zip', + }); + var fs = require('fs'); + fs.writeFileSync(fn, Buffer.from(download.data)); + downloaded_files.push(fn); + } + seen_completed_wfs.push(workflow.name); + } + } + } + } + if (seen_completed_wfs.length < expected_to_see) { + console.log("sleeping " + 300000); + await new Promise(r => setTimeout(r, 300000)); + total_slept = total_slept + 300000; + console.log("done sleeping " + 300000); + } + } + console.log(downloaded_files); + - name: show dir + run: ls -R + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + if: startsWith(github.ref, 'refs/tags') + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: '*.zip' + tag: ${{ github.ref }} + overwrite: 'true' + file_glob: 'true' diff --git a/.github/workflows/server_builds.yml b/.github/workflows/server_builds.yml new file mode 100644 index 00000000..6ab71f31 --- /dev/null +++ b/.github/workflows/server_builds.yml @@ -0,0 +1,65 @@ +name: ☁ Server Builds +'on': +- push +- pull_request +env: + GODOT_BASE_BRANCH: 3.4.4-stable + SCONSFLAGS: ' verbose=yes debug_symbols=no module_mono_enabled=yes mono_static=yes + mono_glue=no' +concurrency: + group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-server + cancel-in-progress: true +jobs: + build-server: + runs-on: ubuntu-20.04 + name: ${{ matrix.name }} + strategy: + fail-fast: false + matrix: + include: + - name: Linux Headless w/ Mono (target=release_debug, tools=yes) + cache-name: server-editor-mono + target: release_debug + tools: true + - name: Linux Server w/ Mono (target=release, tools=no) + cache-name: server-template-mono + target: release + tools: false + steps: + - name: Checkout Godot + uses: actions/checkout@v2 + with: + repository: godotengine/godot + ref: ${{ env.GODOT_BASE_BRANCH }} + - name: Checkout ECMAScript + uses: actions/checkout@v2 + with: + path: ${{github.workspace}}/modules/ECMAScript/ + - name: Linux dependencies + shell: bash + run: | + # Azure repositories are not reliable, we need to prevent azure giving us packages. + sudo rm -f /etc/apt/sources.list.d/* + sudo cp -f misc/ci/sources.list /etc/apt/sources.list + sudo apt-get update + # The actual dependencies + sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \ + libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev \ + libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm xvfb wget unzip + - name: Setup Godot build cache + uses: ./.github/actions/godot-cache + with: + cache-name: ${{ matrix.cache-name }} + continue-on-error: true + - name: Setup python and scons + uses: ./modules/ECMAScript/.github/actions/godot-deps + with: + shell: sh + - name: Compilation + uses: ./modules/ECMAScript/.github/actions/godot-build + with: + sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} + platform: server + target: ${{ matrix.target }} + tools: ${{ matrix.tools }} + shell: sh diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml new file mode 100644 index 00000000..7f958358 --- /dev/null +++ b/.github/workflows/windows_builds.yml @@ -0,0 +1,74 @@ +name: 🏁 Windows Builds +'on': +- push +- pull_request +env: + GODOT_BASE_BRANCH: 3.4.4-stable + SCONSFLAGS: ' use_mingw=yes verbose=yes debug_symbols=no' + SCONS_CACHE_MSVC_CONFIG: true +concurrency: + group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-windows + cancel-in-progress: true +jobs: + build-windows: + runs-on: windows-latest + name: ${{ matrix.name }} + strategy: + fail-fast: false + matrix: + include: + - name: Editor (target=release_debug, tools=yes) + cache-name: windows-editor + target: release_debug + tools: true + bin: ./bin/godot.windows.opt.tools.64.exe + - name: Template (target=release, tools=no) + cache-name: windows-template + target: release + tools: false + steps: + - name: setup-msys2 + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + update: true + install: mingw-w64-x86_64-gcc + - name: update mingw2 + run: pacman -Syu --needed --noconfirm mingw-w64-x86_64-python3-pip mingw-w64-x86_64-gcc + mingw-w64-i686-python3-pip mingw-w64-i686-gcc make + - name: update scons + run: pip3 install scons + - name: Checkout Godot + uses: actions/checkout@v2 + with: + repository: godotengine/godot + ref: ${{ env.GODOT_BASE_BRANCH }} + - name: Checkout ECMAScript + uses: actions/checkout@v2 + with: + path: ${{github.workspace}}/modules/ECMAScript/ + - name: Setup Godot build cache + uses: ./.github/actions/godot-cache + with: + cache-name: ${{ matrix.cache-name }} + continue-on-error: true + - name: Setup python and scons + uses: ./modules/ECMAScript/.github/actions/godot-deps + with: + shell: msys2 {0} + - name: Compilation + uses: ./modules/ECMAScript/.github/actions/godot-build + with: + sconsflags: ${{ env.SCONSFLAGS }} + platform: windows + target: ${{ matrix.target }} + tools: ${{ matrix.tools }} + scons-cache-limit: 3072 + shell: msys2 {0} + - name: Upload artifact + uses: ./.github/actions/upload-artifact + with: + name: ${{ matrix.cache-name }} + defaults: + run: + shell: msys2 {0} diff --git a/README.md b/README.md index ebd65cbf..1b371556 100644 --- a/README.md +++ b/README.md @@ -261,3 +261,14 @@ export default class InputLine extends godot.HBoxContainer { ## Demo You can try demos in the [ECMAScriptDemos](https://github.com/Geequlim/ECMAScriptDemos) + +## Developer notes +* This package is not compatible with MSVC, you will get build errors in quickjs. +* To update the github actions scripts we have the file `build_github_actions.py`. This script will copy the actions from the godot repo (usually at `../../`) and modify them to fix the requirements of quickjs and this repo. +** If you are updating this repo's compatibility, you should run that script (a brief description is at the top of the script) and it will re-create the actions `.yml` files for you. +* The script also build the `on_tag.yml` script which automates the github release publishing. +** The `on_tag.yml` functionality tries to sleep until all jobs with the same `sha` are completed. It should be fine to run whenever, but depending on how github actions culls long running jobs you might want to make sure that all/(most of) the builds look good before tagging. +* Linux ubsan asan build woes: +** The godot repo has ubsan and asan builds that we can't build from. Currently we skip them (get removed via the `build_github_actions.py` script). +** They should definitely be fixed & enabled at some point, **so please submit a PR if you have any ideas of how to do that!** + diff --git a/SCsub b/SCsub index f5c932ba..b44c4cda 100644 --- a/SCsub +++ b/SCsub @@ -32,13 +32,18 @@ if JS_ENGINE == 'quickjs': import quickjs.builtin_binding_generator quickjs.builtin_binding_generator.generate_builtin_bindings() # build quickjs source - version = open('quickjs/quickjs/VERSION', 'r').read().split('\n')[0] + version = open('quickjs/quickjs/VERSION.txt', 'r').read().split('\n')[0] env_module.Append(CPPDEFINES={"QUICKJS_CONFIG_VERSION": '"'+ version +'"'}) env_module.Append(CPPDEFINES=["CONFIG_BIGNUM"]) if env_module['target'] != 'release': env_module.Append(CPPDEFINES={"DUMP_LEAKS": 1}) env_module.Append(CPPDEFINES={"QUICKJS_WITH_DEBUGGER": 1}) env_module.Append(CPPPATH=["quickjs/quickjs"]) + # env_module.Append(CXXFLAGS=["-std=c++20"]) + # env_module.Append(CCFLAGS=["-std=c++20"]) + if env['tools']: + env_module.add_source_files(env.modules_sources, 'tools/editor_tools.cpp') + env_module.add_source_files(env.modules_sources, 'quickjs/quickjs_builtin_binder.gen.cpp') env_module.add_source_files(env.modules_sources, 'quickjs/*.cpp') env_module.add_source_files(env.modules_sources, 'quickjs/quickjs/*.c') @@ -56,19 +61,22 @@ sources = [ ] if env['tools']: - with open_file("tools/godot.d.ts.gen.cpp", "w") as f: - text = '/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "editor_tools.h"\nString ECMAScriptPlugin::BUILTIN_DECLARATION_TEXT = \n${source};' - f.write(text.replace('${source}', dump_text_file_to_cpp("misc/godot.d.ts"))) - with open_file("tools/tsconfig.json.gen.cpp", "w") as f: - text = '/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "editor_tools.h"\nString ECMAScriptPlugin::TSCONFIG_CONTENT = \n${source};' - f.write(text.replace('${source}', dump_text_file_to_cpp("misc/tsconfig.json"))) - with open_file("tools/decorators.ts.gen.cpp", "w") as f: - text = '/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "editor_tools.h"\nString ECMAScriptPlugin::TS_DECORATORS_CONTENT = \n${source};' - f.write(text.replace('${source}', dump_text_file_to_cpp("misc/decorators.ts"))) - with open_file("tools/package.json.gen.cpp", "w") as f: - text = '/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "editor_tools.h"\nString ECMAScriptPlugin::PACKAGE_JSON_CONTENT = \n${source};' - f.write(text.replace('${source}', dump_text_file_to_cpp("misc/package.json"))) - env_module.add_source_files(env.modules_sources, 'tools/*.cpp') + base_text = '/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "editor_tools.h"\nString ECMAScriptPlugin::{} = \n{};' + tool_fns = {"tools/godot.d.ts.gen.cpp": ("BUILTIN_DECLARATION_TEXT", dump_text_file_to_cpp("misc/godot.d.ts")), + "tools/tsconfig.json.gen.cpp": ("TSCONFIG_CONTENT", dump_text_file_to_cpp("misc/tsconfig.json")), + "tools/decorators.ts.gen.cpp": ("TS_DECORATORS_CONTENT", dump_text_file_to_cpp("misc/decorators.ts")), + "tools/package.json.gen.cpp": ("PACKAGE_JSON_CONTENT", dump_text_file_to_cpp("misc/package.json")), + } + for fn, subs in tool_fns.items(): + with open_file(fn, "w") as fh: + fh.write(base_text.format(*subs)) + env_module.add_source_files(env.modules_sources, fn) + +if env.msvc: + # MSVC doesn't have clear C standard support, /std only covers C++. + # We apply it to CCFLAGS (both C and C++ code) in case it impacts C features. + env_module.Append(CCFLAGS=["/std:c++latest"]) + env_module.Append(CPPPATH=["#modules/ECMAScript"]) env_module.add_source_files(env.modules_sources, sources) diff --git a/build_github_actions.py b/build_github_actions.py new file mode 100644 index 00000000..a32a2a3e --- /dev/null +++ b/build_github_actions.py @@ -0,0 +1,345 @@ +#!/usr/bin/env python +""" +run this every time you upgrade the godot-base version to generate new matching github workflows +You must be in this directory, and in the modules subfolder of godot (just as if you would install this project into godot) + +usage: +python build_github_actions.py --godot-version "3.4.4-stable" --godot-github-folder ../../.github --ECMAS-github-folder .github + +""" + +import argparse +import yaml +import os +import subprocess +from dataclasses import dataclass, field +from typing import Dict, List, Any +import copy + +# https://stackoverflow.com/a/33300001 + some changes +def str_presenter(dumper, data): + if len(data.splitlines()) > 1 or "\n" in data: # check for multiline string + return dumper.represent_scalar("tag:yaml.org,2002:str", data, style="|") + return dumper.represent_scalar("tag:yaml.org,2002:str", data) + + +yaml.add_representer(str, str_presenter) + +# to use with safe_dump: +yaml.representer.SafeRepresenter.add_representer(str, str_presenter) + +# END https://stackoverflow.com/a/33300001 + + +@dataclass +class BuildOpts: + SCONSFLAGS: str + GODOT_BASE_BRANCH: str + ENV: Dict[str, str] = field(default_factory=dict) + + def add_to_flags(self, toadd: str) -> None: + if not self.SCONSFLAGS.endswith(" "): + toadd = f" {toadd}" + self.SCONSFLAGS = f"{self.SCONSFLAGS} {toadd}" + + def get_fixed_flags(self) -> str: + todel = ["warnings=all", "werror=yes"] + for x in todel: + self.SCONSFLAGS = self.SCONSFLAGS.replace(x, "") + return self.SCONSFLAGS + + +def parseargs(): + parser = argparse.ArgumentParser() + parser.add_argument("--godot-version", required=True) + parser.add_argument("--godot-github-folder", required=True) + parser.add_argument("--ECMAS-github-folder", required=True) + return parser.parse_args() + + +def checkout_local_godot_install(tag: str): + cmd = ["git", "checkout", f"tags/{tag}"] + ret = subprocess.run(cmd, cwd="../../") + if ret.returncode != 0: + raise RuntimeError(f"godot not setup properly, could not checkout '{' '.join(cmd)}'") + + +def get_windows_mingw_checkout_steps() -> List[Dict[str, Any]]: + out = [ + { + "name": "setup-msys2", + "uses": "msys2/setup-msys2@v2", + "with": {"msystem": "MINGW64", "update": True, "install": "mingw-w64-x86_64-gcc"}, + }, + { + "name": "update mingw2", + "run": "pacman -Syu --needed --noconfirm mingw-w64-x86_64-python3-pip mingw-w64-x86_64-gcc mingw-w64-i686-python3-pip mingw-w64-i686-gcc make", + }, + { + "name": "update scons", + "run": "pip3 install scons", + }, + ] + return out + + +def get_ECMAScript_checkout_steps() -> List[Dict[str, Any]]: + out = [ + { + "name": "Checkout Godot", + "uses": "actions/checkout@v2", + "with": {"repository": "godotengine/godot", "ref": "${{ env.GODOT_BASE_BRANCH }}"}, + }, + { + "name": "Checkout ECMAScript", + "uses": "actions/checkout@v2", + "with": {"path": "${{github.workspace}}/modules/ECMAScript/"}, + }, + ] + return out + + +def get_rid_of_ubsan_asan_linux(matrix_step: Dict[str, Any]) -> Dict[str, Any]: + for get_rid_of in ["use_ubsan=yes", "use_asan=yes"]: + matrix_step["name"] = matrix_step["name"].replace(get_rid_of, "").replace(" , ", " ").replace(", )", ")") + matrix_step["sconsflags"] = matrix_step["sconsflags"].replace(get_rid_of, "").replace(", )", ")") + return matrix_step + + +def fix_all_workflows( + ECMAS_github_folder: str, workflows: Dict[str, BuildOpts], wf_actions_that_require_shell: List[str] +) -> List[str]: + wf_names: List[str] = [] + for wf_base_fn, build_opts in workflows.items(): + full_fn = os.path.join(ECMAS_github_folder, "workflows", wf_base_fn) + data = yaml.safe_load(open(full_fn)) + wf_names.append(data["name"]) + + build_opts.add_to_flags(data["env"]["SCONSFLAGS"]) + data["env"]["SCONSFLAGS"] = build_opts.get_fixed_flags() + data["env"]["GODOT_BASE_BRANCH"] = build_opts.GODOT_BASE_BRANCH + for k, v in build_opts.ENV.items(): + data["env"][k] = v + + if True in data.keys(): + new_data = {"name": data["name"], "on": data[True]} + del data[True] + for k, v in data.items(): + if k in ("name", "on"): + continue + new_data[k] = v + data = new_data + assert len(data["jobs"]) == 1 + only_template_name = list(data["jobs"].keys())[0] + + new_steps = [] + if "windows" in wf_base_fn: + # quickjs can't build under msvc, must use mingw, install it here + new_steps += get_windows_mingw_checkout_steps() + data["jobs"][only_template_name]["defaults"] = {"run": {"shell": "msys2 {0}"}} + + elif "linux" in wf_base_fn: + for matrix_step in data["jobs"][only_template_name]["strategy"]["matrix"]["include"]: + # quickjs fails under ubsan & asan, don't include those flags + if "name" in matrix_step and "Editor and sanitizers" in matrix_step["name"]: + matrix_step = get_rid_of_ubsan_asan_linux(matrix_step) + + base_github_string = "./.github/" + for step in data["jobs"][only_template_name]["steps"]: + # replace godot checkout routine with this checkout routine + if "uses" in step and "checkout" in step["uses"]: + new_steps += get_ECMAScript_checkout_steps() + elif ( + "uses" in step + and base_github_string in step["uses"] + and any(x in step["uses"] for x in wf_actions_that_require_shell) + ): + step["uses"] = step["uses"].replace(base_github_string, "./modules/ECMAScript/.github/") + to_add = {"shell": "msys2 {0}" if "windows" in wf_base_fn else "sh"} + if "with" not in step: + step["with"] = to_add + else: + step["with"].update(to_add) + new_steps.append(step) + else: + new_steps.append(step) + + data["jobs"][only_template_name]["steps"] = new_steps + with open(full_fn, "w") as fh: + yaml.dump(data, fh, sort_keys=False, allow_unicode=True) + return wf_names + + +def fix_all_actions(ECMAS_github_folder: str, actions: List[str]) -> List[str]: + """ + This can be simplified once: + https://github.com/actions/runner/pull/1767 + is completed + """ + actions_that_require_shell_set = set() + for action_base_fn in actions: + full_action_fn = os.path.join(ECMAS_github_folder, action_base_fn) + data = yaml.safe_load(open(full_action_fn)) + new_steps = [] + for step in data["runs"]["steps"]: + if "shell" in step: + for shell in ["sh", "msys2 {0}"]: + cp_step = copy.deepcopy(step) + cp_step["shell"] = shell + cp_step["if"] = f"inputs.shell == '{shell}'" + new_steps.append(cp_step) + data["inputs"]["shell"] = {"description": "the shell to run this under", "default": "sh"} + actions_that_require_shell_set.add(action_base_fn) + else: + new_steps.append(step) + # new_steps.append(step) + # Uncomment this when github actions updated + # if "shell" in step: + # step["shell"] = "${{ inputs.shell }}" + # data["inputs"]["shell"] = {"description": "the shell to run this under", "default": "sh"} + # new_steps.append(step) + + # We ca + data["runs"]["steps"] = new_steps + with open(full_action_fn, "w") as fh: + yaml.dump(data, fh, sort_keys=False, allow_unicode=True) + return list(sorted([x.split("/")[1] for x in actions_that_require_shell_set])) + + +def add_publish_workflow(out_fn: str, wf_name_list: List[str]): + # "on": {"tag": "", "workflow_run": {"workflows": wf_name_list, "types": ["completed"]}}, + # run_id: ${{ github.event.workflow_run.id }}, + # var matchArtifact = artifacts.data.artifacts.filter((artifact) => { + # return artifact.name == "pr" + # })[0]; + + script_text = ( + """var total_slept = 0; +var downloaded_files = []; +var seen_completed_wfs = []; +var expected_to_see = """ + + str(len(wf_name_list)) + + """; +while (total_slept < 3600000 && seen_completed_wfs.length < expected_to_see) { + var all_workflows = await github.rest.actions.listWorkflowRunsForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + }); + console.log("Expecting to download from " + expected_to_see + " workflows, currently at " + seen_completed_wfs.length + ". Have already downloaded " + downloaded_files.length + " files as " + downloaded_files); + for (const workflow of all_workflows.data.workflow_runs) { + if (workflow.head_sha == "${{ github.sha }}") { + console.log("found " + workflow.name + " " + workflow.status); + if (workflow.status == "completed") { + if (seen_completed_wfs.includes(workflow.name)) {continue;} + if (workflow.conclusion == "success") { + var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: workflow.id, + per_page: 100, + }); + for (const artifact of artifacts.data.artifacts) { + var fn = '${{github.workspace}}/' + artifact.name + '.zip'; + if (downloaded_files.includes(fn)) {continue;} + var download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: artifact.id, + archive_format: 'zip', + }); + var fs = require('fs'); + fs.writeFileSync(fn, Buffer.from(download.data)); + downloaded_files.push(fn); + } + seen_completed_wfs.push(workflow.name); + } + } + } + } + if (seen_completed_wfs.length < expected_to_see) { + console.log("sleeping " + 300000); + await new Promise(r => setTimeout(r, 300000)); + total_slept = total_slept + 300000; + console.log("done sleeping " + 300000); + } +} +console.log(downloaded_files);""" + ) + + data = { + "name": "🚢 Publish release", + # You should tag as late as possible, don't want to sleep too long and get push job killed + "on": { + "push": {"tags": ["*"]}, + }, + "jobs": { + "collect-template": { + "runs-on": "ubuntu-latest", + "steps": [ + # {"name": "show dir", "run": "sleep 900"}, + { + "name": "download artifacts", + "uses": "actions/github-script@v6", + "if": "startsWith(github.ref, 'refs/tags')", + "with": {"script": script_text}, + }, + {"name": "show dir", "run": "ls -R"}, + { + "name": "Upload binaries to release", + "uses": "svenstaro/upload-release-action@v2", + "if": "startsWith(github.ref, 'refs/tags')", + "with": { + "repo_token": "${{ secrets.GITHUB_TOKEN }}", + "file": "*.zip", + "tag": "${{ github.ref }}", + "overwrite": "true", + "file_glob": "true", + }, + }, + ], + } + }, + } + + with open(out_fn, "w") as fh: + yaml.dump(data, fh, sort_keys=False, allow_unicode=True) + + +def main(): + args = parseargs() + assert os.path.isdir(args.godot_github_folder) + assert os.path.isdir(args.ECMAS_github_folder) + checkout_local_godot_install(args.godot_version) + + for x in ["actions", "workflows"]: + subprocess.call(["rm", "-rf", os.path.join(args.ECMAS_github_folder, x)]) + subprocess.call( + ["cp", "-r", os.path.join(args.godot_github_folder, x), os.path.join(args.ECMAS_github_folder, x)] + ) + + basic_flags = " " + actions = [ + "actions/godot-build/action.yml", + "actions/godot-cache/action.yml", + "actions/godot-deps/action.yml", + "actions/upload-artifact/action.yml", + ] + wf_actions_that_require_shell = fix_all_actions(args.ECMAS_github_folder, actions) + workflows = { + "android_builds.yml": BuildOpts(basic_flags, args.godot_version), + "ios_builds.yml": BuildOpts(basic_flags, args.godot_version), + "javascript_builds.yml": BuildOpts(basic_flags, args.godot_version), + "linux_builds.yml": BuildOpts(basic_flags, args.godot_version), + "macos_builds.yml": BuildOpts(basic_flags, args.godot_version), + "server_builds.yml": BuildOpts(basic_flags, args.godot_version), + "windows_builds.yml": BuildOpts(f"{basic_flags} use_mingw=yes", args.godot_version), + } + wf_names = fix_all_workflows(args.ECMAS_github_folder, workflows, wf_actions_that_require_shell) + subprocess.call(["rm", os.path.join(args.ECMAS_github_folder, "workflows", "static_checks.yml")]) + + out_publish_fn = os.path.join(args.ECMAS_github_folder, "workflows", "on_tag.yml") + add_publish_workflow(out_publish_fn, wf_names) + + +if __name__ == "__main__": + main() diff --git a/ecmascript.cpp b/ecmascript.cpp index 893fd874..af114dbf 100644 --- a/ecmascript.cpp +++ b/ecmascript.cpp @@ -96,7 +96,7 @@ Error ECMAScript::reload(bool p_keep_state) { if (!ecma_class) { err = ERR_PARSE_ERROR; - ERR_PRINTS(binder->error_to_string(ecma_err)); + ERR_PRINT(binder->error_to_string(ecma_err)); } else { #ifdef TOOLS_ENABLED set_last_modified_time(FileAccess::get_modified_time(script_path)); diff --git a/ecmascript.h b/ecmascript.h index 6a612500..8217031a 100644 --- a/ecmascript.h +++ b/ecmascript.h @@ -43,6 +43,7 @@ class ECMAScript : public Script { public: virtual bool can_instance() const; + virtual bool inherits_script(const Ref