Git Product home page Git Product logo

ftw's Introduction

ftw

A CLI tool to manage your godot-rust project!

Table of contents

General Information

This is a tool to help you manage your game project by providing commands to (1) create a project, (2) create a class, (3) create a singleton class, (4) build the library, (5) export your game, (6) run your project (and more to come in the future!). Its like rails but for game development ๐Ÿ˜‰.

Setup

It leverages tools like godot, godot-headless, godot-server and docker (Optional, only used for cross compilation. See below) to make it all work! In Linux, you can install all godot, godot-headless and godot-server, on others only godot. For additional setup instructions, check the wiki of the default template.

$ cargo install ftw # to install
$ cargo install --force ftw # to upgrade ftw

Usage

ftw new <project-name> [template]

Creates a new project directory

$ ftw new my-awesome-game # this creates a new project using the default template
$ ftw new my-awesome-game default # same as above
$ ftw new my-awesome-game /path/to/custom/template # creates a new project using a custom template
$ ftw new my-awesome-game default v1.2.0 # creates a new project with the default template using a specified tag

Note: The custom template should have same structure as the default template. Using a tag assumes you have created tags in your template repository, just like here

ftw class <class-name> [node-type]

Creates a class

$ ftw class MyHero # creates a class called `MyHero` that is deriving from `Node` as default
$ ftw class MyHero Area2D # creates a class that derives from `Area2D`

Note: This creates the following files rust/src/my_hero.rs, godot/scenes/MyHero.tscn and godot/native/MyHero.gdns then adds the class inside rust/src/lib.rs. A complete list of node types can be found here

Creates a tool class

$ ftw class MyButtonTool Button # creates a tool class called `MyButtonTool` that is deriving from `Button`

Note: Same as creating a regular class and also take note of having Tool at the end of the class name as a convention

You could also organize rs, tscn and gdns files into submodules or subfolders
$ ftw class heros/marvel/avengers/IronMan Area2D # creates a class that derives from `Area2D`

Note: This creates the following files rust/src/heros/marvel/avengers/iron_man.rs, godot/scenes/heros/marvel/avengers/IronMan.tscn, godot/native/heros/marvel/avengers/IronMan.gdns and mod.rs files in each subfolder in rust/src then adds the class inside rust/src/lib.rs

ftw singleton <class-name>

Creates a singleton class for autoloading

$ ftw singleton MySingleton # creates a class called `MySingleton` that derives from `Node`

Note: This creates the following rust/src/my_singleton.rs and godot/native/MySingleton.gdns then adds the class inside rust/src/lib.rs

You can also organize the files into submodules/subfolders as in ftw class command
$ ftw singleton network/Network # creates a class called `Network` that derives from `Node`

ftw build [targets] [build-type]

Builds the library for a particular target

$ ftw build # builds the library for your current platform as target using `debug` as default
$ ftw build linux-x86_64 # builds the library for the `linux-x86_64` platform using `debug` as default
$ ftw build linux-x86_64 debug # same as above
$ ftw build linux-x86_64 release # builds the library for the `linux-x86_64` platform using `release`
$ ftw build linux-x86_64,macos-x86_64,macos-aarch64,windows-x86_64-gnu # this assumes cross compilation is enabled (see below)

[targets] can be separated by ',' and each target can be one of the following

  • android-aarch64
  • android-arm
  • android-x86
  • android-x86_64
  • ios-aarch64
  • linux-x86
  • linux-x86_64
  • macos-x86_64
  • macos-aarch64
  • windows-x86-gnu
  • windows-x86-msvc
  • windows-x86
  • windows-x86_64-gnu
  • windows-x86_64-msvc
  • windows-x86_64

Note: The built libraries (*.so, *.dll, *.dylib, etc.) can be found inside the lib/ folder

ftw export [targets] [build-type]

Exports the game for a particular target

$ ftw export # exports the game for your current platform as target using `debug` as default
$ ftw export linux-x86_64 # exports the game for the `linux-x86_64` platform using `debug` as default
$ ftw export linux-x86_64 debug # same as above
$ ftw export linux-x86_64 release # exports the game for the `linux-x86_64` platform using `release`
$ ftw export linux-x86_64,macos-x86_64,macos-aarch64,windows-x86_64-gnu # this assumes cross compilation is enabled (see below)

Note: The exported games can be found inside the bin/ folder. Before exporting an Android game, create the keystores first (if you have not created them and configured your editor/export settings) with 'cargo make create-debug-keystore' and/or 'cargo make create-release-keystore'. Before exporting Windows games, execute 'cargo make switch-gdnlib-msvc-to-gnu-entry' if you plan to export gnu targets, and execute 'cargo make switch-gdnlib-gnu-to-msvc-entry' if you plan to export msvc targets

ftw run [machine-type]

Builds the library using debug then runs your game

$ ftw run # runs the game on desktop
$ ftw run desktop # same as above
$ ftw run server # runs the game as a server
# enjoy! ๐Ÿ˜†

ftw clean

Cleans your project from excess artifacts, similar to cargo clean

$ ftw clean

Project Configuration

You can create a per-project configuration file at your project root named .ftw with the following contents...

Custom Executables

If you have custom executables to run godot, for example if you have a shell/batch script which do some stuff first before running godot, you can configure using the following inside your project...

[ftw]
godot-exe=/path/to/custom/godot-script
godot-headless-exe=/path/to/custom/godot-headless-script
godot-server-exe=godot-server-script # assuming it's on $PATH

Note: Having the .ftw file and the keys inside it are all optional. If you don't provide them, the defaults (godot, godot-headless and godot-server) will be used. For Windows users use forward-slashes instead of back-slashes (e.g. godot-exe=D:/path/to/godot/bin/godot.windows.tools.64.exe)

Cross Compilation

You can also enable cross compilation, so you could build and export a game from and to any platform. It uses this docker image to set up Linux, Android, Mac, iOS and Windows toolchains (WebAssembly toolchains to follow). Please read this section to know what is currently supported.

[ftw]
enable-cross-compilation=true

(Let's say) On your Linux machine

$ ftw build windows-x86_64-gnu
$ ftw export windows-x86_64-gnu

Contact

Michael Angelo Calimlim <[email protected]>

ftw's People

Contributors

macalimlim avatar piercelbrooks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ftw's Issues

run game in server mode

Run the game in server mode, ftw run should have an option to run in server mode in addition to running via desktop. This feature is only available in Linux...

Add ability to create tool scripts

Currently, FTW supports creating regular classes and singletons using the class and singleton commands. I propose adding another command tool.

Currently, ftw overwrites the lib.rs file and the init function. This means that custom handle.add_class<> calls are removed from the file. In order to register a tool script with godot-rust, you have to do something like

fn init(handle: InitHandle) {
  handle.add_tool_class::<MyClass>();
}

but this will be overwritten if you ever run a command like ftw class again.

I tried implementing this command, but I got stuck because the current implementation reads the source-dir and looks for [NativeClass] using a regex. I couldn't think of a good approach for tool scripts so I decided to post an issue here and get some feedback from you before I proceed. For example, I thought of adding some custom attribute, but this would require users to import a crate into their project which feels messy and against the current approach. I also thought of making the user add a comment but this approach is not always popular.

Another option, instead of implementing this tool command, is some workaround that allows you to call some custom code from the lib.rs file.

Dependency error on install

It appears one of the dependencies might be out of date, looking at cargo git-ref semms to have renamed itself to gix-ref
log.txt

    Updating crates.io index
  Installing ftw v0.12.0
   Compiling libc v0.2.147
   Compiling proc-macro2 v1.0.66
   Compiling unicode-ident v1.0.11
   Compiling memchr v2.5.0
   Compiling cfg-if v1.0.0
   Compiling thiserror v1.0.44
   Compiling autocfg v1.1.0
   Compiling regex-syntax v0.7.4
   Compiling once_cell v1.18.0
   Compiling pkg-config v0.3.27
   Compiling version_check v0.9.4
   Compiling rustix v0.38.6
   Compiling bitflags v2.3.3
   Compiling linux-raw-sys v0.4.5
   Compiling num-traits v0.2.16
   Compiling time-core v0.1.1
   Compiling itoa v1.0.9
   Compiling time-macros v0.2.11
   Compiling num_threads v0.1.6
   Compiling deranged v0.3.7
   Compiling serde v1.0.181
   Compiling aho-corasick v1.0.2
   Compiling quote v1.0.32
   Compiling smallvec v1.11.0
   Compiling jobserver v0.1.26
   Compiling syn v2.0.28
   Compiling getrandom v0.2.10
   Compiling lazy_static v1.4.0
   Compiling vcpkg v0.2.15
   Compiling cc v1.0.81
   Compiling lock_api v0.4.10
   Compiling bitflags v1.3.2
   Compiling ucd-trie v0.1.6
   Compiling crunchy v0.2.2
   Compiling serde_derive v1.0.181
   Compiling parking_lot_core v0.9.8
   Compiling regex-automata v0.3.4
   Compiling openssl-src v111.27.0+1.1.1v
   Compiling scopeguard v1.2.0
   Compiling time v0.3.25
   Compiling signal-hook v0.3.17
   Compiling fastrand v2.0.0
   Compiling tiny-keccak v2.0.2
   Compiling proc-macro-hack v0.5.20+deprecated
   Compiling same-file v1.0.6
   Compiling static_assertions v1.1.0
   Compiling tempfile v3.7.0
   Compiling walkdir v2.3.3
   Compiling openssl-sys v0.9.90
   Compiling libz-sys v1.1.12
   Compiling libssh2-sys v0.2.23
   Compiling signal-hook-registry v1.4.1
   Compiling quick-error v2.0.1
   Compiling syn v1.0.109
   Compiling tinyvec_macros v0.1.1
   Compiling hashbrown v0.14.0
   Compiling minimal-lexical v0.2.1
   Compiling percent-encoding v2.3.0
   Compiling hex v0.4.3
   Compiling bstr v1.6.0
   Compiling regex v1.9.1
   Compiling dashmap v5.5.0
   Compiling nom v7.1.3
   Compiling tinyvec v1.6.0
   Compiling thiserror-impl v1.0.44
   Compiling is-terminal v0.4.9
   Compiling btoi v0.4.3
   Compiling rand_core v0.6.4
   Compiling ahash v0.7.6
   Compiling ppv-lite86 v0.2.17
   Compiling utf8parse v0.2.1
   Compiling either v1.9.0
   Compiling sha1_smol v1.0.0
   Compiling anstyle-parse v0.2.1
   Compiling itertools v0.10.5
   Compiling rand_chacha v0.3.1
   Compiling const-random-macro v0.1.15
   Compiling unicode-normalization v0.1.22
   Compiling liquid-derive v0.26.4
   Compiling git-hash v0.10.3
   Compiling pest v2.7.2
   Compiling git-date v0.4.3
   Compiling git-features v0.26.5
   Compiling git-actor v0.17.2
   Compiling git-validate v0.7.3
   Compiling git-path v0.7.2
   Compiling git-tempfile v3.0.3
   Compiling kstring v2.0.0
   Compiling libgit2-sys v0.14.2+1.5.1
   Compiling ahash v0.8.3
   Compiling smartstring v1.0.1
   Compiling pest_meta v2.7.2
   Compiling anstyle v1.0.1
   Compiling fastrand v1.9.0
   Compiling anstyle-query v1.0.0
   Compiling log v0.4.19
   Compiling heck v0.4.1
   Compiling unicode-bidi v0.3.13
   Compiling colorchoice v1.0.0
   Compiling doc-comment v0.3.3
   Compiling unicode-width v0.1.10
   Compiling anymap2 v0.13.0
   Compiling unicode-segmentation v1.10.1
   Compiling pest_generator v2.7.2
   Compiling portable-atomic v1.4.2
   Compiling idna v0.4.0
   Compiling console v0.15.7
   Compiling anstream v0.3.2
   Compiling git-lock v3.0.3
   Compiling git-object v0.26.2
   Compiling const-random v0.1.15
   Compiling rand v0.8.5
   Compiling form_urlencoded v1.2.0
   Compiling pest_derive v2.7.2
   Compiling memmap2 v0.5.10
   Compiling names v0.14.0
   Compiling semver v1.0.18
   Compiling fnv v1.0.7
   Compiling rustversion v1.0.14
   Compiling paste v1.0.14
   Compiling liquid-core v0.26.4
   Compiling anyhow v1.0.72
   Compiling clap_lex v0.5.0
   Compiling openssl v0.10.55
   Compiling foreign-types-shared v0.1.1
   Compiling clap_builder v4.3.19
   Compiling foreign-types v0.3.2
   Compiling globset v0.4.12
   Compiling git-ref v0.23.1
   Compiling hashbrown v0.12.3
   Compiling url v2.4.0
error[E0277]: the trait bound `BStr: AsRef<[_; 0]>` is not satisfied
  --> /home/rampedindent/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.23.1/src/store/packed/find.rs:95:52
   |
95 |                 .map(|(_rest, r)| r.name.as_bstr().as_ref())
   |                                                    ^^^^^^ the trait `AsRef<[_; 0]>` is not implemented for `BStr`
   |
   = help: the following other types implement trait `AsRef<T>`:
             <BStr as AsRef<BStr>>
             <BStr as AsRef<[u8]>>

error[E0277]: the trait bound `BStr: AsRef<[_; 0]>` is not satisfied
  --> /home/rampedindent/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.23.1/src/store/packed/find.rs:91:43
   |
91 |         a.binary_search_by_key(&full_name.as_ref(), |b: &u8| {
   |                                           ^^^^^^ the trait `AsRef<[_; 0]>` is not implemented for `BStr`
   |
   = help: the following other types implement trait `AsRef<T>`:
             <BStr as AsRef<BStr>>
             <BStr as AsRef<[u8]>>

error[E0283]: type annotations needed
    --> /home/rampedindent/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.23.1/src/fullname.rs:109:43
     |
109  |             if let Some(shortened) = name.strip_prefix(category.prefix().as_ref()) {
     |                                           ^^^^^^^^^^^^ -------------------------- type must be known at this point
     |                                           |
     |                                           cannot infer type of the type parameter `P` declared on the method `strip_prefix`
     |
     = note: cannot satisfy `_: core::slice::SlicePattern`
     = help: the following types implement trait `core::slice::SlicePattern`:
               [T; N]
               [T]
note: required by a bound in `core::slice::<impl [T]>::strip_prefix`
    --> /home/rampedindent/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs:2333:28
     |
2333 |     pub fn strip_prefix<P: SlicePattern<Item = T> + ?Sized>(&self, prefix: &P) -> Option<&[T]>
     |                            ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `core::slice::<impl [T]>::strip_prefix`
help: consider specifying the generic argument
     |
109  |             if let Some(shortened) = name.strip_prefix::<P>(category.prefix().as_ref()) {
     |                                                       +++++

error[E0283]: type annotations needed
   --> /home/rampedindent/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.23.1/src/fullname.rs:109:43
    |
109 |             if let Some(shortened) = name.strip_prefix(category.prefix().as_ref()) {
    |                                           ^^^^^^^^^^^^                   ------ type must be known at this point
    |                                           |
    |                                           cannot infer type of the type parameter `P` declared on the method `strip_prefix`
    |
    = note: multiple `impl`s satisfying `BStr: AsRef<_>` found in the `bstr` crate:
            - impl AsRef<BStr> for BStr;
            - impl AsRef<[u8]> for BStr;
help: consider specifying the generic argument
    |
109 |             if let Some(shortened) = name.strip_prefix::<P>(category.prefix().as_ref()) {
    |                                                       +++++

error[E0283]: type annotations needed
   --> /home/rampedindent/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.23.1/src/fullname.rs:132:46
    |
132 |         } else if let Some(shortened) = name.strip_prefix(Category::MainPseudoRef.prefix().as_ref()) {
    |                                              ^^^^^^^^^^^^                                  ------ type must be known at this point
    |                                              |
    |                                              cannot infer type of the type parameter `P` declared on the method `strip_prefix`
    |
    = note: multiple `impl`s satisfying `BStr: AsRef<_>` found in the `bstr` crate:
            - impl AsRef<BStr> for BStr;
            - impl AsRef<[u8]> for BStr;
help: consider specifying the generic argument
    |
132 |         } else if let Some(shortened) = name.strip_prefix::<P>(Category::MainPseudoRef.prefix().as_ref()) {
    |                                                          +++++

error[E0283]: type annotations needed
   --> /home/rampedindent/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.23.1/src/fullname.rs:139:18
    |
139 |             name.strip_prefix(Category::LinkedPseudoRef { name: "".into() }.prefix().as_ref())
    |                  ^^^^^^^^^^^^                                                        ------ type must be known at this point
    |                  |
    |                  cannot infer type of the type parameter `P` declared on the method `strip_prefix`
    |
    = note: multiple `impl`s satisfying `BStr: AsRef<_>` found in the `bstr` crate:
            - impl AsRef<BStr> for BStr;
            - impl AsRef<[u8]> for BStr;
help: consider specifying the generic argument
    |
139 |             name.strip_prefix::<P>(Category::LinkedPseudoRef { name: "".into() }.prefix().as_ref())
    |                              +++++

error[E0283]: type annotations needed
    --> /home/rampedindent/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.23.1/src/raw.rs:76:18
     |
76   |                 .strip_prefix(namespace.0.as_bstr().as_ref())
     |                  ^^^^^^^^^^^^ ------------------------------ type must be known at this point
     |                  |
     |                  cannot infer type of the type parameter `P` declared on the method `strip_prefix`
     |
     = note: cannot satisfy `_: core::slice::SlicePattern`
     = help: the following types implement trait `core::slice::SlicePattern`:
               [T; N]
               [T]
note: required by a bound in `core::slice::<impl [T]>::strip_prefix`
    --> /home/rampedindent/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs:2333:28
     |
2333 |     pub fn strip_prefix<P: SlicePattern<Item = T> + ?Sized>(&self, prefix: &P) -> Option<&[T]>
     |                            ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `core::slice::<impl [T]>::strip_prefix`
help: consider specifying the generic argument
     |
76   |                 .strip_prefix::<P>(namespace.0.as_bstr().as_ref())
     |                              +++++

error[E0283]: type annotations needed
  --> /home/rampedindent/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.23.1/src/raw.rs:76:18
   |
76 |                 .strip_prefix(namespace.0.as_bstr().as_ref())
   |                  ^^^^^^^^^^^^                       ------ type must be known at this point
   |                  |
   |                  cannot infer type of the type parameter `P` declared on the method `strip_prefix`
   |
   = note: multiple `impl`s satisfying `BStr: AsRef<_>` found in the `bstr` crate:
           - impl AsRef<BStr> for BStr;
           - impl AsRef<[u8]> for BStr;
help: consider specifying the generic argument
   |
76 |                 .strip_prefix::<P>(namespace.0.as_bstr().as_ref())
   |                              +++++

Some errors have detailed explanations: E0277, E0283.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `git-ref` due to 8 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `ftw v0.12.0`, intermediate artifacts can be found at `/tmp/cargo-installhF7YYj`

add github actions

add github actions to test PRs and deploy to crates when new tags are created

Missing "use" in lib.rs with generated class at path

I ran ftw class chars/Player KinematicBody but when I tried to run the whole game (ftw run), Rust gave an error that it couldn't find player in handle.add_class::<player::Player>();. This seemed to be because the generated code added mod chars; to the top, but not use chars::*; or at least use chars::player; and I had to add it myself.

I'm using the released ftw 0.6.0

provide a way to customize which godot binary

provide a way to customize which godot binary to be used to invoke commands that use godot. For example, instead of having godot binary on $PATH, I want to have a custom batch or shell script file to invoke godot...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.