ruby2d 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/assets/README.md +1 -0
- data/assets/linux/simple2d/Makefile +250 -0
- data/assets/linux/simple2d/bin/simple2d.sh +1249 -0
- data/assets/linux/simple2d/include/simple2d.h +735 -0
- data/assets/linux/simple2d/src/controllers.c +110 -0
- data/assets/linux/simple2d/src/gl.c +426 -0
- data/assets/linux/simple2d/src/gl2.c +146 -0
- data/assets/linux/simple2d/src/gl3.c +275 -0
- data/assets/linux/simple2d/src/gles.c +308 -0
- data/assets/linux/simple2d/src/image.c +138 -0
- data/assets/linux/simple2d/src/input.c +48 -0
- data/assets/linux/simple2d/src/music.c +114 -0
- data/assets/linux/simple2d/src/shapes.c +154 -0
- data/assets/linux/simple2d/src/simple2d.c +185 -0
- data/assets/linux/simple2d/src/sound.c +56 -0
- data/assets/linux/simple2d/src/sprite.c +147 -0
- data/assets/linux/simple2d/src/text.c +129 -0
- data/assets/linux/simple2d/src/window.c +403 -0
- data/ext/ruby2d/extconf.rb +110 -29
- data/lib/ruby2d/version.rb +1 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 308c0abd778105c46da28988f34be4578321bdaa7f1b6e7cf83954fd4bb62ff1
|
4
|
+
data.tar.gz: 41ecfc7394fbe39190c4ffc64e4768ae2906ad93b5022fff07d4f7042f7aba0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82e72a5f46833b639ab5bf5a58bdadc2ac74ef1b20111a1018613a4c0adb30d53dfc8f101ba30e049d422672cd2bed29b983d51e35bf6a2ca05a2b3778c961fa
|
7
|
+
data.tar.gz: cab740e1047eb07f4e9e2223cb0409653e58f21cddd6e053e31c98830dd9caa99bc98476d0be82253c87ec397f5fca1a4fdc74cba5bf15ee11bd6a426ea969fe
|
data/assets/README.md
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
- [`ios/`](ios) and [`tvos/`](tvos)
|
7
7
|
- Xcode projects for iOS and tvOS, derived from the [Simple 2D dependencies](https://github.com/simple2d/deps/tree/master/xcode)
|
8
8
|
- iOS and tvOS frameworks from [`mruby-frameworks`](https://github.com/ruby2d/mruby-frameworks)
|
9
|
+
- [`linux/`](linux) — Simple 2D source and includes for Linux
|
9
10
|
- [`macos/`](macos) — Static library dependencies for macOS
|
10
11
|
- [`mingw/`](mingw) — Static and dynamic library dependencies for Windows / MinGW
|
11
12
|
- [`app.icns`](app.icns) — The [Ruby 2D logo](https://github.com/ruby2d/logo) icon
|
@@ -0,0 +1,250 @@
|
|
1
|
+
# Makefile for Unix-like systems:
|
2
|
+
# macOS, Linux, Raspberry Pi, MinGW
|
3
|
+
|
4
|
+
PREFIX?=/usr/local
|
5
|
+
CFLAGS=-std=c11
|
6
|
+
|
7
|
+
# ARM platforms
|
8
|
+
ifneq (,$(findstring arm,$(shell uname -m)))
|
9
|
+
# Raspberry Pi includes
|
10
|
+
INCLUDES=-I/opt/vc/include/
|
11
|
+
endif
|
12
|
+
|
13
|
+
# Apple
|
14
|
+
ifeq ($(shell uname),Darwin)
|
15
|
+
PLATFORM=apple
|
16
|
+
XCPRETTY_STATUS=$(shell xcpretty -v &>/dev/null; echo $$?)
|
17
|
+
ifeq ($(XCPRETTY_STATUS),0)
|
18
|
+
XCPRETTY=xcpretty
|
19
|
+
else
|
20
|
+
XCPRETTY=cat
|
21
|
+
endif
|
22
|
+
endif
|
23
|
+
|
24
|
+
# Linux
|
25
|
+
ifeq ($(shell uname),Linux)
|
26
|
+
CFLAGS+=-fPIC
|
27
|
+
endif
|
28
|
+
|
29
|
+
# MinGW
|
30
|
+
ifneq (,$(findstring MINGW,$(shell uname -s)))
|
31
|
+
PLATFORM=mingw
|
32
|
+
CC=gcc
|
33
|
+
INCLUDES=-I/usr/local/include/
|
34
|
+
endif
|
35
|
+
|
36
|
+
SOURCES=$(notdir $(wildcard src/*.c))
|
37
|
+
OBJECTS=$(addprefix build/,$(notdir $(SOURCES:.c=.o)))
|
38
|
+
|
39
|
+
VERSION=$(shell bash bin/simple2d.sh -v)
|
40
|
+
|
41
|
+
# Release directories and archive filenames
|
42
|
+
APPLE_RELEASE=simple2d-apple-frameworks-$(VERSION)
|
43
|
+
MINGW_RELEASE=simple2d-windows-mingw-$(VERSION)
|
44
|
+
|
45
|
+
# Helper functions
|
46
|
+
|
47
|
+
define task_msg
|
48
|
+
@printf "\n\033[1;34m==>\033[39m $(1)\033[0m\n\n"
|
49
|
+
endef
|
50
|
+
|
51
|
+
define info_msg
|
52
|
+
@printf "\033[1;36mInfo:\e[39m $(1)\033[0m\n"
|
53
|
+
endef
|
54
|
+
|
55
|
+
define run_test
|
56
|
+
$(call task_msg,Running $(1).c)
|
57
|
+
@cd test/; ./$(1)
|
58
|
+
endef
|
59
|
+
|
60
|
+
# Targets
|
61
|
+
|
62
|
+
all: prereqs install-deps $(SOURCES)
|
63
|
+
ar -vq build/libsimple2d.a $(OBJECTS)
|
64
|
+
cp bin/simple2d.sh build/simple2d
|
65
|
+
chmod 0777 build/simple2d
|
66
|
+
rm build/*.o
|
67
|
+
|
68
|
+
prereqs:
|
69
|
+
$(call task_msg,Building)
|
70
|
+
mkdir -p build
|
71
|
+
|
72
|
+
install-deps:
|
73
|
+
ifeq ($(PLATFORM),mingw)
|
74
|
+
$(call task_msg,Installing dependencies for MinGW)
|
75
|
+
mkdir -p $(PREFIX)/include/
|
76
|
+
mkdir -p $(PREFIX)/lib/
|
77
|
+
mkdir -p $(PREFIX)/bin/
|
78
|
+
cp -R deps/mingw/include/* $(PREFIX)/include
|
79
|
+
cp -R deps/mingw/lib/* $(PREFIX)/lib
|
80
|
+
cp -R deps/mingw/bin/* $(PREFIX)/bin
|
81
|
+
endif
|
82
|
+
|
83
|
+
$(SOURCES):
|
84
|
+
$(CC) $(CFLAGS) $(INCLUDES) src/$@ -c -o build/$(basename $@).o
|
85
|
+
|
86
|
+
install:
|
87
|
+
$(call task_msg,Installing Simple 2D)
|
88
|
+
mkdir -p $(PREFIX)/include/
|
89
|
+
mkdir -p $(PREFIX)/lib/
|
90
|
+
mkdir -p $(PREFIX)/bin/
|
91
|
+
cp include/simple2d.h $(PREFIX)/include/
|
92
|
+
cp build/libsimple2d.a $(PREFIX)/lib/
|
93
|
+
cp build/simple2d $(PREFIX)/bin/
|
94
|
+
|
95
|
+
ifeq ($(PLATFORM),apple)
|
96
|
+
frameworks: all
|
97
|
+
$(call task_msg,Building iOS and tvOS frameworks)
|
98
|
+
xcodebuild -version
|
99
|
+
ifneq ($(XCPRETTY_STATUS),0)
|
100
|
+
@echo "xcpretty not found: Run \`gem install xcpretty\` for nicer xcodebuild output.\n"
|
101
|
+
endif
|
102
|
+
mkdir -p build
|
103
|
+
cp -R deps/xcode/Simple2D.xcodeproj build
|
104
|
+
cd build && \
|
105
|
+
xcodebuild -sdk iphoneos | $(XCPRETTY) && \
|
106
|
+
xcodebuild -sdk iphonesimulator | $(XCPRETTY) && \
|
107
|
+
xcodebuild -sdk appletvos | $(XCPRETTY) && \
|
108
|
+
xcodebuild -sdk appletvsimulator | $(XCPRETTY)
|
109
|
+
mkdir -p build/Release-ios-universal
|
110
|
+
mkdir -p build/Release-tvos-universal
|
111
|
+
lipo build/Release-iphoneos/libsimple2d.a build/Release-iphonesimulator/libsimple2d.a -create -output build/Release-ios-universal/libsimple2d.a
|
112
|
+
lipo build/Release-appletvos/libsimple2d.a build/Release-appletvsimulator/libsimple2d.a -create -output build/Release-tvos-universal/libsimple2d.a
|
113
|
+
mkdir -p build/ios build/tvos
|
114
|
+
libtool -static build/Release-ios-universal/libsimple2d.a deps/ios/SDL2.framework/SDL2 -o build/ios/Simple2D
|
115
|
+
libtool -static build/Release-tvos-universal/libsimple2d.a deps/tvos/SDL2.framework/SDL2 -o build/tvos/Simple2D
|
116
|
+
mkdir -p build/ios/Simple2D.framework/Headers
|
117
|
+
mkdir -p build/tvos/Simple2D.framework/Headers
|
118
|
+
cp include/simple2d.h build/ios/Simple2D.framework/Headers
|
119
|
+
cp include/simple2d.h build/tvos/Simple2D.framework/Headers
|
120
|
+
cp -R deps/ios/include/SDL2 build/ios/Simple2D.framework/Headers
|
121
|
+
cp -R deps/tvos/include/SDL2 build/tvos/Simple2D.framework/Headers
|
122
|
+
cp deps/xcode/Info.plist build/ios/Simple2D.framework/Info.plist
|
123
|
+
cp deps/xcode/Info.plist build/tvos/Simple2D.framework/Info.plist
|
124
|
+
mv build/ios/Simple2D build/ios/Simple2D.framework
|
125
|
+
mv build/tvos/Simple2D build/tvos/Simple2D.framework
|
126
|
+
$(call info_msg,iOS framework built at \`build/ios/Simple2D.framework\`)
|
127
|
+
$(call info_msg,tvOS framework built at \`build/tvos/Simple2D.framework\`)
|
128
|
+
endif
|
129
|
+
|
130
|
+
ifeq ($(PLATFORM),apple)
|
131
|
+
install-frameworks: install
|
132
|
+
ifeq ($(shell test -d build/ios/Simple2D.framework && test -d build/tvos/Simple2D.framework; echo $$?),1)
|
133
|
+
$(error Frameworks missing. Run `frameworks` target first)
|
134
|
+
endif
|
135
|
+
$(call task_msg,Installing iOS and tvOS frameworks)
|
136
|
+
mkdir -p $(PREFIX)/Frameworks/Simple2D/iOS/
|
137
|
+
mkdir -p $(PREFIX)/Frameworks/Simple2D/tvOS/
|
138
|
+
cp -R build/ios/Simple2D.framework $(PREFIX)/Frameworks/Simple2D/iOS/
|
139
|
+
cp -R build/tvos/Simple2D.framework $(PREFIX)/Frameworks/Simple2D/tvOS/
|
140
|
+
endif
|
141
|
+
|
142
|
+
ifeq ($(PLATFORM),apple)
|
143
|
+
release: clean frameworks
|
144
|
+
$(call task_msg,Building iOS and tvOS release)
|
145
|
+
mkdir -p build/$(APPLE_RELEASE)/Simple2D/iOS
|
146
|
+
mkdir -p build/$(APPLE_RELEASE)/Simple2D/tvOS
|
147
|
+
cp -R build/ios/* build/$(APPLE_RELEASE)/Simple2D/iOS/
|
148
|
+
cp -R build/tvos/* build/$(APPLE_RELEASE)/Simple2D/tvOS/
|
149
|
+
cd build; zip -rq $(APPLE_RELEASE).zip $(APPLE_RELEASE)
|
150
|
+
$(call info_msg,Frameworks zipped at \`build/$(APPLE_RELEASE).zip\`)
|
151
|
+
endif
|
152
|
+
|
153
|
+
ifeq ($(PLATFORM),mingw)
|
154
|
+
release: clean all
|
155
|
+
mkdir -p build/$(MINGW_RELEASE)/include
|
156
|
+
mkdir -p build/$(MINGW_RELEASE)/lib
|
157
|
+
mkdir -p build/$(MINGW_RELEASE)/bin
|
158
|
+
cp -R deps/mingw/include/* build/$(MINGW_RELEASE)/include
|
159
|
+
cp -R deps/mingw/lib/* build/$(MINGW_RELEASE)/lib
|
160
|
+
cp -R deps/mingw/bin/* build/$(MINGW_RELEASE)/bin
|
161
|
+
cp deps/LICENSES.md build/$(MINGW_RELEASE)
|
162
|
+
cp include/simple2d.h build/$(MINGW_RELEASE)/include
|
163
|
+
cp build/libsimple2d.a build/$(MINGW_RELEASE)/lib
|
164
|
+
cp build/simple2d build/$(MINGW_RELEASE)/bin
|
165
|
+
cp bin/win-installer-mingw.sh build/$(MINGW_RELEASE)/install.sh
|
166
|
+
PowerShell -Command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::CreateFromDirectory('build/$(MINGW_RELEASE)', 'build/\$(MINGW_RELEASE).zip'); }"
|
167
|
+
endif
|
168
|
+
|
169
|
+
clean:
|
170
|
+
$(call task_msg,Cleaning)
|
171
|
+
rm -rf build/*
|
172
|
+
ifeq ($(PLATFORM),mingw)
|
173
|
+
rm -f test/auto.exe
|
174
|
+
rm -f test/triangle.exe
|
175
|
+
rm -f test/testcard.exe
|
176
|
+
rm -f test/audio.exe
|
177
|
+
rm -f test/controller.exe
|
178
|
+
else
|
179
|
+
rm -f test/auto
|
180
|
+
rm -f test/triangle
|
181
|
+
rm -f test/testcard
|
182
|
+
rm -f test/audio
|
183
|
+
rm -f test/controller
|
184
|
+
endif
|
185
|
+
|
186
|
+
uninstall:
|
187
|
+
$(call task_msg,Uninstalling)
|
188
|
+
rm -f /usr/local/include/simple2d.h
|
189
|
+
rm -f /usr/local/lib/libsimple2d.a
|
190
|
+
rm -f /usr/local/bin/simple2d
|
191
|
+
ifeq ($(PLATFORM),apple)
|
192
|
+
rm -rf /usr/local/Frameworks/Simple2D
|
193
|
+
endif
|
194
|
+
|
195
|
+
test:
|
196
|
+
$(call task_msg,Building tests)
|
197
|
+
simple2d build test/auto.c
|
198
|
+
simple2d build test/triangle.c
|
199
|
+
simple2d build test/testcard.c
|
200
|
+
simple2d build test/audio.c
|
201
|
+
simple2d build test/controller.c
|
202
|
+
|
203
|
+
rebuild: uninstall clean all install test
|
204
|
+
|
205
|
+
auto:
|
206
|
+
$(call run_test,auto)
|
207
|
+
|
208
|
+
triangle:
|
209
|
+
$(call run_test,triangle)
|
210
|
+
|
211
|
+
testcard:
|
212
|
+
$(call run_test,testcard)
|
213
|
+
|
214
|
+
audio:
|
215
|
+
$(call run_test,audio)
|
216
|
+
|
217
|
+
controller:
|
218
|
+
$(call run_test,controller)
|
219
|
+
|
220
|
+
ifeq ($(PLATFORM),apple)
|
221
|
+
ios:
|
222
|
+
ifeq ($(shell test -d /usr/local/Frameworks/Simple2D/iOS/Simple2D.framework; echo $$?),1)
|
223
|
+
$(error Simple2D.framework missing for iOS. Run `frameworks` and `install-frameworks` targets first)
|
224
|
+
endif
|
225
|
+
$(call task_msg,Running iOS test)
|
226
|
+
mkdir -p build/ios
|
227
|
+
cp -R deps/xcode/ios/* build/ios
|
228
|
+
cp test/triangle-ios-tvos.c build/ios/main.c
|
229
|
+
simple2d build --ios build/ios/MyApp.xcodeproj
|
230
|
+
simple2d simulator --open "iPhone X"
|
231
|
+
simple2d simulator --install "build/ios/build/Release-iphonesimulator/MyApp.app"
|
232
|
+
simple2d simulator --launch "Simple2D.MyApp"
|
233
|
+
endif
|
234
|
+
|
235
|
+
ifeq ($(PLATFORM),apple)
|
236
|
+
tvos:
|
237
|
+
ifeq ($(shell test -d /usr/local/Frameworks/Simple2D/tvOS/Simple2D.framework; echo $$?),1)
|
238
|
+
$(error Simple2D.framework missing for tvOS. Run `frameworks` and `install-frameworks` targets first)
|
239
|
+
endif
|
240
|
+
$(call task_msg,Running tvOS test)
|
241
|
+
mkdir -p build/tvos
|
242
|
+
cp -R deps/xcode/tvos/* build/tvos
|
243
|
+
cp test/triangle-ios-tvos.c build/tvos/main.c
|
244
|
+
simple2d build --tvos build/tvos/MyApp.xcodeproj
|
245
|
+
simple2d simulator --open "Apple TV 4K"
|
246
|
+
simple2d simulator --install "build/tvos/build/Release-appletvsimulator/MyApp.app"
|
247
|
+
simple2d simulator --launch "Simple2D.MyApp"
|
248
|
+
endif
|
249
|
+
|
250
|
+
.PHONY: build test
|
@@ -0,0 +1,1249 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# ------------------------------------------------------------------------------
|
4
|
+
# The Simple 2D Command-Line Utility for Unix-like Systems
|
5
|
+
#
|
6
|
+
# Run from the web using:
|
7
|
+
# bash <(curl -fsSL https://script_url_here)
|
8
|
+
# or...
|
9
|
+
# bash <(wget -qO - https://script_url_here)
|
10
|
+
# ------------------------------------------------------------------------------
|
11
|
+
|
12
|
+
# Set Constants ################################################################
|
13
|
+
|
14
|
+
# The installed version
|
15
|
+
VERSION='1.1.0'
|
16
|
+
|
17
|
+
# URL to this script in the repo
|
18
|
+
SCRIPT_URL="https://raw.githubusercontent.com/simple2d/simple2d/master/bin/simple2d.sh"
|
19
|
+
|
20
|
+
# MinGW Simple 2D installer
|
21
|
+
s2d_mingw_installer_fname="simple2d-windows-mingw-${VERSION}.zip"
|
22
|
+
s2d_mingw_installer_url="https://github.com/simple2d/simple2d/releases/download/v${VERSION}/${s2d_mingw_installer_fname}"
|
23
|
+
|
24
|
+
# SDL minimum version
|
25
|
+
SDL_MIN_VERSION='2.0.4'
|
26
|
+
|
27
|
+
# SDL download paths
|
28
|
+
libsdl_url="https://www.libsdl.org"
|
29
|
+
|
30
|
+
sdl_fname="SDL2-2.0.9"
|
31
|
+
sdl_url="${libsdl_url}/release/${sdl_fname}.tar.gz"
|
32
|
+
|
33
|
+
image_fname="SDL2_image-2.0.4"
|
34
|
+
image_url="${libsdl_url}/projects/SDL_image/release/${image_fname}.tar.gz"
|
35
|
+
|
36
|
+
mixer_fname="SDL2_mixer-2.0.4"
|
37
|
+
mixer_url="${libsdl_url}/projects/SDL_mixer/release/${mixer_fname}.tar.gz"
|
38
|
+
|
39
|
+
ttf_fname="SDL2_ttf-2.0.14"
|
40
|
+
ttf_url="${libsdl_url}/projects/SDL_ttf/release/${ttf_fname}.tar.gz"
|
41
|
+
|
42
|
+
# SDL config
|
43
|
+
sdl_arm_config_flags="\
|
44
|
+
--disable-video-opengl --disable-video-x11 \
|
45
|
+
--disable-pulseaudio --disable-esd \
|
46
|
+
--disable-video-mir --disable-video-wayland"
|
47
|
+
|
48
|
+
# Colors
|
49
|
+
BOLD='\033[1;39m' # default, bold
|
50
|
+
UNDERLINE='\033[4m' # underline
|
51
|
+
TASK='\033[1;34m' # blue, bold
|
52
|
+
BLUE=$TASK
|
53
|
+
INFO='\033[1;36m' # cyan, underline
|
54
|
+
WARN='\033[1;33m' # yellow, underline
|
55
|
+
ERROR='\033[1;31m' # red, underline
|
56
|
+
SUCCESS='\033[1;32m' # green, bold
|
57
|
+
NORMAL='\033[0m' # reset
|
58
|
+
|
59
|
+
# Set Variables ################################################################
|
60
|
+
|
61
|
+
platform='unknown'
|
62
|
+
platform_display='unknown'
|
63
|
+
platform_rpi=false
|
64
|
+
ret='' # for storing function return values
|
65
|
+
confirmed=false # to skip confirmation prompts
|
66
|
+
|
67
|
+
# Use xcpretty for nicer output: gem install xcpretty
|
68
|
+
if xcpretty -v &>/dev/null; then
|
69
|
+
XCPRETTY=xcpretty
|
70
|
+
else
|
71
|
+
XCPRETTY=cat
|
72
|
+
fi
|
73
|
+
|
74
|
+
# Helper Functions #############################################################
|
75
|
+
|
76
|
+
|
77
|
+
# Prints an information messages
|
78
|
+
# params:
|
79
|
+
# $1 String Message text
|
80
|
+
info_msg() {
|
81
|
+
echo -e "${INFO}Info:${NORMAL} $1\n"
|
82
|
+
}
|
83
|
+
warning_msg() {
|
84
|
+
echo -e "${WARN}Warning:${NORMAL} $1\n"
|
85
|
+
}
|
86
|
+
error_msg() {
|
87
|
+
echo -e "${ERROR}Error:${NORMAL} $1\n"
|
88
|
+
}
|
89
|
+
success_msg() {
|
90
|
+
echo -e "${SUCCESS}$1${NORMAL}\n"
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
# Prompts to continue, or exits
|
95
|
+
# params:
|
96
|
+
# $1 String Message before y/n prompt
|
97
|
+
prompt_to_continue() {
|
98
|
+
if ! $confirmed; then
|
99
|
+
printf "${BOLD}$1${NORMAL} "
|
100
|
+
read -p "(y/n) " ans
|
101
|
+
if [[ $ans != "y" ]]; then
|
102
|
+
echo -e "\nQuitting...\n"
|
103
|
+
exit
|
104
|
+
fi
|
105
|
+
echo
|
106
|
+
fi
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
# Prints the task in progress
|
111
|
+
# params:
|
112
|
+
# $1 String Name of task
|
113
|
+
# $2 String Optional white space, e.g. "\n\n"
|
114
|
+
print_task() {
|
115
|
+
printf "${TASK}==>${BOLD} $1${NORMAL}$2"
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
# Prints and runs a command
|
120
|
+
# params:
|
121
|
+
# $1 String The command
|
122
|
+
print_and_run() {
|
123
|
+
echo "==> $1"; $1
|
124
|
+
}
|
125
|
+
|
126
|
+
|
127
|
+
# Checks if a library is installed
|
128
|
+
# params:
|
129
|
+
# $1 String Name of the library, e.g. SDL2, without the "-l"
|
130
|
+
have_lib?() {
|
131
|
+
print_task "Checking for $1... "
|
132
|
+
|
133
|
+
if $(ld -o /dev/null -l$1 2>&1 | grep -qE '(library not found|ld: cannot find -l)'); then
|
134
|
+
echo "no"
|
135
|
+
return 1
|
136
|
+
else
|
137
|
+
echo "yes"
|
138
|
+
return 0
|
139
|
+
fi
|
140
|
+
}
|
141
|
+
|
142
|
+
|
143
|
+
# Gets the text from a remote resource
|
144
|
+
# params:
|
145
|
+
# $1 String URL of the resource
|
146
|
+
get_remote_str() {
|
147
|
+
which curl &>/dev/null && cmd='curl -fsSL' || cmd='wget -qO -';
|
148
|
+
ret=$($cmd $1)
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
# Compares version numbers in the form `#.#.#`
|
153
|
+
# Adapted from:
|
154
|
+
# stackoverflow.com/questions/4023830/bash-how-compare-two-strings-in-version-format
|
155
|
+
# params:
|
156
|
+
# $1 String First version number to compare
|
157
|
+
# $2 String Second version number to compare
|
158
|
+
# returns:
|
159
|
+
# 0 If $1 is equal to $2
|
160
|
+
# 1 If $1 is newer than $2
|
161
|
+
# 2 If $1 is older than $2
|
162
|
+
compare_versions() {
|
163
|
+
if [[ $1 == $2 ]]
|
164
|
+
then
|
165
|
+
return 0
|
166
|
+
fi
|
167
|
+
local IFS=.
|
168
|
+
local i ver1=($1) ver2=($2)
|
169
|
+
# fill empty fields in ver1 with zeros
|
170
|
+
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
|
171
|
+
do
|
172
|
+
ver1[i]=0
|
173
|
+
done
|
174
|
+
for ((i=0; i<${#ver1[@]}; i++))
|
175
|
+
do
|
176
|
+
if [[ -z ${ver2[i]} ]]
|
177
|
+
then
|
178
|
+
# fill empty fields in ver2 with zeros
|
179
|
+
ver2[i]=0
|
180
|
+
fi
|
181
|
+
if ((10#${ver1[i]} > 10#${ver2[i]}))
|
182
|
+
then
|
183
|
+
return 1
|
184
|
+
fi
|
185
|
+
if ((10#${ver1[i]} < 10#${ver2[i]}))
|
186
|
+
then
|
187
|
+
return 2
|
188
|
+
fi
|
189
|
+
done
|
190
|
+
return 0
|
191
|
+
}
|
192
|
+
|
193
|
+
|
194
|
+
# Build #######################################################################
|
195
|
+
|
196
|
+
|
197
|
+
# Builds a Simple 2D program
|
198
|
+
# If directory contains an Xcode project, it will call `xcodebuild`.
|
199
|
+
# If $1 is a C or C++ source file, it will attempt to compile using `gcc`.
|
200
|
+
build() {
|
201
|
+
|
202
|
+
# If no input, print build usage
|
203
|
+
if [[ $1 == '' ]]; then print_usage_build; exit; fi
|
204
|
+
|
205
|
+
# If C or C++ source file given, e.g.:
|
206
|
+
# build app.c; build app.cpp
|
207
|
+
if [[ ${1: -2} == '.c' || ${1: -4} == '.cpp' ]]; then
|
208
|
+
# Compile
|
209
|
+
gcc -std=c11 $1 `simple2d --libs` -o ${1%.*}
|
210
|
+
exit
|
211
|
+
fi
|
212
|
+
|
213
|
+
# Check if current directory has an Xcode project
|
214
|
+
has_xcodeproj?() {
|
215
|
+
if [[ $(ls *.xcodeproj 2>/dev/null) ]]; then
|
216
|
+
return 0
|
217
|
+
else
|
218
|
+
return 1
|
219
|
+
fi
|
220
|
+
}
|
221
|
+
|
222
|
+
# Build an Xcode project
|
223
|
+
build_with_xcodebuild() {
|
224
|
+
if [[ $XCPRETTY != 'xcpretty' ]]; then
|
225
|
+
echo -e "xcpretty not found: Run \`gem install xcpretty\` for nicer xcodebuild output.\n"
|
226
|
+
fi
|
227
|
+
case $1 in
|
228
|
+
--ios)
|
229
|
+
xcodebuild -sdk iphonesimulator | $XCPRETTY; exit;;
|
230
|
+
--ios-device)
|
231
|
+
xcodebuild -sdk iphoneos | $XCPRETTY; exit;;
|
232
|
+
--tvos)
|
233
|
+
xcodebuild -sdk appletvsimulator | $XCPRETTY; exit;;
|
234
|
+
--tvos-device)
|
235
|
+
xcodebuild -sdk appletvos | $XCPRETTY; exit;;
|
236
|
+
esac
|
237
|
+
}
|
238
|
+
|
239
|
+
# If bad SDK flag, print build usage
|
240
|
+
if ! [[ $1 =~ ^(--ios|--ios-device|--tvos|--tvos-device)$ ]]; then
|
241
|
+
print_usage_build; exit 1
|
242
|
+
fi
|
243
|
+
|
244
|
+
# If current directory has an Xcode project, e.g.:
|
245
|
+
# build --[ios|tvos][-device]
|
246
|
+
if has_xcodeproj?; then
|
247
|
+
build_with_xcodebuild $1
|
248
|
+
fi
|
249
|
+
|
250
|
+
# If an Xcode project path and options are provided, e.g.:
|
251
|
+
# build --ios[-device] build/ios
|
252
|
+
# build --tvos[-device] build/tvos
|
253
|
+
# build --ios[-device] build/ios/MyApp.xcodeproj
|
254
|
+
# build --tvos[-device] build/tvos/MyApp.xcodeproj
|
255
|
+
if [[ ${2: -10} == '.xcodeproj' ]]; then
|
256
|
+
cd $(dirname $2)
|
257
|
+
elif [[ -d $2 ]]; then
|
258
|
+
cd $2
|
259
|
+
else
|
260
|
+
error_msg "\"$2\" is not a directory or Xcode project"; exit 1
|
261
|
+
fi
|
262
|
+
|
263
|
+
if ! has_xcodeproj?; then
|
264
|
+
error_msg "The directory does not contain an Xcode project"; exit 1
|
265
|
+
fi
|
266
|
+
|
267
|
+
build_with_xcodebuild $1
|
268
|
+
}
|
269
|
+
|
270
|
+
|
271
|
+
# Installation #################################################################
|
272
|
+
|
273
|
+
|
274
|
+
# Checks installed versions of SDL
|
275
|
+
check_sdl_versions() {
|
276
|
+
|
277
|
+
print_task "Checking SDL2 version... "
|
278
|
+
|
279
|
+
# Check SDL version installed
|
280
|
+
SDL_INSTALLED_VERSION=$(sdl2-config --version)
|
281
|
+
compare_versions $SDL_MIN_VERSION $SDL_INSTALLED_VERSION
|
282
|
+
|
283
|
+
if [[ $? == 1 ]]; then
|
284
|
+
echo $SDL_INSTALLED_VERSION
|
285
|
+
error_msg "Installed version of SDL2 is too old (must be at least $SDL_MIN_VERSION)"
|
286
|
+
return 1
|
287
|
+
else
|
288
|
+
echo "$SDL_INSTALLED_VERSION"
|
289
|
+
return 0
|
290
|
+
fi
|
291
|
+
}
|
292
|
+
|
293
|
+
|
294
|
+
# Checks if SDL libraries are installed
|
295
|
+
have_sdl_libs?() {
|
296
|
+
|
297
|
+
have_all_libs=true
|
298
|
+
have_sdl2_lib=true
|
299
|
+
have_image_lib=true
|
300
|
+
have_mixer_lib=true
|
301
|
+
have_ttf_lib=true
|
302
|
+
|
303
|
+
if ! have_lib? 'SDL2'; then
|
304
|
+
have_sdl2_lib=false
|
305
|
+
have_all_libs=false
|
306
|
+
else
|
307
|
+
if ! check_sdl_versions; then
|
308
|
+
have_sdl2_lib=false
|
309
|
+
have_all_libs=false
|
310
|
+
fi
|
311
|
+
fi
|
312
|
+
|
313
|
+
if ! have_lib? 'SDL2_image'; then
|
314
|
+
have_image_lib=false
|
315
|
+
have_all_libs=false
|
316
|
+
fi
|
317
|
+
|
318
|
+
if ! have_lib? 'SDL2_mixer'; then
|
319
|
+
have_mixer_lib=false
|
320
|
+
have_all_libs=false
|
321
|
+
fi
|
322
|
+
|
323
|
+
if ! have_lib? 'SDL2_ttf'; then
|
324
|
+
have_ttf_lib=false
|
325
|
+
have_all_libs=false
|
326
|
+
fi
|
327
|
+
|
328
|
+
if $have_all_libs; then
|
329
|
+
return 0
|
330
|
+
else
|
331
|
+
return 1
|
332
|
+
fi
|
333
|
+
}
|
334
|
+
|
335
|
+
|
336
|
+
# Installs SDL on Linux
|
337
|
+
install_sdl_linux() {
|
338
|
+
|
339
|
+
echo "The following packages will be installed:"
|
340
|
+
# Fedora and CentOS
|
341
|
+
if which yum &>/dev/null; then
|
342
|
+
echo " SDL2-devel"
|
343
|
+
echo " SDL2_image-devel"
|
344
|
+
echo " SDL2_mixer-devel"
|
345
|
+
echo " SDL2_ttf-devel"
|
346
|
+
# Arch
|
347
|
+
elif which pacman &>/dev/null; then
|
348
|
+
echo " sdl2"
|
349
|
+
echo " sdl2_image"
|
350
|
+
echo " sdl2_mixer"
|
351
|
+
echo " sdl2_ttf"
|
352
|
+
# openSUSE
|
353
|
+
elif which zypper &>/dev/null; then
|
354
|
+
echo " libSDL2-devel"
|
355
|
+
echo " libSDL2_image-devel"
|
356
|
+
echo " libSDL2_mixer-devel"
|
357
|
+
echo " libSDL2_ttf-devel"
|
358
|
+
# Ubuntu, Debian, and Mint
|
359
|
+
# `apt` must be last because openSUSE has it aliased to `zypper`
|
360
|
+
elif which apt &>/dev/null; then
|
361
|
+
echo " libsdl2-dev"
|
362
|
+
echo " libsdl2-image-dev"
|
363
|
+
echo " libsdl2-mixer-dev"
|
364
|
+
echo " libsdl2-ttf-dev"
|
365
|
+
else
|
366
|
+
error_msg "Could not find a package manager to install SDL"; exit 1
|
367
|
+
fi
|
368
|
+
echo
|
369
|
+
|
370
|
+
prompt_to_continue "Install SDL now?"
|
371
|
+
|
372
|
+
print_task "Updating packages" "\n\n"
|
373
|
+
|
374
|
+
if which yum &>/dev/null; then
|
375
|
+
print_and_run "yum check-update"
|
376
|
+
elif which pacman &>/dev/null; then
|
377
|
+
print_and_run "sudo pacman -Syy"
|
378
|
+
elif which zypper &>/dev/null; then
|
379
|
+
print_and_run "sudo zypper refresh"
|
380
|
+
elif which apt &>/dev/null; then
|
381
|
+
print_and_run "sudo apt update"
|
382
|
+
fi
|
383
|
+
|
384
|
+
echo; print_task "Installing packages" "\n\n"
|
385
|
+
|
386
|
+
if which yum &>/dev/null; then
|
387
|
+
print_and_run "sudo yum install -y SDL2-devel SDL2_image-devel SDL2_mixer-devel SDL2_ttf-devel"
|
388
|
+
elif which pacman &>/dev/null; then
|
389
|
+
print_and_run "sudo pacman -S --noconfirm sdl2 sdl2_image sdl2_mixer sdl2_ttf"
|
390
|
+
elif which zypper &>/dev/null; then
|
391
|
+
print_and_run "sudo zypper install -y libSDL2-devel libSDL2_image-devel libSDL2_mixer-devel libSDL2_ttf-devel"
|
392
|
+
elif which apt &>/dev/null; then
|
393
|
+
print_and_run "sudo apt install -y libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev"
|
394
|
+
fi
|
395
|
+
echo
|
396
|
+
|
397
|
+
if ! have_sdl_libs?; then
|
398
|
+
echo; error_msg "SDL libraries did not install correctly"; exit 1
|
399
|
+
else
|
400
|
+
echo; info_msg "SDL was installed successfully"
|
401
|
+
fi
|
402
|
+
}
|
403
|
+
|
404
|
+
|
405
|
+
# Installs SDL from source
|
406
|
+
# Takes about 30 min on RPI 2
|
407
|
+
install_sdl_source() {
|
408
|
+
|
409
|
+
echo "SDL will be compiled and installed from source."; echo
|
410
|
+
|
411
|
+
prompt_to_continue "Install SDL now?"
|
412
|
+
|
413
|
+
# Install SDL dependencies
|
414
|
+
print_task "Installing SDL2 dependencies" "\n\n"
|
415
|
+
sudo apt update
|
416
|
+
|
417
|
+
libs=(
|
418
|
+
build-essential # This may be missing on some ARM platforms
|
419
|
+
|
420
|
+
# SDL2
|
421
|
+
libudev-dev
|
422
|
+
libdbus-1-dev
|
423
|
+
libasound2-dev
|
424
|
+
|
425
|
+
# SDL2_image
|
426
|
+
libjpeg9-dev
|
427
|
+
libpng-dev
|
428
|
+
|
429
|
+
# SDL2_mixer
|
430
|
+
libmpg123-dev
|
431
|
+
libvorbis-dev
|
432
|
+
libflac-dev
|
433
|
+
|
434
|
+
# SDL2_ttf
|
435
|
+
libgl1-mesa-dev # Solves error missing -lGL
|
436
|
+
libfreetype6-dev
|
437
|
+
)
|
438
|
+
|
439
|
+
sudo apt install -y ${libs[*]}
|
440
|
+
|
441
|
+
# Downloads, compiles, and installs an SDL library from source
|
442
|
+
# params:
|
443
|
+
# $1 String URL of the tar archive
|
444
|
+
# $2 String Name of the tar file
|
445
|
+
# $3 String ./configure flags
|
446
|
+
install_sdl_lib () {
|
447
|
+
cd /tmp
|
448
|
+
wget -N $1
|
449
|
+
tar -xzf $2.tar.gz
|
450
|
+
cd $2
|
451
|
+
print_task "Configuring" "\n\n"
|
452
|
+
print_and_run "./configure $3"
|
453
|
+
echo; print_task "Compiling" "\n\n"
|
454
|
+
make
|
455
|
+
echo; print_task "Installing" "\n\n"
|
456
|
+
sudo make install
|
457
|
+
rm /tmp/$2.tar.gz
|
458
|
+
rm -rf /tmp/$2
|
459
|
+
}
|
460
|
+
|
461
|
+
# Note that `$have_*_lib` variables are set by `have_sdl_libs?()`
|
462
|
+
|
463
|
+
if [[ $have_sdl2_lib == 'false' ]]; then
|
464
|
+
echo; print_task "Downloading SDL2" "\n\n"
|
465
|
+
if [[ $platform == 'arm' ]]; then
|
466
|
+
if $platform_rpi; then
|
467
|
+
config="--host=arm-raspberry-linux-gnueabihf $sdl_arm_config_flags"
|
468
|
+
else
|
469
|
+
config=$sdl_arm_config_flags
|
470
|
+
fi
|
471
|
+
install_sdl_lib $sdl_url $sdl_fname "$config"
|
472
|
+
else
|
473
|
+
install_sdl_lib $sdl_url $sdl_fname
|
474
|
+
fi
|
475
|
+
fi
|
476
|
+
|
477
|
+
if [[ $have_image_lib == 'false' ]]; then
|
478
|
+
echo; print_task "Downloading SDL2_image" "\n\n"
|
479
|
+
install_sdl_lib $image_url $image_fname
|
480
|
+
fi
|
481
|
+
|
482
|
+
if [[ $have_mixer_lib == 'false' ]]; then
|
483
|
+
echo; print_task "Downloading SDL2_mixer" "\n\n"
|
484
|
+
install_sdl_lib $mixer_url $mixer_fname
|
485
|
+
fi
|
486
|
+
|
487
|
+
if [[ $have_ttf_lib == 'false' ]]; then
|
488
|
+
echo; print_task "Downloading SDL2_ttf" "\n\n"
|
489
|
+
install_sdl_lib $ttf_url $ttf_fname
|
490
|
+
fi
|
491
|
+
|
492
|
+
echo
|
493
|
+
if ! have_sdl_libs?; then
|
494
|
+
error_msg "SDL libraries did not install correctly"; exit 1
|
495
|
+
else
|
496
|
+
echo; info_msg "SDL was installed successfully"
|
497
|
+
fi
|
498
|
+
}
|
499
|
+
|
500
|
+
|
501
|
+
# Installs SDL
|
502
|
+
install_sdl() {
|
503
|
+
if [[ $platform == 'linux' ]]; then
|
504
|
+
install_sdl_linux
|
505
|
+
elif [[ $platform == 'arm' ]]; then
|
506
|
+
install_sdl_source
|
507
|
+
fi
|
508
|
+
}
|
509
|
+
|
510
|
+
|
511
|
+
# Installs Simple 2D for MinGW environments
|
512
|
+
install_s2d_mingw() {
|
513
|
+
tmp_dir="/tmp/simple2d"
|
514
|
+
mkdir -p $tmp_dir
|
515
|
+
print_and_run "wget -NP $tmp_dir $s2d_mingw_installer_url"
|
516
|
+
print_and_run "pacman -S unzip --needed --noconfirm"
|
517
|
+
print_and_run "unzip -q $tmp_dir/$s2d_mingw_installer_fname -d $tmp_dir"
|
518
|
+
print_and_run "cd $tmp_dir"
|
519
|
+
print_and_run "bash install.sh -y"
|
520
|
+
print_and_run "rm -rf $tmp_dir"
|
521
|
+
}
|
522
|
+
|
523
|
+
|
524
|
+
# Installs Simple 2D
|
525
|
+
# params:
|
526
|
+
# $1 String Version to install, either 'master' or $VERSION
|
527
|
+
install_s2d() {
|
528
|
+
|
529
|
+
tmp_dir="/tmp/simple2d"
|
530
|
+
|
531
|
+
mkdir $tmp_dir
|
532
|
+
|
533
|
+
if [[ $1 == 'master' ]]; then
|
534
|
+
f_name=$1
|
535
|
+
else
|
536
|
+
f_name="v$1"
|
537
|
+
fi
|
538
|
+
|
539
|
+
url="https://github.com/simple2d/simple2d/archive/$f_name.zip"
|
540
|
+
|
541
|
+
print_task "Downloading Simple 2D" "\n\n"
|
542
|
+
# Linux and Raspberry Pi may not have curl installed by default
|
543
|
+
if which curl &>/dev/null; then
|
544
|
+
print_and_run "curl -L $url -o $tmp_dir/$f_name.zip"
|
545
|
+
else
|
546
|
+
print_and_run "wget -NP $tmp_dir $url"
|
547
|
+
fi
|
548
|
+
|
549
|
+
# Check if archive was downloaded properly
|
550
|
+
if [[ ! -f "$tmp_dir/$f_name.zip" ]]; then
|
551
|
+
echo; error_msg "Simple 2D could not be downloaded"; exit 1
|
552
|
+
fi
|
553
|
+
|
554
|
+
echo; print_task "Unpacking" "\n\n"
|
555
|
+
print_and_run "unzip -q $tmp_dir/$f_name -d $tmp_dir"
|
556
|
+
|
557
|
+
# Check if archive was unpacked properly
|
558
|
+
if [[ $? != 0 ]]; then
|
559
|
+
echo; error_msg "Could not unpack. The downloaded Simple 2D package may be damaged."; exit 1
|
560
|
+
fi
|
561
|
+
|
562
|
+
print_and_run "cd $tmp_dir/simple2d-$1"
|
563
|
+
|
564
|
+
echo; print_and_run "make"
|
565
|
+
echo; print_and_run "sudo make install"
|
566
|
+
|
567
|
+
echo; print_task "Cleaning up" "\n"; echo
|
568
|
+
print_and_run "rm -rf $tmp_dir"; echo
|
569
|
+
|
570
|
+
# Check if S2D installed correctly
|
571
|
+
if ! have_lib? 'simple2d'; then
|
572
|
+
echo; error_msg "Simple 2D did not install correctly"; exit 1
|
573
|
+
fi
|
574
|
+
echo
|
575
|
+
}
|
576
|
+
|
577
|
+
|
578
|
+
# Main entry point to install Simple 2D and SDL
|
579
|
+
# params:
|
580
|
+
# $1 String Flags used, e.g. `--sdl`
|
581
|
+
install() {
|
582
|
+
|
583
|
+
# If macOS, print message and quit
|
584
|
+
if [[ $platform == 'macos' ]]; then
|
585
|
+
macos_homebrew_message $1
|
586
|
+
fi
|
587
|
+
|
588
|
+
# If SDL flag, install only SDL and quit
|
589
|
+
if [[ $1 == '--sdl' ]]; then
|
590
|
+
echo
|
591
|
+
if have_sdl_libs?; then
|
592
|
+
echo; info_msg "SDL is already installed"
|
593
|
+
else
|
594
|
+
echo; install_sdl
|
595
|
+
fi
|
596
|
+
exit
|
597
|
+
fi
|
598
|
+
|
599
|
+
# Welcome message
|
600
|
+
echo -e "\n${BOLD}Welcome to Simple 2D!${NORMAL}"
|
601
|
+
echo -e "${BLUE}---------------------${NORMAL}\n"
|
602
|
+
|
603
|
+
echo -e "Platform detected: ${BOLD}${platform_display}${NORMAL}\n"
|
604
|
+
|
605
|
+
# If MinGW, install Simple 2D release and quit
|
606
|
+
if [[ $platform == 'mingw' ]]; then
|
607
|
+
prompt_to_continue "Continue to install?"
|
608
|
+
install_s2d_mingw
|
609
|
+
exit
|
610
|
+
fi
|
611
|
+
|
612
|
+
if have_lib? 'simple2d' > /dev/null; then
|
613
|
+
warning_msg "Simple 2D is already installed. Proceeding will reinstall."
|
614
|
+
fi
|
615
|
+
|
616
|
+
echo -e "Simple 2D will be installed to the following locations:
|
617
|
+
/usr/local/include/simple2d.h
|
618
|
+
/usr/local/lib/libsimple2d.a
|
619
|
+
/usr/local/bin/simple2d"
|
620
|
+
echo
|
621
|
+
|
622
|
+
if [[ $1 == '--HEAD' ]]; then
|
623
|
+
echo -e "This will install Simple 2D from the \`master\` development branch.\n"
|
624
|
+
fi
|
625
|
+
|
626
|
+
prompt_to_continue "Continue?"
|
627
|
+
|
628
|
+
if have_sdl_libs?; then
|
629
|
+
echo
|
630
|
+
else
|
631
|
+
echo; install_sdl
|
632
|
+
fi
|
633
|
+
|
634
|
+
if [[ $1 == '--HEAD' ]]; then
|
635
|
+
install_s2d 'master'
|
636
|
+
else
|
637
|
+
install_s2d $VERSION
|
638
|
+
fi
|
639
|
+
|
640
|
+
success_msg "Simple 2D installed successfully!"
|
641
|
+
}
|
642
|
+
|
643
|
+
|
644
|
+
# Uninstall ####################################################################
|
645
|
+
|
646
|
+
|
647
|
+
# Uninstalls SDL on Linux
|
648
|
+
uninstall_sdl_linux() {
|
649
|
+
|
650
|
+
echo "The following packages will be removed:"
|
651
|
+
# Fedora and CentOS
|
652
|
+
if which yum &>/dev/null; then
|
653
|
+
echo " SDL2-devel"
|
654
|
+
echo " SDL2_image-devel"
|
655
|
+
echo " SDL2_mixer-devel"
|
656
|
+
echo " SDL2_ttf-devel"
|
657
|
+
# Arch
|
658
|
+
elif which pacman &>/dev/null; then
|
659
|
+
echo " sdl2"
|
660
|
+
echo " sdl2_image"
|
661
|
+
echo " sdl2_mixer"
|
662
|
+
echo " sdl2_ttf"
|
663
|
+
# openSUSE
|
664
|
+
elif which zypper &>/dev/null; then
|
665
|
+
echo " libSDL2-devel"
|
666
|
+
echo " libSDL2_image-devel"
|
667
|
+
echo " libSDL2_mixer-devel"
|
668
|
+
echo " libSDL2_ttf-devel"
|
669
|
+
# Ubuntu, Debian, and Mint
|
670
|
+
# `apt` must be last because openSUSE has it aliased to `zypper`
|
671
|
+
elif which apt &>/dev/null; then
|
672
|
+
echo " libsdl2-dev"
|
673
|
+
echo " libsdl2-image-dev"
|
674
|
+
echo " libsdl2-mixer-dev"
|
675
|
+
echo " libsdl2-ttf-dev"
|
676
|
+
else
|
677
|
+
error_msg "Could not find a package manager to uninstall SDL"; exit 1
|
678
|
+
fi
|
679
|
+
echo
|
680
|
+
|
681
|
+
prompt_to_continue "Uninstall SDL now?"
|
682
|
+
|
683
|
+
print_task "Uninstalling packages" "\n\n"
|
684
|
+
|
685
|
+
if which yum &>/dev/null; then
|
686
|
+
print_and_run "sudo yum remove -y SDL2-devel SDL2_image-devel SDL2_mixer-devel SDL2_ttf-devel"
|
687
|
+
elif which pacman &>/dev/null; then
|
688
|
+
print_and_run "sudo pacman -Rs --noconfirm sdl2 sdl2_image sdl2_mixer sdl2_ttf"
|
689
|
+
elif which zypper &>/dev/null; then
|
690
|
+
print_and_run "sudo zypper remove -y libSDL2-devel libSDL2_image-devel libSDL2_mixer-devel libSDL2_ttf-devel"
|
691
|
+
elif which apt &>/dev/null; then
|
692
|
+
print_and_run "sudo apt remove -y --purge libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev"
|
693
|
+
fi
|
694
|
+
echo
|
695
|
+
|
696
|
+
if have_sdl_libs?; then
|
697
|
+
echo; error_msg "SDL libraries did not uninstall correctly"
|
698
|
+
else
|
699
|
+
echo; info_msg "SDL was uninstalled successfully"
|
700
|
+
fi
|
701
|
+
}
|
702
|
+
|
703
|
+
|
704
|
+
# Uninstalls SDL from source
|
705
|
+
uninstall_sdl_source() {
|
706
|
+
|
707
|
+
prompt_to_continue "Uninstall SDL now?"
|
708
|
+
|
709
|
+
# Uninstall packages in case they were used
|
710
|
+
print_and_run "sudo apt remove -y --purge libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev"
|
711
|
+
|
712
|
+
uninstall_sdl_lib () {
|
713
|
+
cd /tmp
|
714
|
+
wget -N $1
|
715
|
+
tar -xzf $2.tar.gz
|
716
|
+
cd $2
|
717
|
+
./configure $3
|
718
|
+
sudo make uninstall
|
719
|
+
rm /tmp/$2.tar.gz
|
720
|
+
rm -rf /tmp/$2
|
721
|
+
}
|
722
|
+
|
723
|
+
echo; print_task "Uninstalling SDL2_image" "\n\n"
|
724
|
+
uninstall_sdl_lib $image_url $image_fname
|
725
|
+
|
726
|
+
echo; print_task "Uninstalling SDL2_mixer" "\n\n"
|
727
|
+
uninstall_sdl_lib $mixer_url $mixer_fname
|
728
|
+
|
729
|
+
echo; print_task "Uninstalling SDL2_ttf" "\n\n"
|
730
|
+
uninstall_sdl_lib $ttf_url $ttf_fname
|
731
|
+
|
732
|
+
echo; print_task "Uninstalling SDL2" "\n\n"
|
733
|
+
if [[ $platform == 'arm' ]]; then
|
734
|
+
uninstall_sdl_lib $sdl_url $sdl_fname "$sdl_arm_config_flags"
|
735
|
+
else
|
736
|
+
uninstall_sdl_lib $sdl_url $sdl_fname
|
737
|
+
fi
|
738
|
+
|
739
|
+
echo
|
740
|
+
if have_sdl_libs?; then
|
741
|
+
echo; error_msg "SDL libraries did not uninstall correctly"; exit 1
|
742
|
+
else
|
743
|
+
echo; info_msg "SDL was uninstalled successfully"
|
744
|
+
fi
|
745
|
+
}
|
746
|
+
|
747
|
+
|
748
|
+
# Uninstalls SDL
|
749
|
+
uninstall_sdl() {
|
750
|
+
|
751
|
+
if have_sdl_libs?; then
|
752
|
+
echo
|
753
|
+
else
|
754
|
+
echo; info_msg "SDL appears to be already uninstalled"
|
755
|
+
prompt_to_continue "Try uninstalling SDL anyways?"
|
756
|
+
fi
|
757
|
+
|
758
|
+
if [[ $platform == 'linux' ]]; then
|
759
|
+
uninstall_sdl_linux
|
760
|
+
elif [[ $platform == 'arm' ]]; then
|
761
|
+
uninstall_sdl_source
|
762
|
+
fi
|
763
|
+
}
|
764
|
+
|
765
|
+
|
766
|
+
# Uninstalls Simple 2D
|
767
|
+
# params:
|
768
|
+
# $1 String Flags used, e.g. `--sdl`
|
769
|
+
uninstall() {
|
770
|
+
|
771
|
+
if [[ $platform == 'macos' ]]; then
|
772
|
+
macos_homebrew_message $1
|
773
|
+
fi
|
774
|
+
|
775
|
+
# If MinGW, print message and quit
|
776
|
+
if [[ $platform == 'mingw' ]]; then
|
777
|
+
mingw_not_implemented_message
|
778
|
+
fi
|
779
|
+
|
780
|
+
if [[ $1 == '--sdl' ]]; then
|
781
|
+
echo; uninstall_sdl
|
782
|
+
exit
|
783
|
+
fi
|
784
|
+
|
785
|
+
echo; echo -e "The following files will be removed:
|
786
|
+
/usr/local/include/simple2d.h
|
787
|
+
/usr/local/lib/libsimple2d.a
|
788
|
+
/usr/local/bin/simple2d"
|
789
|
+
|
790
|
+
echo; prompt_to_continue "Uninstall Simple 2D?"
|
791
|
+
|
792
|
+
# Use hard-coded, absolute paths for safety
|
793
|
+
print_and_run "rm -f /usr/local/include/simple2d.h"
|
794
|
+
print_and_run "rm -f /usr/local/lib/libsimple2d.a"
|
795
|
+
print_and_run "rm -f /usr/local/bin/simple2d"
|
796
|
+
|
797
|
+
# Check if files were actually deleted
|
798
|
+
files=(/usr/local/include/simple2d.h
|
799
|
+
/usr/local/lib/libsimple2d.a
|
800
|
+
/usr/local/bin/simple2d)
|
801
|
+
|
802
|
+
if [ -f ${files[0]} -o -f ${files[1]} -o -f ${files[2]} ]; then
|
803
|
+
echo; error_msg "Simple 2D files could not be removed. Try using \`sudo\`?"
|
804
|
+
else
|
805
|
+
echo; success_msg "Simple 2D uninstalled!"
|
806
|
+
fi
|
807
|
+
}
|
808
|
+
|
809
|
+
|
810
|
+
# Update #######################################################################
|
811
|
+
|
812
|
+
|
813
|
+
# Updates Simple 2D to latest version or commit
|
814
|
+
# params:
|
815
|
+
# $1 String Flags used, e.g. `--HEAD`
|
816
|
+
update() {
|
817
|
+
|
818
|
+
if [[ $platform == 'macos' ]]; then
|
819
|
+
macos_homebrew_message
|
820
|
+
fi
|
821
|
+
|
822
|
+
# If MinGW, print message and quit
|
823
|
+
if [[ $platform == 'mingw' ]]; then
|
824
|
+
mingw_not_implemented_message
|
825
|
+
fi
|
826
|
+
|
827
|
+
# Check if Simple 2D is installed
|
828
|
+
if ! have_lib? 'simple2d' > /dev/null; then
|
829
|
+
error_msg "Simple 2D isn't currently installed"
|
830
|
+
echo -e "Use the \`install\` command to install Simple 2D.\n"
|
831
|
+
exit 1
|
832
|
+
fi
|
833
|
+
|
834
|
+
# Check if SDL is installed
|
835
|
+
update_check_sdl() {
|
836
|
+
if have_sdl_libs?; then
|
837
|
+
echo
|
838
|
+
else
|
839
|
+
echo; error_msg "SDL libraries missing"
|
840
|
+
echo -e "Run \`simple2d install --sdl\` to install SDL.\n"
|
841
|
+
exit 1
|
842
|
+
fi
|
843
|
+
}
|
844
|
+
|
845
|
+
# Read this script from repo, get the version number
|
846
|
+
get_remote_str $SCRIPT_URL
|
847
|
+
LATEST_VERSION=$(bash -c "$ret" -- -v)
|
848
|
+
|
849
|
+
compare_versions $LATEST_VERSION $VERSION
|
850
|
+
|
851
|
+
# $LATEST_VERSION is newer $VERSION (the version installed)
|
852
|
+
if [[ $? == 1 ]]; then
|
853
|
+
echo -e "A new version of Simple 2D is available.\n"
|
854
|
+
prompt_to_continue "Upgrade from v$VERSION to v$LATEST_VERSION?"
|
855
|
+
update_check_sdl
|
856
|
+
install_s2d $LATEST_VERSION
|
857
|
+
success_msg "Simple 2D has been updated to $LATEST_VERSION!"
|
858
|
+
echo -e "View the release notes:
|
859
|
+
${UNDERLINE}https://github.com/simple2d/simple2d/releases/latest${NORMAL}"; echo
|
860
|
+
|
861
|
+
# $LATEST_VERSION is the same as installed version
|
862
|
+
else
|
863
|
+
echo "Simple 2D is already up to date!"
|
864
|
+
fi
|
865
|
+
}
|
866
|
+
|
867
|
+
|
868
|
+
# Doctor #######################################################################
|
869
|
+
|
870
|
+
|
871
|
+
# Runs the diagnostics
|
872
|
+
doctor() {
|
873
|
+
|
874
|
+
echo; echo -e "Running diagnostics...\n"
|
875
|
+
|
876
|
+
errors=false
|
877
|
+
|
878
|
+
if ! have_sdl_libs?; then
|
879
|
+
errors=true
|
880
|
+
echo; error_msg "SDL libraries missing"
|
881
|
+
fi
|
882
|
+
|
883
|
+
if have_lib? 'simple2d'; then
|
884
|
+
echo
|
885
|
+
else
|
886
|
+
errors=true
|
887
|
+
echo; error_msg "Simple 2D library missing"
|
888
|
+
fi
|
889
|
+
|
890
|
+
if $errors; then
|
891
|
+
echo -e "Issues were found.\n"
|
892
|
+
else
|
893
|
+
success_msg "No issues found!"
|
894
|
+
fi
|
895
|
+
}
|
896
|
+
|
897
|
+
|
898
|
+
# Simulator ####################################################################
|
899
|
+
|
900
|
+
|
901
|
+
# Get list of booted iOS or tvOS simulators, store in $booted
|
902
|
+
# $1 Equals 'cmd' if called from command line
|
903
|
+
simulator_booted() {
|
904
|
+
booted=`xcrun simctl list devices | grep Booted`
|
905
|
+
if [[ $1 == 'cmd' ]]; then
|
906
|
+
if [[ $booted == '' ]]; then
|
907
|
+
echo "No devices are booted."
|
908
|
+
else
|
909
|
+
echo $booted
|
910
|
+
fi
|
911
|
+
fi
|
912
|
+
}
|
913
|
+
|
914
|
+
|
915
|
+
# List all iOS and tvOS simulator devices available
|
916
|
+
simulator_list() {
|
917
|
+
xcrun simctl list devices | grep -iv unavailable
|
918
|
+
}
|
919
|
+
|
920
|
+
|
921
|
+
# Open an iOS or tvOS simulator
|
922
|
+
# $1 The device name, e.g. iPhone X
|
923
|
+
# See `simulator_list` function for available names
|
924
|
+
simulator_open() {
|
925
|
+
device=$1
|
926
|
+
|
927
|
+
# Check if device name exists
|
928
|
+
if ! xcrun simctl list devices | grep -q "$device"; then
|
929
|
+
error_msg "\"$device\" does not match any simulator device names"
|
930
|
+
echo -e "Choose a device name from the following:\n"
|
931
|
+
simulator_list
|
932
|
+
exit 1
|
933
|
+
fi
|
934
|
+
|
935
|
+
# Get the device UDID
|
936
|
+
device_udid=`xcrun simctl list devices | grep "$device" | head -n1 | egrep -wo '\([-0-9A-F]+\)' | tr -d '\(\)'`
|
937
|
+
echo "Requested device: $device with UDID $device_udid"
|
938
|
+
simulator_booted
|
939
|
+
|
940
|
+
# If the current simulator running is not the requested device, then quit
|
941
|
+
if [[ $booted != '' && $booted != *$device* ]]; then
|
942
|
+
echo "Quitting current device simulator..."
|
943
|
+
osascript -e 'quit app "Simulator"'
|
944
|
+
fi
|
945
|
+
|
946
|
+
# Open the requsted simulator
|
947
|
+
echo "Opening $device simulator..."
|
948
|
+
open -a Simulator --args -CurrentDeviceUDID $device_udid
|
949
|
+
|
950
|
+
# Wait for device to boot
|
951
|
+
not_booted=true
|
952
|
+
while $not_booted; do
|
953
|
+
simulator_booted
|
954
|
+
if [[ $booted == *$device* ]]; then
|
955
|
+
not_booted=false
|
956
|
+
else
|
957
|
+
sleep 2
|
958
|
+
fi
|
959
|
+
done
|
960
|
+
}
|
961
|
+
|
962
|
+
|
963
|
+
# Install an app on the booted iOS or tvOS simulator
|
964
|
+
# $1 The path to the `.app` file, e.g. Release-iphonesimulator/MyApp.app
|
965
|
+
simulator_install() {
|
966
|
+
echo "Installing app..."
|
967
|
+
xcrun simctl install booted $1
|
968
|
+
}
|
969
|
+
|
970
|
+
|
971
|
+
# Launch an installed app on the booted iOS or tvOS simulator
|
972
|
+
# $1 The bundle identifier, e.g. "Simple2D.MyApp"
|
973
|
+
simulator_launch() {
|
974
|
+
echo "Launching app..."
|
975
|
+
xcrun simctl launch booted $1
|
976
|
+
}
|
977
|
+
|
978
|
+
|
979
|
+
# Stream log of currently running iOS or tvOS simulator
|
980
|
+
# $1 Optional app name to filter by
|
981
|
+
simulator_log() {
|
982
|
+
if [[ $1 == '' ]]; then
|
983
|
+
xcrun simctl spawn booted log stream --level=debug
|
984
|
+
else
|
985
|
+
xcrun simctl spawn booted log stream --predicate "processImagePath endswith \"$1\""
|
986
|
+
fi
|
987
|
+
}
|
988
|
+
|
989
|
+
|
990
|
+
# Stream log of currently running iOS or tvOS simulator, error messages only
|
991
|
+
simulator_log_errors() {
|
992
|
+
xcrun simctl spawn booted log stream --predicate 'eventMessage contains "error" or messageType == error'
|
993
|
+
}
|
994
|
+
|
995
|
+
|
996
|
+
# Platform Specifics ###########################################################
|
997
|
+
|
998
|
+
|
999
|
+
# Prints homebrew message and quit
|
1000
|
+
# params:
|
1001
|
+
# $1 String The message to show, e.g. '--sdl'
|
1002
|
+
macos_homebrew_message() {
|
1003
|
+
|
1004
|
+
if [[ $1 == '--sdl' ]]; then
|
1005
|
+
echo -e "
|
1006
|
+
We recommend using ${BOLD}Homebrew${NORMAL} to install, update, and uninstall
|
1007
|
+
SDL on macOS. If you installed Simple 2D using Homebrew, the
|
1008
|
+
following SDL packages were installed:
|
1009
|
+
|
1010
|
+
sdl2
|
1011
|
+
sdl2_image
|
1012
|
+
sdl2_mixer
|
1013
|
+
sdl2_ttf
|
1014
|
+
|
1015
|
+
Run \`brew info <formula>\` to see information about each and
|
1016
|
+
their dependencies, which were also installed.
|
1017
|
+
|
1018
|
+
Learn more at ${UNDERLINE}http://brew.sh${NORMAL}
|
1019
|
+
"
|
1020
|
+
elif [[ $1 == '--HEAD' ]]; then
|
1021
|
+
echo -e "
|
1022
|
+
Use ${BOLD}Homebrew${NORMAL} to install, update, and uninstall Simple 2D on macOS.
|
1023
|
+
|
1024
|
+
To install the latest changes from the \`master\` development branch, use:
|
1025
|
+
brew install --HEAD simple2d
|
1026
|
+
|
1027
|
+
Note \`brew update\` will not update formulas installed with \`--HEAD\`,
|
1028
|
+
but you can use \`brew reinstall --HEAD simple2d\` to manually grab
|
1029
|
+
the latest changes.
|
1030
|
+
"
|
1031
|
+
else
|
1032
|
+
echo -e "
|
1033
|
+
Use ${BOLD}Homebrew${NORMAL} to install, update, and uninstall Simple 2D on macOS.
|
1034
|
+
|
1035
|
+
First, use \`brew tap\` to get Simple 2D formulas:
|
1036
|
+
brew tap simple2d/tap
|
1037
|
+
|
1038
|
+
Then, the following \`brew\` commands will be available:
|
1039
|
+
brew install simple2d
|
1040
|
+
brew upgrade simple2d
|
1041
|
+
brew uninstall simple2d
|
1042
|
+
|
1043
|
+
Learn more at ${UNDERLINE}http://brew.sh${NORMAL}
|
1044
|
+
"
|
1045
|
+
fi
|
1046
|
+
|
1047
|
+
exit
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
|
1051
|
+
# Commands only available on macOS
|
1052
|
+
macos_only_command() {
|
1053
|
+
echo -e "This command is only available on macOS"; exit 1
|
1054
|
+
}
|
1055
|
+
|
1056
|
+
|
1057
|
+
# For stuff not yet implemented in MinGW
|
1058
|
+
mingw_not_implemented_message() {
|
1059
|
+
echo -e "This isn't implemented in MinGW yet :("; exit 1
|
1060
|
+
}
|
1061
|
+
|
1062
|
+
|
1063
|
+
# Detect Platform ##############################################################
|
1064
|
+
|
1065
|
+
|
1066
|
+
unamestr=$(uname)
|
1067
|
+
|
1068
|
+
# macOS
|
1069
|
+
if [[ $unamestr == 'Darwin' ]]; then
|
1070
|
+
platform_display='macOS'
|
1071
|
+
platform='macos'
|
1072
|
+
|
1073
|
+
# ARM
|
1074
|
+
elif [[ $(uname -m) =~ 'arm' && $unamestr == 'Linux' ]]; then
|
1075
|
+
platform_display='ARM / Linux'
|
1076
|
+
platform='arm'
|
1077
|
+
|
1078
|
+
# Raspberry Pi
|
1079
|
+
if [[ $(cat /etc/os-release | grep -i raspbian) ]]; then
|
1080
|
+
platform_display='ARM / Linux (Raspberry Pi)'
|
1081
|
+
platform_rpi=true
|
1082
|
+
fi
|
1083
|
+
|
1084
|
+
# Linux
|
1085
|
+
elif [[ $unamestr == 'Linux' ]]; then
|
1086
|
+
platform_display='Linux'
|
1087
|
+
platform='linux'
|
1088
|
+
|
1089
|
+
# Windows / MinGW
|
1090
|
+
elif [[ $unamestr =~ 'MINGW' ]]; then
|
1091
|
+
platform_display='Windows / MinGW'
|
1092
|
+
platform='mingw'
|
1093
|
+
fi
|
1094
|
+
|
1095
|
+
# Unsupported platform
|
1096
|
+
if [[ $platform == 'unknown' ]]; then
|
1097
|
+
echo; error_msg "Not a supported system (macOS, Linux, or ARM platform)"; exit 1
|
1098
|
+
fi
|
1099
|
+
|
1100
|
+
|
1101
|
+
# Check Command-line Arguments #################################################
|
1102
|
+
|
1103
|
+
|
1104
|
+
print_usage() {
|
1105
|
+
echo -e "${BOLD}Simple 2D is a simple, open-source 2D graphics engine for everyone.${NORMAL}
|
1106
|
+
|
1107
|
+
Usage: simple2d [--libs] [-v|--version]
|
1108
|
+
<command> <options>
|
1109
|
+
|
1110
|
+
Summary of commands and options:
|
1111
|
+
build Build a C/C++ source file or Xcode project; run for options
|
1112
|
+
install Installs the latest release
|
1113
|
+
--HEAD Installs from the development branch
|
1114
|
+
--sdl Installs SDL only
|
1115
|
+
uninstall Removes Simple 2D files
|
1116
|
+
--sdl Removes SDL only
|
1117
|
+
update Updates to latest release
|
1118
|
+
doctor Runs diagnostics, checks installation, reports issues
|
1119
|
+
simulator Interact with iOS and tvOS simulators; run for options
|
1120
|
+
--libs Outputs libraries needed to compile Simple 2D apps
|
1121
|
+
-v|--version Prints the installed version
|
1122
|
+
"
|
1123
|
+
}
|
1124
|
+
|
1125
|
+
|
1126
|
+
print_usage_build() {
|
1127
|
+
echo -e "
|
1128
|
+
Use the ${BOLD}build${NORMAL} command to compile or build Simple 2D apps.
|
1129
|
+
|
1130
|
+
For compiling C/C++ source files, use:
|
1131
|
+
build <c_or_cpp_file>
|
1132
|
+
|
1133
|
+
To build an Xcode project, use:
|
1134
|
+
build <sdk_option> <optional_path_to_xcode_project>
|
1135
|
+
|
1136
|
+
For <sdk_option> above, use one of the following:
|
1137
|
+
--ios iOS simulator SDK
|
1138
|
+
--ios-device iOS device SDK (requires signing)
|
1139
|
+
--tvos tvOS simulator SDK
|
1140
|
+
--tvos-device tvOS device SDK (requires signing)
|
1141
|
+
"
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
|
1145
|
+
print_usage_simulator() {
|
1146
|
+
echo -e "
|
1147
|
+
Choose an option with the ${BOLD}simulator${NORMAL} command:
|
1148
|
+
|
1149
|
+
--list List available devices
|
1150
|
+
--booted Show currently booted devices
|
1151
|
+
|
1152
|
+
--open <device_name> Open a simulator device with a given device name
|
1153
|
+
|
1154
|
+
--install <app_file> Install an app on the booted simulator given the path
|
1155
|
+
to the app e.g. \"Release-iphonesimulator/MyApp.app\"
|
1156
|
+
|
1157
|
+
--launch <bundle_id> Launch an app given the app bundle's identifier,
|
1158
|
+
e.g. \"Simple2D.MyApp\"
|
1159
|
+
|
1160
|
+
--log Stream log of the booted simulator
|
1161
|
+
--log <app> Stream log for the app only, given the app name
|
1162
|
+
--log-errors Stream log containing only error messages
|
1163
|
+
"
|
1164
|
+
}
|
1165
|
+
|
1166
|
+
|
1167
|
+
case $1 in
|
1168
|
+
build)
|
1169
|
+
build $2 $3;;
|
1170
|
+
install)
|
1171
|
+
case $2 in
|
1172
|
+
'')
|
1173
|
+
install;;
|
1174
|
+
-y)
|
1175
|
+
confirmed=true
|
1176
|
+
install;;
|
1177
|
+
--HEAD)
|
1178
|
+
install '--HEAD';;
|
1179
|
+
--sdl)
|
1180
|
+
install '--sdl';;
|
1181
|
+
*)
|
1182
|
+
print_usage;;
|
1183
|
+
esac;;
|
1184
|
+
uninstall)
|
1185
|
+
case $2 in
|
1186
|
+
'')
|
1187
|
+
uninstall;;
|
1188
|
+
--sdl)
|
1189
|
+
uninstall '--sdl';;
|
1190
|
+
*)
|
1191
|
+
print_usage;;
|
1192
|
+
esac;;
|
1193
|
+
update)
|
1194
|
+
case $2 in
|
1195
|
+
'')
|
1196
|
+
update;;
|
1197
|
+
--HEAD)
|
1198
|
+
update '--HEAD';;
|
1199
|
+
*)
|
1200
|
+
print_usage;;
|
1201
|
+
esac;;
|
1202
|
+
doctor)
|
1203
|
+
doctor;;
|
1204
|
+
simulator)
|
1205
|
+
if [[ $platform != 'macos' ]]; then macos_only_command; fi
|
1206
|
+
case $2 in
|
1207
|
+
'')
|
1208
|
+
print_usage_simulator;;
|
1209
|
+
--list)
|
1210
|
+
simulator_list;;
|
1211
|
+
--booted)
|
1212
|
+
simulator_booted 'cmd';;
|
1213
|
+
--open)
|
1214
|
+
simulator_open "$3";;
|
1215
|
+
--install)
|
1216
|
+
simulator_install "$3";;
|
1217
|
+
--launch)
|
1218
|
+
simulator_launch "$3";;
|
1219
|
+
--log)
|
1220
|
+
simulator_log "$3";;
|
1221
|
+
--log-errors)
|
1222
|
+
simulator_log_errors;;
|
1223
|
+
*)
|
1224
|
+
print_usage_simulator;;
|
1225
|
+
esac;;
|
1226
|
+
--libs)
|
1227
|
+
if [[ $platform == 'macos' ]]; then
|
1228
|
+
FLAGS='-Wl,-framework,OpenGL'
|
1229
|
+
elif [[ $platform == 'linux' ]]; then
|
1230
|
+
FLAGS='-lGL -lm'
|
1231
|
+
elif [[ $platform == 'arm' ]]; then
|
1232
|
+
FLAGS='-lm -I/opt/vc/include/ -L/opt/vc/lib'
|
1233
|
+
if $platform_rpi; then
|
1234
|
+
FLAGS+=' -lbrcmGLESv2'
|
1235
|
+
else
|
1236
|
+
FLAGS+=' -lGLESv2'
|
1237
|
+
fi
|
1238
|
+
fi
|
1239
|
+
if [[ $platform == 'mingw' ]]; then
|
1240
|
+
echo "-I/usr/local/include/ -L/usr/local/lib -lmingw32 -lsimple2d -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lopengl32 -lglew32"
|
1241
|
+
else
|
1242
|
+
echo "-lsimple2d `sdl2-config --cflags --libs`"\
|
1243
|
+
"${FLAGS} -lSDL2_image -lSDL2_mixer -lSDL2_ttf"
|
1244
|
+
fi;;
|
1245
|
+
-v|--version)
|
1246
|
+
echo $VERSION;;
|
1247
|
+
*)
|
1248
|
+
print_usage;;
|
1249
|
+
esac
|