iOS port initial commit

Known Issues
------------
- No printing support.
- No typing support using the OS virtual keyboard.  iOS needs to be signalled
  to bring up the virtual keyboard when the text tool is active.  We also may
  need to do some finagling to make IM work with the virtual keyboard.
- OS language detection doesn't work yet.
- Quitting doesn't close the app.  It just displays a black screen until it is
  force-closed.
- Need to include cross-compilation instructions.

Possible Issues
---------------
- No text display.  This is likely an issue with how pango and related
  libraries were cross-compiled rather than an issue with Tux Paint code.  From
  the error output it appears to be a font rendering issue.
- SVG integration couldn't be tested because RSVG library has not yet be
  cross-compiled successfully.
- Only tested under the iOS Simulator (and not on an actual iOS device yet.)
This commit is contained in:
Mark Kim 2021-03-21 20:46:03 -04:00
parent bb357a51a1
commit 92196bd69a
16 changed files with 483 additions and 49 deletions

153
Makefile
View file

@ -38,6 +38,12 @@ else
ifeq ($(SYSNAME),Darwin) ifeq ($(SYSNAME),Darwin)
OS:=macos OS:=macos
GPERF:=/usr/bin/gperf GPERF:=/usr/bin/gperf
CC:=$(shell xcrun -f clang)
ARCHS:=$(shell uname -m)
MINVER:=10.8
SDKROOT:=$(shell xcrun --show-sdk-path)
HOSTROOT:=/opt/local
else else
ifeq ($(SYSNAME),BeOS) ifeq ($(SYSNAME),BeOS)
OS:=beos OS:=beos
@ -59,16 +65,67 @@ else
endif endif
endif endif
# CROSS COMPILATION OVERRIDES
#
# Usage:
# make HOST=<HOST> HOSTROOT=<HOSTROOT> [EXTRA_ARGS]
#
# <HOST> may be one of:
# iphoneos Build for the iphoneos, presumably on macOS.
# iphonesimulator Build for the iphonesimulator, presumably on macOS.
#
# <HOSTROOT> is the directory containing support files for building for <HOST>:
# <HOSTROOT>/include Header files.
# <HOSTROOT>/lib Library files.
# <HOSTROOT>/lib/pkgconfig *.pc files.
#
ifdef HOST
ifndef HOSTROOT
$(error Must set HOSTROOT to cross compile)
endif
ifeq ($(wildcard $(HOSTROOT)/.),)
$(error Invalid HOSTROOT: $(HOSTROOT))
endif
ifeq ($(HOST),iphoneos)
OS:=iphoneos
CC:=$(shell xcrun --sdk iphoneos -f clang)
ARCHS:=arm64 armv7s armv7
MINVER:=9.0
SDKROOT:=$(shell xcrun --sdk iphoneos --show-sdk-path)
else ifeq ($(HOST),iphonesimulator)
OS:=iphonesimulator
CC:=$(shell xcrun --sdk iphonesimulator -f clang)
ARCHS:=$(shell uname -m)
MINVER:=9.0
SDKROOT:=$(shell xcrun --sdk iphonesimulator --show-sdk-path)
else
$(error Invalid HOST: $(HOST))
endif
# We set PKG_CONFIG_LIBDIR instead of PKG_CONFIG_PATH because we want to
# *change* where pkg-config looks for .pc files instead of adding to the
# default path which may have libraries that aren't for HOST.
export PKG_CONFIG_LIBDIR:=$(HOSTROOT)/lib/pkgconfig
endif
# change to sdl-console to build a console version on Windows # change to sdl-console to build a console version on Windows
SDL_PCNAME:=sdl2 SDL_PCNAME:=sdl2
WINDRES:=windres WINDRES:=windres
PKG_CONFIG:=pkg-config PKG_CONFIG:=pkg-config
ifdef PKG_CONFIG_LIBDIR
# Cross compilation override
PKG_CONFIG:=PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR) $(PKG_CONFIG)
endif
# test if a library can be linked # test if a pkg-config library exists or can be linked manually
linktest = $(shell if $(CC) $(CPPFLAGS) $(CFLAGS) -o dummy.o dummy.c $(LDFLAGS) $(1) $(2) > /dev/null 2>&1; \ linktest = $(shell [ -n "$(1)" ] \
&& $(PKG_CONFIG) --exists $(1) \
&& $(PKG_CONFIG) --libs $(1) \
|| if $(CC) $(CPPFLAGS) $(CFLAGS) -o dummy.o dummy.c $(LDFLAGS) $(2) $(3) > /dev/null 2>&1; \
then \ then \
echo "$(1)"; \ echo "$(2)"; \
fi ;) fi ;)
# test compiler options # test compiler options
@ -88,50 +145,59 @@ RAD_CMD:=$($(OS)_RAD_CMD)
windows_SO_TYPE:=dll windows_SO_TYPE:=dll
macos_SO_TYPE:=dylib macos_SO_TYPE:=dylib
iphoneos_SO_TYPE:=dylib
iphonesimulator_SO_TYPE:=dylib
beos_SO_TYPE:=so beos_SO_TYPE:=so
linux_SO_TYPE:=so linux_SO_TYPE:=so
SO_TYPE:=$($(OS)_SO_TYPE) SO_TYPE:=$($(OS)_SO_TYPE)
windows_LIBMINGW:=-lmingw32 windows_LIBMINGW:=-L/usr/local/lib -lmingw32
LIBMINGW:=$($(OS)_LIBMINGW) LIBMINGW:=$($(OS)_LIBMINGW)
windows_EXE_EXT:=.exe windows_EXE_EXT:=.exe
EXE_EXT:=$($(OS)_EXE_EXT) EXE_EXT:=$($(OS)_EXE_EXT)
windows_BUNDLE:= macos_BUNDLE:=./TuxPaint.app
macos_BUNDLE=./TuxPaint.app iphoneos_BUNDLE:=./TuxPaint-iphoneos.app
beos_BUNDLE:= iphonesimulator_BUNDLE:=./TuxPaint-iphonesimulator.app
linux_BUNDLE:=
BUNDLE:=$($(OS)_BUNDLE) BUNDLE:=$($(OS)_BUNDLE)
windows_ARCH_LIBS:=obj/win32_print.o obj/resource.o windows_ARCH_LIBS:=obj/win32_print.o obj/resource.o
macos_ARCH_LIBS:=src/macos_print.m obj/macos.o macos_ARCH_LIBS:=src/macos_print.m obj/macos.o
iphoneos_ARCH_LIBS:=src/ios_print.m obj/ios.o
iphonesimulator_ARCH_LIBS:=src/ios_print.m obj/ios.o
beos_ARCH_LIBS:=obj/BeOS_print.o beos_ARCH_LIBS:=obj/BeOS_print.o
linux_ARCH_LIBS:=obj/postscript_print.o linux_ARCH_LIBS:=obj/postscript_print.o
ARCH_LIBS:=$($(OS)_ARCH_LIBS) ARCH_LIBS:=$($(OS)_ARCH_LIBS)
windows_ARCH_CFLAGS:= windows_ARCH_CFLAGS:=
macos_ARCH_CFLAGS:=-mmacosx-version-min=10.8 -isystem /opt/local/include -DHAVE_STRCASESTR -w -headerpad_max_install_names macos_ARCH_CFLAGS:=-isysroot $(SDKROOT) -I$(SDKROOT)/usr/include -I$(HOSTROOT)/include -mmacosx-version-min=$(MINVER) -arch $(subst $() $(), -arch ,$(ARCHS)) -w -headerpad_max_install_names -DHAVE_STRCASESTR
iphoneos_ARCH_CFLAGS:=-isysroot $(SDKROOT) -I$(SDKROOT)/usr/include -I$(HOSTROOT)/include -miphoneos-version-min=$(MINVER) -arch $(subst $() $(), -arch ,$(ARCHS)) -w -fPIC -DHAVE_STRCASESTR -DUNLINK_ONLY
iphonesimulator_ARCH_CFLAGS:=-isysroot $(SDKROOT) -I$(SDKROOT)/usr/include -I$(HOSTROOT)/include -mios-simulator-version-min=$(MINVER) -arch $(subst $() $(), -arch ,$(ARCHS)) -w -fPIC -DHAVE_STRCASESTR -DUNLINK_ONLY
beos_ARCH_CFLAGS:= beos_ARCH_CFLAGS:=
linux_ARCH_CFLAGS:= linux_ARCH_CFLAGS:=
ARCH_CFLAGS:=$($(OS)_ARCH_CFLAGS) ARCH_CFLAGS:=$($(OS)_ARCH_CFLAGS)
windows_ARCH_LDFLAGS:= windows_ARCH_LDFLAGS:=
macos_ARCH_LDFLAGS:=-L/opt/local/lib macos_ARCH_LDFLAGS:=-isysroot $(SDKROOT) -L$(HOSTROOT)/lib -mmacosx-version-min=$(MINVER) -arch $(subst $() $(), -arch ,$(ARCHS))
iphoneos_ARCH_LDFLAGS:=-isysroot $(SDKROOT) -L$(HOSTROOT)/lib -miphoneos-version-min=$(MINVER) -arch $(subst $() $(), -arch ,$(ARCHS))
iphonesimulator_ARCH_LDFLAGS:=-isysroot $(SDKROOT) -L$(HOSTROOT)/lib -mios-simulator-version-min=$(MINVER) -arch $(subst $() $(), -arch ,$(ARCHS))
beos_ARCH_LDFLAGS:= beos_ARCH_LDFLAGS:=
linux_ARCH_LDFLAGS:= linux_ARCH_LDFLAGS:=
ARCH_LDFLAGS:=$($(OS)_ARCH_LDFLAGS) ARCH_LDFLAGS:=$($(OS)_ARCH_LDFLAGS)
LDFLAGS:=$(ARCH_LDFLAGS) LDFLAGS:=$(ARCH_LDFLAGS)
PAPER_LIB:=$(call linktest,-lpaper,) PAPER_LIB:=$(call linktest,,-lpaper,)
PNG:=$(call linktest,-lpng,) PNG:=$(call linktest,libpng,-lpng,)
PNG:=$(if $(PNG),$(PNG),$(call linktest,-lpng12,)) PNG:=$(if $(PNG),$(PNG),$(call linktest,,-lpng12,))
FRIBIDI_LIB:=$(shell $(PKG_CONFIG) --libs fribidi) FRIBIDI_LIB:=$(shell $(PKG_CONFIG) --libs fribidi)
FRIBIDI_CFLAGS:=$(shell $(PKG_CONFIG) --cflags fribidi) FRIBIDI_CFLAGS:=$(shell $(PKG_CONFIG) --cflags fribidi)
windows_ARCH_LINKS:=-lgdi32 -lcomdlg32 $(PNG) -lz -lwinspool -lshlwapi $(FRIBIDI_LIB) -liconv -limagequant windows_ARCH_LINKS:=-lgdi32 -lcomdlg32 $(PNG) -lz -lwinspool -lshlwapi $(FRIBIDI_LIB) -liconv -limagequant
macos_ARCH_LINKS:=$(FRIBIDI_LIB) -limagequant -lSDLmain -Wl,-framework,AppKit -Wl,-framework,Cocoa macos_ARCH_LINKS:=$(FRIBIDI_LIB) -limagequant -lSDLmain -Wl,-framework,AppKit -Wl,-framework,Cocoa
iphoneos_ARCH_LINKS:=$(FRIBIDI_LIB) -limagequant -ljpeg -lbz2 $(shell $(PKG_CONFIG) --libs freetype2 libtiff-4 libwebp libffi harfbuzz libmpg123 ogg vorbisenc vorbisidec libxml-2.0 pangoft2 libpcre)
iphonesimulator_ARCH_LINKS:=$(FRIBIDI_LIB) -limagequant -ljpeg -lbz2 $(shell $(PKG_CONFIG) --libs freetype2 libtiff-4 libwebp libffi harfbuzz libmpg123 ogg vorbisenc vorbisidec libxml-2.0 pangoft2 libpcre)
beos_ARCH_LINKS:=-lintl $(PNG) -lz -lbe -lnetwork -liconv $(FRIBIDI_LIB) $(PAPER_LIB) $(STDC_LIB) -limagequant beos_ARCH_LINKS:=-lintl $(PNG) -lz -lbe -lnetwork -liconv $(FRIBIDI_LIB) $(PAPER_LIB) $(STDC_LIB) -limagequant
linux_ARCH_LINKS:=$(PAPER_LIB) $(FRIBIDI_LIB) -limagequant linux_ARCH_LINKS:=$(PAPER_LIB) $(FRIBIDI_LIB) -limagequant
ARCH_LINKS:=$($(OS)_ARCH_LINKS) ARCH_LINKS:=$($(OS)_ARCH_LINKS)
@ -143,18 +209,24 @@ linux_ARCH_HEADERS:=
ARCH_HEADERS:=$($(OS)_ARCH_HEADERS) ARCH_HEADERS:=$($(OS)_ARCH_HEADERS)
# Where things will go when ultimately installed: # Where things will go when ultimately installed:
# For macOS, the prefix is relative to DESTDIR. # For macOS and iOS, the prefix is relative to DESTDIR.
windows_PREFIX:=/usr/local windows_PREFIX:=/usr/local
macos_PREFIX:=Resources macos_PREFIX:=Resources
iphoneos_PREFIX:=Resources
iphonesimulator_PREFIX:=Resources
linux_PREFIX:=/usr/local linux_PREFIX:=/usr/local
PREFIX:=$($(OS)_PREFIX) PREFIX:=$($(OS)_PREFIX)
# Root directory to place files when creating packages. # Root directory to place files when creating packages.
# PKG_ROOT is the old name for this, and should be undefined. # PKG_ROOT is the old name for this, and should be undefined.
# macOS is set up as a bundle, with all files under 'Contents'. # macOS and iOS are set up as bundles, with all files under the bundle.
# "TuxPaint-1" is the OLPC XO name. Installing to ./ is bad! # "TuxPaint-1" is the OLPC XO name. Installing to ./ is bad!
ifeq ($(OS),macos) ifeq ($(OS),macos)
DESTDIR:=$(BUNDLE)/Contents/ DESTDIR:=$(BUNDLE)/Contents/
else ifeq ($(OS),iphoneos)
DESTDIR:=$(BUNDLE)/
else ifeq ($(OS),iphonesimulator)
DESTDIR:=$(BUNDLE)/
else ifeq ($(PREFIX),./) else ifeq ($(PREFIX),./)
DESTDIR:=TuxPaint-1 DESTDIR:=TuxPaint-1
else else
@ -216,14 +288,18 @@ CURSOR_SHAPES:=LARGE
# CURSOR_SHAPES:=SMALL # CURSOR_SHAPES:=SMALL
# Libraries, paths, and flags: # Libraries, paths, and flags:
SDL_LIBS:=$(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL2_image -lSDL2_ttf -lz $(PNG) SDL_LIBS:=$(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs)
SDL_LIBS+=$(call linktest,SDL2_image,-lSDL2_image,$(SDL_LIBS))
SDL_LIBS+=$(call linktest,SDL2_ttf,-lSDL2_ttf,$(SDL_LIBS))
SDL_LIBS+=$(call linktest,zlib,-lz,)
SDL_LIBS+=$(call linktest,libpng,$(PNG),)
# Sound support # Sound support
SDL_MIXER_LIB:=$(call linktest,-lSDL2_mixer,$(SDL_LIBS)) SDL_MIXER_LIB:=$(call linktest,SDL2_mixer,-lSDL2_mixer,$(SDL_LIBS))
NOSOUNDFLAG:=$(if $(SDL_MIXER_LIB),,-DNOSOUND$(warning -lSDL2_Mixer failed, no sound for you!)) NOSOUNDFLAG:=$(if $(SDL_MIXER_LIB),,-DNOSOUND$(warning -lSDL2_Mixer failed, no sound for you!))
# SDL Pango is needed to render complex scripts like Thai and Arabic # SDL Pango is needed to render complex scripts like Thai and Arabic
SDL2_PANGO_LIB:=$(call linktest,-lSDL2_Pango,$(SDL_LIBS)) SDL2_PANGO_LIB:=$(call linktest,SDL2_Pango,-lSDL2_Pango,$(SDL_LIBS))
NOPANGOFLAG:=$(if $(SDL2_PANGO_LIB),,-DNO_SDLPANGO$(warning -lSDL2_Pango failed, no scripts for you!)) NOPANGOFLAG:=$(if $(SDL2_PANGO_LIB),,-DNO_SDLPANGO$(warning -lSDL2_Pango failed, no scripts for you!))
SDL_LIBS+=$(SDL_MIXER_LIB) $(SDL2_PANGO_LIB) SDL_LIBS+=$(SDL_MIXER_LIB) $(SDL2_PANGO_LIB)
@ -478,6 +554,8 @@ trans:
windows_ARCH_INSTALL:= windows_ARCH_INSTALL:=
macos_ARCH_INSTALL:=install-macbundle TuxPaint.dmg macos_ARCH_INSTALL:=install-macbundle TuxPaint.dmg
iphoneos_ARCH_INSTALL:=install-iosbundle
iphonesimulator_ARCH_INSTALL:=install-iosbundle
linux_ARCH_INSTALL:=install-xdg linux_ARCH_INSTALL:=install-xdg
ARCH_INSTALL:=$($(OS)_ARCH_INSTALL) ARCH_INSTALL:=$($(OS)_ARCH_INSTALL)
@ -1025,7 +1103,7 @@ install-man:
.PHONY: install-macbundle .PHONY: install-macbundle
install-macbundle: install-macbundle:
@echo @echo
@echo "...Installing App Bundle Support Files..." @echo "...Installing macOS App Bundle Support Files..."
@install -d -m 755 $(BUNDLE)/Contents/MacOS @install -d -m 755 $(BUNDLE)/Contents/MacOS
@install -d -m 755 $(BUNDLE)/Contents/Resources @install -d -m 755 $(BUNDLE)/Contents/Resources
@install -d -m 755 $(BUNDLE)/Contents/lib @install -d -m 755 $(BUNDLE)/Contents/lib
@ -1035,6 +1113,20 @@ install-macbundle:
@install -m 644 macos/tuxpaint.icns $(BUNDLE)/Contents/Resources @install -m 644 macos/tuxpaint.icns $(BUNDLE)/Contents/Resources
@macos/build-app.sh @macos/build-app.sh
# Install the support files for iOS application bundle
.PHONY: install-iosbundle
install-iosbundle:
@echo
@echo "...Installing iOS App Bundle Support Files..."
install -m 755 tuxpaint $(BUNDLE)
install -m 644 ios/PkgInfo $(BUNDLE)
install -m 644 ios/Info.plist $(BUNDLE)
install -m 644 ios/Info.plist $(BUNDLE)/Resources
install -m 644 ios/tuxpaint.icns $(BUNDLE)
install -m 644 ios/tuxpaint.cfg $(BUNDLE)
install -m 644 ios/Splash.png $(BUNDLE)
ibtool --compile $(BUNDLE)/Splash.storyboardc ios/Splash.storyboard
# Create DMG for macOS # Create DMG for macOS
TuxPaint.dmg: TuxPaint.dmg:
@ -1071,7 +1163,7 @@ obj/tuxpaint.o: src/tuxpaint.c \
src/tools.h src/titles.h src/colors.h src/shapes.h \ src/tools.h src/titles.h src/colors.h src/shapes.h \
src/sounds.h src/tip_tux.h src/great.h \ src/sounds.h src/tip_tux.h src/great.h \
src/tp_magic_api.h src/parse.h src/onscreen_keyboard.h \ src/tp_magic_api.h src/parse.h src/onscreen_keyboard.h \
src/gifenc.h \ src/gifenc.h src/platform.h \
src/$(MOUSEDIR)/arrow.xbm src/$(MOUSEDIR)/arrow-mask.xbm \ src/$(MOUSEDIR)/arrow.xbm src/$(MOUSEDIR)/arrow-mask.xbm \
src/$(MOUSEDIR)/hand.xbm src/$(MOUSEDIR)/hand-mask.xbm \ src/$(MOUSEDIR)/hand.xbm src/$(MOUSEDIR)/hand-mask.xbm \
src/$(MOUSEDIR)/insertion.xbm \ src/$(MOUSEDIR)/insertion.xbm \
@ -1211,12 +1303,18 @@ obj/postscript_print.o: src/postscript_print.c \
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \ @$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/postscript_print.c -o obj/postscript_print.o -c src/postscript_print.c -o obj/postscript_print.o
obj/macos.o: src/macos.c src/macos.h src/debug.h obj/macos.o: src/macos.c src/macos.h src/platform.h src/debug.h
@echo @echo
@echo "...Compiling macOS support..." @echo "...Compiling macOS support..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \ @$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/macos.c -o obj/macos.o -c src/macos.c -o obj/macos.o
obj/ios.o: src/ios.c src/ios.h src/platform.h src/debug.h
@echo
@echo "...Compiling iOS support..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/ios.c -o obj/ios.o
obj/resource.o: win32/resources.rc win32/resource.h obj/resource.o: win32/resources.rc win32/resource.h
@echo @echo
@echo "...Compiling win32 resources..." @echo "...Compiling win32 resources..."
@ -1256,11 +1354,20 @@ obj:
###### ######
MAGIC_SDL_CPPFLAGS:=$(shell $(PKG_CONFIG) $(SDL_PCNAME) --cflags) MAGIC_SDL_CPPFLAGS:=$(shell $(PKG_CONFIG) $(SDL_PCNAME) --cflags)
MAGIC_SDL_LIBS:=-L/usr/local/lib $(LIBMINGW) $(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL2_image -lSDL2_ttf $(SDL_MIXER_LIB) MAGIC_SDL_LIBS:=$(LIBMINGW) $(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL2_image -lSDL2_ttf $(SDL_MIXER_LIB)
MAGIC_ARCH_LINKS:=-lintl $(PNG) windows_MAGIC_ARCH_LINKS:=-lintl $(PNG)
macos_MAGIC_ARCH_LINKS:=-lintl $(PNG)
iphoneos_MAGIC_ARCH_LINKS:=-lintl -ljpeg $(PNG) $(shell $(PKG_CONFIG) --libs libtiff-4 libwebp libmpg123 ogg vorbisenc vorbisidec)
iphonesimulator_MAGIC_ARCH_LINKS:=-lintl -ljpeg $(PNG) $(shell $(PKG_CONFIG) --libs libtiff-4 libwebp libmpg123 ogg vorbisenc vorbisidec)
beos_MAGIC_ARCH_LINKS:=-lintl $(PNG)
linux_MAGIC_ARCH_LINKS:=-lintl $(PNG)
MAGIC_ARCH_LINKS:=$($(OS)_MAGIC_ARCH_LINKS)
windows_PLUGIN_LIBS:=$(MAGIC_SDL_LIBS) $(MAGIC_ARCH_LINKS) windows_PLUGIN_LIBS:=$(MAGIC_SDL_LIBS) $(MAGIC_ARCH_LINKS)
macos_PLUGIN_LIBS:=$(MAGIC_SDL_LIBS) $(MAGIC_ARCH_LINKS) macos_PLUGIN_LIBS:=$(MAGIC_SDL_LIBS) $(MAGIC_ARCH_LINKS)
iphoneos_PLUGIN_LIBS:=$(MAGIC_SDL_LIBS) $(MAGIC_ARCH_LINKS)
iphonesimulator_PLUGIN_LIBS:=$(MAGIC_SDL_LIBS) $(MAGIC_ARCH_LINKS)
beos_PLUGIN_LIBS:="$(MAGIC_SDL_LIBS) $(MAGIC_ARCH_LINKS) $(MAGIC_SDL_CPPFLAGS)" beos_PLUGIN_LIBS:="$(MAGIC_SDL_LIBS) $(MAGIC_ARCH_LINKS) $(MAGIC_SDL_CPPFLAGS)"
linux_PLUGIN_LIBS:= linux_PLUGIN_LIBS:=
PLUGIN_LIBS:=$($(OS)_PLUGIN_LIBS) PLUGIN_LIBS:=$($(OS)_PLUGIN_LIBS)

39
ios/Info.plist Normal file
View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>tuxpaint</string>
<key>CFBundleGetInfoString</key>
<string>0.9.26, Copyright 2009-2020, Tux Paint Development Team</string>
<key>CFBundleIconFile</key>
<string>tuxpaint.icns</string>
<key>CFBundleIdentifier</key>
<string>com.newbreedsoftware.tuxpaint</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Tux Paint</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.9.26</string>
<key>CFBundleSignature</key>
<string>TXPT</string>
<key>CFBundleVersion</key>
<string>2020-12-27</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UILaunchStoryboardName</key>
<string>Splash</string>
</dict>
</plist>

1
ios/PkgInfo Normal file
View file

@ -0,0 +1 @@
APPLTXPT

BIN
ios/Splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

40
ios/Splash.storyboard Normal file
View file

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Splash.png" translatesAutoresizingMaskIntoConstraints="NO" id="VeL-6u-rS3"/>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="VeL-6u-rS3" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="C5X-Vg-tvO"/>
<constraint firstAttribute="trailing" secondItem="VeL-6u-rS3" secondAttribute="trailing" id="X4i-1U-3JE"/>
<constraint firstItem="VeL-6u-rS3" firstAttribute="bottom" secondItem="xb3-aO-Qok" secondAttribute="top" id="dSu-2l-DcF"/>
<constraint firstItem="VeL-6u-rS3" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="xKC-uj-bxE"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="52" y="374.66266866566718"/>
</scene>
</scenes>
<resources>
<image name="Splash.png" width="800" height="550"/>
</resources>
</document>

4
ios/tuxpaint.cfg Normal file
View file

@ -0,0 +1,4 @@
# Default iOS tuxpaint.cfg
fullscreen=native
noprint=yes

BIN
ios/tuxpaint.icns Normal file

Binary file not shown.

View file

@ -56,6 +56,7 @@
The renaming ends here. The renaming ends here.
*/ */
#include "platform.h"
#include "fonts.h" #include "fonts.h"
#include "i18n.h" #include "i18n.h"
#include "progressbar.h" #include "progressbar.h"
@ -67,8 +68,10 @@
#include "win32_print.h" #include "win32_print.h"
#endif #endif
#ifdef __APPLE__ #if defined(__MACOS__)
#include "macos.h" #include "macos.h"
#elif defined(__IOS__)
#include "ios.h"
#endif #endif
#ifdef __HAIKU__ #ifdef __HAIKU__
@ -193,7 +196,7 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size)
if (!ret) if (!ret)
{ {
snprintf(str, sizeof(str), "%s/%s.ttf", macos_fontsPath(), lang_prefix); snprintf(str, sizeof(str), "%s/%s.ttf", apple_fontsPath(), lang_prefix);
ret = TuxPaint_Font_OpenFont("", str, size); ret = TuxPaint_Font_OpenFont("", str, size);
} }
#endif #endif
@ -981,7 +984,7 @@ static void loadfonts(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer
#elif defined(__APPLE__) #elif defined(__APPLE__)
loadfonts(screen, texture, renderer, "/System/Library/Fonts"); loadfonts(screen, texture, renderer, "/System/Library/Fonts");
loadfonts(screen, texture, renderer, "/Library/Fonts"); loadfonts(screen, texture, renderer, "/Library/Fonts");
loadfonts(screen, texture, renderer, macos_fontsPath()); loadfonts(screen, texture, renderer, apple_fontsPath());
loadfonts(screen, texture, renderer, "/usr/share/fonts"); loadfonts(screen, texture, renderer, "/usr/share/fonts");
loadfonts(screen, texture, renderer, "/usr/X11R6/lib/X11/fonts"); loadfonts(screen, texture, renderer, "/usr/X11R6/lib/X11/fonts");
#elif defined(__ANDROID__) #elif defined(__ANDROID__)

46
src/ios.c Normal file
View file

@ -0,0 +1,46 @@
/*
ios.c
Copyright (c) 2021
http://www.tuxpaint.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ios.h"
#define IOS_FONTS_PATH "../Library/Fonts"
#define IOS_PREFERENCES_PATH "../Library/Application Support/TuxPaint"
const char *apple_fontsPath(void)
{
return IOS_FONTS_PATH;
}
const char *apple_preferencesPath(void)
{
return IOS_PREFERENCES_PATH;
}
const char *apple_globalPreferencesPath(void)
{
return IOS_PREFERENCES_PATH;
}

30
src/ios.h Normal file
View file

@ -0,0 +1,30 @@
/*
ios.h
Copyright (c) 2021
http://www.tuxpaint.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
*/
#ifndef __IOS_H__
#define __IOS_H__
const char *apple_fontsPath(void);
const char *apple_preferencesPath(void);
const char *apple_globalPreferencesPath(void);
#endif /* __IOS_H__ */

32
src/ios_print.h Normal file
View file

@ -0,0 +1,32 @@
/*
ios_print.h
Copyright (c) 2021
http://www.tuxpaint.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
*/
#ifndef __IOS_PRINT_H__
#define __IOS_PRINT_H__
#include "SDL.h"
int DisplayPageSetup(const SDL_Surface* surface);
const char* SurfacePrint(const SDL_Surface* surface, int showDialog);
#endif /* __IOS_PRINT_H__ */

39
src/ios_print.m Normal file
View file

@ -0,0 +1,39 @@
/*
ios_print.m
Copyright (c) 2021
http://www.tuxpaint.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
*/
#import "ios_print.h"
int DisplayPageSetup(const SDL_Surface* surface)
{
/* TODO */
return 0;
}
const char* SurfacePrint(const SDL_Surface* surface, int showDialog)
{
/* TODO */
return NULL;
}

View file

@ -1,5 +1,23 @@
/* /*
* FIXME macos.c
Copyright (c) 2021
http://www.tuxpaint.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -14,7 +32,7 @@
/** /**
* FIXME * FIXME
*/ */
const char *macos_fontsPath(void) const char *apple_fontsPath(void)
{ {
static char *p = NULL; static char *p = NULL;
@ -27,7 +45,7 @@ const char *macos_fontsPath(void)
if (p) if (p)
sprintf(p, MACOS_FONTS_PATH, getenv("HOME")); sprintf(p, MACOS_FONTS_PATH, getenv("HOME"));
else else
perror("macos_fontsPath"); perror("apple_fontsPath");
} }
return p; return p;
@ -37,7 +55,7 @@ const char *macos_fontsPath(void)
/** /**
* FIXME * FIXME
*/ */
const char *macos_preferencesPath(void) const char *apple_preferencesPath(void)
{ {
static char *p = NULL; static char *p = NULL;
@ -50,7 +68,7 @@ const char *macos_preferencesPath(void)
if (p) if (p)
sprintf(p, MACOS_PREFERENCES_PATH, getenv("HOME")); sprintf(p, MACOS_PREFERENCES_PATH, getenv("HOME"));
else else
perror("macos_preferencesPath"); perror("apple_preferencesPath");
} }
return p; return p;
@ -60,7 +78,7 @@ const char *macos_preferencesPath(void)
/** /**
* FIXME * FIXME
*/ */
const char *macos_globalPreferencesPath(void) const char *apple_globalPreferencesPath(void)
{ {
return MACOS_GLOBAL_PREFERENCES_PATH; return MACOS_GLOBAL_PREFERENCES_PATH;
} }

View file

@ -1,9 +1,30 @@
/*
macos.h
Copyright (c) 2021
http://www.tuxpaint.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
*/
#ifndef __MACOS_H__ #ifndef __MACOS_H__
#define __MACOS_H__ #define __MACOS_H__
const char *macos_fontsPath(void); const char *apple_fontsPath(void);
const char *macos_preferencesPath(void); const char *apple_preferencesPath(void);
const char *macos_globalPreferencesPath(void); const char *apple_globalPreferencesPath(void);
#endif /* __MACOS_H__ */ #endif /* __MACOS_H__ */

45
src/platform.h Normal file
View file

@ -0,0 +1,45 @@
/*
platform.h
Copyright (c) 2021
http://www.tuxpaint.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
*/
#ifndef __PLATFORM_H__
#define __PLATFORM_H__
#if defined(__APPLE__)
#include <TargetConditionals.h>
/*
* MAC test must be last because it tests true even on iOS / tvOS / watchOS.
*/
#if TARGET_OS_IOS || TARGET_OS_IPHONE || TARGET_OS_SIMULATOR || TARGET_IPHONE_SIMULATOR || TARGET_OS_EMBEDDED
#define __IOS__ 1
#elif TARGET_OS_OSX || TARGET_OS_MAC
#define __MACOS__ 1
#else
#define __OTHER_APPLE__ 1
#warning "Unsupported Apple platform, will build on a best-effort basis"
#endif
#endif /* __APPLE__ */
#endif /* __PLATFORM_H__ */

View file

@ -25,6 +25,7 @@
June 14, 2002 - March 8, 2021 June 14, 2002 - March 8, 2021
*/ */
#include "platform.h"
/* (Note: VER_VERSION and VER_DATE are now handled by Makefile) */ /* (Note: VER_VERSION and VER_DATE are now handled by Makefile) */
@ -303,15 +304,21 @@ typedef struct safer_dirent
/* Not BeOS */ /* Not BeOS */
#ifdef __APPLE__ #if defined(__MACOS__)
/* Apple */ /* macOS */
#include "macos_print.h" #include "macos_print.h"
#else /* __APPLE__ */ #elif defined(__IOS__)
/* Not Windows, not BeOS, not Apple */ /* iOS */
#include "ios_print.h"
#else /* __MACOS__, __IOS__ */
/* Not Windows, not BeOS, not macOS, not iOS */
#ifdef __ANDROID__ #ifdef __ANDROID__
#define AUTOSAVE_GOING_BACKGROUND #define AUTOSAVE_GOING_BACKGROUND
@ -326,7 +333,7 @@ typedef struct safer_dirent
#endif /* __ANDROID__ */ #endif /* __ANDROID__ */
#endif /* __APPLE__ */ #endif /* __MACOS__, __IOS__ */
#endif /* __BEOS__ */ #endif /* __BEOS__ */
@ -373,8 +380,10 @@ static void mtw(wchar_t * wtok, char *tok)
#endif /* WIN32 */ #endif /* WIN32 */
#ifdef __APPLE__ #if defined(__MACOS__)
#include "macos.h" #include "macos.h"
#elif defined(__IOS__)
#include "ios.h"
#endif #endif
#include <errno.h> #include <errno.h>
@ -17718,7 +17727,7 @@ void do_print(void)
SurfacePrint(save_canvas); SurfacePrint(save_canvas);
#elif defined(__APPLE__) #elif defined(__APPLE__)
/* Mac OS X */ /* macOS, iOS */
int show = (want_alt_printcommand && !fullscreen); int show = (want_alt_printcommand && !fullscreen);
const char *error = SurfacePrint(save_canvas, show); const char *error = SurfacePrint(save_canvas, show);
@ -23925,7 +23934,7 @@ static void setup_config(char *argv[])
result = find_directory(B_USER_SETTINGS_DIRECTORY, volume, false, buffer, sizeof(buffer)); result = find_directory(B_USER_SETTINGS_DIRECTORY, volume, false, buffer, sizeof(buffer));
asprintf((char **)&savedir, "%s/%s", buffer, "TuxPaint"); asprintf((char **)&savedir, "%s/%s", buffer, "TuxPaint");
#elif __APPLE__ #elif __APPLE__
savedir = strdup(macos_preferencesPath()); savedir = strdup(apple_preferencesPath());
#elif __ANDROID__ #elif __ANDROID__
savedir = SDL_AndroidGetExternalStoragePath(); savedir = SDL_AndroidGetExternalStoragePath();
#else #else
@ -23969,8 +23978,8 @@ static void setup_config(char *argv[])
/* BeOS: Use a "tuxpaint.cfg" file: */ /* BeOS: Use a "tuxpaint.cfg" file: */
strcpy(str, "tuxpaint.cfg"); /* safe; sufficient size */ strcpy(str, "tuxpaint.cfg"); /* safe; sufficient size */
#elif defined(__APPLE__) #elif defined(__APPLE__)
/* Mac OS X: Use a "tuxpaint.cfg" file in the Tux Paint application support folder */ /* macOS, iOS: Use a "tuxpaint.cfg" file in the Tux Paint application support folder */
safe_snprintf(str, sizeof(str), "%s/tuxpaint.cfg", macos_preferencesPath()); safe_snprintf(str, sizeof(str), "%s/tuxpaint.cfg", apple_preferencesPath());
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
/* Try to find the user's config file */ /* Try to find the user's config file */
/* This file is writed by the tuxpaint config activity when the user runs it */ /* This file is writed by the tuxpaint config activity when the user runs it */
@ -24004,9 +24013,9 @@ static void setup_config(char *argv[])
#elif defined(__APPLE__) #elif defined(__APPLE__)
/* EP added this conditional section for Mac to fix /* EP added this conditional section for Mac to fix
folder & extension inconsistency with Tux Paint Config application) */ folder & extension inconsistency with Tux Paint Config application) */
/* Mac OS X: Use a "tuxpaint.cfg" file in the *global* Tux Paint /* macOS, iOS: Use a "tuxpaint.cfg" file in the *global* Tux Paint
application support folder */ application support folder */
safe_snprintf(str, sizeof(str), "%s/tuxpaint.cfg", macos_globalPreferencesPath()); safe_snprintf(str, sizeof(str), "%s/tuxpaint.cfg", apple_globalPreferencesPath());
parse_file_options(&tmpcfg_sys, str); parse_file_options(&tmpcfg_sys, str);
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
/* Load the config file we provide in assets/etc/tuxpaint.cfg */ /* Load the config file we provide in assets/etc/tuxpaint.cfg */
@ -24500,7 +24509,7 @@ static void chdir_to_binary(char *argv0)
char *app_path = strdup(argv0); char *app_path = strdup(argv0);
char *slash = strrchr(app_path, '/'); char *slash = strrchr(app_path, '/');
#if defined(__APPLE__) #if defined(__MACOS__)
// On macOS, execution is deep inside the app bundle. // On macOS, execution is deep inside the app bundle.
// E.g., "/Applications/TuxPaint.app/Contents/MacOS/tuxpaint" // E.g., "/Applications/TuxPaint.app/Contents/MacOS/tuxpaint"
// But we want to point somewhere higher up, say to "Contents", so we can access // But we want to point somewhere higher up, say to "Contents", so we can access