GithubHelp home page GithubHelp logo

pd-rs / crank Goto Github PK

View Code? Open in Web Editor NEW
83.0 5.0 16.0 89 KB

A wrapper for cargo to use creating games for the Playdate handheld gaming system.

License: MIT License

Rust 100.00%
panic playdate game rust

crank's People

Contributors

boozook avatar catt-io avatar kettle11 avatar lilyinstarlight avatar lyonbeckers avatar parasyte avatar rtsuk avatar ruin0x11 avatar skeet70 avatar softdevca avatar tjkirch 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

Watchers

 avatar  avatar  avatar  avatar  avatar

crank's Issues

Simulator builds fail due to use of stable release channel

I'm getting failing simulator builds of the crankstart examples.
The device builds (eg --device) are fine.

I'm new to both playdate & rust so bare with me. I've followed the full setup in the README including the nightly toolchain and thumbv7em-none-eabihf target. I'm on macOS 13.6.6.

Here's the full error:

crank build --release --example hello_world
   Compiling num-traits v0.2.18
   Compiling cstr_core v0.1.2
   Compiling rand v0.8.5
   Compiling rand_pcg v0.3.1
   Compiling randomize v3.0.1
   Compiling syn v1.0.109
   Compiling hashbrown v0.14.3
error[E0554]: `#![feature]` may not be used on the stable release channel
  --> /Users/garethknowles/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cstr_core-0.1.2/src/lib.rs:12:40
   |
12 | #![cfg_attr(feature = "alloc", feature(alloc))]
   |                                        ^^^^^

For more information about this error, try `rustc --explain E0554`.
error: could not compile `cstr_core` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
Error: cargo failed with error ExitStatus(unix_wait_status(25856))

Cannot run workspace projects

A Playdate application cannot be built if it is part of a workspace. Excluding it from the workspace is a workaround.

workspace Cargo.toml partial listing

[workspace]
members = [
  "game_core_library",
  "game_pc",
]
exclude = [
  "game_playdate",
]

error: no such command `+nightly`

When providing the --device flag, +nightly is added to cargo build:

crank/src/main.rs

Lines 611 to 615 in f46cda4

let mut args = if self.device {
vec!["+nightly", "build"]
} else {
vec!["build"]
};

and I run into the following error:

 INFO  crank > build command: RUSTFLAGS="-Ctarget-cpu=cortex-m7 -Clink-args=--emit-relocs -Crelocation-model=pic -Cpanic=abort" "cargo" "+nightly" "build" "--lib" "--target" "thumbv7em-none-eabihf" "-Zbuild-std=core,alloc" "-Zbuild-std-features=panic_immediate_abort"
error: no such command: `+nightly`

	Cargo does not handle `+toolchain` directives.
	Did you mean to invoke `cargo` through `rustup` instead?
Error: cargo failed with error ExitStatus(unix_wait_status(25856))

I've been using a local copy of crank that removes +nightly and everything seems to work fine.

What's the motivation for adding +nightly when the --device flag is provided?

Better support for cross-compilation when neccesary

Crank doesn't recognize when cargo compiles to a target that doesn't match the host system. This is necessary on arm64 windows since the playdate simulator is only built for amd64 on windows.

My workaround is to build with cargo, copy the files to the default debug/release target and then execute crank run. For example:

cargo build --target x86_64-pc-windows-msvc
cp -fo .\target\x86_64-pc-windows-msvc\debug\* .\target\debug\
crank run

This works but it would be nice for crank to just work.
I would also be down to implement this but I've had some trouble finding a simple way to determine the output folder or all the sources we'd need to check to determine it. Any guidance on that and I think this would be a pretty simple patch.

Dynamically linked libraries

tl; dr

It seems possible to use dynamically linked libraries with the simulator but I can't figure out how to modify the search paths.

Hopefully this is doable on device as well or this is all moot.


I'm depending on a crate that provides bindings for a library, and it expects the library to be dynamically linked.

At first I was getting Undefined symbols for architecture with crank build. I've addressed that with the following build.rs:

use std::{env, path::Path};

fn main() {
    let cargo_manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();

   // This approach doesn't work because the library is named `foo_libqux.dylib`
   /*
    println!(
        "cargo:rustc-link-search=all={}",
        Path::new(&cargo_manifest_dir).join("lib").display()
    );

    println!("cargo:rustc-link-lib=dylib=retro");
   */

    println!(
        "cargo:rustc-link-arg={}",
        Path::new(&cargo_manifest_dir).join("lib/foo_libqux.dylib").display()
    );
}

However, crank build --run results in this error at runtime:

dlopen(/Users/py/projects/paulyoung/MyProject/main/target/My Project.pdx/pdex.dylib, 0x0006): Library not loaded: foo_libqux.dylib
  Referenced from: /Users/py/projects/paulyoung/MyProject/main/target/My Project.pdx/pdex.dylib
  Reason: tried: '/nix/store/g8b81w9kpb82gm7702ca692mp5flm7pf-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/foo_libqux.dylib' (no such file), '/nix/store/g8b81w9kpb82gm7702ca692mp5flm7pf-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/foo_libqux.dylib' (no such file), '/usr/lib/swift/foo_libqux.dylib' (no such file), '/Users/py/Developer/PlaydateSDK/bin/Playdate Simulator.app/Contents/MacOS/../Frameworks/foo_libqux.dylib' (no such file), '/Users/py/Developer/PlaydateSDK/bin/Playdate Simulator.app/Contents/MacOS/../Frameworks/foo_libqux.dylib' (no such file), '/usr/lib/swift/foo_libqux.dylib' (no such file), '/Users/py/Developer/PlaydateSDK/bin/Playdate Simulator.app/Contents/MacOS/../Frameworks/foo_libqux.dylib' (no such file), '/Users/py/Developer/PlaydateSDK/bin/Playdate Simulator.app/Contents/MacOS/../Frameworks/foo_libqux.dylib' (no such file), 'foo_libqux.dylib' (no such file), '/usr/local/lib/foo_libqux.dylib' (no such file), '/usr/lib/foo_libqux.dylib' (no such file), '//foo_libqux.dylib' (no such file), '/usr/local/lib/foo_libqux.dylib' (no such file), '/usr/lib/foo_libqux.dylib' (no such file)
(expand for a bulleted list of search paths)
  • /nix/store/g8b81w9kpb82gm7702ca692mp5flm7pf-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/foo_libqux.dylib
  • /nix/store/g8b81w9kpb82gm7702ca692mp5flm7pf-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/foo_libqux.dylib
  • /usr/lib/swift/foo_libqux.dylib
  • /Users/py/Developer/PlaydateSDK/bin/Playdate Simulator.app/Contents/MacOS/../Frameworks/foo_libqux.dylib
  • /Users/py/Developer/PlaydateSDK/bin/Playdate Simulator.app/Contents/MacOS/../Frameworks/foo_libqux.dylib
  • /usr/lib/swift/foo_libqux.dylib
  • /Users/py/Developer/PlaydateSDK/bin/Playdate Simulator.app/Contents/MacOS/../Frameworks/foo_libqux.dylib
  • /Users/py/Developer/PlaydateSDK/bin/Playdate Simulator.app/Contents/MacOS/../Frameworks/foo_libqux.dylib
  • foo_libqux.dylib
  • /usr/local/lib/foo_libqux.dylib
  • /usr/lib/foo_libqux.dylib
  • //foo_libqux.dylib
  • /usr/local/lib/foo_libqux.dylib
  • /usr/lib/foo_libqux.dylib

I've tried setting LD_LIBRARY_PATH=./lib, DYLD_LIBRARY_PATH=./lib, and DYLD_FALLBACK_LIBRARY_PATH=./lib when invoking crank but it doesn't make a difference to the search paths. I tried the same thing with open -a "Playdate Simulator" ./target/My\ Project.pdx but that didn't change anything either.

I also tried adding those environment variables via cmd.env in run_pdc and run_simulator in main.rs but still no change.

This obviously isn't a solution, but I copied the library and made it available at ~/Developer/PlaydateSDK/bin/Playdate Simulator.app/Contents/Frameworks/foo_libqux.dylib and things appear to work.

It at least seems to demonstrate that this should work for the simulator as long as the search paths are set correctly. I don't have a device yet and I'm not sure where to begin on making this work there but hopefully there's nothing preventing this.

If I could get some insight or advice on how to go about this properly I'd be very grateful. Happy to make a PR to propose changes or document what I've found as a result.

CI: autorelease workflow

Release workflow have to

  • can be triggered by "push tag" to "main" branches
  • watch crate version changes and push tag same as version of crate, then release
  • create "draft" release page with uploaded builds

Note: "main" branches means set of branches like:

  • main
  • master
  • release-{version}

Also will be great to have got a think about deploy to crates.io after release publication.

Error on windows about paths

This error and that

Screenshot 2023-07-15 at 22 29 14

Because of arm-gcc already installed, I'm sure problem in searching-algorithm in crank.

INFO  crank > compile_setup: "C:\\Program Files (x86)\\GNU Tools Arm Embedded\\9 2019-q4-major\\bin\\arm-none-eabi-gcc.exe" "-g3" "-c" "-mthumb" "-mcpu=cortex-m7" "-mfloat-abi=hard" "-mfpu=fpv5-sp-d16" "-D__FPU_USED=1" "-O2" "-falign-functions=16" "-fomit-frame-pointer" "-gdwarf-2" "-Wall" "-Wno-unused" "-Wstrict-prototypes" "-Wno-unknown-pragmas" "-fverbose-asm" "-Wdouble-promotion" "-mword-relocations" "-fno-common" "-ffunction-sections" "-fdata-sections" "-DTARGET_PLAYDATE=1" "-DTARGET_EXTENSION=1" "-fno-exceptions" "C:/Users/runneradmin/Documents/PlaydateSDK\\C_API\\buildsupport\\setup.c" "-I" "C:/Users/runneradmin/Documents/PlaydateSDK\\C_API" "-o" "D:\\a\\crank\\crank\\crankstart\\target\\thumbv7em-none-eabihf\\release\\setup.o"
Error: The system cannot find the path specified. (os error 3)

I suppose we need to pass normalized non-windows paths to gcc, replace \\ with normal separators /.

Control over `pdxinfo` contents

Hey,

Absolutely love these tools! Just wondering, when packaging up for a nice, proper app on the Playdate home screen, I couldn't seem to find a way to supply pdxinfo files?

I'd like to provide a card + launch image for my game, as well as supply the basic info fields like Author etc.

I might just be being silly and have missed for example a specific place I'm meant to put the file in, but I couldn't quite figure it out if that's the case.

Is there a way to do this with crank?

Thanks in advance

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.