Skip to content

Commit

Permalink
Implement virtual methods that accept or return pointers (per godot-r…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercerenies committed May 13, 2023
1 parent 60f75bf commit 973e1a5
Show file tree
Hide file tree
Showing 24 changed files with 683 additions and 154 deletions.
4 changes: 1 addition & 3 deletions .github/composite/godot-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ inputs:
runs:
using: "composite"
steps:
# Do not check out here, as this would overwrite (clean) the current directory and is already done by the parent workflow.
- uses: actions/checkout@v3

# Replaces also backspaces on Windows, since they cause problems in Bash
- name: "Store variable to Godot binary"
Expand All @@ -38,8 +38,6 @@ runs:

- name: "Download Godot artifact"
# if: steps.cache-godot.outputs.cache-hit != 'true'
# If a specific Godot revision should be used, rather than latest, use this:
# curl https://nightly.link/Bromeon/godot4-nightly/actions/runs/4910907653/${{ inputs.artifact-name }}.zip \
run: |
curl https://nightly.link/Bromeon/godot4-nightly/workflows/compile-godot/master/${{ inputs.artifact-name }}.zip \
-Lo artifact.zip \
Expand Down
2 changes: 1 addition & 1 deletion .github/composite/godot-itest/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ inputs:
runs:
using: "composite"
steps:
# Do not check out here, as this would overwrite (clean) the current directory and is already done by the parent workflow.
- uses: actions/checkout@v3

- name: "Install Godot"
uses: ./.github/composite/godot-install
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
- name: macos-double
os: macos-12
godot-binary: godot.macos.editor.dev.double.x86_64
rust-extra-args: --features godot/double-precision
rust-extra-args: --features double-precision

- name: macos-nightly
os: macos-12
Expand All @@ -150,7 +150,7 @@ jobs:
- name: windows-double
os: windows-latest
godot-binary: godot.windows.editor.dev.double.x86_64.exe
rust-extra-args: --features godot/double-precision
rust-extra-args: --features double-precision

- name: windows-nightly
os: windows-latest
Expand All @@ -167,13 +167,13 @@ jobs:
- name: linux-double
os: ubuntu-20.04
godot-binary: godot.linuxbsd.editor.dev.double.x86_64
rust-extra-args: --features godot/double-precision
rust-extra-args: --features double-precision

- name: linux-features
os: ubuntu-20.04
artifact-name: linux
godot-binary: godot.linuxbsd.editor.dev.x86_64
rust-extra-args: --features godot/threads,godot/serde
rust-extra-args: --features threads,serde

- name: linux-nightly
os: ubuntu-20.04
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/minimal-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ jobs:
# token: # optional: the token that license eye uses when it needs to comment on the pull request.
# Set to empty ("") to disable commenting on pull request. The default value is ${{ github.token }}
# mode: # optional: Which mode License-Eye should be run in. Choices are `check` or `fix`. The default value is `check`.
mode: check

# - name: "Commit changes"
# uses: EndBug/add-and-commit@v9
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# author_name: 'Godot-Rust Automation'
# author_email: 'actions@github.com'
# message: 'Auto-apply license headers'
mode: fix

- name: "Commit changes"
uses: EndBug/add-and-commit@v9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
author_name: 'Godot-Rust Automation'
author_email: 'actions@github.com'
message: 'Auto-apply license headers'

29 changes: 3 additions & 26 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,8 @@ function cmd_dok() {
# Argument parsing
################################################################################

# By default, disable `codegen-full` to reduce compile times and prevent flip-flopping
# between `itest` compilations and `check.sh` runs.
extraCargoArgs=("--no-default-features")
cmds=()
extraCargoArgs=()

for arg in "$@"; do
case "$arg" in
Expand All @@ -167,7 +165,7 @@ for arg in "$@"; do
exit 0
;;
--double)
extraCargoArgs+=("--features" "godot/double-precision")
extraCargoArgs+=("--features" "double-precision")
;;
fmt | clippy | test | itest | doc | dok)
cmds+=("$arg")
Expand All @@ -185,39 +183,18 @@ if [[ ${#cmds[@]} -eq 0 ]]; then
fi

################################################################################
# Execution and summary
# Execution
################################################################################

function compute_elapsed() {
local total=$SECONDS
local min=$(("$total" / 60))
if [[ "$min" -gt 0 ]]; then
min="${min}min "
else
min=""
fi
local sec=$(("$total" % 60))

# Don't use echo and call it with $(compute_elapsed), it messes with stdout
elapsed="${min}${sec}s"
}

for cmd in "${cmds[@]}"; do
"cmd_${cmd}" || {
compute_elapsed
log -ne "$RED\n====================="
log -ne "\ngdext: checks FAILED."
log -ne "\n=====================\n$END"
log -ne "\nTotal duration: $elapsed.\n"
exit 1
}
done

compute_elapsed
log -ne "$CYAN\n========================="
log -ne "\ngdext: checks SUCCESSFUL."
log -ne "\n=========================\n$END"
log -ne "\nTotal duration: $elapsed.\n"

# If invoked with sh instead of bash, pressing Up arrow after executing `sh check.sh` may cause a `[A` to appear.
# See https://unix.stackexchange.com/q/103608.
3 changes: 1 addition & 2 deletions examples/dodge-the-creeps/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
name = "dodge-the-creeps"
version = "0.1.0"
edition = "2021"
rust-version = "1.66"
publish = false

[lib]
crate-type = ["cdylib"]

[dependencies]
godot = { path = "../../../godot", default-features = false }
godot = { path = "../../../godot", default-features = false, features = ["formatted"] }
rand = "0.8"
7 changes: 7 additions & 0 deletions godot-codegen/src/api_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct ExtensionApi {
pub classes: Vec<Class>,
pub global_enums: Vec<Enum>,
pub utility_functions: Vec<UtilityFunction>,
pub native_structures: Vec<NativeStructure>,
pub singletons: Vec<Singleton>,
}

Expand Down Expand Up @@ -63,6 +64,12 @@ pub struct Class {
// pub signals: Option<Vec<Signal>>,
}

#[derive(DeJson)]
pub struct NativeStructure {
pub name: String,
pub format: String,
}

#[derive(DeJson)]
pub struct Singleton {
pub name: String,
Expand Down
1 change: 1 addition & 0 deletions godot-codegen/src/central_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub(crate) fn generate_core_mod_file(core_gen_path: &Path, out_files: &mut Vec<P
pub mod classes;
pub mod builtin_classes;
pub mod utilities;
pub mod native;
};

write_file(core_gen_path, "mod.rs", code.to_string(), out_files);
Expand Down
Loading

0 comments on commit 973e1a5

Please sign in to comment.