Skip to content

Commit

Permalink
Add support for OS 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
samdze committed Jul 12, 2023
1 parent 5644250 commit c297918
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 21 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ jobs:
runs-on: ubuntu-latest
container: nimlang/nim
steps:
- name: Update dependencies
run: apt-get update
- name: Install dependencies
run: apt-get install -y make libpng16-16 gcc-arm-none-eabi
- uses: actions/checkout@v1
Expand Down Expand Up @@ -46,9 +48,9 @@ jobs:
- name: Force non-interactive apt installations
run: echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

- name: Update apt dependencies
- name: Update dependencies
run: apt-get update
- name: Install apt dependencies
- name: Install dependencies
run: apt-get install -y make libpng16-16 gcc-arm-none-eabi xvfb libgtk-3-0 sudo libwebkit2gtk-4.0 libwebkit2gtk-4.0-dev libsdl2-dev pulseaudio

# Because we are headless there is no audio driver to interact with by default, which causes a set
Expand Down
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"request": "launch",
"name": "Debug PDX",
"program": "${env:PLAYDATE_SDK_PATH}/bin/Playdate Simulator.app",
"args": ["${workspaceFolder}/PlaydateNim.pdx"],
"args": ["${workspaceFolder}/playdate_example.pdx"],
"cwd": "${workspaceFolder}"
},
{
Expand All @@ -18,7 +18,7 @@
"name": "Build & Debug PDX",
"preLaunchTask": "Build Universal PDX",
"program": "${env:PLAYDATE_SDK_PATH}/bin/Playdate Simulator.app",
"args": ["${workspaceFolder}/PlaydateNim.pdx"],
"args": ["${workspaceFolder}/playdate_example.pdx"],
"cwd": "${workspaceFolder}"
},
{
Expand All @@ -27,7 +27,7 @@
"name": "Build Sim. & Debug PDX",
"preLaunchTask": "Build Simulator PDX",
"program": "${env:PLAYDATE_SDK_PATH}/bin/Playdate Simulator.app",
"args": ["${workspaceFolder}/PlaydateNim.pdx"],
"args": ["${workspaceFolder}/playdate_example.pdx"],
"cwd": "${workspaceFolder}"
},
{
Expand Down
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
{
"label": "Build Universal PDX",
"type": "shell",
"command": "nim all"
"command": "nimble all",
},
{
"label": "Build Simulator PDX",
"type": "shell",
"command": "nim simulator"
"command": "nimble simulator"
},
{
"label": "Build Device PDX",
"type": "shell",
"command": "nim device"
"command": "nimble device"
}
]
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ A pre-compiled pdx is also provided, please test it on your device!

Compile the project (pdx) for the simulator using:
```sh
nim simulator
nimble simulator
```
For the device (compile only, no pdx):
For the device (elf only, use pdc to create a pdx):
```sh
nim device
nimble device
```
For simulator + device (pdx):
```sh
nim all
nimble all
```

The template also has a VSCode launch configuration file to build, start and debug the Nim application from the editor.
Expand Down
2 changes: 1 addition & 1 deletion playdate.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.7.2"
version = "0.8.0"
author = "Samuele Zolfanelli"
description = "Playdate Nim bindings with extra features."
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion playdate_example/playdate_example.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.7.0"
version = "0.8.0"
author = "Samuele Zolfanelli"
description = "An example application using the Playdate Nim bindings"
license = "MIT"
Expand Down
6 changes: 5 additions & 1 deletion src/playdate/api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ macro initSDK*() =
NimMain()
api.playdate = playdateAPI
handler(event, arg)
return 0
return 0

when not defined(simulator):
proc fini() {.cdecl, exportc: "_fini".} =
discard
1 change: 1 addition & 0 deletions src/playdate/build/config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ when defined(simulator):
switch("debugger", "native")
switch("opt", "none")
switch("define", "nimPage256")
switch("define", "simulator")
3 changes: 2 additions & 1 deletion tests/config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import ../src/playdate/build/nimble
switch("compileOnly", "off")
switch("noMain", "off")
switch("path", "$projectDir/../src")
switch("passC", "-I" & sdkPath() & "/C_API -DTARGET_EXTENSION=1")
switch("passC", "-I" & sdkPath() & "/C_API -DTARGET_EXTENSION=1")
switch("define", "simulator")
2 changes: 1 addition & 1 deletion tests/playdate_tests.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.7.0"
version = "0.8.0"
author = "Samuele Zolfanelli"
description = "Unit tests for the Playdate Nim bindings"
license = "MIT"
Expand Down
10 changes: 6 additions & 4 deletions tests/t_graphics.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ proc execGraphicsTests*(runnable: bool) =
if runnable:
var value = create
discard value.get(1, 1)
value.set(0, 0)
# Using graphics.set to disambiguate.
# Otherwise, Nim complains in cases like this when we are inside a template.
graphics.set(value, 0, 0)
value.clear(0, 0)
value.set(0, 0, kColorWhite)
value.set(0, 0, kColorBlack)
graphics.set(value, 0, 0, kColorWhite)
graphics.set(value, 0, 0, kColorBlack)

test "Setting Frame bits should compile":
frameTests(playdate.graphics.getFrame())
Expand Down Expand Up @@ -48,5 +50,5 @@ proc execGraphicsTests*(runnable: bool) =

when isMainModule:
# We can't run these methods from the tests, so we're only interested in
# whether they compile
# whether they compile.
execGraphicsTests(runnable = false)

0 comments on commit c297918

Please sign in to comment.