Skip to content

Commit b874050

Browse files
fix: Fix missing functions in codegen (#210)
* make the codegen crate work with vscode finally * update CI to use xtask for bindings * refactor slightly * add nightly toolchain to setup * update PR command * control vscode settings.json from init * add docs mention * tighten codegen ordering * clean bevy target dir before codegen * add more context to errors * tighten the codegen ordering again, for collection * print faulty json * escape json * chore(codegen): update bevy bindings (#214) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * typo * ignore less paths now that everything is one workflow * fix bug causing incomplete codegen * fix clippy * inject BMS into codegen :D * remove 'dependencies' key from tera * remove mlua references from codegen --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 67b253d commit b874050

38 files changed

+3166
-1191
lines changed

.github/workflows/bevy_api_gen.yml

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

.github/workflows/bevy_mod_scripting.yml

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ on:
33
branches:
44
- "**"
55
paths-ignore:
6-
- 'crates/bevy_api_gen/**'
7-
- 'crates/macro_tests/**'
86
- '.github/workflows/release-plz.yml'
9-
- '.github/workflows/bevy_api_gen.yml'
10-
- '.github/workflows/macro_tests.yml'
117
- 'docs/**'
128

139

@@ -17,7 +13,9 @@ name: Check and Lint - bevy_mod_scripting
1713
env:
1814
REGISTRY: ghcr.io
1915
IMAGE_NAME: bevy-mod-scripting
20-
16+
CODEGEN_BRANCH_NAME: __update-bevy-bindings-${{ github.head_ref || github.ref_name }}
17+
GH_TOKEN: ${{ github.token }}
18+
2119
concurrency:
2220
# Use github.run_id on main branch
2321
# Use github.event.pull_request.number on pull requests, so it's unique per pull request
@@ -99,4 +97,48 @@ jobs:
9997
if [[ -n $(git status -s) ]]; then
10098
git commit -m "chore(badge): Update coverage badge" -m "[skip ci]"
10199
git push
102-
fi
100+
fi
101+
generate_bindings:
102+
name: Bindings - Synchronise
103+
permissions:
104+
contents: write
105+
pull-requests: write
106+
runs-on: ubuntu-latest
107+
steps:
108+
- name: Checkout
109+
uses: actions/checkout@v4
110+
- name: Setup Bot GitHub Credentials
111+
run: |
112+
git config user.name "github-actions[bot]"
113+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
114+
- name: Setup
115+
run: |
116+
cargo xtask init
117+
- name: Generate Bindings
118+
run: |
119+
cargo xtask codegen
120+
- name: Check for changes
121+
id: check_changes
122+
run: |
123+
if [[ -n $(git status --porcelain) ]]; then
124+
echo "changes=true" >> "$GITHUB_OUTPUT";
125+
fi
126+
- name: Commit Changes
127+
if: steps.check_changes.outputs.changes
128+
run: |
129+
git checkout -b ${{ env.CODEGEN_BRANCH_NAME }} || git checkout ${{ env.CODEGEN_BRANCH_NAME }}
130+
git add -A
131+
git commit -m "chore(codegen): update bevy bindings"
132+
git push -u origin ${{ env.CODEGEN_BRANCH_NAME }} --force
133+
- uses: jwalton/gh-find-current-pr@master
134+
if: steps.check_changes.outputs.changes
135+
id: findPR
136+
with:
137+
state: all
138+
- name: Create Or Update PR
139+
if: steps.check_changes.outputs.changes && success() && steps.findPR.outputs.number
140+
run: |
141+
gh pr list --base ${{ github.ref }} --search "chore(codegen): update bevy bindings" --json number > prs.json
142+
if [ $(jq '. | length' prs.json) -eq 0 ]; then
143+
gh pr create --title "chore(codegen): update bevy bindings" --body "This PR updates the bevy bindings for #${{ steps.findPR.outputs.number }}" --base ${{ github.ref }} --head ${{ env.CODEGEN_BRANCH_NAME }} || true
144+
fi

.github/workflows/generate_bindings.yml

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

.vscode/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
settings.json

.vscode/settings.json

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

check.exe

-25.5 KB
Binary file not shown.

check.ps1

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
#!/usr/bin/env pwsh
2-
Remove-Variable -Name RUSTUP_TOOLCHAIN -ErrorAction SilentlyContinue
3-
$CURRENT_DIR = Split-Path -Leaf -Path (Get-Location)
4-
5-
if ($CURRENT_DIR -eq "bevy_api_gen") {
6-
cargo +nightly-2024-12-15 clippy --all-targets --message-format=json
7-
} else {
8-
cargo clippy --workspace --all-targets --message-format=json --features="lua54 rhai rune bevy/file_watcher bevy/multi_threaded"
9-
}
2+
Set-Location -Path (Split-Path -Parent $MyInvocation.MyCommand.Definition)
3+
cargo xtask check --ide-mode

crates/bevy_api_gen/Cargo.bootstrap.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Cargo.toml file used for bootstrapping of mlua and other dependencies which need to be included in every crate for analysis
1+
# Cargo.toml file used for bootstrapping of bms and other dependencies which need to be included in every crate for analysis
22
[package]
33
name = "bevy_analyzer_deps_bootstrap"
44
version = "0.1.0"
55
edition = "2021"
66

77
[dependencies]
8-
mlua = { version = "0.10", features = ["lua54", "vendored", "send", "macros"] }
8+
bevy_mod_scripting_core = { path = "{{BMS_CORE_PATH}}" }
99
bevy_reflect = { version = "0.15.0", features = [
1010
"bevy",
1111
"glam",

crates/bevy_api_gen/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ convert_case = "0.6"
5454
syn = { version = "2", features = ["parsing"], no-default-features = true }
5555
clap-verbosity-flag = "2.2"
5656
itertools = "0.12"
57+
chrono = "0.4"
5758

5859
[build-dependencies]
5960
toml = "0.8"

crates/bevy_api_gen/src/args.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ pub struct Args {
5454
/// additional template context in the form of json, provided to the templates under an 'args' key
5555
#[arg(global = true, long)]
5656
pub template_args: Option<String>,
57+
58+
/// The path to the bevy_mod_scripting_core crate, used to bootstrap necessary traits
59+
#[arg(global = true, long, default_value = ".")]
60+
pub bms_core_path: Utf8PathBuf,
5761
}
5862

5963
#[derive(clap::Args, Debug, Clone, Default, Serialize, Deserialize)]

0 commit comments

Comments
 (0)