-
Notifications
You must be signed in to change notification settings - Fork 125
/
pass_PluginCompilation.ml
66 lines (55 loc) · 1.99 KB
/
pass_PluginCompilation.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
(*
Copyright © 2011, 2012 MLstate
This file is part of Opa.
Opa is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.
Opa is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with Opa. If not, see <http://www.gnu.org/licenses/>.
*)
(** Generate plugin files from JS given to the opa compiler. Mostly
copied from bslregister.ml.
@author Arthur Azevedo de Amorim
*)
module BR = BslRegisterLib
module BI = BslInterface
module PH = PassHandler
module O = OpaEnv
module List = BaseList
let process env =
let js_files = env.PH.options.O.client_plugin_files in
let nodejs_files = env.PH.options.O.server_plugin_files in
let all_files = js_files @ nodejs_files in
if not (List.is_empty js_files && List.is_empty nodejs_files) then (
(* TODO: ensure we are in qmljs, and not qmlflat *)
let basename = None in
let ml_plugin_filename =
"bundled" ^ BslConvention.Suffix.plugin ^ ".ml" in
let ml_runtime_filename =
"bundled" ^ BslConvention.Suffix.mlruntime ^ ".ml" in
let options = {
BI.
basename;
bypass_plugins = [];
check_style = false;
js_files;
nodejs_files;
js_validator = None;
ml_plugin_filename;
ml_runtime_filename;
modular_plugins = false;
unsafe_js = false;
unsafe_opa = false;
js_classic_bypass_syntax = env.PH.options.O.js_classic_bypass_syntax;
} in
let session = BR.create ~options in
let session = List.fold_left BR.preprocess_file session all_files in
let fin = BR.finalize session in
let plugin = BR.plugin fin in
BslPluginTable.store plugin;
);
env