text
stringlengths
12
786k
let ocamlopt_byte = new compiler ~ name : Ocaml_commands . ocamlrun_ocamlopt ~ flags : " " ~ directory : " ocamlopt . byte " ~ exit_status_variable : Ocaml_variables . ocamlopt_byte_exit_status ~ reference_variable : Ocaml_variables . compiler_reference ~ output_variable : Ocaml_variables ....
let ocamlopt_opt = new compiler ~ name : Ocaml_files . ocamlopt_dot_opt ~ flags : " " ~ directory : " ocamlopt . opt " ~ exit_status_variable : Ocaml_variables . ocamlopt_opt_exit_status ~ reference_variable : Ocaml_variables . compiler_reference2 ~ output_variable : Ocaml_variables . com...
let eval_err_to_error err = Jv . Error . v ( Jv . to_jstr @@ Jv . call err " toString " [ ] ) ||
let eval_of_devtool_eval eval = fun expr -> let res , set_res = Fut . create ( ) in let cb r err = if Jv . is_undefined r && not ( Jv . is_undefined err ) then set_res ( Error ( eval_err_to_error err ) ) else set_res ( Ok r ) in match ignore @@ Jv . apply eval Jv . [ | of_jstr e...
let get_eval ( ) : ( Jstr . t -> Brr . Json . t Fut . or_error , Jv . Error . t ) result = let eval_id = [ " chrome " ; " devtools " ; " inspectedWindow " ; " eval " ] in match Jv . find_path Jv . global eval_id with | Some eval -> Ok ( eval_of_devtool_eval ev...
let try_await_inspected_document_complete eval = let is_complete ( ) = let complete = Jstr . v " globalThis . document . readyState == " \ complete " " \ in Fut . map ( Result . map Jv . to_bool ) ( eval complete ) in let rec loop = function | 0 -> Fut . ok ( ) | n -> l...
let reset_panel ( ) = let reload = El . button El . [ txt ' " Reset panel " ] in let reload_act _ = Window . reload G . window in Ev . listen Ev . click reload_act ( El . as_target reload ) ; reload
let rec warn_no_poke panel ui = let msg = " No OCaml poke found in inspected page . \ n \ Consult the OCaml console manual in ‘ odig doc brr ’ for more information . " in let retry = El . button El . [ txt ' " Retry " ] in let retry_connect _ = ignore ( connect_poke panel ) in Ev . ...
let listen ev func = match Jv . find_path Jv . global ev with
let setup_reconnect_on_reload panel = let prefix = [ " chrome " ; " devtools " ; " network " ; ] in let on_navigated = prefix @ [ " onNavigated " ] in let reconnect _ = ignore ( connect_poke panel ) in listen on_navigated reconnect ; ( )
let setup_theme ( ) = let prefix = [ " chrome " ; " devtools " ; " panels " ; ] in let theme_name = prefix @ [ " themeName " ] in let on_theme_changed = prefix @ [ " onThemeChanged " ] in let set_theme theme = let html = Document . root G . document in let theme = ...
let main ( ) = let panel = El . div [ ] in setup_theme ( ) ; setup_reconnect_on_reload panel ; El . set_children ( Document . body G . document ) [ panel ] ; connect_poke panel
let ( ) = ignore ( main ( ) )
let mydprintf fmt = dprintf 10 fmt
module type INPUT = sig val fold_dependencies : ( string -> string -> ' a -> ' a ) -> ' a -> ' a val fold_libraries : ( string -> string list -> ' a -> ' a ) -> ' a -> ' a val fold_packages : ( string -> string list -> ' a -> ' a ) -> ' a -> ' a end
module Make ( I : INPUT ) = struct open I module SMap = Map . Make ( String ) module Resources = Resource . Resources module Utils = struct let add = SMap . add let empty = SMap . empty let find_all_set x acc = try SMap . find x acc with Not_found -> Resources . empty let smap_add_set src d...
type runtime_variant = | Normal | Debug | Instrumented
let runtime_variant ( ) = let use_runtime = Sys . safe_getenv " USE_RUNTIME " in if use_runtime " = d " then Debug else if use_runtime " = i " then Instrumented else Normal
let ocamlrun = let runtime = match runtime_variant ( ) with | Normal -> " ocamlrun " | Debug -> " ocamlrund " | Instrumented -> " ocamlruni " in let ocamlrunfile = Filename . mkexe runtime in Filename . make_path [ Ocaml_directories . srcdir ; " runtime " ; ocamlrunfile ]
let ocamlc = Filename . make_path [ Ocaml_directories . srcdir ; Filename . mkexe " ocamlc " ]
let ocaml = Filename . make_path [ Ocaml_directories . srcdir ; Filename . mkexe " ocaml " ]
let ocamlc_dot_opt = Filename . make_path [ Ocaml_directories . srcdir ; Filename . mkexe " ocamlc . opt " ]
let ocamlopt = Filename . make_path [ Ocaml_directories . srcdir ; Filename . mkexe " ocamlopt " ]
let ocamlopt_dot_opt = Filename . make_path [ Ocaml_directories . srcdir ; Filename . mkexe " ocamlopt . opt " ]
let ocamlnat = Filename . make_path [ Ocaml_directories . srcdir ; Filename . mkexe " ocamlnat " ]
let cmpbyt = Filename . make_path [ Ocaml_directories . srcdir ; " tools " ; Filename . mkexe " cmpbyt " ]
let expect_test = Filename . make_path [ Ocaml_directories . srcdir ; " testsuite " ; " tools " ; Filename . mkexe " expect_test " ]
let ocamllex = Filename . make_path [ Ocaml_directories . srcdir ; " lex " ; Filename . mkexe " ocamllex " ]
let ocamlyacc = Filename . make_path [ Ocaml_directories . srcdir ; " yacc " ; Filename . mkexe " ocamlyacc " ]
let ocamldoc = Filename . make_path [ Ocaml_directories . srcdir ; " ocamldoc " ; Filename . mkexe " ocamldoc " ]
let ocamldebug = Filename . make_path [ Ocaml_directories . srcdir ; " debugger " ; Filename . mkexe " ocamldebug " ]
let ocamlobjinfo = Filename . make_path [ Ocaml_directories . srcdir ; " tools " ; Filename . mkexe " ocamlobjinfo " ]
let ocamlmklib = Filename . make_path [ Ocaml_directories . srcdir ; " tools " ; Filename . mkexe " ocamlmklib " ]
let codegen = Filename . make_path [ Ocaml_directories . srcdir ; " testsuite " ; " tools " ; Filename . mkexe " codegen " ]
let asmgen_archmod = let objname = " asmgen_ " ^ Ocamltest_config . arch ^ " . " ^ Ocamltest_config . objext in Filename . make_path [ Ocaml_directories . srcdir ; " testsuite " ; " tools " ; objname ]
type backend_specific = Object | Library | Program
type t = | Implementation | Interface | C | C_minus_minus | Lexer | Grammar | Binary_interface | Obj | Backend_specific of Ocaml_backends . t * backend_specific | Text
let string_of_backend_specific = function | Object -> " object " | Library -> " library " | Program -> " program "
let string_of_filetype = function | Implementation -> " implementation " | Interface -> " interface " | C -> " C source file " | C_minus_minus -> " C minus minus source file " | Lexer -> " lexer " | Grammar -> " grammar " | Binary_interface -> " binary interface " | Obj -> "...
let extension_of_filetype = function | Implementation -> " ml " | Interface -> " mli " | C -> " c " | C_minus_minus -> " cmm " | Lexer -> " mll " | Grammar -> " mly " | Binary_interface -> " cmi " | Obj -> Ocamltest_config . objext | Backend_specific ( backend , filet...
let filetype_of_extension = function | " ml " -> Implementation | " mli " -> Interface | " c " -> C | " cmm " -> C_minus_minus | " mll " -> Lexer | " mly " -> Grammar | " cmi " -> Binary_interface | " o " -> Obj | " obj " -> Obj | " cmx " -> Backend_specific ...
let split_filename name = let l = String . length name in let is_dir_sep name i = name . [ i ] = Filename . dir_sep . [ 0 ] in let rec search_dot i = if i < 0 || is_dir_sep name i then ( name , " " ) else if name . [ i ] = ' . ' then let basename = String . sub name 0 ...
let filetype filename = let ( basename , extension ) = split_filename filename in ( basename , filetype_of_extension extension )
let make_filename ( basename , filetype ) = let extension = extension_of_filetype filetype in basename ^ " . " ^ extension
let action_of_filetype = function | Implementation -> " Compiling implementation " | Interface -> " Compiling interface " | C -> " Compiling C source file " | C_minus_minus -> " Processing C -- file " | Lexer -> " Generating lexer " | Grammar -> " Generating parser " | filetype -...
let stdlib = let stdlib_path = Ocaml_directories . stdlib in " - nostdlib - I " ^ stdlib_path
let include_toplevel_directory = " - I " ^ Ocaml_directories . toplevel
let c_includes = let dir = Ocaml_directories . runtime in " - ccopt - I " ^ dir
let runtime_variant_flags ( ) = match Ocaml_files . runtime_variant ( ) with | Ocaml_files . Normal -> " " | Ocaml_files . Debug -> " - runtime - variant d " | Ocaml_files . Instrumented -> " - runtime - variant i "
let runtime_flags env backend c_files = let runtime_library_flags = " - I " ^ Ocaml_directories . runtime in let rt_flags = match backend with | Ocaml_backends . Native -> runtime_variant_flags ( ) | Ocaml_backends . Bytecode -> begin if c_files then begin " - custom " ^ ( runtime_variant...
let toplevel_default_flags = " - noinit - no - version - noprompt "
let ocamldebug_default_flags = " - no - version - no - prompt - no - time - no - breakpoint - message " ^ ( " - I " ^ Ocaml_directories . stdlib ^ " " ) ^ ( " - topdirs - path " ^ Ocaml_directories . toplevel )
let wrap sl = " " ^ String . concat " " sl ^ " "
let append var sl = Append ( var , wrap sl )
let add var s = Add ( var , s )
let principal = [ append Ocaml_variables . flags [ " - principal " ] ; add Ocaml_variables . compiler_directory_suffix " . principal " ; add Ocaml_variables . compiler_reference_suffix " . principal " ; ]
let latex = [ add Ocaml_variables . ocamldoc_backend " latex " ; append Ocaml_variables . ocamldoc_flags [ " - latex - type - prefix = TYP " ] ; append Ocaml_variables . ocamldoc_flags [ " - latex - module - prefix " ] ; = append Ocaml_variables . ocamldoc_flags [ " - l...
let html = [ add Ocaml_variables . ocamldoc_backend " html " ; append Ocaml_variables . ocamldoc_flags [ " - colorize - code " ] ; ]
let man = [ add Ocaml_variables . ocamldoc_backend " man " ; ]
let make_library_modifier library directories = [ append Ocaml_variables . directories directories ; append Ocaml_variables . libraries [ library ] ; append Ocaml_variables . caml_ld_library_path directories ; ]
let make_module_modifier unit_name directory = [ append Ocaml_variables . directories [ directory ] ; append Ocaml_variables . binary_modules [ unit_name ] ; ]
let compiler_subdir subdir = Filename . make_path ( Ocaml_directories . srcdir :: subdir )
let config = [ append Ocaml_variables . directories [ compiler_subdir [ " utils " ] ] ; ]
let testing = make_library_modifier " testing " [ compiler_subdir [ " testsuite " ; " lib " ] ]
let tool_ocaml_lib = make_module_modifier " lib " ( compiler_subdir [ " testsuite " ; " lib " ] )
let unixlibdir = if Sys . win32 then " win32unix " else " unix "
let unix = make_library_modifier " unix " [ compiler_subdir [ " otherlibs " ; unixlibdir ] ]
let dynlink = make_library_modifier " dynlink " [ compiler_subdir [ " otherlibs " ; " dynlink " ] ; compiler_subdir [ " otherlibs " ; " dynlink " ; " native " ] ]
let str = make_library_modifier " str " [ compiler_subdir [ " otherlibs " ; " str " ] ]
let systhreads = unix @ ( make_library_modifier " threads " [ compiler_subdir [ " otherlibs " ; " systhreads " ] ] )
let compilerlibs_subdirs = [ " asmcomp " ; " bytecomp " ; " compilerlibs " ; " driver " ; " file_formats " ; " lambda " ; " middle_end " ; " parsing " ; " toplevel " ; " typing " ; " utils " ; ]
let add_compiler_subdir subdir = append Ocaml_variables . directories [ compiler_subdir [ subdir ] ]
let compilerlibs_archive archive = append Ocaml_variables . libraries [ archive ] :: List . map add_compiler_subdir compilerlibs_subdirs
let debugger = [ add_compiler_subdir " debugger " ]
let _ = register_modifiers " principal " principal ; register_modifiers " config " config ; register_modifiers " testing " testing ; register_modifiers " unix " unix ; register_modifiers " dynlink " dynlink ; register_modifiers " str " str ; List . iter ( fun archive -> regist...
module C_tools = struct let link_C_library clib a libname env build = let clib = env clib and a = env a and libname = env libname in let objs = string_list_of_file clib in let include_dirs = Pathname . include_dirs_of ( Pathname . dirname a ) in let obj_of_o x = if Filename . check_suffix x " . o ...
let init ( ) = let module M = struct
let x_p_dll = " . % p " . -- ext_dll ; ; ~ dep " . :% itarget " ~ stamp " . :% otarget " begin fun env build -> let itarget = env " . % itarget " in let dir = Pathname . dirname itarget in let targets = string_list_of_file itarget in List . iter ignore_good ( build ( Li...
let ( ) = if ! Options . use_ocamlfind then begin flag [ " ocaml " ; " link " ; " program " ] & A " - linkpkg " ; flag [ " ocaml " ; " link " ; " toplevel " ] & A " - linkpkg " ; let all_tags = [ [ " ocaml " ; " byte " ; " compile " ] ...
let ( ) = pflag [ " ocaml " ; " native " ; " compile " ] " for - pack " ( fun param -> S [ A " - for - pack " ; A param ] ) ; pflag [ " ocaml " ; " native " ; " compile " ] " inline " ( fun param -> S [ A " - inline " ; A param ] ) ...
let camlp4_flags camlp4s = List . iter begin fun camlp4 -> flag [ " ocaml " ; " pp " ; camlp4 ] ( A camlp4 ) end camlp4s ; ;
let camlp4_flags ' camlp4s = List . iter begin fun ( camlp4 , flags ) -> flag [ " ocaml " ; " pp " ; camlp4 ] flags end camlp4s ; ; " camlp4rrr " , S [ A " camlp4rf " ; A " - parser " ; A " reloaded " ] ] ; ; ( S [ A " - I " ; A " + camlp4 ...
let ocaml_warn_flag c = flag [ " ocaml " ; " compile " ; sprintf " warn_ % c " ( Char . uppercase c ) ] ( S [ A " - w " ; A ( sprintf " % c " ( Char . uppercase c ) ) ] ) ; flag [ " ocaml " ; " compile " ; sprintf " warn_error_ % c " ( Cha...
let bytecode = let test_actions = if Ocamltest_config . arch " = none " then [ setup_ocamlc_byte_build_env ; ocamlc_byte ; check_ocamlc_byte_output ; run ; check_program_output ; ] else [ setup_ocamlc_opt_build_env ; ocamlc_opt ; check_ocamlc_opt_output ; run ; check_program_output ] ...
let native = let test_actions = if not Ocamltest_config . native_compiler then [ skip ] else [ setup_ocamlopt_opt_build_env ; ocamlopt_opt ; check_ocamlopt_opt_output ; run ; check_program_output ] in { test_name = " native " ; test_run_by_default = true ; test_actions ; }
let toplevel = { test_name = " toplevel " ; test_run_by_default = false ; test_actions = [ setup_ocaml_build_env ; ocaml ; check_ocaml_output ; ] }
let expect = { test_name = " expect " ; test_run_by_default = false ; test_actions = [ setup_simple_build_env ; run_expect ; check_program_output ] }
let ocamldoc = { test_name = " ocamldoc " ; test_run_by_default = false ; test_actions = if Ocamltest_config . ocamldoc then [ shared_libraries ; setup_ocamldoc_build_env ; run_ocamldoc ; check_program_output ; check_ocamldoc_output ] else [ skip ] }
let asmgen_skip_on_bytecode_only = Actions_helpers . skip_with_reason " native compiler disabled "
let msvc64 = Ocamltest_config . ccomptype = " msvc " && Ocamltest_config . arch " = amd64 "
let asmgen_skip_on_msvc64 = Actions_helpers . skip_with_reason " not ported to MSVC64 yet "
let asmgen_actions = if not Ocamltest_config . native_compiler then [ asmgen_skip_on_bytecode_only ] else if msvc64 then [ asmgen_skip_on_msvc64 ] else [ setup_simple_build_env ; codegen ; cc ; ]
let asmgen = { test_name = " asmgen " ; test_run_by_default = false ; test_actions = asmgen_actions }
let _ = List . iter register [ bytecode ; native ; toplevel ; expect ; ocamldoc ; asmgen ; ]
( ~ name : string ) ( ~ family : string ) ( ~ flags : string ) ( ~ directory : string ) ( ~ exit_status_variable : Variables . t ) ( ~ reference_variable : Variables . t ) ( ~ output_variable : Variables . t ) method name = name method family = family method flags = fl...
let expected_exit_status env tool = Actions_helpers . exit_status_of_variable env tool # exit_status_variable
let ocamldoc = object inherit tool ~ name : Ocaml_files . ocamldoc ~ family " : doc " ~ flags " " : ~ directory " : ocamldoc " ~ exit_status_variable : Ocaml_variables . ocamldoc_exit_status ~ reference_variable : Ocaml_variables . ocamldoc_reference ~ output_variable : Ocaml_variables ...
( ~ name : string ) ( ~ flags : string ) ( ~ directory : string ) ( ~ exit_status_variable : Variables . t ) ( ~ reference_variable : Variables . t ) ( ~ output_variable : Variables . t ) ( ~ backend : Ocaml_backends . t ) ( ~ compiler : Ocaml_compilers . compiler...
let ocaml = new toplevel ~ name : Ocaml_commands . ocamlrun_ocaml ~ flags : " " ~ directory : " ocaml " ~ exit_status_variable : Ocaml_variables . ocaml_exit_status ~ reference_variable : Ocaml_variables . compiler_reference ~ output_variable : Ocaml_variables . compiler_output ~ backend ...
let ocamlnat = new toplevel ~ name : Ocaml_files . ocamlnat ~ flags : " - S " ~ directory : " ocamlnat " ~ exit_status_variable : Ocaml_variables . ocamlnat_exit_status ~ reference_variable : Ocaml_variables . compiler_reference2 ~ output_variable : Ocaml_variables . compiler_output2 ~ ba...