Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[feature] bslregister: activate js validation

this commit is ugly, we need some refactoring because
bslregister.ml is constructing destination name of final js files
but bslRegisterLib.ml has no information about theses name

everything should be moved to bslRegisterLib
  • Loading branch information...
commit 6f114593a5d87fbbc2f9cc05c42f28fc4e988a19 1 parent 7178477
@OpaOnWindowsNow OpaOnWindowsNow authored
View
5 build/myocamlbuild_prefix.ml
@@ -431,6 +431,7 @@ let _ = dispatch begin function
~prods:["%.ml"; "%.mli"]
(trx_build "%" N);
+
(* -- Macro-rules generating ML files -- *)
(* aspell custom dictionnary *)
@@ -476,11 +477,11 @@ let _ = dispatch begin function
| Not_found -> false
) in
(if cond then (A a)::acc else acc) in
- List.fold_left fold []
+ List.fold_left fold [A"--js-validator-off"] (* until bsl is a standard plugin *)
[
("bsl_debug", "-debug");
("bsl_unsafe", "-unsafe") ;
- ("bsl_no_js_validator", "--no-js-validator");
+ ("bsl_no_js_validator", "--js-validator-off");
]
in
View
4 libbsl/bslInterface.ml
@@ -709,11 +709,9 @@ type options = {
of jsconf files.
*)
- js_syntax_checker : ( (executable * shell_options) * filename list ) option ;
js_validator : ( (executable * shell_options) * filename list ) option ;
(**
- The executable for performing syntax check.
- TODO(maxime) merge them both. Not in one year please.
+ The executable for performing js validation (syntax at least).
*)
ml_plugin_filename : filename ;
View
2  libbsl/bslJsConf.ml
@@ -287,7 +287,7 @@ let parse_line pos files line =
FilePos.pp pos
message
in
- let filter s = Str.string_match regexp s 0 in
+ let filter s = Str.string_match regexp (Filename.basename s) 0 in
let files = List.rev_filter filter files in
if files = [] then
OManager.warning ~wclass:WarningClass.bsl_register (
View
28 libbsl/bslRegisterLib.ml
@@ -895,7 +895,7 @@ let finalizing_ocaml session =
let finalizing_js_code_conf s_js_confs s_js_code =
let confs = BslJsConf.export s_js_confs in
let map (filename, content) =
- let index = Filename.basename filename in
+ let index = filename in
match StringMap.find_opt index confs with
| Some conf -> filename, content, conf
| None ->
@@ -1044,6 +1044,32 @@ let finalize s =
finalized_t
+let js_validator finalized_t =
+ let name = finalized_t.f_options.BI.basename in
+ match finalized_t.f_options.BI.js_validator with
+ | Some ((executable,files),cmd_options) ->
+ let pp_str_list = Format.pp_list " " Format.pp_print_string in
+ let pp_file_list = Format.pp_list " " (
+ if true || (List.mem "jschecker.jar" cmd_options) then (fun fmt v -> Format.fprintf fmt "--js %s" v) (* google compiler *)
+ else Format.pp_print_string
+ )
+ in
+ let command = Format.sprintf "%s %a %a %a"
+ executable
+ pp_str_list cmd_options
+ pp_str_list files
+ pp_file_list (List.map (fun (f,_,_)-> Printf.sprintf "%s.opp/%s/%s_%s" name (Filename.dirname f) name (Filename.basename f)) finalized_t.f_js_code)
+ in
+ Printf.printf "%s\n" command;
+ let r = Sys.command command in
+ if r<>0 && not(finalized_t.f_options.BI.unsafe_js) then (
+ Printf.printf "Failure(%d) %s\n" r command;
+ exit r
+ ) else ()
+ | None -> ()
+;;
+
+
(* Output *)
View
3  libbsl/bslRegisterLib.mli
@@ -106,6 +106,9 @@ type finalized_t
*)
val finalize : session -> finalized_t
+(** check *)
+val js_validator : finalized_t -> unit
+
(** {6 Files Production} *)
(**
View
58 libbsl/bslregister.ml
@@ -286,24 +286,9 @@ let files_generated = ref 0
let js_files = MutableList.create ()
-let js_syntax_checker = ref (Some "js")
-let js_syntax_checker_files = MutableList.create ()
-let js_syntax_checker_add_file s =
- List.iter (fun f ->
- if not (File.is_regular f)
- then OManager.error "cannot find file %S (js-validation)" f
- else MutableList.add js_syntax_checker_files f)
- (spliter s)
-
-let js_syntax_checker_options = MutableList.create ()
-let js_syntax_checker_add_option o =
- MutableList.add js_syntax_checker_options o
-
-
-
-
-let js_validator = ref None
+let js_validator = ref (Some "js")
let js_validator_files = MutableList.create ()
+let js_validator_files_set = ref StringSet.empty
let js_validator_add_file s =
List.iter (fun f ->
if not (File.is_regular f)
@@ -392,31 +377,6 @@ let spec = [
(* j *)
-
- "--js-syntax-checker",
- Arg.String (fun s -> js_syntax_checker := Some s),
- !>
- " Specify a js-syntax-checker (default is %a)" (Option.pp Format.pp_print_string) !js_syntax_checker ;
-
-
- "--js-syntax-checker-file",
- Arg.String js_syntax_checker_add_file,
- !>
- "<file> add an js init file for the js-syntax-checker only" ;
-
-
- "--js-syntax-checker-off",
- Arg.Unit (fun () -> js_syntax_checker := None),
- !>
- " Disable the js syntax checking (sad)" ;
-
-
- "--js-syntax-checker-opt",
- Arg.String js_syntax_checker_add_option,
- !>
- "<opt> Add an shell option for the the js-syntax-checker" ;
-
-
"--js-validator",
Arg.String (fun s -> js_validator := Some s),
!>
@@ -533,8 +493,8 @@ let anon_fun file =
(*
The js files are indexed by their basename.
*)
- let file = Filename.basename file in
- if MutableList.mem file js_files
+ let key = file in
+ if StringSet.mem key (!js_validator_files_set)
then
OManager.error (
"Found several js files with the same basename : @{<bright>%s@}@\n"^^
@@ -544,6 +504,7 @@ let anon_fun file =
)
file
;
+ js_validator_files_set := StringSet.add key (!js_validator_files_set);
MutableList.add js_files file
) ;
MutableList.add files file
@@ -792,12 +753,6 @@ let bslregister_options ()=
let js_files = MutableList.to_list js_files in
- let js_syntax_checker =
- Option.map (
- fun js -> (js, MutableList.to_list js_syntax_checker_files), MutableList.to_list js_syntax_checker_options
- ) (!js_syntax_checker)
- in
-
let js_validator =
Option.map (
fun js -> (js, MutableList.to_list js_validator_files), MutableList.to_list js_validator_options
@@ -820,7 +775,6 @@ let bslregister_options ()=
check_style ;
js_files ;
- js_syntax_checker ;
js_validator ;
ml_plugin_filename ;
@@ -956,6 +910,8 @@ let _ =
let finalized_t = BR.finalize session in
files_generation finalized_t ;
+ BR.js_validator finalized_t;
+
OManager.verbose "successfull generation of plugin files : @{<bright>%d@} files" !files_generated ;
if !auto_build then (
Please sign in to comment.
Something went wrong with that request. Please try again.