Skip to content

Commit

Permalink
Fixed missing dependency caused by previous commit. Added asset proce…
Browse files Browse the repository at this point in the history
…ssing to Android build. Disabled parallel compilation in Android build. Added function to read text files which is portable between host and Android versions (reads from apk/assets using SDL2 RWops)
  • Loading branch information
fjvallarino committed Mar 13, 2014
1 parent b4a92ca commit e1fd7c3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config.scm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
(energy: log)
(energy: template)))
(core
(include
(core: base-macros))
(load
(cond-expand
(mobile (opengl: gl-es2))
Expand Down
14 changes: 14 additions & 0 deletions src/core.scm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
shader-id))

;;!! Link a list of shaders
;; .parameter The shaders to link as a program
;; .parameter An optional callback receiving one argument (the program id) which will be invoked before linking
(define* (fusion:create-program shaders (bind-callback #f))
(let ((program-id (glCreateProgram))
(program-status* (alloc-GLint* 1)))
Expand All @@ -63,3 +65,15 @@
(fusion:error (string-append "GL Shading Language linkage -- " (*->string info-log*))))))
(for-each (lambda (s) (glDetachShader program-id s)) shaders)
program-id))

;;!! Loads a text file from the given path. Returns a string with the contents or #f if the file does not exists
;; .parameter The path of the file to load
(define (fusion:load-text-file path)
(and-let* ((rw (SDL_RWFromFile path "rt"))
(file-size (SDL_RWsize rw))
(buffer (alloc-char* file-size))
(bytes-read (SDL_RWread rw (*->void* buffer) 1 file-size))
(contents (*->string buffer)))
(SDL_RWclose rw)
contents))

11 changes: 10 additions & 1 deletion src/sake-extensions/fusion.scm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
(define android-link-file
(make-parameter "linkfile_.c"))

(define assets-directory
(make-parameter "assets/"))

;;------------------------------------------------------------------------------
;;!! Host programs
Expand Down Expand Up @@ -184,6 +186,11 @@
(arg-values `("main"
"main"
,(apply string-append (map (lambda (file) (string-append file " ")) all-c-files)))))
;; Process 'assets'
(fusion#process-directory-with-templates (string-append (android-directory) "assets/")
(assets-directory)
arguments
arg-values)
;; Process 'src'
(fusion#process-directory-with-templates (android-src-directory)
(string-append (android-directory) "src-generator/")
Expand Down Expand Up @@ -234,7 +241,9 @@
(fusion#android-generate-link-file all-modules version: version))))
(info/color 'blue "compiling JNI C/Scheme code")
;; Call "ndk-build". We dump the output to a file, as Gambit has issues with the "-j" flag for concurrent compilation
(unless (zero? (shell-command (string-append (android-ndk-build-path) " -j -C " (android-directory) " &>ndk-log")))
(unless (zero? (shell-command (string-append (android-ndk-build-path) " -C " (android-directory))))
(err "error building native code\n\n"))
#;(unless (zero? (shell-command (string-append (android-ndk-build-path) " -j -C " (android-directory) " &>ndk-log")))
(err "error building native code\n\n" (sake#read-file "ndk-log")))
(if verbose (display (sake#read-file "ndk-log")))
(info/color 'blue "compiling Java code")
Expand Down

0 comments on commit e1fd7c3

Please sign in to comment.