diff options
author | Artyom Shalkhakov <artyom.shalkhakov@gmail.com> | 2017-03-07 13:47:55 +0000 |
---|---|---|
committer | Artyom Shalkhakov <artyom.shalkhakov@gmail.com> | 2017-03-07 13:47:55 +0000 |
commit | bfc7faaf3b8cdff7ca6baec6b3358aef531eb9e2 (patch) | |
tree | f0b93d51b82fc11f75bdeb2ae991b74c057d74c8 | |
parent | 5c7051419520ca3449649dbfc68e755b45cde0f1 (diff) |
Adding support for emitting JS to a given file.
-rw-r--r-- | src/cjr_print.sml | 6 | ||||
-rw-r--r-- | src/main.mlton.sml | 3 | ||||
-rw-r--r-- | src/settings.sig | 2 | ||||
-rw-r--r-- | src/settings.sml | 7 |
4 files changed, 16 insertions, 2 deletions
diff --git a/src/cjr_print.sml b/src/cjr_print.sml index 688b3e4d..53587ff7 100644 --- a/src/cjr_print.sml +++ b/src/cjr_print.sml @@ -2513,8 +2513,12 @@ fun p_decl env (dAll as (d, loc) : decl) = | DJavaScript s => let + val name = + (case Settings.getOutputJsFile () of + NONE => "app." ^ SHA1.bintohex (SHA1.hash s) ^ ".js" + | SOME s => s) val () = app_js := OS.Path.joinDirFile {dir = Settings.getUrlPrefix (), - file = "app." ^ SHA1.bintohex (SHA1.hash s) ^ ".js"} + file = name} in box [string "static char jslib[] = \"", string (Prim.toCString s), diff --git a/src/main.mlton.sml b/src/main.mlton.sml index fb1a1723..2caa43f8 100644 --- a/src/main.mlton.sml +++ b/src/main.mlton.sml @@ -134,6 +134,9 @@ fun oneRun args = | "-output" :: s :: rest => (Settings.setExe (SOME s); doArgs rest) + | "-js" :: s :: rest => + (Settings.setOutputJsFile (SOME s); + doArgs rest) | "-sql" :: s :: rest => (Settings.setSql (SOME s); doArgs rest) diff --git a/src/settings.sig b/src/settings.sig index 05ab5e23..0ae81b13 100644 --- a/src/settings.sig +++ b/src/settings.sig @@ -303,4 +303,6 @@ signature SETTINGS = sig val addJsFile : string (* filename *) -> unit val listJsFiles : unit -> {Filename : string, Content : string} list + val setOutputJsFile : string option (* filename *) -> unit + val getOutputJsFile : unit -> string option end diff --git a/src/settings.sml b/src/settings.sml index 70ea1861..9fdc2232 100644 --- a/src/settings.sml +++ b/src/settings.sml @@ -951,6 +951,10 @@ fun addJsFile LoadFromFilename = fun listJsFiles () = SM.listItems (!jsFiles) +val jsOutput = ref (NONE : string option) +fun setOutputJsFile so = jsOutput := so +fun getOutputJsFile () = !jsOutput + fun reset () = (Globals.setResetTime (); urlPrefixFull := "/"; @@ -996,6 +1000,7 @@ fun reset () = mimeTypes := NONE; files := SM.empty; jsFiles := SM.empty; - filePath := ".") + filePath := "."; + jsOutput := NONE) end |