Skip to content

Commit

Permalink
fix: Fix missing functions in codegen (#210)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
makspll and github-actions[bot] authored Jan 19, 2025
1 parent 67b253d commit b874050
Show file tree
Hide file tree
Showing 38 changed files with 3,166 additions and 1,191 deletions.
145 changes: 0 additions & 145 deletions .github/workflows/bevy_api_gen.yml

This file was deleted.

54 changes: 48 additions & 6 deletions .github/workflows/bevy_mod_scripting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ on:
branches:
- "**"
paths-ignore:
- 'crates/bevy_api_gen/**'
- 'crates/macro_tests/**'
- '.github/workflows/release-plz.yml'
- '.github/workflows/bevy_api_gen.yml'
- '.github/workflows/macro_tests.yml'
- 'docs/**'


Expand All @@ -17,7 +13,9 @@ name: Check and Lint - bevy_mod_scripting
env:
REGISTRY: ghcr.io
IMAGE_NAME: bevy-mod-scripting

CODEGEN_BRANCH_NAME: __update-bevy-bindings-${{ github.head_ref || github.ref_name }}
GH_TOKEN: ${{ github.token }}

concurrency:
# Use github.run_id on main branch
# Use github.event.pull_request.number on pull requests, so it's unique per pull request
Expand Down Expand Up @@ -99,4 +97,48 @@ jobs:
if [[ -n $(git status -s) ]]; then
git commit -m "chore(badge): Update coverage badge" -m "[skip ci]"
git push
fi
fi
generate_bindings:
name: Bindings - Synchronise
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bot GitHub Credentials
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Setup
run: |
cargo xtask init
- name: Generate Bindings
run: |
cargo xtask codegen
- name: Check for changes
id: check_changes
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "changes=true" >> "$GITHUB_OUTPUT";
fi
- name: Commit Changes
if: steps.check_changes.outputs.changes
run: |
git checkout -b ${{ env.CODEGEN_BRANCH_NAME }} || git checkout ${{ env.CODEGEN_BRANCH_NAME }}
git add -A
git commit -m "chore(codegen): update bevy bindings"
git push -u origin ${{ env.CODEGEN_BRANCH_NAME }} --force
- uses: jwalton/gh-find-current-pr@master
if: steps.check_changes.outputs.changes
id: findPR
with:
state: all
- name: Create Or Update PR
if: steps.check_changes.outputs.changes && success() && steps.findPR.outputs.number
run: |
gh pr list --base ${{ github.ref }} --search "chore(codegen): update bevy bindings" --json number > prs.json
if [ $(jq '. | length' prs.json) -eq 0 ]; then
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
fi
87 changes: 0 additions & 87 deletions .github/workflows/generate_bindings.yml

This file was deleted.

1 change: 1 addition & 0 deletions .vscode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
settings.json
34 changes: 0 additions & 34 deletions .vscode/settings.json

This file was deleted.

Binary file removed check.exe
Binary file not shown.
10 changes: 2 additions & 8 deletions check.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#!/usr/bin/env pwsh
Remove-Variable -Name RUSTUP_TOOLCHAIN -ErrorAction SilentlyContinue
$CURRENT_DIR = Split-Path -Leaf -Path (Get-Location)

if ($CURRENT_DIR -eq "bevy_api_gen") {
cargo +nightly-2024-12-15 clippy --all-targets --message-format=json
} else {
cargo clippy --workspace --all-targets --message-format=json --features="lua54 rhai rune bevy/file_watcher bevy/multi_threaded"
}
Set-Location -Path (Split-Path -Parent $MyInvocation.MyCommand.Definition)
cargo xtask check --ide-mode
4 changes: 2 additions & 2 deletions crates/bevy_api_gen/Cargo.bootstrap.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Cargo.toml file used for bootstrapping of mlua and other dependencies which need to be included in every crate for analysis
# Cargo.toml file used for bootstrapping of bms and other dependencies which need to be included in every crate for analysis
[package]
name = "bevy_analyzer_deps_bootstrap"
version = "0.1.0"
edition = "2021"

[dependencies]
mlua = { version = "0.10", features = ["lua54", "vendored", "send", "macros"] }
bevy_mod_scripting_core = { path = "{{BMS_CORE_PATH}}" }
bevy_reflect = { version = "0.15.0", features = [
"bevy",
"glam",
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_api_gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ convert_case = "0.6"
syn = { version = "2", features = ["parsing"], no-default-features = true }
clap-verbosity-flag = "2.2"
itertools = "0.12"
chrono = "0.4"

[build-dependencies]
toml = "0.8"
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_api_gen/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ pub struct Args {
/// additional template context in the form of json, provided to the templates under an 'args' key
#[arg(global = true, long)]
pub template_args: Option<String>,

/// The path to the bevy_mod_scripting_core crate, used to bootstrap necessary traits
#[arg(global = true, long, default_value = ".")]
pub bms_core_path: Utf8PathBuf,
}

#[derive(clap::Args, Debug, Clone, Default, Serialize, Deserialize)]
Expand Down
Loading

0 comments on commit b874050

Please sign in to comment.