working on splitting
This commit is contained in:
parent
080bd24bda
commit
890b388ed9
|
@ -404,8 +404,8 @@ EOF
|
|||
)
|
||||
|
||||
|
||||
;; get-html-template: string -> string
|
||||
(define (get-html-template js)
|
||||
;; get-html-template: (listof string) -> string
|
||||
(define (get-html-template js-files)
|
||||
(format #<<EOF
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -414,7 +414,7 @@ EOF
|
|||
<meta charset="utf-8"/>
|
||||
<title></title>
|
||||
</head>
|
||||
<script src="~a"></script>
|
||||
~a
|
||||
<script>
|
||||
~a
|
||||
</script>
|
||||
|
@ -424,9 +424,11 @@ EOF
|
|||
</html>
|
||||
EOF
|
||||
|
||||
js
|
||||
invoke-main-module-code
|
||||
))
|
||||
(string-join (map (lambda (js)
|
||||
(format " <script src='~a'></script>\n" js))
|
||||
js-files)
|
||||
"")
|
||||
invoke-main-module-code))
|
||||
|
||||
|
||||
;; get-inert-code: source -> string
|
||||
|
|
27
notes/phonegap-stuff.txt
Normal file
27
notes/phonegap-stuff.txt
Normal file
|
@ -0,0 +1,27 @@
|
|||
Seeing how to use the new Phonegap. I first create a directory for android with the
|
||||
following:
|
||||
|
||||
Say that I'm trying to package where-am-i.rkt.
|
||||
|
||||
|
||||
$ android create project --target "android-8" --name WhereAmI --path where-am-i --activity WhereAmI --package org.plt
|
||||
|
||||
|
||||
I go into the created directory and make an assets subdirectory:
|
||||
|
||||
$ cd where-am-i
|
||||
~/where-am-i $ mkdir -p assets
|
||||
|
||||
|
||||
I then build my where-am-i stuff into assets:
|
||||
|
||||
$ cd assets
|
||||
$ cp ~/work/whalesong/web-world/examples/where-am-i/* .
|
||||
$ whalesong build --compress-javascript where-am-i.rkt
|
||||
|
||||
|
||||
|
||||
One problem that's coming up is that the assets file isn't allowed to
|
||||
have files larger than a megabyte. So I'm forced to split up the
|
||||
files, after
|
||||
all... (http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/)
|
|
@ -74,6 +74,12 @@
|
|||
(define current-compress-javascript? (make-parameter #f))
|
||||
|
||||
|
||||
;; Turn this one so that js-assembler/package generates a file per module, as
|
||||
;; opposed to trying to bundle them all together.
|
||||
(: current-one-module-per-file? (Parameterof Boolean))
|
||||
(define current-one-module-per-file? (make-parameter #f))
|
||||
|
||||
|
||||
|
||||
|
||||
(: current-report-port (Parameterof Output-Port))
|
||||
|
|
|
@ -85,6 +85,23 @@
|
|||
|
||||
(define (build-html-and-javascript f)
|
||||
(turn-on-logger!)
|
||||
|
||||
(define written-js-paths '())
|
||||
(define make-output-js-filename
|
||||
(let ([n 0])
|
||||
(lambda (source-path)
|
||||
(define-values (base filename dir?) (split-path f))
|
||||
(define result (build-path (current-output-path)
|
||||
(regexp-replace #rx"[.](rkt|ss)$"
|
||||
(path->string filename)
|
||||
(if (= n 0)
|
||||
".js"
|
||||
(format "_~a.js" n)))))
|
||||
(set! written-js-paths (cons result written-js-paths))
|
||||
(set! n (add1 n))
|
||||
result)))
|
||||
|
||||
|
||||
(define start-time (current-inexact-milliseconds))
|
||||
(let-values ([(base filename dir?)
|
||||
(split-path f)])
|
||||
|
@ -126,8 +143,8 @@
|
|||
(build-path (current-output-dir)
|
||||
(resource-key r)))]))])
|
||||
(fprintf (current-report-port)
|
||||
(format "Writing program ~s\n" (build-path (current-output-dir) output-js-filename)))
|
||||
(call-with-output-file* (build-path (current-output-dir) output-js-filename)
|
||||
(format "Writing program ~s\n" output-js-filename))
|
||||
(call-with-output-file* output-js-filename
|
||||
(lambda (op)
|
||||
(display (get-runtime) op)
|
||||
(display (get-inert-code (make-ModuleSource (build-path f)))
|
||||
|
@ -138,7 +155,8 @@
|
|||
(format "Writing html ~s\n" (build-path (current-output-dir) output-html-filename)))
|
||||
(call-with-output-file* (build-path (current-output-dir) output-html-filename)
|
||||
(lambda (op)
|
||||
(display (get-html-template output-js-filename) op))
|
||||
(display (get-html-template (map file-name-from-path written-js-paths))
|
||||
op))
|
||||
#:exists 'replace)
|
||||
(define stop-time (current-inexact-milliseconds))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user