From a8bdb29993c3599cf6ea6dde3695410d1aba87b8 Mon Sep 17 00:00:00 2001 From: zw7u9tru Date: Sat, 2 Apr 2022 13:36:13 -0700 Subject: [PATCH 001/132] fix build --- .github/workflows/build.yml | 519 ++++------------------- .github/workflows/tag.yml | 5 + SCsub | 27 +- ecmascript.cpp | 2 +- ecmascript.h | 1 + ecmascript_language.cpp | 19 + ecmascript_language.h | 3 +- generate_builtin_api.py | 2 +- quickjs/builtin_binding_generator.py | 14 +- quickjs/quickjs/{VERSION => VERSION.txt} | 0 quickjs/quickjs_binder.cpp | 56 ++- quickjs/quickjs_builtin_binder.cpp | 1 - quickjs/quickjs_worker.cpp | 8 +- register_types.cpp | 21 +- 14 files changed, 174 insertions(+), 504 deletions(-) create mode 100644 .github/workflows/tag.yml rename quickjs/quickjs/{VERSION => VERSION.txt} (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d677309..0d955c01 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,494 +1,141 @@ name: Build Godot with ECMAScript # TODO: Investigate making this on tag instead of push since builds take so long -on: [push] +on: [tag] # Global Cache Settings env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true - GODOT_BASE_BRANCH: '3.3-stable' + GODOT_BASE_BRANCH: '3.4-stable' BASE_BRANCH: master SCONS_CACHE_LIMIT: 4096 jobs: - android-template: + collect-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 + - name: Download artifact android_release + uses: actions/download-artifact@v3 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 + path: bin/android_release - - name: Publish artifact (debug) - uses: actions/upload-artifact@v2 + - name: Download artifacts android_debug + uses: actions/download-artifact@v3 with: name: android_debug - path: bin/ + path: bin/android_debug - 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 + - name: Download wasm artifact (release) + uses: actions/download-artifact@v3 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 + - name: Download wasm artifact (release) + uses: actions/download-artifact@v3 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: webassembly_release + path: bin/godot.javascript.opt.zip - - name: Publish artifact (release) - uses: actions/upload-artifact@v2 + - name: Download iphone artifact (release) + uses: actions/download-artifact@v3 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 + path: bin/iphone_bin_release.zip - - name: Publish artifact (debug) - uses: actions/upload-artifact@v2 + - name: Download iphone artifact (debug) + uses: actions/download-artifact@v3 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/ + path: bin/iphone_bin_debug.zip - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - id: linux-editor-cache - uses: actions/cache@v2 + - name: Download android artifact (release) + uses: actions/download-artifact@v3 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: android_release + path: bin/android_release - - name: Publish artifact - uses: actions/upload-artifact@v2 + - name: Download android artifact (debug) + uses: actions/download-artifact@v3 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: android_release + path: bin/android_release - - name: Checkout Godot - uses: actions/checkout@v2 + - name: Download win64 artifact (release) + uses: actions/download-artifact@v3 with: - repository: 'godotengine/godot' - ref: ${{ env.GODOT_BASE_BRANCH }} + name: windows_64_release + path: bin/godot.windows.opt.64.exe - - name: Checkout ECMAScript - uses: actions/checkout@v2 + - name: Download win64 artifact (debug) + uses: actions/download-artifact@v3 with: - path: ${{github.workspace}}/modules/ECMAScript/ + name: windows_64_debug + path: bin/godot.windows.opt.debug.64.exe - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - id: macos-template-cache - uses: actions/cache@v2 + - name: Download win64 editor artifact + uses: actions/download-artifact@v3 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: windows_64_editor + path: bin/godot.windows.opt.tools.64.exe - - name: Publish artifact (release) - uses: actions/upload-artifact@v2 + - name: Download osx artifact (release) + uses: actions/download-artifact@v3 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 + - name: Download osx artifact (debug) + uses: actions/download-artifact@v3 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 + - name: Download osx editor artifact + uses: actions/download-artifact@v3 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: osx_editor.64 + path: bin/godot.osx.opt.tools.x86_64 - - name: Checkout ECMAScript - uses: actions/checkout@v2 + - name: Download linux editor artifact + uses: actions/download-artifact@v3 with: - path: ${{github.workspace}}/modules/ECMAScript/ + name: linux_x11_64_editor + path: bin/godot.x11.opt.tools.64 - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - id: windows-template-cache - uses: actions/cache@v2 + - name: Download x11 artifact (release/64) + uses: actions/download-artifact@3 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: linux_x11_64_release + path: bin/godot.x11.opt.64 - - name: Publish artifact (release) - uses: actions/upload-artifact@v2 + - name: Download x11 artifact (debug/64) + uses: actions/download-artifact@v3 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: linux_x11_64_debug + path: bin/godot.x11.opt.debug.64 - - name: Publish artifact (debug) - uses: actions/upload-artifact@v2 - with: - name: windows_64_debug - path: bin/godot.windows.opt.debug.64.exe + - name: Publish release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + bin/android_release + bin/android_debug + bin/godot.javascript.opt.zip + bin/godot.javascript.opt.zip + bin/iphone_bin_release.zip + bin/iphone_bin_debug.zip + bin/android_release + bin/android_release + bin/godot.windows.opt.64.exe + bin/godot.windows.opt.debug.64.exe + bin/godot.windows.opt.tools.64.exe + bin/godot.osx.opt.x86_64 + bin/godot.osx.opt.debug.x86_64 + bin/godot.osx.opt.tools.x86_64 + bin/godot.x11.opt.64 + bin/godot.x11.opt.debug.64 + bin/godot.x11.opt.tools.64 diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 00000000..6c3ff98b --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,5 @@ + +name: Publish Godot with ECMAScript +on: [tag] + +jobs: diff --git a/SCsub b/SCsub index f5c932ba..ca8b305e 100644 --- a/SCsub +++ b/SCsub @@ -32,13 +32,14 @@ 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.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') @@ -48,6 +49,7 @@ with open("misc/godot.binding_script.gen.cpp", "w") as f: f.write(text.replace('${source}', dump_text_file_to_cpp("misc/binding_script.js"))) sources = [ + 'tools/editor_tools.cpp', 'register_types.cpp', 'ecmascript_language.cpp', 'ecmascript_instance.cpp', @@ -56,19 +58,16 @@ 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) env_module.Append(CPPPATH=["#modules/ECMAScript"]) env_module.add_source_files(env.modules_sources, sources) 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