Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fix] plugins: Use the js preprocessor on external libs too

  • Loading branch information...
commit 5108c26814bc6e483c6ea4138a675d138d9049bc 1 parent e6a178c
@BourgerieQuentin BourgerieQuentin authored
Showing with 13 additions and 0 deletions.
  1. +1 −0  compiler/jslang/_tags
  2. +12 −0 compiler/jslang/globalizer.ml
View
1  compiler/jslang/_tags
@@ -6,3 +6,4 @@
# todo: find a way to link fewer libs
<{jspp,jsstat,globalizer}.{byte,native}>: use_passlib, use_opacapi, use_libtrx, use_ulex, use_str, use_unix, use_buildinfos, use_libbase, use_libqmlcompil, use_compilerlib, use_graph, use_nums, use_dynlink, use_jslang, use_ocamllang, use_libbsl, use_opalang, use_pplib, use_qml2ocaml, use_qml2js, use_qmlcpsrewriter, use_qmlpasses
<{jspp,jsstat,globalizer}.{ml,byte,native}>: use_libtools, use_libruntime, use_oparuntime, use_ssl, use_appruntime, use_libnet, use_libsecurity, use_qmljsimp
+<globalizer.{ml,byte,native}>:use_pplib
View
12 compiler/jslang/globalizer.ml
@@ -65,6 +65,17 @@ let process formatter (files : (path * JsAst.code) list) =
let die message =
Printf.eprintf "error: %s\n" message; exit 1
+
+let pp_nodejs filename contents =
+ let ppenv =
+ let ppenv = Pprocess.fill_with_sysenv Pprocess.empty_env in
+ let ppenv = Pprocess.add_env "OPABSL_NODE" "1" ppenv in
+ Pprocess.add_env "OPA_CPS_CLIENT" "1" ppenv in
+ let ppopt = Pprocess.default_options ppenv in
+ let contents = Pprocess.process ~name:filename
+ Pplang.js_description ppopt contents in
+ contents
+
let _ =
let args = List.tl (Array.to_list Sys.argv) in
match read_cmd_line_args args with
@@ -74,6 +85,7 @@ let _ =
(* Read files and reexport their identifiers *)
let files = List.map (fun filename ->
let content = File.content filename in
+ let content = pp_nodejs filename content in
let content =
try
JsParse.String.code ~throw_exn:true content
Please sign in to comment.
Something went wrong with that request. Please try again.