Skip to content

Commit 7fecf15

Browse files
authored
Merge pull request #164 from nmerget/fix-gd4-rebase-2
Refactor JavaScript integration and improve code readability.
2 parents ca34e79 + 7160c86 commit 7fecf15

22 files changed

+104
-356
lines changed

.github/workflows/linux_builds.yml

Lines changed: 10 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -33,46 +33,11 @@ jobs:
3333
proj-conv: true
3434
artifact: true
3535

36-
- name: Editor with doubles and GCC sanitizers (target=editor, tests=yes, dev_build=yes, precision=double, use_asan=yes, use_ubsan=yes, linker=gold)
37-
cache-name: linux-editor-double-sanitizers
38-
target: editor
39-
tests: true
40-
# Debug symbols disabled as they're huge on this build and we hit the 14 GB limit for runners.
41-
sconsflags: dev_build=yes debug_symbols=no precision=double use_asan=yes use_ubsan=yes linker=gold
42-
proj-test: true
43-
# Can be turned off for PRs that intentionally break compat with godot-cpp,
44-
# until both the upstream PR and the matching godot-cpp changes are merged.
45-
godot-cpp-test: true
46-
bin: "./bin/godot.linuxbsd.editor.dev.double.x86_64.san"
47-
build-mono: false
48-
# Skip 2GiB artifact speeding up action.
49-
artifact: false
50-
51-
- name: Editor with clang sanitizers (target=editor, tests=yes, dev_build=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)
52-
cache-name: linux-editor-llvm-sanitizers
53-
target: editor
54-
tests: true
55-
sconsflags: dev_build=yes use_asan=yes use_ubsan=yes use_llvm=yes linker=lld
56-
bin: "./bin/godot.linuxbsd.editor.dev.x86_64.llvm.san"
57-
build-mono: false
58-
# Skip 2GiB artifact speeding up action.
59-
artifact: false
60-
61-
- name: Template w/ Mono (target=template_release)
62-
cache-name: linux-template-mono
63-
target: template_release
64-
tests: false
65-
sconsflags: module_mono_enabled=yes
66-
build-mono: false
67-
artifact: true
68-
69-
- name: Minimal template (target=template_release, everything disabled)
70-
cache-name: linux-template-minimal
71-
target: template_release
72-
tests: false
73-
sconsflags: modules_enabled_by_default=no disable_3d=yes disable_advanced_gui=yes deprecated=no minizip=no
74-
artifact: true
75-
36+
- name: Minimal template (target=template_release, everything disabled)
37+
cache-name: linux-template-minimal
38+
target: template_release
39+
tests: false
40+
sconsflags: modules_enabled_by_default=no disable_3d=yes disable_advanced_gui=yes deprecated=no
7641
steps:
7742
- name: Checkout Godot
7843
uses: actions/checkout@v2
@@ -185,40 +150,8 @@ jobs:
185150
xvfb-run ${{ matrix.bin }} 40 --audio-driver Dummy --path test_project 2>&1 | tee sanitizers_log.txt || true
186151
misc/scripts/check_ci_log.py sanitizers_log.txt
187152
188-
# Checkout godot-cpp
189-
- name: Checkout godot-cpp
190-
if: ${{ matrix.godot-cpp-test }}
191-
uses: actions/checkout@v3
192-
with:
193-
repository: godotengine/godot-cpp
194-
ref: ${{ env.GODOT_BASE_BRANCH }}
195-
submodules: 'recursive'
196-
path: 'godot-cpp'
197-
198-
# Dump GDExtension interface and API
199-
- name: Dump GDExtension interface and API for godot-cpp build
200-
if: ${{ matrix.godot-cpp-test }}
201-
run: |
202-
${{ matrix.bin }} --headless --dump-gdextension-interface --dump-extension-api
203-
cp -f gdextension_interface.h godot-cpp/gdextension/
204-
cp -f extension_api.json godot-cpp/gdextension/
205-
206-
# Build godot-cpp test extension
207-
- name: Build godot-cpp test extension
208-
if: ${{ matrix.godot-cpp-test }}
209-
run: |
210-
cd godot-cpp/test
211-
scons target=template_debug dev_build=yes
212-
cd ../..
213-
214-
- name: Prepare artifact
215-
if: ${{ matrix.artifact }}
216-
run: |
217-
strip bin/godot.*
218-
chmod +x bin/godot.*
219-
220-
- name: Upload artifact
221-
uses: ./.github/actions/upload-artifact
222-
if: ${{ matrix.artifact }}
223-
with:
224-
name: ${{ matrix.cache-name }}
153+
- name: Upload artifact
154+
uses: ./.github/actions/upload-artifact
155+
if: ${{ matrix.artifact }}
156+
with:
157+
name: ${{ matrix.cache-name }}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ You can try demos in the [ECMAScriptDemos](https://github.com/Geequlim/ECMAScrip
282282
## Developer notes
283283

284284
- This package is not compatible with MSVC, you will get build errors in quickjs.
285+
- 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.
286+
\*\* 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.
285287
- The script also build the `on_tag.yml` script which automates the github release publishing.
286288
\*\* 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.
289+
- Linux ubsan asan build woes:
290+
- 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).
287291
- They should definitely be fixed & enabled at some point, **so please submit a PR if you have any ideas of how to do that!**

SCsub

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ env_module = env_modules.Clone()
77
JS_ENGINE = "quickjs"
88
TOOLS = "editor" == env_module["target"]
99

10-
if env["platform"] == "windows":
11-
if env["use_mingw"]:
12-
env.Append(LIBS=["pthread"])
13-
1410

1511
def open_file(path, mode):
1612
if platform.python_version() > "3":
@@ -41,27 +37,20 @@ if JS_ENGINE == "quickjs":
4137

4238
thirdparty.quickjs.builtin_binding_generator.generate_builtin_bindings()
4339
version = open("thirdparty/quickjs/quickjs/VERSION.txt", "r").read().split("\n")[0]
44-
quickjs_env = env_modules.Clone()
45-
quickjs_env.Append(CPPDEFINES={"QUICKJS_CONFIG_VERSION": '"' + version + '"'})
46-
quickjs_env.Append(CPPDEFINES=["CONFIG_BIGNUM"])
47-
if "release" not in (quickjs_env["target"] or ""):
48-
quickjs_env.Append(CPPDEFINES={"DUMP_LEAKS": 1})
49-
if not env.msvc:
50-
env_module.Append(CPPDEFINES={"QUICKJS_WITH_DEBUGGER": 1})
51-
quickjs_env.Append(CPPPATH=["thirdparty/quickjs/quickjs"])
52-
quickjs_env.Append(CPPPATH=["thirdparty/quickjs"])
53-
quickjs_env.disable_warnings()
54-
quickjs_env.add_source_files(env.modules_sources, "thirdparty/quickjs/quickjs_builtin_binder.gen.cpp")
55-
quickjs_env.add_source_files(env.modules_sources, "thirdparty/quickjs/*.cpp")
56-
57-
env_thirdparty = quickjs_env.Clone()
58-
if env.msvc:
59-
env_thirdparty.AppendUnique(CCFLAGS=["/TC"])
60-
61-
# TODO: find a better way to remove /std:c++17
62-
del env_thirdparty["CCFLAGS"][0]
63-
env_thirdparty.Prepend(CCFLAGS=["/std:c11"])
64-
env_thirdparty.add_source_files(env.modules_sources, "thirdparty/quickjs/quickjs/*.c")
40+
env_module.Append(CPPDEFINES={"QUICKJS_CONFIG_VERSION": '"' + version + '"'})
41+
env_module.Append(CPPDEFINES=["CONFIG_BIGNUM"])
42+
if "release" not in (env_module["target"] or ""):
43+
env_module.Append(CPPDEFINES={"DUMP_LEAKS": 1})
44+
env_module.Append(CPPDEFINES={"QUICKJS_WITH_DEBUGGER": 1})
45+
env_module.Append(CPPPATH=["thirdparty/quickjs/quickjs"])
46+
env_module.Append(CPPPATH=["thirdparty/quickjs"])
47+
48+
if TOOLS:
49+
env_module.add_source_files(env.modules_sources, "tools/editor_tools.cpp")
50+
env_module.add_source_files(env.modules_sources, "thirdparty/quickjs/quickjs_builtin_binder.gen.cpp")
51+
env_module.add_source_files(env.modules_sources, "thirdparty/quickjs/*.cpp")
52+
env_module.add_source_files(env.modules_sources, "thirdparty/quickjs/quickjs/*.c")
53+
6554

6655
# Binding script to run at engine initializing
6756
with open("misc/godot.binding_script.gen.cpp", "w") as f:
@@ -81,19 +70,19 @@ if TOOLS:
8170
'/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "editor_tools.h"\nString JavaScriptPlugin::{} = \n{};'
8271
)
8372
tool_fns = {
84-
"editor/godot.d.ts.gen.cpp": (
73+
"tools/godot.d.ts.gen.cpp": (
8574
"BUILTIN_DECLARATION_TEXT",
8675
dump_text_file_to_cpp("misc/godot.d.ts"),
8776
),
88-
"editor/tsconfig.json.gen.cpp": (
77+
"tools/tsconfig.json.gen.cpp": (
8978
"TSCONFIG_CONTENT",
9079
dump_text_file_to_cpp("misc/tsconfig.json"),
9180
),
92-
"editor/decorators.ts.gen.cpp": (
81+
"tools/decorators.ts.gen.cpp": (
9382
"TS_DECORATORS_CONTENT",
9483
dump_text_file_to_cpp("misc/decorators.ts"),
9584
),
96-
"editor/package.json.gen.cpp": (
85+
"tools/package.json.gen.cpp": (
9786
"PACKAGE_JSON_CONTENT",
9887
dump_text_file_to_cpp("misc/package.json"),
9988
),

config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def can_build(env, platform):
2-
return not platform == "android" and not platform == "mono"
2+
return not (platform == "windows" and not env["use_mingw"])
33

44

55
def configure(env):

doc_classes/JavaScript.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<class name="JavaScript" inherits="Script" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
2+
<class name="JavaScript" inherits="Script" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
33
<brief_description>
44
A JavaScript script resource for creating and managing JavaScript scripts in Godot.
55
</brief_description>

doc_classes/JavaScriptModule.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<class name="JavaScriptModule" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
2+
<class name="JavaScriptModule" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
33
<brief_description>
44
A JavaScript module resource for managing JavaScript source code and bytecode.
55
</brief_description>

editor/editor_tools.h

Lines changed: 0 additions & 72 deletions
This file was deleted.

javascript_language.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "core/object/class_db.h"
3434

3535
#include "javascript_binder.h"
36-
#include "thirdparty/quickjs/quickjs_binder.h"
36+
#include "quickjs_binder.h"
3737

3838
JavaScriptLanguage *JavaScriptLanguage::singleton = nullptr;
3939

misc/godot.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ declare module globalThis {
5656
*
5757
* Workers run in another global context that is different from the current context.
5858
*
59-
* You can run whatever code you like inside the worker thread. All of the godot API are available inside workers.
59+
* You can run whatever code you like inside the worker thread. All of the godot API are avaliable inside workers.
6060
*
6161
* Data is sent between workers and the main thread via a system of messages — both sides send their messages using the `postMessage()` method, and respond to messages via the `onmessage` event handler (the message is contained within the Message event's data attribute.) The data is copied rather than shared.
6262
*

quickjs/quickjs_callable.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "../../quickjs_binder.h"
3333
#include "../javascript_language.h"
3434
#include "quickjs/quickjs.h"
35+
#include "../../quickjs_binder.h"
3536

3637
bool QuickJSCallable::compare_equal(const CallableCustom *p_a, const CallableCustom *p_b) {
3738
const QuickJSCallable *a = static_cast<const QuickJSCallable *>(p_a);

0 commit comments

Comments
 (0)