Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
5fd05b6
Starting port to godot 4.0
Geequlim Aug 22, 2022
254fe19
Fix compile error for godot 4.0
Geequlim Aug 23, 2022
56016ee
Fix reference object constructor
Geequlim Aug 24, 2022
bb7a344
Improve RefCounted binding
Geequlim Aug 25, 2022
39421ba
Rename ECMAScript to JavaScript for godot 4
Geequlim Sep 2, 2022
98f6b3b
Fix compile error with non-editor build
Geequlim Sep 2, 2022
7c68bbe
Implement JavaScriptCallable for Signal & slot
Geequlim Sep 9, 2022
fbc40b6
Implement script workflow
Geequlim Sep 23, 2022
19b54c1
fix typo
Geequlim Sep 23, 2022
c21426e
[FIX] Failsafe env["TOOLS"] variable getter
why-try313 Feb 21, 2023
3314963
[FIX] Fixed missing comma
why-try313 Feb 21, 2023
1216d8d
[FIX] Adds GDNative to GDExtension migration changes
why-try313 Feb 21, 2023
9b16953
[FIX] Adds missing get_global_name method
why-try313 Feb 21, 2023
5cc9c4c
Merge pull request #148 from why-try313/gd4
Geequlim Mar 9, 2023
6bcd1fa
Updated JavaScript modules for Godot 4.0 branch
animanmaster Mar 15, 2023
2c325ea
Merge pull request #150 from V-Sekai/gd4
Geequlim Apr 23, 2023
783517a
Update README.md
ogrotten Oct 21, 2022
01457b9
Fix Godot 4.0 compile errors, update JavaScript integration, refactor…
fire Apr 23, 2023
398a108
Update generate_builtin_api.py, javascript.cpp, javascript.h, and 13 …
fire Jun 15, 2023
847fe10
Remove build_github_actions.py
fire Jun 15, 2023
caa8840
Update godot-javascript to better pass tests.
fire Jun 15, 2023
3f6a3b4
Remove pthread library and run format.
fire Jun 15, 2023
e547560
Format binding generator.
fire Jun 15, 2023
7655597
Apply formatting.
fire Jun 15, 2023
53f4051
Apply python formatting.
fire Jun 15, 2023
bcaa414
Add a condition to avoid building javascript on msvc.
fire Jun 15, 2023
e3e97ba
Disable unit tests.
fire Jun 15, 2023
4dad363
Remove c++ version check.
fire Jun 15, 2023
537e2b4
Avoid extras.
fire Jun 15, 2023
5261a4f
Only build windows and linux.
fire Jun 15, 2023
1c75361
Move versions back to 4.0.
fire Jun 18, 2023
9dabb22
Fix error in includes.
fire Jun 18, 2023
b87a29e
git subrepo pull (merge) modules/javascript
fire Jun 18, 2023
f430ed2
Handle cases that aren't supported.
fire Jun 18, 2023
f6687c5
git subrepo pull (merge) modules/javascript
fire Jun 18, 2023
245f8d0
Update scons.
fire Jun 18, 2023
166c796
Force a tag.
fire Jun 19, 2023
087e244
git subrepo pull (merge) modules/javascript
fire Jun 19, 2023
17caa75
Switch to match master.
fire Jun 19, 2023
23ba457
Update build scripts.
fire Jun 19, 2023
0919fc3
Add pthread for mingw.
fire Jun 19, 2023
78dbf97
If use mingw, use pthread.
fire Jun 19, 2023
eca30e6
Restore file format.
fire Jun 19, 2023
a91c1f4
Restore header guards too.
fire Jun 19, 2023
fdd5180
Fix include guards style.
fire Jun 19, 2023
8d976e4
Restore black format.
fire Jun 19, 2023
f4bc581
Restore all the scripts.
fire Jun 19, 2023
48305ba
Add python build.
fire Jun 19, 2023
01abd78
Remove python tests.
fire Jun 19, 2023
f648c5b
Disabled a few builds.
fire Jun 19, 2023
5b66370
feat: add icons
jaune Aug 19, 2023
2911768
Revert "Disabled a few builds."
fire Jun 19, 2023
d3ebf68
Update XML file paths for JavaScript and JavaScriptModule classes
fire Aug 20, 2023
007e94a
Refactor JavaScript bindings and fix file paths
fire Aug 20, 2023
dfbdf57
Format SCsub.
fire Aug 20, 2023
0fe880e
Update the readme.
fire Aug 20, 2023
1bb9edf
Format black_format.sh and SCsub scripts
fire Aug 20, 2023
0b9283b
Add XML schema for class documentation
fire Aug 20, 2023
5fd3ce9
Refactor static checks workflow
fire Aug 20, 2023
d5a9cf7
Refactor static checks workflow
fire Aug 20, 2023
6177b3e
Add .clang-format and .clang-tidy configuration files
fire Aug 24, 2023
94d95b5
Apply formatting.
fire Aug 24, 2023
76692da
Apply whitespace change.
fire Aug 24, 2023
3863950
Run spell checker.
fire Aug 24, 2023
ec74bb0
Refactor platform condition in config.py
fire Aug 24, 2023
5bf37c6
Remove JavaScript style checks
fire Aug 24, 2023
71c6704
Update JSValue typedef in quickjs.h to avoid error.
fire Aug 24, 2023
8d86711
Support MSVC builds without error in Github Actions.
fire Aug 24, 2023
221e358
Fix function name and use safer string formatting in JavaScript module
fire Aug 24, 2023
d487bcf
Format python files for automated tests.
fire Aug 24, 2023
b2cacc0
Fix gitub actions tests.
fire Aug 24, 2023
c2533ae
Fix tests.
fire Aug 24, 2023
60db283
Try to pass tests.
fire Aug 24, 2023
45ca44b
Exclude mono platform
fire Aug 24, 2023
483c70d
Apply xml docs fixes for tests.
fire Aug 24, 2023
ca34e79
Merge pull request #160 from jaune/gd4-icons
fire Aug 31, 2023
7160c86
Refactor JavaScript integration and improve code readability.
fire Oct 1, 2023
7fecf15
Merge pull request #164 from nmerget/fix-gd4-rebase-2
fire Oct 1, 2023
b23b482
Merge pull request #156 from Geequlim/gd4-rebase
fire Oct 1, 2023
dc296d9
Merge branch 'master' into 4.1
fire Oct 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename ECMAScript to JavaScript for godot 4
  • Loading branch information
Geequlim committed Sep 2, 2022
commit 39421baee3340fdf3002cdebd89d6275eff7d4fd
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## JavaScript language binding for godot game engine

This module implements JavaScript/TypeScript language support for the godot game engine. [QuickJS](https://bellard.org/quickjs/) is used as the ECMAScript engine.
This module implements JavaScript/TypeScript language support for the godot game engine. [QuickJS](https://bellard.org/quickjs/) is used as the JavaScript engine.

-----

Expand All @@ -20,15 +20,15 @@ You can also get the binaries with lastest commits from the [github build action

### 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`
* Clone this module and put it into `godot/modules/` and make sure the folder name of this module is `javascript`
* [Recompile the godot engine](https://docs.godotengine.org/en/3.3/development/compiling/index.html) <b>(Only MinGW is supported on Windows for now!)</b>

![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 ECMAScript class and inherit from a godot class then export it as the **default** entry
1. Define your JavaScript 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
export default class MySprite extends godot.Sprite {
Expand Down Expand Up @@ -94,15 +94,15 @@ godot.register_property(MyClass, 'number_value', {
});
```

For more detail on how to use it, [click here](https://github.com/GodotExplorer/ECMAScript/issues/24#issuecomment-655584829).
For more detail on how to use it, [click here](https://github.com/Geequlim/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
GDScript | JavaScript
---- | ---
null | null
int | number
Expand Down Expand Up @@ -180,7 +180,7 @@ Label.Align.ALIGN_LEFT | godot.Label.Align.ALIGN_LEFT
```

### 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 the menu command `Project > Tools > JavaScript > 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
Expand Down Expand Up @@ -269,6 +269,6 @@ You can try demos in the [ECMAScriptDemos](https://github.com/Geequlim/ECMAScrip
* 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!**
* 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!**

12 changes: 6 additions & 6 deletions SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ if JS_ENGINE == 'quickjs':

# 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 "../ecmascript_binder.h"\nString ECMAScriptBinder::BINDING_SCRIPT_CONTENT = \n${source};'
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")))

sources = [
'register_types.cpp',
'ecmascript_language.cpp',
'ecmascript_instance.cpp',
'ecmascript.cpp',
'javascript_language.cpp',
'javascript_instance.cpp',
'javascript.cpp',
'misc/godot.binding_script.gen.cpp',
]

if env['tools']:
base_text = '/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "editor_tools.h"\nString ECMAScriptPlugin::{} = \n{};'
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")),
Expand All @@ -73,5 +73,5 @@ if env['tools']:
env_module.add_source_files(env.modules_sources, fn)


env_module.Append(CPPPATH=["#modules/ECMAScript"])
env_module.Append(CPPPATH=["#modules/javascript"])
env_module.add_source_files(env.modules_sources, sources)
36 changes: 18 additions & 18 deletions build_github_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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
python build_github_actions.py --godot-version "3.5-stable" --godot-github-folder ../../.github --js-github-folder .github

"""

Expand Down Expand Up @@ -53,7 +53,7 @@ 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)
parser.add_argument("--js-github-folder", required=True)
return parser.parse_args()


Expand Down Expand Up @@ -83,17 +83,17 @@ def get_windows_mingw_checkout_steps() -> List[Dict[str, Any]]:
return out


def get_ECMAScript_checkout_steps() -> List[Dict[str, Any]]:
def get_js_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",
"name": "Checkout javascript",
"uses": "actions/checkout@v2",
"with": {"path": "${{github.workspace}}/modules/ECMAScript/"},
"with": {"path": "${{github.workspace}}/modules/javascript/"},
},
]
return out
Expand All @@ -107,11 +107,11 @@ def get_rid_of_ubsan_asan_linux(matrix_step: Dict[str, Any]) -> Dict[str, Any]:


def fix_all_workflows(
ECMAS_github_folder: str, workflows: Dict[str, BuildOpts], wf_actions_that_require_shell: List[str]
js_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)
full_fn = os.path.join(js_github_folder, "workflows", wf_base_fn)
data = yaml.safe_load(open(full_fn))
wf_names.append(data["name"])

Expand Down Expand Up @@ -148,13 +148,13 @@ def fix_all_workflows(
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()
new_steps += get_js_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/")
step["uses"] = step["uses"].replace(base_github_string, "./modules/javascript/.github/")
to_add = {"shell": "msys2 {0}" if "windows" in wf_base_fn else "sh"}
if "with" not in step:
step["with"] = to_add
Expand All @@ -170,15 +170,15 @@ def fix_all_workflows(
return wf_names


def fix_all_actions(ECMAS_github_folder: str, actions: List[str]) -> List[str]:
def fix_all_actions(js_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)
full_action_fn = os.path.join(js_github_folder, action_base_fn)
data = yaml.safe_load(open(full_action_fn))
new_steps = []
for step in data["runs"]["steps"]:
Expand Down Expand Up @@ -308,13 +308,13 @@ def add_publish_workflow(out_fn: str, wf_name_list: List[str]):
def main():
args = parseargs()
assert os.path.isdir(args.godot_github_folder)
assert os.path.isdir(args.ECMAS_github_folder)
assert os.path.isdir(args.js_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(["rm", "-rf", os.path.join(args.js_github_folder, x)])
subprocess.call(
["cp", "-r", os.path.join(args.godot_github_folder, x), os.path.join(args.ECMAS_github_folder, x)]
["cp", "-r", os.path.join(args.godot_github_folder, x), os.path.join(args.js_github_folder, x)]
)

basic_flags = " "
Expand All @@ -324,7 +324,7 @@ def main():
"actions/godot-deps/action.yml",
"actions/upload-artifact/action.yml",
]
wf_actions_that_require_shell = fix_all_actions(args.ECMAS_github_folder, actions)
wf_actions_that_require_shell = fix_all_actions(args.js_github_folder, actions)
workflows = {
"android_builds.yml": BuildOpts(basic_flags, args.godot_version),
"ios_builds.yml": BuildOpts(basic_flags, args.godot_version),
Expand All @@ -334,10 +334,10 @@ def main():
"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")])
wf_names = fix_all_workflows(args.js_github_folder, workflows, wf_actions_that_require_shell)
subprocess.call(["rm", os.path.join(args.js_github_folder, "workflows", "static_checks.yml")])

out_publish_fn = os.path.join(args.ECMAS_github_folder, "workflows", "on_tag.yml")
out_publish_fn = os.path.join(args.js_github_folder, "workflows", "on_tag.yml")
add_publish_workflow(out_publish_fn, wf_names)


Expand Down
102 changes: 0 additions & 102 deletions ecmascript_binder.h

This file was deleted.

71 changes: 0 additions & 71 deletions ecmascript_instance.cpp

This file was deleted.

Loading