Skip to content

Commit

Permalink
Merge pull request #8 from Stary2001/linux
Browse files Browse the repository at this point in the history
Fix building on Linux, add PLAYDATE_SDK_PATH support
  • Loading branch information
jaames authored Apr 17, 2022
2 parents 9ca209d + 0d5f18b commit 0d817bf
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 16 deletions.
26 changes: 19 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
cmake_minimum_required(VERSION 3.14)
set(CMAKE_C_STANDARD 11)

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
)
set(ENVSDK $ENV{PLAYDATE_SDK_PATH})

if (NOT ${ENVSDK} STREQUAL "")
# Convert path from Windows
file(TO_CMAKE_PATH ${ENVSDK} SDK)
else()
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
)
endif()

if (NOT EXISTS ${SDK})
message(FATAL_ERROR "SDK Path not found; set ENV value PLAYDATE_SDK_PATH")
return()
endif()

# Game Name Customization
set(PLAYDATE_GAME_NAME Playnote)
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ STACK_SIZE = 61800
PRODUCT = Playnote.pdx

# Locate the SDK
SDK = $(shell egrep '^\s*SDKRoot' ~/.Playdate/config | head -n 1 | cut -c9-)
SDK = ${PLAYDATE_SDK_PATH}
ifeq ($(SDK),)
SDK = $(shell egrep '^\s*SDKRoot' ~/.Playdate/config | head -n 1 | cut -c9-)
endif

ifeq ($(SDK),)
$(error SDK path not found; set ENV value PLAYDATE_SDK_PATH)
endif

######
# IMPORTANT: You must add your source folders to VPATH for make to find them
Expand Down
6 changes: 3 additions & 3 deletions Source/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ import './components/NoNoteDialog'
import './components/Thumbnail'
import './components/Timeline'
import './components/DitherSwatch'
import './components/ScrollBar'
import './components/Scrollbar'
import './components/KeyValList'
import './components/TextView'

import './scenes/Screenbase'
import './scenes/ScreenBase'

playdate.graphics.setFont(MAIN_FONT)
playdate.display.setRefreshRate(REFRESH_RATE_GLOBAL)
Expand Down Expand Up @@ -97,4 +97,4 @@ end
-- playdate.graphics.generateQRCode('https://playnote.studio/filehelp', 120, function (qr)
-- playdate.simulator.writeToFile(qr, '~/qr.png')
-- print('qr generated')
-- end)
-- end)
18 changes: 13 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@

# REPLACE WITH THE NAME OF YOUR PLAYDATE GAME PDX
GAME="Playnote.pdx"

# SDK installer writes the install location to ~/.Playdate/config
SDK = ${PLAYDATE_SDK_PATH}
ifeq ($(SDK),)
SDK = $(shell egrep '^\s*SDKRoot' ~/.Playdate/config | head -n 1 | cut -c9-)
endif
if [ -z $PLAYDATE_SDK_PATH ]; then
SDK=$(egrep '^\s*SDKRoot' ~/.Playdate/config | head -n 1 | cut -c9-)
else
SDK=$PLAYDATE_SDK_PATH
fi

if [ -z $SDK ]; then
echo "Playdate SDK path not found; set environment value PLAYDATE_SDK_PATH."
exit 1
fi

CMD=$1

if [ -z $CMD ]; then
Expand Down Expand Up @@ -84,4 +92,4 @@ if [ $CMD == "release" ]; then
rm ./${GAME}.zip
fi

exit 0
exit 0

0 comments on commit 0d817bf

Please sign in to comment.