pd-rs / crank Goto Github PK
View Code? Open in Web Editor NEWA wrapper for cargo to use creating games for the Playdate handheld gaming system.
License: MIT License
A wrapper for cargo to use creating games for the Playdate handheld gaming system.
License: MIT License
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))
That's neat nightly feature with which we don't need cargo-xbuild.
Just add args cargo +nightly -Z build-std --target=thumbv7em-none-eabihf
to cargo call for native build (I mean --device
).
I have already tested it for hello_world example and it works perfectly!
relevant issue: pd-rs/get-playdate-sdk#1
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",
]
Assuming it is in the SDK for linux as well, it would be better to use pdutil for all platforms.
So that the --device option works on Linux
manifest has no
This line is hardcoded for a specific playdate number so it won't work unless you're lucky enough to have that exact playdate.:
Line 370 in 6ac4323
When providing the --device
flag, +nightly
is added to cargo build
:
Lines 611 to 615 in f46cda4
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?
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.
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)
/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.
Release workflow have to
Note: "main" branches means set of branches like:
Also will be great to have got a think about deploy to crates.io after release publication.
This error and that
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 /
.
Currently they are hard coded, this issue represents designing and implementing some way of overriding those locations that works on Mac and Windows.
The Playdate has a small stack. Is it feasible to bake flip link into crank
for "stack overflow protection"?
https://github.com/knurling-rs/flip-link
The main problem appears to be "if you [are] using GNU ld
or GNU gcc
to link your program then [using the flip-link linker] won't work." crank
appears to use gcc
for linking.
As discovered in pd-rs/crankstart#41 (comment).
This happens in at least 2 cases that I'm aware of:
PLAYDATE_SERIAL_DEVICE
isn't set and the hard-coded value is used.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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.