diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 1df6c35b..00000000 --- a/.clang-format +++ /dev/null @@ -1,199 +0,0 @@ -# Commented out parameters are those with the same value as base LLVM style. -# We can uncomment them if we want to change their value, or enforce the -# chosen value in case the base style changes (last sync: Clang 14.0). ---- -### General config, applies to all languages ### -BasedOnStyle: LLVM -AccessModifierOffset: -4 -AlignAfterOpenBracket: DontAlign -# AlignArrayOfStructures: None -# AlignConsecutiveMacros: None -# AlignConsecutiveAssignments: None -# AlignConsecutiveBitFields: None -# AlignConsecutiveDeclarations: None -# AlignEscapedNewlines: Right -AlignOperands: DontAlign -AlignTrailingComments: false -# AllowAllArgumentsOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: false -# AllowShortEnumsOnASingleLine: true -# AllowShortBlocksOnASingleLine: Never -# AllowShortCaseLabelsOnASingleLine: false -# AllowShortFunctionsOnASingleLine: All -# AllowShortLambdasOnASingleLine: All -# AllowShortIfStatementsOnASingleLine: Never -# AllowShortLoopsOnASingleLine: false -# AlwaysBreakAfterDefinitionReturnType: None -# AlwaysBreakAfterReturnType: None -# AlwaysBreakBeforeMultilineStrings: false -# AlwaysBreakTemplateDeclarations: MultiLine -# AttributeMacros: -# - __capability -# BinPackArguments: true -# BinPackParameters: true -# BraceWrapping: -# AfterCaseLabel: false -# AfterClass: false -# AfterControlStatement: Never -# AfterEnum: false -# AfterFunction: false -# AfterNamespace: false -# AfterObjCDeclaration: false -# AfterStruct: false -# AfterUnion: false -# AfterExternBlock: false -# BeforeCatch: false -# BeforeElse: false -# BeforeLambdaBody: false -# BeforeWhile: false -# IndentBraces: false -# SplitEmptyFunction: true -# SplitEmptyRecord: true -# SplitEmptyNamespace: true -# BreakBeforeBinaryOperators: None -# BreakBeforeConceptDeclarations: true -# BreakBeforeBraces: Attach -# BreakBeforeInheritanceComma: false -# BreakInheritanceList: BeforeColon -# BreakBeforeTernaryOperators: true -# BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: AfterColon -# BreakStringLiterals: true -ColumnLimit: 0 -# CommentPragmas: '^ IWYU pragma:' -# QualifierAlignment: Leave -# CompactNamespaces: false -ConstructorInitializerIndentWidth: 8 -ContinuationIndentWidth: 8 -Cpp11BracedListStyle: false -# DeriveLineEnding: true -# DerivePointerAlignment: false -# DisableFormat: false -# EmptyLineAfterAccessModifier: Never -# EmptyLineBeforeAccessModifier: LogicalBlock -# ExperimentalAutoDetectBinPacking: false -# PackConstructorInitializers: BinPack -ConstructorInitializerAllOnOneLineOrOnePerLine: true -# AllowAllConstructorInitializersOnNextLine: true -# FixNamespaceComments: true -# ForEachMacros: -# - foreach -# - Q_FOREACH -# - BOOST_FOREACH -# IfMacros: -# - KJ_IF_MAYBE -# IncludeBlocks: Preserve -IncludeCategories: - - Regex: '".*"' - Priority: 1 - - Regex: '^<.*\.h>' - Priority: 2 - - Regex: '^<.*' - Priority: 3 -# IncludeIsMainRegex: '(Test)?$' -# IncludeIsMainSourceRegex: '' -# IndentAccessModifiers: false -IndentCaseLabels: true -# IndentCaseBlocks: false -# IndentGotoLabels: true -# IndentPPDirectives: None -# IndentExternBlock: AfterExternBlock -# IndentRequires: false -IndentWidth: 4 -# IndentWrappedFunctionNames: false -# InsertTrailingCommas: None -# JavaScriptQuotes: Leave -# JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: false -# LambdaBodyIndentation: Signature -# MacroBlockBegin: '' -# MacroBlockEnd: '' -# MaxEmptyLinesToKeep: 1 -# NamespaceIndentation: None -# PenaltyBreakAssignment: 2 -# PenaltyBreakBeforeFirstCallParameter: 19 -# PenaltyBreakComment: 300 -# PenaltyBreakFirstLessLess: 120 -# PenaltyBreakOpenParenthesis: 0 -# PenaltyBreakString: 1000 -# PenaltyBreakTemplateDeclaration: 10 -# PenaltyExcessCharacter: 1000000 -# PenaltyReturnTypeOnItsOwnLine: 60 -# PenaltyIndentedWhitespace: 0 -# PointerAlignment: Right -# PPIndentWidth: -1 -# ReferenceAlignment: Pointer -# ReflowComments: true -# RemoveBracesLLVM: false -# SeparateDefinitionBlocks: Leave -# ShortNamespaceLines: 1 -# SortIncludes: CaseSensitive -# SortJavaStaticImport: Before -# SortUsingDeclarations: true -# SpaceAfterCStyleCast: false -# SpaceAfterLogicalNot: false -# SpaceAfterTemplateKeyword: true -# SpaceBeforeAssignmentOperators: true -# SpaceBeforeCaseColon: false -# SpaceBeforeCpp11BracedList: false -# SpaceBeforeCtorInitializerColon: true -# SpaceBeforeInheritanceColon: true -# SpaceBeforeParens: ControlStatements -# SpaceBeforeParensOptions: -# AfterControlStatements: true -# AfterForeachMacros: true -# AfterFunctionDefinitionName: false -# AfterFunctionDeclarationName: false -# AfterIfMacros: true -# AfterOverloadedOperator: false -# BeforeNonEmptyParentheses: false -# SpaceAroundPointerQualifiers: Default -# SpaceBeforeRangeBasedForLoopColon: true -# SpaceInEmptyBlock: false -# SpaceInEmptyParentheses: false -# SpacesBeforeTrailingComments: 1 -# SpacesInAngles: Never -# SpacesInConditionalStatement: false -# SpacesInContainerLiterals: true -# SpacesInCStyleCastParentheses: false -## Godot TODO: We'll want to use a min of 1, but we need to see how to fix -## our comment capitalization at the same time. -SpacesInLineCommentPrefix: - Minimum: 0 - Maximum: -1 -# SpacesInParentheses: false -# SpacesInSquareBrackets: false -# SpaceBeforeSquareBrackets: false -# BitFieldColonSpacing: Both -# StatementAttributeLikeMacros: -# - Q_EMIT -# StatementMacros: -# - Q_UNUSED -# - QT_REQUIRE_VERSION -TabWidth: 4 -# UseCRLF: false -UseTab: Always -# WhitespaceSensitiveMacros: -# - STRINGIZE -# - PP_STRINGIZE -# - BOOST_PP_STRINGIZE -# - NS_SWIFT_NAME -# - CF_SWIFT_NAME ---- -### C++ specific config ### -Language: Cpp -Standard: c++17 ---- -### ObjC specific config ### -Language: ObjC -# ObjCBinPackProtocolList: Auto -ObjCBlockIndentWidth: 4 -# ObjCBreakBeforeNestedBlockParam: true -# ObjCSpaceAfterProperty: false -# ObjCSpaceBeforeProtocolList: true ---- -### Java specific config ### -Language: Java -# BreakAfterJavaFieldAnnotations: false -JavaImportGroups: ['org.godotengine', 'android', 'androidx', 'com.android', 'com.google', 'java', 'javax'] -... diff --git a/.clang-tidy b/.clang-tidy deleted file mode 100644 index 659b9101..00000000 --- a/.clang-tidy +++ /dev/null @@ -1,47 +0,0 @@ ---- -Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,cppcoreguidelines-pro-type-member-init,modernize-redundant-void-arg,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-nullptr,readability-braces-around-statements,readability-redundant-member-init' -WarningsAsErrors: '' -HeaderFilterRegex: '' -AnalyzeTemporaryDtors: false -FormatStyle: none -CheckOptions: - - key: cert-dcl16-c.NewSuffixes - value: 'L;LL;LU;LLU' - - key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField - value: '0' - - key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors - value: '1' - - key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic - value: '1' - - key: cppcoreguidelines-pro-type-member-init.IgnoreArrays - value: '1' - - key: cppcoreguidelines-pro-type-member-init.UseAssignment - value: '1' - - key: google-readability-function-size.StatementThreshold - value: '800' - - key: google-readability-namespace-comments.ShortNamespaceLines - value: '10' - - key: google-readability-namespace-comments.SpacesBeforeComments - value: '2' - - key: modernize-loop-convert.MaxCopySize - value: '16' - - key: modernize-loop-convert.MinConfidence - value: reasonable - - key: modernize-loop-convert.NamingStyle - value: CamelCase - - key: modernize-pass-by-value.IncludeStyle - value: llvm - - key: modernize-replace-auto-ptr.IncludeStyle - value: llvm - - key: modernize-use-bool-literals.IgnoreMacros - value: '0' - - key: modernize-use-default-member-init.IgnoreMacros - value: '0' - - key: modernize-use-default-member-init.UseAssignment - value: '1' - - key: modernize-use-nullptr.NullMacros - value: 'NULL' - - key: readability-braces-around-statements.ShortStatementLines - value: '0' -... - diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 031582bc..00000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,180 +0,0 @@ -# Lines starting with '#' are comments. -# Each line is a file pattern followed by one or more owners. -# Owners can be @users, @org/teams or emails - -# Buildsystem - -.* @godotengine/buildsystem -.github/ @godotengine/buildsystem -*.py @godotengine/buildsystem -SConstruct @godotengine/buildsystem -SCsub @godotengine/buildsystem - -# Core - -/core/ @godotengine/core -/core/crypto/ @godotengine/network -/core/debugger/ @godotengine/debugger -/core/extension/ @godotengine/gdextension -/core/input/ @godotengine/input - -# Doc - -/doc/ @godotengine/documentation -doc_classes/* @godotengine/documentation - -# Drivers - -## Audio -/drivers/alsa/ @godotengine/audio -/drivers/alsamidi/ @godotengine/audio -/drivers/coreaudio/ @godotengine/audio -/drivers/coremidi/ @godotengine/audio -/drivers/pulseaudio/ @godotengine/audio -/drivers/wasapi/ @godotengine/audio -/drivers/winmidi/ @godotengine/audio -/drivers/xaudio2/ @godotengine/audio - -## Rendering -/drivers/dummy/ @godotengine/rendering -/drivers/gles3/ @godotengine/rendering -/drivers/spirv-reflect/ @godotengine/rendering -/drivers/vulkan/ @godotengine/rendering - -## OS -/drivers/unix/ @godotengine/_platforms -/drivers/windows/ @godotengine/windows - -## Misc -/drivers/png/ @godotengine/import - -# Editor - -/editor/*debugger* @godotengine/debugger -/editor/icons/ @godotengine/usability -/editor/import/ @godotengine/import -/editor/plugins/*2d_*.* @godotengine/2d-editor -/editor/plugins/*3d_*.* @godotengine/3d-editor -/editor/plugins/script_*.* @godotengine/script-editor -/editor/plugins/*shader*.* @godotengine/shaders -/editor/code_editor.* @godotengine/script-editor -/editor/*dock*.* @godotengine/docks -/editor/*shader*.* @godotengine/shaders - -# Main - -/main/ @godotengine/core - -# Misc - -/misc/ @godotengine/buildsystem - -# Modules - -## Audio (+ video) -/modules/minimp3/ @godotengine/audio -/modules/ogg/ @godotengine/audio -/modules/opus/ @godotengine/audio -/modules/theora/ @godotengine/audio -/modules/vorbis/ @godotengine/audio -/modules/webm/ @godotengine/audio - -## Import -/modules/basis_universal/ @godotengine/import -/modules/bmp/ @godotengine/import -/modules/cvtt/ @godotengine/import -/modules/dds/ @godotengine/import -/modules/etc/ @godotengine/import -/modules/fbx/ @godotengine/import -/modules/gltf/ @godotengine/import -/modules/hdr/ @godotengine/import -/modules/jpg/ @godotengine/import -/modules/pvr/ @godotengine/import -/modules/squish/ @godotengine/import -/modules/svg/ @godotengine/import -/modules/tga/ @godotengine/import -/modules/tinyexr/ @godotengine/import -/modules/webp/ @godotengine/import - -## Network -/modules/enet/ @godotengine/network -/modules/mbedtls/ @godotengine/network -/modules/upnp/ @godotengine/network -/modules/webrtc/ @godotengine/network -/modules/websocket/ @godotengine/network - -## Rendering -/modules/denoise/ @godotengine/rendering -/modules/glslang/ @godotengine/rendering -/modules/lightmapper_rd/ @godotengine/rendering -/modules/meshoptimizer/ @godotengine/rendering -/modules/vhacd/ @godotengine/rendering -/modules/xatlas_unwrap/ @godotengine/rendering - -## Scripting -/modules/gdscript/ @godotengine/gdscript -/modules/jsonrpc/ @godotengine/gdscript -/modules/mono/ @godotengine/dotnet - -## Text -/modules/freetype/ @godotengine/buildsystem -/modules/text_server_adv/ @godotengine/gui-nodes -/modules/text_server_fb/ @godotengine/gui-nodes - -## XR -/modules/camera/ @godotengine/xr -/modules/gdextension/xr/ @godotengine/xr -/modules/mobile_vr/ @godotengine/xr -/modules/webxr/ @godotengine/xr - -## Misc -/modules/bullet/ @godotengine/physics -/modules/csg/ @godotengine/3d-nodes -/modules/gdnavigation/ @godotengine/navigation -/modules/gridmap/ @godotengine/3d-nodes -/modules/opensimplex/ @godotengine/3d-nodes -/modules/regex/ @godotengine/core - -# Platform - -/platform/android/ @godotengine/android -/platform/ios/ @godotengine/ios -/platform/javascript/ @godotengine/html5 -/platform/linuxbsd/ @godotengine/linux-bsd -/platform/macos/ @godotengine/macos -/platform/uwp/ @godotengine/uwp -/platform/windows/ @godotengine/windows - -# Scene - -/scene/2d/ @godotengine/2d-nodes -/scene/3d/ @godotengine/3d-nodes -/scene/animation/ @godotengine/animation -/scene/audio/ @godotengine/audio -/scene/debugger/ @godotengine/debugger -/scene/gui/ @godotengine/gui-nodes -/scene/main/ @godotengine/core -/scene/resources/default_theme/ @godotengine/gui-nodes -/scene/resources/font.* @godotengine/gui-nodes -/scene/resources/text_line.* @godotengine/gui-nodes -/scene/resources/text_paragraph.* @godotengine/gui-nodes -/scene/resources/visual_shader*.* @godotengine/shaders - -# Servers - -/servers/audio* @godotengine/audio -/servers/camera* @godotengine/xr -/servers/display_server.* @godotengine/_platforms -/servers/navigation_server*.* @godotengine/navigation -/servers/physics* @godotengine/physics -/servers/rendering* @godotengine/rendering -/servers/text_server.* @godotengine/gui-nodes -/servers/xr* @godotengine/xr - -# Tests - -/tests/ @godotengine/tests - -# Thirdparty - -/thirdparty/ @godotengine/buildsystem diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 0b4abac1..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Bug report -description: Report a bug in Godot -body: - -- type: markdown - attributes: - value: | - - Read our [CONTRIBUTING.md guide](https://github.com/godotengine/godot/blob/master/CONTRIBUTING.md#reporting-bugs) on reporting bugs. - - Write a descriptive issue title above. - - Search [open](https://github.com/godotengine/godot/issues) and [closed](https://github.com/godotengine/godot/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported. - - Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/stable/about/release_policy.html). - -- type: input - attributes: - label: Godot version - description: > - Specify the Git commit hash if using a development or non-official build. - If you use a custom build, please test if your issue is reproducible in official builds too. - placeholder: 3.3.stable, 4.0.dev (3041becc6) - validations: - required: true - -- type: input - attributes: - label: System information - description: | - Specify the OS version, and when relevant hardware information. - For graphics-related issues, specify the GPU model, driver version, and the rendering backend (GLES2, GLES3, Vulkan). - placeholder: Windows 10, GLES3, Intel HD Graphics 620 (27.20.100.9616) - validations: - required: true - -- type: textarea - attributes: - label: Issue description - description: | - Describe your issue briefly. What doesn't work, and how do you expect it to work instead? - You can include images or videos with drag and drop, and format code blocks or logs with ``` tags. - validations: - required: true - -- type: textarea - attributes: - label: Steps to reproduce - description: | - List of steps or sample code that reproduces the issue. Having reproducible issues is a prerequisite for contributors to be able to solve them. - If you include a minimal reproduction project below, you can detail how to use it here. - validations: - required: true - -- type: textarea - attributes: - label: Minimal reproduction project - description: | - A small Godot project which reproduces the issue, with no unnecessary files included. Be sure to not include the `.godot` folder in the archive (but keep `project.godot`). - Required, unless the reproduction steps are trivial and don't require any project files to be followed. In this case, write "N/A" in the field. - Drag and drop a ZIP archive to upload it. **Do not select another field until the project is done uploading.** - validations: - required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index f787bec0..00000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,14 +0,0 @@ -blank_issues_enabled: false - -contact_links: - - name: Godot proposals - url: https://github.com/godotengine/godot-proposals - about: Please submit feature proposals on the Godot proposals repository, not here. - - - name: Godot documentation repository - url: https://github.com/godotengine/godot-docs - about: Please report issues with documentation on the Godot documentation repository, not here. - - - name: Godot community channels - url: https://godotengine.org/community - about: Please ask for technical support on one of the other community channels, not here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dc712c7..00000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/.github/actions/godot-build/action.yml b/.github/actions/godot-build/action.yml index 377480b1..bfb9ca15 100644 --- a/.github/actions/godot-build/action.yml +++ b/.github/actions/godot-build/action.yml @@ -2,35 +2,50 @@ name: Build Godot description: Build Godot with the provided options. inputs: target: - description: Build target (editor, template_release, template_debug). - default: "editor" + description: The scons target (debug/release_debug/release). + default: debug + tools: + description: If tools are to be built. + default: false tests: - description: Unit tests. + description: If tests are to be built. default: false platform: - description: Target platform. + description: The Godot platform to build. required: false sconsflags: - default: "" + default: '' scons-cache: description: The scons cache path. - default: "${{ github.workspace }}/.scons-cache/" + default: ${{ github.workspace }}/.scons-cache/ scons-cache-limit: description: The scons cache size limit. - # actions/cache has 10 GiB limit, and GitHub runners have a 14 GiB disk. - # Limit to 7 GiB to avoid having the extracted cache fill the disk. - default: 7168 + default: 4096 + shell: + description: the shell to run this under + default: sh runs: - using: "composite" + 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:" platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }} - if [ "${{ inputs.target }}" != "editor" ]; then rm -rf editor; fi # Ensure we don't include editor code. - scons platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }} - ls -l bin/ + - 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 index 2d7afc85..72ed281d 100644 --- a/.github/actions/godot-cache/action.yml +++ b/.github/actions/godot-cache/action.yml @@ -3,20 +3,19 @@ description: Setup Godot build cache. inputs: cache-name: description: The cache base name (job name by default). - default: "${{github.job}}" + default: ${{github.job}} scons-cache: description: The scons cache path. - default: "${{github.workspace}}/.scons-cache/" + default: ${{github.workspace}}/.scons-cache/ runs: - using: "composite" + using: composite steps: - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - uses: actions/cache@v3 - 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}} + - 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 index 38731db5..1d7347bc 100644 --- a/.github/actions/godot-deps/action.yml +++ b/.github/actions/godot-deps/action.yml @@ -3,25 +3,32 @@ description: Setup python, install the pip version of scons. inputs: python-version: description: The python version to use. - default: "3.x" + default: 3.x python-arch: description: The python architecture. - default: "x64" + default: x64 + shell: + description: the shell to run this under + default: sh runs: - using: "composite" + using: composite steps: - # Use python 3.x release (works cross platform) - - name: Set up Python 3.x - uses: actions/setup-python@v4 - with: - # Semantic version range syntax or exact version of a Python version - python-version: ${{ inputs.python-version }} - # Optional - x64 or x86 architecture, defaults to x64 - architecture: ${{ inputs.python-arch }} - - - name: Setup scons - shell: bash - run: | - python -c "import sys; print(sys.version)" - python -m pip install scons==4.4.0 - scons --version + - 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 index ae0e634c..820273b1 100644 --- a/.github/actions/upload-artifact/action.yml +++ b/.github/actions/upload-artifact/action.yml @@ -3,17 +3,17 @@ description: Upload the Godot artifact. inputs: name: description: The artifact name. - default: "${{ github.job }}" + default: ${{ github.job }} path: description: The path to upload. required: true - default: "bin/*" + default: bin/* runs: - using: "composite" + using: composite steps: - - name: Upload Godot Artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ inputs.name }} - path: ${{ inputs.path }} - retention-days: 14 + - 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 index 42125db9..de5db1b0 100644 --- a/.github/workflows/android_builds.yml +++ b/.github/workflows/android_builds.yml @@ -1,69 +1,64 @@ name: 🤖 Android Builds -on: - workflow_call: - -# Global Settings +'on': +- push +- pull_request env: - # Used for the cache key. Add version suffix to force clean build. - GODOT_BASE_BRANCH: '4.0' - SCONSFLAGS: verbose=yes warnings=extra werror=yes debug_symbols=no module_text_server_fb_enabled=yes - + GODOT_BASE_BRANCH: 3.5-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=template_release) - + 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/javascript/ - - - name: Set up Java 11 - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 11 - - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache - continue-on-error: true - - - name: Setup python and scons - uses: ./.github/actions/godot-deps - - - name: Compilation (arm32) - uses: ./.github/actions/godot-build - with: - sconsflags: ${{ env.SCONSFLAGS }} arch=arm32 - platform: android - target: template_release - tests: false - - - name: Compilation (arm64) - uses: ./.github/actions/godot-build - with: - sconsflags: ${{ env.SCONSFLAGS }} arch=arm64 - platform: android - target: template_release - tests: false - - - name: Generate Godot templates - run: | - cd platform/android/java - ./gradlew generateGodotTemplates - cd ../../.. - ls -l bin/ - - - name: Upload artifact - uses: ./.github/actions/upload-artifact + - 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/ios_builds.yml b/.github/workflows/ios_builds.yml index 78c05c78..1f117d20 100644 --- a/.github/workflows/ios_builds.yml +++ b/.github/workflows/ios_builds.yml @@ -1,48 +1,41 @@ name: 🍏 iOS Builds -on: - workflow_call: - -# Global Settings +'on': +- push +- pull_request env: - # Used for the cache key. Add version suffix to force clean build. - GODOT_BASE_BRANCH: '4.0' - SCONSFLAGS: verbose=yes warnings=extra werror=yes debug_symbols=no module_text_server_fb_enabled=yes - + GODOT_BASE_BRANCH: 3.5-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=template_release) - + 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/javascript/ - - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache - continue-on-error: true - - - name: Setup python and scons - uses: ./.github/actions/godot-deps - - - name: Compilation (arm64) - uses: ./.github/actions/godot-build - with: - sconsflags: ${{ env.SCONSFLAGS }} - platform: ios - target: template_release - tests: false - - - name: Upload artifact - uses: ./.github/actions/upload-artifact + - 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..5f1848ea --- /dev/null +++ b/.github/workflows/javascript_builds.yml @@ -0,0 +1,57 @@ +name: 🌐 JavaScript Builds +'on': +- push +- pull_request +env: + GODOT_BASE_BRANCH: 3.5-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 index d180139c..67861de0 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -1,155 +1,123 @@ name: 🐧 Linux Builds -on: - workflow_call: - -# Global Settings +'on': +- push +- pull_request env: - # Used for the cache key, and godot-cpp checkout. Add version suffix to force clean build. - GODOT_BASE_BRANCH: '4.0' - SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes - DOTNET_NOLOGO: true - DOTNET_CLI_TELEMETRY_OPTOUT: true - + GODOT_BASE_BRANCH: 3.5-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" + runs-on: ubuntu-20.04 name: ${{ matrix.name }} strategy: fail-fast: false matrix: include: - - name: Editor w/ Mono (target=editor) - cache-name: linux-editor-mono - target: editor - tests: false # Disabled due freeze caused by mix Mono build and CI - sconsflags: module_mono_enabled=yes - doc-test: true - bin: "./bin/godot.linuxbsd.editor.x86_64.mono" - build-mono: true - proj-conv: true - artifact: true - - - name: Minimal template (target=template_release, everything disabled) - cache-name: linux-template-minimal - target: template_release - tests: false - sconsflags: modules_enabled_by_default=no disable_3d=yes disable_advanced_gui=yes deprecated=no + - 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/javascript/ - - # Need newer mesa for lavapipe to work properly. - - name: Linux dependencies for tests - if: ${{ matrix.proj-test }} - run: | - sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list - sudo add-apt-repository ppa:kisak/kisak-mesa - sudo apt-get install -qq mesa-vulkan-drivers - - - 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: ./.github/actions/godot-deps - - - name: Set up .NET Sdk - uses: actions/setup-dotnet@v2 - if: ${{ matrix.build-mono }} - with: - dotnet-version: '6.0.x' - - - name: Setup GCC problem matcher - uses: ammaraskar/gcc-problem-matcher@master - - - name: Compilation - uses: ./.github/actions/godot-build - with: - sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} - platform: linuxbsd - target: ${{ matrix.target }} - tests: ${{ matrix.tests }} - - - name: Generate C# glue - if: ${{ matrix.build-mono }} - run: | - ${{ matrix.bin }} --headless --generate-mono-glue ./modules/mono/glue || true - - - name: Build .NET solutions - if: ${{ matrix.build-mono }} - run: | - ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir=./bin --godot-platform=linuxbsd - - # Execute unit tests for the editor - - name: Unit tests - if: ${{ matrix.tests }} - run: | - ${{ matrix.bin }} --version - ${{ matrix.bin }} --help - ${{ matrix.bin }} --test --headless - - # Check class reference - - name: Check for class reference updates - if: ${{ matrix.doc-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" - ${{ matrix.bin }} --doctool --headless 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$' - - # Test 3.x -> 4.x project converter - - name: Test project converter - if: ${{ matrix.proj-conv }} - run: | - mkdir converter_test - cd converter_test - touch project.godot - ../${{ matrix.bin }} --headless --validate-conversion-3to4 - cd .. - rm converter_test -rf - - # Download and extract zip archive with project, folder is renamed to be able to easy change used project - - name: Download test project - if: ${{ matrix.proj-test }} - run: | - wget https://github.com/godotengine/regression-test-project/archive/4.0.zip - unzip 4.0.zip - mv "regression-test-project-4.0" "test_project" - - # Editor is quite complicated piece of software, so it is easy to introduce bug here - - name: Open and close editor (Vulkan) - if: ${{ matrix.proj-test }} - run: | - xvfb-run ${{ matrix.bin }} --audio-driver Dummy --editor --quit --path test_project 2>&1 | tee sanitizers_log.txt || true - misc/scripts/check_ci_log.py sanitizers_log.txt - - - name: Open and close editor (GLES3) - if: ${{ matrix.proj-test }} - run: | - DRI_PRIME=0 xvfb-run ${{ matrix.bin }} --audio-driver Dummy --rendering-driver opengl3 --editor --quit --path test_project 2>&1 | tee sanitizers_log.txt || true - misc/scripts/check_ci_log.py sanitizers_log.txt - - # Run test project - - name: Run project - if: ${{ matrix.proj-test }} - run: | - xvfb-run ${{ matrix.bin }} 40 --audio-driver Dummy --path test_project 2>&1 | tee sanitizers_log.txt || true - misc/scripts/check_ci_log.py sanitizers_log.txt - + - 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 }} diff --git a/.github/workflows/macos_builds.yml b/.github/workflows/macos_builds.yml index 7cb31994..35d3ab03 100644 --- a/.github/workflows/macos_builds.yml +++ b/.github/workflows/macos_builds.yml @@ -1,84 +1,58 @@ name: 🍎 macOS Builds -on: - workflow_call: - -# Global Settings +'on': +- push +- pull_request env: - # Used for the cache key. Add version suffix to force clean build. - GODOT_BASE_BRANCH: '4.0' - SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes - + GODOT_BASE_BRANCH: 3.5-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" + runs-on: macos-latest name: ${{ matrix.name }} strategy: fail-fast: false matrix: include: - - name: Editor (target=editor, tests=yes) - cache-name: macos-editor - target: editor - tests: true - bin: "./bin/godot.macos.editor.x86_64" - - - name: Template (target=template_release) - cache-name: macos-template - target: template_release - tests: false - sconsflags: debug_symbols=no - + - 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/javascript/ - - - 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: ./.github/actions/godot-deps - - - name: Setup Vulkan SDK - run: | - sh misc/scripts/install_vulkan_sdk_macos.sh - - - name: Compilation - uses: ./.github/actions/godot-build - with: - sconsflags: ${{ env.SCONSFLAGS }} - platform: macos - target: ${{ matrix.target }} - tests: ${{ matrix.tests }} - - # Execute unit tests for the editor - - name: Unit tests - if: ${{ matrix.tests }} - run: | - ${{ matrix.bin }} --version - ${{ matrix.bin }} --help - ${{ matrix.bin }} --test - - - name: Prepare artifact - run: | - strip bin/godot.* - chmod +x bin/godot.* - - - name: Upload artifact - uses: ./.github/actions/upload-artifact - with: - name: ${{ matrix.cache-name }} + - 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..3fd76b41 --- /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 < 7200000 && 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/runner.yml b/.github/workflows/runner.yml deleted file mode 100644 index be255b54..00000000 --- a/.github/workflows/runner.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: 🔗 GHA -on: [push, pull_request] - -concurrency: - group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-runner - cancel-in-progress: true - -jobs: - static-checks: - name: 📊 Static checks - uses: ./.github/workflows/static_checks.yml - - android-build: - name: 🤖 Android - needs: static-checks - uses: ./.github/workflows/android_builds.yml - - ios-build: - name: 🍏 iOS - needs: static-checks - uses: ./.github/workflows/ios_builds.yml - - linux-build: - name: 🐧 Linux - needs: static-checks - uses: ./.github/workflows/linux_builds.yml - - macos-build: - name: 🍎 macOS - needs: static-checks - uses: ./.github/workflows/macos_builds.yml - - windows-build: - name: 🏁 Windows - needs: static-checks - uses: ./.github/workflows/windows_builds.yml - - web-build: - name: 🌐 Web - needs: static-checks - uses: ./.github/workflows/web_builds.yml diff --git a/.github/workflows/server_builds.yml b/.github/workflows/server_builds.yml new file mode 100644 index 00000000..de2dc19c --- /dev/null +++ b/.github/workflows/server_builds.yml @@ -0,0 +1,65 @@ +name: ☁ Server Builds +'on': +- push +- pull_request +env: + GODOT_BASE_BRANCH: 3.5-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/static_checks.yml b/.github/workflows/static_checks.yml deleted file mode 100644 index a004c269..00000000 --- a/.github/workflows/static_checks.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: 📊 Static Checks -on: - workflow_call: - -concurrency: - group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-static - cancel-in-progress: true - -jobs: - static-checks: - name: Code style, file formatting, and docs - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - - name: Install APT dependencies - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: dos2unix libxml2-utils moreutils - - - name: Install Python dependencies and general setup - run: | - pip3 install black==22.3.0 pytest==7.1.2 mypy==0.971 - git config diff.wsErrorHighlight all - - - name: Get changed files - id: changed-files - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - if [ "${{ github.event_name }}" == "pull_request" ]; then - files=$(gh pr diff ${{ github.event.pull_request.number }} --name-only) - elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then - files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true) - fi - echo "$files" >> changed.txt - cat changed.txt - files=$(echo "$files" | grep -v 'thirdparty' | xargs -I {} sh -c 'echo "./{}"' | tr '\n' ' ') - echo "CHANGED_FILES=$files" >> $GITHUB_ENV - - - name: File formatting checks (file_format.sh) - run: | - bash ./misc/scripts/file_format.sh changed.txt - - - name: Header guards formatting checks (header_guards.sh) - run: | - bash ./misc/scripts/header_guards.sh changed.txt - - - name: Python style checks via black (black_format.sh) - run: | - if grep -qE '\.py$|SConstruct|SCsub' changed.txt || [ -z "$(cat changed.txt)" ]; then - bash ./misc/scripts/black_format.sh - else - echo "Skipping Python formatting as no Python files were changed." - fi - - - name: Python scripts static analysis (mypy_check.sh) - run: | - if grep -qE '\.py$|SConstruct|SCsub' changed.txt || [ -z "$(cat changed.txt)" ]; then - bash ./misc/scripts/mypy_check.sh - else - echo "Skipping Python static analysis as no Python files were changed." - fi - - - name: Style checks via clang-format (clang_format.sh) - run: | - clang-format --version - bash ./misc/scripts/clang_format.sh changed.txt - - - name: Style checks via dotnet format (dotnet_format.sh) - run: | - if grep -q "modules/mono" changed.txt || [ -z "$(cat changed.txt)" ]; then - bash ./misc/scripts/dotnet_format.sh - else - echo "Skipping dotnet format as no C# files were changed." - fi - - - name: Spell checks via codespell - if: github.event_name == 'pull_request' && env.CHANGED_FILES != '' - uses: codespell-project/actions-codespell@v1 - with: - skip: "./bin,./thirdparty,*.desktop,*.gen.*,*.po,*.pot,*.rc,./AUTHORS.md,./COPYRIGHT.txt,./DONORS.md,./core/input/gamecontrollerdb.txt,./core/string/locales.h,./editor/project_converter_3_to_4.cpp,./misc/scripts/codespell.sh,./platform/android/java/lib/src/com,./platform/web/node_modules,./platform/web/package-lock.json" - ignore_words_list: "curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,nd,numer,ot,te,vai" - path: ${{ env.CHANGED_FILES }} diff --git a/.github/workflows/web_builds.yml b/.github/workflows/web_builds.yml deleted file mode 100644 index 12b32b8d..00000000 --- a/.github/workflows/web_builds.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: 🌐 Web Builds -on: - workflow_call: - -# Global Settings -env: - # Used for the cache key. Add version suffix to force clean build. - GODOT_BASE_BRANCH: '4.0' - SCONSFLAGS: verbose=yes warnings=extra werror=yes debug_symbols=no - EM_VERSION: 3.1.18 - EM_CACHE_FOLDER: "emsdk-cache" - -concurrency: - group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-web - cancel-in-progress: true - -jobs: - web-template: - runs-on: "ubuntu-20.04" - name: Template (target=template_release) - - 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/javascript/ - - - name: Set up Emscripten latest - uses: mymindstorm/setup-emsdk@v12 - 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: ./.github/actions/godot-deps - - - name: Compilation - uses: ./.github/actions/godot-build - with: - sconsflags: ${{ env.SCONSFLAGS }} - platform: web - target: template_release - tests: false - - - name: Upload artifact - uses: ./.github/actions/upload-artifact diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml index 67af76e3..642871ca 100644 --- a/.github/workflows/windows_builds.yml +++ b/.github/workflows/windows_builds.yml @@ -1,87 +1,74 @@ name: 🏁 Windows Builds -on: - workflow_call: - -# Global Settings -# SCONS_CACHE for windows must be set in the build environment +'on': +- push +- pull_request env: - # Used for the cache key. Add version suffix to force clean build. - GODOT_BASE_BRANCH: '4.0' - SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes + GODOT_BASE_BRANCH: 3.5-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: - # Windows 10 with latest image - runs-on: "windows-latest" + runs-on: windows-latest name: ${{ matrix.name }} strategy: fail-fast: false matrix: include: - - name: Editor (target=editor, tests=yes) - cache-name: windows-editor - target: editor - tests: true - # Skip debug symbols, they're way too big with MSVC. - sconsflags: debug_symbols=no vsproj=yes - bin: "./bin/godot.windows.editor.x86_64.exe" - - - name: Template (target=template_release) - cache-name: windows-template - target: template_release - tests: false - sconsflags: debug_symbols=no - + - 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: 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/javascript/ - - - 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: ./.github/actions/godot-deps - - - name: Setup MSVC problem matcher - uses: ammaraskar/msvc-problem-matcher@master - - - name: Compilation - uses: ./.github/actions/godot-build - with: - sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} - platform: windows - target: ${{ matrix.target }} - tests: ${{ matrix.tests }} - - # Execute unit tests for the editor - - name: Unit tests - if: ${{ matrix.tests }} - run: | - ${{ matrix.bin }} --version - ${{ matrix.bin }} --help - ${{ matrix.bin }} --test - - - name: Prepare artifact - run: | - Remove-Item bin/* -Include *.exp,*.lib,*.pdb -Force - - - name: Upload artifact - uses: ./.github/actions/upload-artifact - with: - name: ${{ matrix.cache-name }} + - 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/.gitignore b/.gitignore index a3c7a391..6a7d3c7d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ *.os *.gen.cpp *.gen.json -.vscode +.vscode \ No newline at end of file diff --git a/README.md b/README.md index 0af0483f..b5bd3f21 100644 --- a/README.md +++ b/README.md @@ -1,138 +1,136 @@ -# JavaScript language binding for Godot game engine +## JavaScript language binding for godot game engine -This module implements JavaScript/TypeScript language support for the Godot game engine using [QuickJS](https://bellard.org/quickjs/) as the JavaScript engine. +This module implements JavaScript/TypeScript language support for the godot game engine. [QuickJS](https://bellard.org/quickjs/) is used as the ECMAScript engine. -## Features +----- +### Features - Almost complete ES2020 support -- All Godot API available -- Operator overriding for built-in types (Vector3, Color, etc) -- TypeScript support -- [Using third-party libraries from npm](https://github.com/GodotExplorer/ECMAScriptDemos/tree/master/npm_module) +- All godot api avaliable +- Operator overriding for builtin types (Vector3, Color, etc) +- TypeScript support +- [Using thirdpart libraries from npm](https://github.com/GodotExplorer/ECMAScriptDemos/tree/master/npm_module) - Multi-thread support with Worker API -- Full code completion support for all Godot APIs including signals and enumerations +- Full code completion support for all godot APIs including signals and enumerations - Debug in Visual Studio Code with the [plugin](https://marketplace.visualstudio.com/items?itemName=geequlim.godot-javascript-debug) -## Installation - +### Installation No installation or setup necessary. The binaries for download are the complete, usable Godot editor and engine with Javascript/Typescript language support. ### Download - You can try the pre-compiled binaries from the [release page](https://github.com/GodotExplorer/ECMAScript/releases) You can also get the binaries with lastest commits from the [github build action result](https://github.com/GodotExplorer/ECMAScript/actions) -## Compilation - -1. Clone the source code of [godot](https://github.com/godotengine/godot) -2. Clone this module and put it into `godot/modules/` and make sure the folder name of this module is `javascript` -3. [Recompile the godot engine](https://docs.godotengine.org/en/3.3/development/compiling/index.html) **(Only MinGW is supported on Windows for now!)** +### Compilation +* Clone the source code of [godot](https://github.com/godotengine/godot) +* Clone this module and put it into `godot/modules/` and make sure the folder name of this module is `ECMAScript` +* [Recompile the godot engine](https://docs.godotengine.org/en/3.3/development/compiling/index.html) (Only MinGW is supported on Windows for now!) ![Build Godot with ECMAScript](https://github.com/GodotExplorer/ECMAScript/workflows/Build%20Godot%20with%20ECMAScript/badge.svg) -## Usage - -### How to export script class to Godot - -1. Define your JavaScript class and inherit from a Godot class, then export it as the **default** entry: +### Usage +##### How to export script class to godot +1. Define your ECMAScript class and inherit from a godot class then export it as the **default** entry ```js -// The default export entry is treated as an exported class to Godot +// The default export entry is treated as an exported class to godot export default class MySprite extends godot.Sprite { + // this is _init() in GDScript constructor() { super(); } - - _ready() {} - - _process(delta) {} + + _ready() { + + } + + _process(delta) { + + } } ``` - -2. Save the script with extension `.mjs` +2. Save the script with extension `.jsx` 3. Attach the script file to the node or resource object like you do with GDScript -### How to export signals +##### How to export signals ```js -export default class MySprite extends godot.Sprite {} +export default class MySprite extends godot.Sprite {}; // register game_over signal to MySprite class -godot.register_signal(MySprite, "game_over"); +godot.register_signal(MySprite, 'game_over'); ``` -### How to export properties - +##### How to export properties ```js export default class MySprite extends godot.Sprite { _process(delta) { // Yes! We can use operators in JavaScript like GDScript this.position += this.direction * delta; } -} -// export 'direction' properties to MySprite Godot inspector -godot.register_property(MySprite, "direction", new godot.Vector2(1, 0)); +}; +// export 'direction' properties to MySprite godot inspector +godot.register_property(MySprite, 'direction', new godot.Vector2(1, 0)); ``` -There are 2 ways of using the `godot.register_property`. The third parameter can either be a default value for the property you're trying to export or an object giving a more detailed description of how the editor should show it. +There are 2 ways of using the `godot.register_property`, the thrid param can either be +a default value for the property you're trying to export or an object giving a more detailed +description on how the editor should show it. ```js function register_property(target: GodotClass | godot.Object, name: string, value: any); function register_property(target: GodotClass | godot.Object, name: string, info: PropertyInfo); ``` -So calling the `register_property` like this: - +So calling the register_property like this: ```js -godot.register_property(MyClass, "number_value", 3.14); +godot.register_property(MyClass, 'number_value', 3.14); ``` Is the simplified version of: - ```js -godot.register_property(MyClass, "number_value", { +godot.register_property(MyClass, 'number_value', { type: godot.TYPE_REAL, hint: godot.PropertyHint.PROPERTY_HINT_NONE, hint_string: "", - default: 3.14, + default: 3.14 }); ``` -For more detail on how to use it, [click here](https://github.com/Geequlim/ECMAScript/issues/24#issuecomment-655584829). - -### About the API - -All of Godot's APIs are defined within the `godot` namespace. - -No API names have been renamed or changed, so you shouldn't need to change your habits. - -| GDScript | JavaScript | -| ---------------------- | ---------------------------- | -| null | null | -| int | number | -| float | number | -| String | string | -| Array | Array | -| Dictionary | Object | -| NodePath | string | -| Object | godot.Object | -| Resource | godot.Resource | -| Vector2 | godot.Vector2 | -| Color | godot.Color | -| sin(v) | godot.sin(v) | -| print(v) | godot.print(v) | -| PI | godot.PI | -| Color.black | godot.Color.black | -| Control.CursorShape | godot.Control.CursorShape | -| Label.Align.ALIGN_LEFT | godot.Label.Align.ALIGN_LEFT | - -#### API specification: - +For more detail on how to use it, [click here](https://github.com/GodotExplorer/ECMAScript/issues/24#issuecomment-655584829). + +#### About the API + +All of godots api's are defined within the `godot` namespace. + +No API names have been renamed or changed so you shouldn't need to change your habits. + +GDScript | ECMAScript +---- | --- +null | null +int | number +float | number +String | string +Array | Array +Dictionary | Object +NodePath | string +Object | godot.Object +Resource | godot.Resource +Vector2 | godot.Vector2 +Color | godot.Color +sin(v)| godot.sin(v) +print(v)| godot.print(v) +PI|godot.PI +Color.black | godot.Color.black +Control.CursorShape | godot.Control.CursorShape +Label.Align.ALIGN_LEFT | godot.Label.Align.ALIGN_LEFT + +##### API specification: - Keys of Dictionary are converted to String in JavaScript -- Signals are defined as constants to their classes - ``` - godot.Control.resized === 'resized' // true - ``` +- Signals are defined as constants to its classes + ``` + godot.Control.resized === 'resized' // true + ``` - Additional functions - `godot.register_signal(cls, signal_name)` to register signals - `godot.register_property(cls, name, default_value)` to define and export properties @@ -146,62 +144,55 @@ No API names have been renamed or changed, so you shouldn't need to change your - `require(module_id)` to load a CommonJS module or load a resource file - `$` is the alias of `Node.get_node` - Using signals in the ECMAScript way - - Allow passing functions for `godot.Object.connect`, `godot.Object.disconnect`, and `godot.Object.is_connected` - ```js - this.panel.connect(godot.Control.resized, (size) => { - console.log("The size of the panel changed to:", size); - }); - ``` - - Using `await` to wait for signals - ```js - await godot.yield( - this.get_tree().create_timer(1), - godot.SceneTreeTimer.timeout - ); - console.log("After one second to show"); - ``` + - Allow passing functions for `godot.Object.connect`, `godot.Object.disconnect` and `godot.Object.is_connected` + ```js + this.panel.connect(godot.Control.resized, (size) => { + console.log('The size of the panel changed to:', size); + }); + ``` + - Using `await` to wait signals + ```js + await godot.yield(this.get_tree().create_timer(1), godot.SceneTreeTimer.timeout); + console.log('After one second to show'); + ``` - Preload resources with ECMAScript import statement - ```js - import ICON from "res://icon.png"; - ``` + ```js + import ICON from 'res://icon.png'; + ``` - Multi-threading with minimal [Worker API](https://developer.mozilla.org/en-US/docs/Web/API/Worker) (**This is an experimental feature**) - - - Start a new thread with Worker - ```js - const worker = new Worker("worker.js"); // Run worker.js in a new thread context - worker.postMessage({ type: "load_dlc", value: "dlc01.pck" }); - worker.onmessage = function (msg) { - console.log("[MainThread] received message from worker thread:", msg); - }; - ``` - - Transfer value in different thread context with `godot.abandon_value` and `godot.adopt_value` - - ```js - // In worker thread - let id = godot.abandon_value(object); - postMessage({ type: "return_value", id: id }); - - // In the host thread - worker.onmessage = function (msg) { - if (typeof msg === "object" && msg.type === "return_value") { - let value_from_worker = godot.adopt_value(msg.id); - } - }; - ``` - -### TypeScript support - -- Run the menu command `Project > Tools > JavaScript > Generate TypeScript Project` from the Godot editor to generate a TypeScript project + - Start a new thread with Worker + ```js + const worker = new Worker('worker.js'); // Run worker.js in a new thread context + worker.postMessage({type: 'load_dlc', value: 'dlc01.pck'}); + worker.onmessage = function(msg) { + console.log("[MainThread] received message from worker thread:", msg); + } + ``` + - Transfer value in different thread context with `godot.abandon_value` and `godot.adopt_value` + ```js + // In worker thread + let id = godot.abandon_value(object); + postMessage({ type: 'return_value', id: id }); + + // In the host thread + worker.onmessage = function(msg) { + if (typeof msg === 'object' && msg.type === 'return_value') { + let value_from_worker = godot.adopt_value(msg.id); + } + } + ``` + +### TypeScript support and JSX code completion +- Run the menu command `Project > Tools > ECMAScript > Generate TypeScript Project` from the godot editor to generate a TypeScript project - Run `tsc -w -p .` under your project folder in the terminal to compile scripts #### Code completion - -- Code completion in TS will automatically work once the TypeScript project is generated by the above steps. -- Code completion in VSCode is achieved by the property `"types": "./godot.d.ts"` in the generated package.json file of the TypeScript project. The `godot.d.ts` file can be generated alone via the `Project > Tools > ECMAScript > Generate TypeScript Declaration File` editor menu option and added to a `package.json` file manually to achieve this without a full TypeScript project. +- Code completion in TSX will automatically work once the TypeScript project is generated by the above steps. +- Code completion in JSX in VS Code is achieved by the property `"types": "./godot.d.ts"` in the generated package.json file of the TypeScript project. The `godot.d.ts` file can be generated alone via the `Project > Tools > ECMAScript > Generate TypeScript Declaration File` editor menu option and added to a `package.json` file manually to achieve this without a full TypeScript project. #### Example TypeScript Usage -Compile your `ts` script to a `.mjs` file then we can attach it to a node in godot editor. +Make sure the file with extension '.tsx' so it can be compiled to a `.jsx` file then we can attach it to a node in godot editor. Most of the `register` functions are available as various decorators as seen below. @@ -210,6 +201,7 @@ import { signal, property, tool, onready, node } from "./decorators"; @tool // make the script runnable in godot editor export default class InputLine extends godot.HBoxContainer { + // define a signal @signal static readonly OnTextChanged: string; @@ -221,12 +213,10 @@ export default class InputLine extends godot.HBoxContainer { // register offset property with the godot inspector with default value of Vector2(0, 0) @property({ default: godot.Vector2.ZERO }) offset: godot.Vector2; - + // register properties for godot editor inspector @property({ type: godot.VariantType.TYPE_STRING }) - get title() { - return this._title; - } + get title() { return this._title; } set title(v: string) { this._title = v; if (this._label) { @@ -236,9 +226,7 @@ export default class InputLine extends godot.HBoxContainer { private _title: string; @property({ default: "Input text here" }) - get hint() { - return this._hint; - } + get hint() { return this._hint; } set hint(v: string) { this._hint = v; if (this.edit) { @@ -248,13 +236,11 @@ export default class InputLine extends godot.HBoxContainer { } private _hint: string; - get label(): godot.Label { - return this._label; - } + get label(): godot.Label { return this._label; } protected _label: godot.Label; // call get_node('LineEdit') and assign the returned value to 'this.edit' automatically when the node is ready - @onready("LineEdit") + @onready('LineEdit') edit: godot.LineEdit; get text(): string { @@ -264,12 +250,12 @@ export default class InputLine extends godot.HBoxContainer { _ready() { // get first child with the type of godot.Label this._label = this.get_node(godot.Label); - + // Apply the inspector filled values with property setters this.title = this.title; this.hint = this.hint; - this.edit.connect(godot.LineEdit.text_changed, (text: string) => { + this.edit.connect(godot.LineEdit.text_changed, (text: string)=>{ this.emit_signal(InputLine.OnTextChanged, text); }); } @@ -277,16 +263,15 @@ 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!** -- 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 1efe9a28..b0afd308 100644 --- a/SCsub +++ b/SCsub @@ -1,100 +1,77 @@ #!/usr/bin/env python import platform, os, sys -Import("env") -Import("env_modules") +Import('env') +Import('env_modules') env_module = env_modules.Clone() -JS_ENGINE = "quickjs" -TOOLS = "editor" == env_module["target"] - +JS_ENGINE = 'quickjs' def open_file(path, mode): - if platform.python_version() > "3": - return open(path, mode, encoding="utf8") - else: - return open(path, mode) - + if platform.python_version() > '3': + return open(path, mode, encoding='utf8') + else: + return open(path, mode) def dump_text_file_to_cpp(file): - source = open_file(file, "r").read() - lines = source.split("\n") - source = "" - length = len(lines) - for i in range(length): - line = lines[i].replace('"', '\\"') - line = '\t"' + line + '\\n"' - if i < length - 1: - line += "\n" - source += line - return source - - -if JS_ENGINE == "quickjs": - import generate_builtin_api - - generate_builtin_api.generate_api_json(os.path.join(GetLaunchDir(), "modules", os.path.basename(os.getcwd()))) - import thirdparty.quickjs.builtin_binding_generator - - thirdparty.quickjs.builtin_binding_generator.generate_builtin_bindings() - version = open("thirdparty/quickjs/quickjs/VERSION.txt", "r").read().split("\n")[0] - env_module.Append(CPPDEFINES={"QUICKJS_CONFIG_VERSION": '"' + version + '"'}) - env_module.Append(CPPDEFINES=["CONFIG_BIGNUM"]) - if "release" not in (env_module["target"] or ""): - env_module.Append(CPPDEFINES={"DUMP_LEAKS": 1}) - env_module.Append(CPPDEFINES={"QUICKJS_WITH_DEBUGGER": 1}) - env_module.Append(CPPPATH=["thirdparty/quickjs/quickjs"]) - env_module.Append(CPPPATH=["thirdparty/quickjs"]) - - if TOOLS: - env_module.add_source_files(env.modules_sources, "tools/editor_tools.cpp") - env_module.add_source_files(env.modules_sources, "thirdparty/quickjs/quickjs_builtin_binder.gen.cpp") - env_module.add_source_files(env.modules_sources, "thirdparty/quickjs/*.cpp") - env_module.add_source_files(env.modules_sources, "thirdparty/quickjs/quickjs/*.c") - + source = open_file(file, 'r').read() + lines = source.split('\n') + source = "" + length = len(lines) + for i in range(length): + line = lines[i].replace('"', '\\"') + line = '\t"' + line + '\\n"' + if i < length -1: + line += "\n" + source += line + return source + +if JS_ENGINE == 'quickjs': + # generate builtin binding code + import generate_builtin_api + generate_builtin_api.generate_api_json(os.path.join(GetLaunchDir(), "modules", os.path.basename(os.getcwd()))) + import quickjs.builtin_binding_generator + quickjs.builtin_binding_generator.generate_builtin_bindings() + # build quickjs source + 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') # Binding script to run at engine initializing with open("misc/godot.binding_script.gen.cpp", "w") as f: - text = '/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "../javascript_binder.h"\nString JavaScriptBinder::BINDING_SCRIPT_CONTENT = \n${source};' - f.write(text.replace("${source}", dump_text_file_to_cpp("misc/binding_script.js"))) + text = '/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "../ecmascript_binder.h"\nString ECMAScriptBinder::BINDING_SCRIPT_CONTENT = \n${source};' + f.write(text.replace('${source}', dump_text_file_to_cpp("misc/binding_script.js"))) sources = [ - "register_types.cpp", - "javascript_language.cpp", - "javascript_instance.cpp", - "javascript.cpp", - "misc/godot.binding_script.gen.cpp", + 'register_types.cpp', + 'ecmascript_language.cpp', + 'ecmascript_instance.cpp', + 'ecmascript.cpp', + 'misc/godot.binding_script.gen.cpp', ] -if TOOLS: - base_text = ( - '/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "editor_tools.h"\nString JavaScriptPlugin::{} = \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['tools']: + 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/javascript"]) +env_module.Append(CPPPATH=["#modules/ECMAScript"]) env_module.add_source_files(env.modules_sources, sources) - -if env.editor_build: - env_module.add_source_files(env.modules_sources, "editor/*.cpp") diff --git a/build_github_actions.py b/build_github_actions.py new file mode 100644 index 00000000..6f610467 --- /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.5-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/config.py b/config.py index 951e814f..53bc8270 100644 --- a/config.py +++ b/config.py @@ -1,17 +1,5 @@ def can_build(env, platform): - return not (platform == "windows" and not env["use_mingw"]) - + return True def configure(env): - pass - - -def get_doc_classes(): - return [ - "JavaScript", - "JavaScriptModule", - ] - - -def get_doc_path(): - return "doc_classes" + pass diff --git a/doc/class.xsd b/doc/class.xsd deleted file mode 100644 index 22821ac7..00000000 --- a/doc/class.xsd +++ /dev/null @@ -1,278 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc_classes/JavaScript.xml b/doc_classes/JavaScript.xml deleted file mode 100644 index ca3f4659..00000000 --- a/doc_classes/JavaScript.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - A JavaScript script resource for creating and managing JavaScript scripts in Godot. - - - The JavaScript class provides a way to create and manage JavaScript scripts within the Godot game engine. It inherits from the Script class and allows you to write game logic using JavaScript as the scripting language. - - - - diff --git a/doc_classes/JavaScriptModule.xml b/doc_classes/JavaScriptModule.xml deleted file mode 100644 index c9f1c7f9..00000000 --- a/doc_classes/JavaScriptModule.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - A JavaScript module resource for managing JavaScript source code and bytecode. - - - The JavaScriptModule class provides methods to manage JavaScript source code and bytecode. It allows you to get and set both the source code and bytecode of a JavaScript module. - - - - - - - - Returns the bytecode of the JavaScript module as a PackedByteArray. - - - - - - Returns the source code of the JavaScript module as a String. - - - - - - - Sets the bytecode of the JavaScript module using a PackedByteArray. - - - - - - - Sets the source code of the JavaScript module using a String. - - - - - - The path to the JavaScript script file. - - - diff --git a/ecmascript.cpp b/ecmascript.cpp new file mode 100644 index 00000000..af114dbf --- /dev/null +++ b/ecmascript.cpp @@ -0,0 +1,429 @@ +#include "ecmascript.h" +#include "core/engine.h" +#include "core/io/file_access_encrypted.h" +#include "ecmascript_instance.h" +#include "ecmascript_language.h" +#include "scene/resources/resource_format_text.h" + +ScriptLanguage *ECMAScript::get_language() const { + return ECMAScriptLanguage::get_singleton(); +} + +ECMAScript::ECMAScript() { +} + +ECMAScript::~ECMAScript() { +} + +bool ECMAScript::can_instance() const { + +#ifdef TOOLS_ENABLED + return is_valid() && (is_tool() || ScriptServer::is_scripting_enabled()); +#else + return is_valid(); +#endif +} + +StringName ECMAScript::get_instance_base_type() const { + static StringName empty; + ERR_FAIL_NULL_V(ecma_class, empty); + ERR_FAIL_NULL_V(ecma_class->native_class, empty); + return ecma_class->native_class->name; +} + +ScriptInstance *ECMAScript::instance_create(Object *p_this) { + + ECMAScriptBinder *binder = ECMAScriptLanguage::get_thread_binder(Thread::get_caller_id()); + ERR_FAIL_NULL_V_MSG(binder, NULL, "Cannot create instance from this thread"); + const ECMAClassInfo *cls = NULL; + ECMAscriptScriptError ecma_err; + if (!bytecode.empty()) { + cls = binder->parse_ecma_class(bytecode, script_path, false, &ecma_err); + } else { + cls = binder->parse_ecma_class(code, script_path, false, &ecma_err); + } + ERR_FAIL_NULL_V_MSG(cls, NULL, vformat("Cannot parse class from %s", get_script_path())); + + if (!ClassDB::is_parent_class(p_this->get_class_name(), cls->native_class->name)) { + ERR_FAIL_V_MSG(NULL, vformat("Script inherits from native type '%s', so it can't be instanced in object of type: '%s'", cls->native_class->name, p_this->get_class())); + } + + ECMAScriptGCHandler ecma_instance = binder->create_ecma_instance_for_godot_object(cls, p_this); + ERR_FAIL_NULL_V(ecma_instance.ecma_object, NULL); + + ECMAScriptInstance *instance = memnew(ECMAScriptInstance); + instance->script = Ref(this); + instance->owner = p_this; + instance->binder = binder; + instance->ecma_object = ecma_instance; + instance->ecma_class = cls; + instance->owner->set_script_instance(instance); + instances.insert(p_this); + return instance; +} + +PlaceHolderScriptInstance *ECMAScript::placeholder_instance_create(Object *p_this) { +#ifdef TOOLS_ENABLED + PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(ECMAScriptLanguage::get_singleton(), Ref