So I want to chronicle what I did to get a Playdate game with the C API compiling on Linux. This might not be the ideal solutions, but it’s what got me running.
I downloaded the 1.4.0 Linux SDK https://devforum.play.date/t/playdate-sdk-1-4-0/1858
I’m on Manjaro Linux (KDE).
I’ve done my initial Playdate setup according to info in this thread: https://devforum.play.date/t/playdate-sdk-for-linux/628
Copy the Example Project
As a starting point I copied the folder
/C_API/Examples/Hello World/ from the Playdate SDK, as it contains a simple example project.
Install the correct Compiler
I’m on Manjaro, so in my case I had to install the
community/arm-none-eabi-newlib packages. This might be different for your distro.
CMake or Make?
There are two possible approaches to take, either using only a Makefile, or using CMake. Both work just fine. Just a Makefile is less complex, but if you want integration with IDEs (e.g. CLion) you will want to use CMake/CLion. I’ll go over both. (I’ll assume you’ve already installed make/cmake.)
Just a Makefile
Okay, what we want to do, is open that
Makefile and fix the path to the Playdate SDK. It will have something like
# Locate the SDK SDK = $(shell egrep '^\s*SDKRoot' ~/.Playdate/config | head -n 1 | cut -c9-)
in there, which seems to try to parse the path out of a config file, which doesn’t exist. So instead I just hardcoded the path (of course your path will most likely be different)
# Locate the SDK SDK = /home/toni/playdate
While you’re here, you can change the name of your output folder by changing:
PRODUCT = HelloWorld.pdx
Then simply call
make in your project directory and you will get a
HelloWorld.pdx (or whatever you changed it to), which you should be able to open in the simulator or upload to the device.
CMake + CLion
Again, first we want to fix the Playdate SDK path in the
CMakeLists.txt file in our example project. We will change
execute_process( COMMAND bash -c "egrep '^\\s*SDKRoot' $HOME/.Playdate/config" COMMAND head -n 1 COMMAND cut -c9- OUTPUT_VARIABLE SDK OUTPUT_STRIP_TRAILING_WHITESPACE )
to (of course again, use YOUR sdk path)
execute_process( COMMAND bash -c "echo /home/toni/playdate" OUTPUT_VARIABLE SDK OUTPUT_STRIP_TRAILING_WHITESPACE )
Again, you can change the name of the output pdx by changing the
hello_world in the following lines
# Game Name Customization set(PLAYDATE_GAME_NAME hello_world) set(PLAYDATE_GAME_DEVICE hello_world_DEVICE)
The instructions in the
Inside Playdate with C document in the SDK actually do a good job of explaining how to import the project in CLion, so best to follow those instructions next.
After you’ve set up the CLion project you will want to go to your Playdate SDK and open up the file
C_API/buildsupport/arm.cmake and fix the following line
which is most likely not the correct path to your arm gcc. Use the command
which arm-none-eabi-gcc to find the correct path, in my case it was
/usr/bin/arm-none-eabi-gcc. So I changed the line to
/bin/arm-none-eabi-gcc is appended after it.
Now when you build your project in CLion, you will get a
hello_world.pdx (or however you named it) which again you should be able to use in the simulator and device.
All in all it’s not to complicated, it’s just not fully documented. Things might change in future SDK releases, but this hopefully can still be a useful resource. Some things I did might not be a good idea, so please correct me in that case, I want to learn.
I haven’t even tackled debugging yet, but this at least gets me started to get something working.