-
Notifications
You must be signed in to change notification settings - Fork 0
/
sakefile.scm
executable file
·229 lines (201 loc) · 11.3 KB
/
sakefile.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
;;----------------------------------------------------------------------------------------
;;!! Android tasks
(define-task android:setup ()
;; Set up Android project files
(fusion#android-project-setup 'android-15)
;; Create symlink to SDL library from SDL2 Sphere
(let ((SDL-link (string-append (android-jni-generator-directory) "deps/SDL")))
(unless (file-exists? SDL-link)
(create-symbolic-link (string-append (%sphere-path 'sdl2) "deps/SDL2-2.0.3") SDL-link))))
(define-task android:compile ()
(if #t ;; #t to compile as a single app executable
;; Compile all modules within the app executable
(fusion#android-compile-app "main" 'main
target: 'debug
cond-expand-features: '(debug)
compiler-options: '(debug)
num-threads: +inf.0
verbose: #t)
(begin
;; Compile the Android app with just the loader code
(fusion#android-compile-app "my-app" 'loader
target: 'debug
cond-expand-features: '(debug)
compiler-options: '(debug)
verbose: #t)
;; Compile the main module and its dependencies as a loadable object for the ARM
;; arch. The (load) function takes care of loading code dinamically, both compiled
;; and source code. This can be used during Android development in the following ways:
;; - Bundling the code within the APK
;; - Uploading the code to the SD card
;; - Dynamically running code within the Remote Debugger in Emacs or the terminal
(fusion#android-compile-loadable-set "main-minimal.o1" 'main-minimal
merge-modules: #f
target: 'debug
cond-expand-features: '(debug)
compiler-options: '(debug)
cc-options: `(,(string-append "-I" (android-jni-directory) "deps/SDL/include") "-w")
ld-options: '("-lEGL" "-lGLESv2")
verbose: #t))))
(define-task android:install ()
(fusion#android-install 'debug))
(define-task android:run ()
;; Run the Activity
(fusion#android-run "org.libsdl.app/org.libsdl.app.SDLActivity")
;; Log cat
(shell-command (string-append (android-adb-path) " logcat *:S *:F SchemeSpheres SDL SDL/APP")))
(define-task android (android:compile android:install android:run)
'android)
(define-task android:clean ()
(fusion#android-clean))
;;----------------------------------------------------------------------------------------
;;!! iOS tasks
(define-task ios:setup ()
;; Create symlink to SDL include library from SDL2 Sphere
(let ((SDL-link (string-append (ios-directory) "SDL/include")))
(unless (file-exists? SDL-link)
(create-symbolic-link (string-append (%sphere-path 'sdl2) "deps/SDL2-2.0.3/include")
SDL-link))))
(define-task ios:compile ()
(if #f ;; #t to compile as a single app executable
;; Compile all modules within the app executable
(fusion#ios-compile-app 'app
arch: 'i386 ;; armv7 / armv7s
target: 'debug
cond-expand-features: '(debug static)
compiler-options: '(debug)
cc-options: (list "-w"
;;"-D___SINGLE_HOST"
"-O1"
"-fdiagnostics-show-note-include-stack"
"-fcolor-diagnostics"
(string-append "-I" (ios-directory) "SDL/include")
(string-append "-I" (ios-directory) "SDL_image/include"))
verbose: #t)
(let ((arch 'i386)) ;; armv7 / armv7s
;; Copy all the foreign dependencies of the module, so they can be automatically
;; loaded by the application loader
(fusion#ios-copy-foreign-dependencies 'app)
;; Compile the main module and its dependencies as a loadable object, for all iOS
;; archs. The (load) function takes care of loading code dinamically, both compiled
;; and source code. This can be used during iOS development in the following ways:
;; - Uploading code to the Resources folder (part of the app bundle)
;; - Uploading code to the Documents folder (created at runtime, read/write when the app is running)
;; - Dynamically running within the Remote Debugger in Emacs or the terminal
;; Finally, take into account that loadable libraries do work only on the simulator
#;
(fusion#ios-compile-loadable-set "globals.o1" 'globals
merge-modules: #f
target: 'debug
arch: arch
cond-expand-features: '(ios debug)
compiler-options: '(debug)
cc-options: (list "-w"
(string-append "-I" (ios-directory) "SDL/include")
(string-append "-I" (ios-directory) "SDL_image/include"))
verbose: #t)
;; Compile the iOS app with just the loader module
;; The loader will decide which object to load according to the runtime architecture
(fusion#ios-compile-app 'loader
arch: arch
target: 'debug
cond-expand-features: '(debug)
compiler-options: '(debug)
cc-options: (list "-w"
(string-append "-I" (ios-directory) "SDL/include")
(string-append "-I" (ios-directory) "SDL_image/include"))
verbose: #t))))
(define-task ios:run ()
;; First kill any running instance of the iPhone simulator
(shell-command "killall -9 iPhone\\ Simulator &>/dev/null")
;; Run asset server and iOS simulator
(let* ((asset-server (parameterize
((current-directory (current-source-directory)))
(open-process (list path: "python"
arguments: '("-m" "SimpleHTTPServer")
stdin-redirection: #t
stdout-redirection: #t
stderr-redirection: #t))))
(server-pid (process-pid asset-server))
(ios-simulator (parameterize
((current-directory (ios-directory)))
(open-process (list path: (ios-sim-path)
arguments: '("launch" "build/Debug-iphonesimulator/SchemeSpheres.app")))))
(simulator-pid (process-pid ios-simulator)))
;; Wait for the iOS simulator to finish
(process-status ios-simulator)
;; Kill asset server when leaving simulator
(let ((kill-server (open-process
(list path: "kill"
arguments: `("-15" ,(number->string server-pid)))))
(kill-simulator (open-process
(list path: "kill"
arguments: `("-9" ,(number->string simulator-pid))))))
(process-status kill-server)
(process-status kill-simulator))))
(define-task ios:xcode ()
(shell-command "open -a Xcode ios/SchemeSpheres.xcodeproj"))
(define-task ios:clean ()
(fusion#ios-clean))
(define-task ios (ios:compile ios:run)
'ios)
;;----------------------------------------------------------------------------------------
;;!! Host (Linux/OSX) tasks
(define-task host:run ()
(fusion#host-run-interpreted 'loader))
(define-task host:compile ()
;; Note (merge-modules): If #t this will include all dependencies in one big file before compiling to C
;; Note (compile-loadable-set): this must be linked flat
(if #t ;; #t to compile the application as a single standalone
;; Bundle as a single executable
(fusion#host-compile-exe "my-application-standalone" 'app
cond-expand-features: (case (sake#host-platform)
((osx) '(osx debug static))
(else '(debug static)))
merge-modules: #f
verbose: #t)
(begin
(error "loadable modules in the host system is not supported yet (WIP)")
;; Compile as a loader and a loadable library
(fusion#host-compile-exe "my-application" 'loader
cond-expand-features: '(osx debug static)
compiler-options: '(debug))
;; Compile the main module and its dependencies as a loadable object. The (load)
;; function takes care of loading code dinamically, both compiled and source code.
(fusion#host-compile-loadable-set "app.o1" 'app
merge-modules: #f
cond-expand-features: '(osx debug)
compiler-options: '(debug)
verbose: #t))))
(define-task host:clean ()
(sake#default-clean))
(define-task host (host:run)
'host)
;;----------------------------------------------------------------------------------------
;;!! General
(define help #<<end-of-help
Tasks (run with 'ssake <task>')
------------------------------
android:setup Setup Android project before running other tasks
android:compile Compile the Android app
android:install Install App in current Android device (hardware or emulated)
android:run Run App in current Android device
android:clean Clean all Android generated files
android Execute compile, install, run
ios:setup Setup iOS project before running other tasks
ios:compile Compile the iOS app
ios:run Launch the iOS Simulator and run the app
ios:xcode Open the iOS project in Xcode
ios:clean Clean all iOS generated files
ios Execute compile and run
host:compile Compile the host program as standalone
host:run Run the host OS (Linux/OSX) program interpreted
host:clean Clean the generated host program files
host Defaults to host:run
clean Clean all targets
end-of-help
)
(define-task clean (android:clean ios:clean host:clean)
'clean)
(define-task all ()
(println help))