Skip to content

Improved development environment #65

@LilithSilver

Description

@LilithSilver

Motivation

Currently, the build system is opaque. It's split across Rust, Python, GitHub Actions, etc and a lot of code is outdated/irrelevant or buggy.

Additionally, to even get to the point where you can launch a project, you have to clone a minimum of three repositories and symlink them all over the place.

We need a build system where everything is in one place, so that it's maintainable, and which handles all these tasks for us.

Just

Although any build system would work, I think just makes the most sense -- it's lightweight, lets us use any language we want for tasks, has VSCode integration, and is easy to read and setup. It's also particularly "rusty".

File Structure

  • public: Public plugin assets like gdscript, .gdextension, UI scenes, etc that we need shipped directly with the plugin
  • rust: Rust code to produce our plugin DLL
  • editor: Patchwork's C++ editor module necessary to build with Godot
  • build: Our entire build environment, ignored by git.
    • plugin: The built plugin folder, intended to be dropped in a project's addons
      • native/*: The various binaries generated by Rust
    • godot: A copy of the Godot repository with Patchwork's editor module linked inside
    • moddable-platformer/threadbare: A testing project we can easily dev on

Environment Variables/Config

  • PATCHWORK_DEBUG: Whether we should build Patchwork (Rust) in debug mode
  • GODOT_DEBUG: Whether we should build Godot in debug mode
  • {PROJECT}_URL: Git URL of the project (threadbare or moddable-platformer)

Tasks

Setup:

  • make_build_dir: Makes ./build

Cloning:

  • acquire_project {PROJECT}: Acquire build/{PROJECT}
    • Requires: make_build_dir
    • Clone if it doesn't exist already
  • acquire_godot: Acquire build/godot
    • Requires: make_build_dir
    • Clone if it doesn't exist already

Linking:

  • link_project {PROJECT}: Symlink build/{PROJECT}/addons/patchwork <=> build/plugin
    • Requires: acquire_project
    • Allows us to launch a project while developing the plugin
  • link_editor: Symlink build/godot/modules/patchwork_editor <=> editor
    • Requires: acquire_godot
    • Allows us to build Godot with the editor module linked in
  • link_public Symlink build/plugin/public <=> public
    • Requires: make_build_dir
    • Ensures our public assets like gdscript, images, etc are included in the plugin build folder

Building:

  • build_godot: If necessary, build Godot with Patchwork with Scons
    • Requires: link_editor
  • build_patchwork: Run cargo build on Rust

Plugin setup:

  • make_plugin_dir: Make build/plugin
    • Requires: make_build_dir
  • copy_libs: Find Rust-generated DLLs and copy them to build/plugin/native
    • Requires: make_plugin_dir
    • Replaces build.rs, post_build.rs
  • sign_libs: Sign Mac .dylib files and whatever else (? idk how this works yet)
    • Requires: copy_libs
    • Hopefully replaces some github workflows(?)
  • sign_plugin {SERVER_URL}: Generate build/plugin/plugin.cfg and insert the correct server URL in patchwork.cfg
    • Requires: make_plugin_dir
    • Replaces update_version.py.

Cleaning:

  • clean_godot: Clean Godot (scons --clean)
  • clean_patchwork: Clean Patchwork (cargo clean)
  • clean_plugin: Clean plugin DLLs etc
  • clean_project {PROJECT}: Reset a project state (reset the repository, remove .patchwork, and reset patchwork.config)
  • clean: Clean everything

Running:

  • launch_project <PROJECT> [-u <SERVER_URL>]: Launch project with built Godot
    • Requires: build_patchwork, build_godot, link_{PROJECT}, sign_plugin

Targets

  • Launch threadbare/moddable-platformer (debug/release) for the current platform
  • Hot-reload Rust plugin

Stretch Goals

  • When starting a project in dev mode, also start up a local instance of automerge-rust-sync-server and automatically link it in plugin.cfg.
  • Use Rust watcher to hot-reload rust plugin automatically
  • Generate releases using this build system (i.e. move as much code from github actions to running these tasks as possible), since release issues are annoying to debug in general.
    • Automatically edit README.md upon release

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions