#lang racket/base
(require racket/path
racket/contract
(prefix-in js-vm: "js-vm/main.rkt")
"js-vm/private/misc.rkt"
"js-vm/private/log-port.rkt"
"src/android/android-packager.ss")
(provide/contract
[create-android-phone-package (path-string? path-string? . -> . any)]
[run-in-browser (path-string? . -> . any)])
(define (make-package-name a-path)
(let-values ([(base name dir?)
(split-path a-path)])
(remove-filename-extension name)))
(define run-in-browser js-vm:run-in-browser)
(define (create-android-phone-package a-filename output-file)
(let ([a-filename (normalize-path a-filename)]
[output-file (normalize-path output-file)])
(with-handlers
([exn:fail?
(lambda (exn)
(log-warning (format "An internal error occurred during compilation: ~a\n"
(exn-message exn)))
(raise exn))])
(call-with-output-file output-file
(lambda (op)
(log-info (format "Writing package to file ~a...\n" output-file))
(log-info (format "This may take up to a minute. Please wait...\n"))
(write-bytes (build-android-package
(make-package-name output-file)
a-filename)
op))
#:exists 'replace)
(log-info "Done!\n"))))