diff --git a/.github/actions/build-setup/action.yml b/.github/actions/build-setup/action.yml index 09f54e9..f6453b9 100644 --- a/.github/actions/build-setup/action.yml +++ b/.github/actions/build-setup/action.yml @@ -1,4 +1,7 @@ name: Common build setup +inputs: + nim-version: + required: true runs: using: "composite" steps: @@ -7,6 +10,21 @@ runs: shell: bash run: git config --global --add safe.directory "$(pwd)" + - name: Install Nim + shell: bash + run: choosenim -y update ${{ inputs.nim-version }} + + - run: nimble --accept refresh + shell: bash + + - run: nimble install + shell: bash + + - name: Locally publish playdate nimble package + shell: bash + if: ${{ startsWith(inputs.nim-version, '1.') }} + run: nimble develop + # Some of the apt dependencies require input from the installer. This disables those # prompts so we can do a headless install - name: Force non-interactive apt installations @@ -28,7 +46,3 @@ runs: - name: Set PLAYDATE_SDK_PATH shell: bash run: echo "PLAYDATE_SDK_PATH=$(readlink -f $(find PlaydateSDK-* -maxdepth 0 -type d))" >> "$GITHUB_ENV" - - - name: Locally publish playdate nimble package - shell: bash - run: nimble develop \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 90ed24a..2aac1c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,13 +4,16 @@ jobs: example-project: runs-on: ubuntu-latest - container: nimlang/nim + container: nimlang/choosenim strategy: matrix: target: [ device, simulator ] + nim-version: [ 1.6.16, 2.0.2 ] steps: - uses: actions/checkout@v3 - uses: ./.github/actions/build-setup + with: + nim-version: ${{ matrix.nim-version }} - uses: ./.github/actions/project-setup with: working-directory: ./playdate_example @@ -19,21 +22,31 @@ jobs: tests: runs-on: ubuntu-latest - container: nimlang/nim + container: nimlang/choosenim + strategy: + matrix: + nim-version: [ 1.6.16, 2.0.2 ] steps: - uses: actions/checkout@v3 - uses: ./.github/actions/build-setup + with: + nim-version: ${{ matrix.nim-version }} - run: nimble test headless-tests: runs-on: ubuntu-latest timeout-minutes: 5 - container: nimlang/nim + container: nimlang/choosenim + strategy: + matrix: + nim-version: [ 1.6.16, 2.0.2 ] steps: - uses: actions/checkout@v3 - uses: ./.github/actions/build-setup + with: + nim-version: ${{ matrix.nim-version }} - uses: ./.github/actions/project-setup with: @@ -46,6 +59,7 @@ jobs: # of warnings to be emitted. This set of commands sets up a dummy audio sink that silences those warnings. - name: Setup audio sink run: | + export HOME="/config" pulseaudio -D --exit-idle-time=-1 pactl load-module module-null-sink sink_name=SpeakerOutput sink_properties=device.description="Dummy_Output" @@ -57,12 +71,15 @@ jobs: # alert from showing in the first place - name: Create simulator ini run: | - export PD_INI_DIR="$HOME/.config/Playdate Simulator" + export PD_INI_DIR="/config/.config/Playdate Simulator" mkdir -p "$PD_INI_DIR" export PD_INI_FILE="$PD_INI_DIR/Playdate Simulator.ini" echo "ShowPerfWarning=0" > $PD_INI_FILE echo "ShowElist=0" >> $PD_INI_FILE echo "LastRelease=$(cat PlaydateSDK-*/VERSION.txt)" >> $PD_INI_FILE - - run: xvfb-run ../PlaydateSDK-*/bin/PlaydateSimulator tests.pdx + - name: Run headless test working-directory: ./tests + run: | + export HOME="/config" + xvfb-run ../PlaydateSDK-*/bin/PlaydateSimulator tests.pdx \ No newline at end of file diff --git a/README.md b/README.md index caca804..37411c2 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ This package is an independent bindings library, not affiliated with Panic. ### Prerequisites - Playdate SDK -- Nim 1.6.10+ (check with `nim -v`, untested with 2.0+) ([recommended extension for VSCode](https://marketplace.visualstudio.com/items?itemName=nimsaem.nimvscode)) +- Nim 1.6.10+ or Nim 2+ ([recommended extension for VSCode](https://marketplace.visualstudio.com/items?itemName=nimsaem.nimvscode)) - Nimble 0.13.1 (check with `nimble -v`) - `PLAYDATE_SDK_PATH` environment variable - [SDK Prerequisites](https://sdk.play.date/Inside%20Playdate%20with%20C.html#_prerequisites) based on OS, and [MinGW on Windows](https://code.visualstudio.com/docs/cpp/config-mingw). diff --git a/playdate_example/nimble.develop b/playdate_example/nimble.develop new file mode 100644 index 0000000..49def8e --- /dev/null +++ b/playdate_example/nimble.develop @@ -0,0 +1,7 @@ +{ + "version": 1, + "includes": [], + "dependencies": [ + ".." + ] +} diff --git a/src/playdate/build/config.nim b/src/playdate/build/config.nim index 865513a..0460b76 100644 --- a/src/playdate/build/config.nim +++ b/src/playdate/build/config.nim @@ -33,6 +33,7 @@ switch("passC", "-Wall") switch("passC", "-Wno-unknown-pragmas") switch("passC", "-Wdouble-promotion") switch("passC", "-I" & sdkPath() / "C_API") +switch("define", "useMalloc") when defined(device): switch("os", "any") @@ -46,7 +47,6 @@ when defined(device): switch("threads", "off") switch("assertions", "off") switch("hotCodeReloading", "off") - switch("define", "useMalloc") switch("define", "standalone") let heapSize = 8388208 diff --git a/tests/nimble.develop b/tests/nimble.develop new file mode 100644 index 0000000..49def8e --- /dev/null +++ b/tests/nimble.develop @@ -0,0 +1,7 @@ +{ + "version": 1, + "includes": [], + "dependencies": [ + ".." + ] +}