text
stringlengths
12
786k
let last_flags env = Environments . safe_lookup Ocaml_variables . last_flags env
let ocamllex_flags env = Environments . safe_lookup Ocaml_variables . ocamllex_flags env
let ocamlyacc_flags env = Environments . safe_lookup Ocaml_variables . ocamlyacc_flags env
let filelist env variable extension = let value = Environments . safe_lookup variable env in let filenames = String . words value in let add_extension filename = Filename . make_filename filename extension in String . concat " " ( List . map add_extension filenames )
let libraries backend env = let extension = Ocaml_backends . library_extension backend in filelist env Ocaml_variables . libraries extension
let binary_modules backend env = let extension = Ocaml_backends . module_extension backend in filelist env Ocaml_variables . binary_modules extension
let backend_default_flags env = get_backend_value_from_env env Ocaml_variables . ocamlc_default_flags Ocaml_variables . ocamlopt_default_flags
let backend_flags env = get_backend_value_from_env env Ocaml_variables . ocamlc_flags Ocaml_variables . ocamlopt_flags
let env_setting env_reader default_setting = Printf . sprintf " % s =% s " env_reader . Clflags . env_var ( env_reader . Clflags . print default_setting )
let default_ocaml_env = [ | " TERM = dumb " ; env_setting Clflags . color_reader Misc . Color . default_setting ; env_setting Clflags . error_style_reader Misc . Error_style . default_setting ; ] |
type module_generator = { description : string ; command : string ; flags : Environments . t -> string ; generated_compilation_units : string -> ( string * Ocaml_filetypes . t ) list }
let ocamllex = { description = " lexer " ; command = Ocaml_commands . ocamlrun_ocamllex ; flags = ocamllex_flags ; generated_compilation_units = fun lexer_name -> [ ( lexer_name , Ocaml_filetypes . Implementation ) ] }
let ocamlyacc = { description = " parser " ; command = Ocaml_files . ocamlyacc ; flags = ocamlyacc_flags ; generated_compilation_units = fun parser_name -> [ ( parser_name , Ocaml_filetypes . Interface ) ; ( parser_name , Ocaml_filetypes . Implementation ) ] }
let generate_module generator output_variable input log env = let basename = fst input in let input_file = Ocaml_filetypes . make_filename input in let what = Printf . sprintf " Generating % s module from % s " generator . description input_file in Printf . fprintf log " % s \ n " %! what ; l...
let generate_lexer = generate_module ocamllex
let generate_parser = generate_module ocamlyacc
let prepare_module output_variable log env input = let input_type = snd input in let open Ocaml_filetypes in match input_type with | Implementation | Interface | C | Obj -> [ input ] | Binary_interface -> [ input ] | Backend_specific _ -> [ input ] | C_minus_minus -> assert false | Lexer -> ...
let get_program_file backend env = let testfile = Actions_helpers . testfile env in let testfile_basename = Filename . chop_extension testfile in let program_filename = Filename . mkexe ( Filename . make_filename testfile_basename ( Ocaml_backends . executable_extension backend ) ) in let test_bui...
let is_c_file ( _filename , filetype ) = filetype = Ocaml_filetypes . C
let cmas_need_dynamic_loading directories libraries = let loads_c_code library = let library = Misc . find_in_path directories library in let ic = open_in_bin library in try let len_magic_number = String . length Config . cma_magic_number in let magic_number = really_input_string ic len_magic_number in if m...
let compile_program ( compiler : Ocaml_compilers . compiler ) log env = let program_variable = compiler # program_variable in let program_file = Environments . safe_lookup program_variable env in let all_modules = Actions_helpers . words_of_variable env Ocaml_variables . all_modules in let output_vari...
let compile_module compiler module_ log env = let expected_exit_status = Ocaml_tools . expected_exit_status env ( compiler :> Ocaml_tools . tool ) in let what = Printf . sprintf " Compiling module % s " module_ in Printf . fprintf log " % s \ n " %! what ; let module_with_filetype = Ocaml...
let module_has_interface directory module_name = let interface_name = Ocaml_filetypes . make_filename ( module_name , Ocaml_filetypes . Interface ) in let interface_fullpath = Filename . make_path [ directory ; interface_name ] in Sys . file_exists interface_fullpath
let add_module_interface directory module_description = match module_description with | ( filename , Ocaml_filetypes . Implementation ) when module_has_interface directory filename -> [ ( filename , Ocaml_filetypes . Interface ) ; module_description ] | _ -> [ module_description ]
let print_module_names log description modules = Printf . fprintf log " % s modules : % s \ n " %! description ( String . concat " " ( List . map Ocaml_filetypes . make_filename modules ) )
let find_source_modules log env = let source_directory = Actions_helpers . test_source_directory env in let specified_modules = List . map Ocaml_filetypes . filetype ( ( plugins env ) @ ( modules env ) @ [ ( Actions_helpers . testfile env ) ] ) in print_module_names log " Specified " ...
let setup_tool_build_env tool log env = let source_directory = Actions_helpers . test_source_directory env in let testfile = Actions_helpers . testfile env in let testfile_basename = Filename . chop_extension testfile in let tool_reference_variable = tool # reference_variable in let tool_reference_prefix =...
let setup_compiler_build_env ( compiler : Ocaml_compilers . compiler ) log env = let ( r , env ) = setup_tool_build_env compiler log env in if Result . is_pass r then begin let prog_var = compiler # program_variable in let prog_output_var = compiler # program_output_variable in let default_prog_fil...
let setup_toplevel_build_env ( toplevel : Ocaml_toplevels . toplevel ) log env = setup_tool_build_env toplevel log env
let mk_compiler_env_setup name ( compiler : Ocaml_compilers . compiler ) = Actions . make name ( setup_compiler_build_env compiler )
let mk_toplevel_env_setup name ( toplevel : Ocaml_toplevels . toplevel ) = Actions . make name ( setup_toplevel_build_env toplevel )
let setup_ocamlc_byte_build_env = mk_compiler_env_setup " setup - ocamlc . byte - build - env " Ocaml_compilers . ocamlc_byte
let setup_ocamlc_opt_build_env = native_action ( mk_compiler_env_setup " setup - ocamlc . opt - build - env " Ocaml_compilers . ocamlc_opt )
let setup_ocamlopt_byte_build_env = native_action ( mk_compiler_env_setup " setup - ocamlopt . byte - build - env " Ocaml_compilers . ocamlopt_byte )
let setup_ocamlopt_opt_build_env = native_action ( mk_compiler_env_setup " setup - ocamlopt . opt - build - env " Ocaml_compilers . ocamlopt_opt )
let setup_ocaml_build_env = mk_toplevel_env_setup " setup - ocaml - build - env " Ocaml_toplevels . ocaml
let setup_ocamlnat_build_env = native_action ( mk_toplevel_env_setup " setup - ocamlnat - build - env " Ocaml_toplevels . ocamlnat )
let compile ( compiler : Ocaml_compilers . compiler ) log env = match Environments . lookup_nonempty Builtin_variables . commandline env with | None -> begin match Environments . lookup_nonempty Ocaml_variables . module_ env with | None -> compile_program compiler log env | Some module_ -> compile...
let ocamlc_byte = Actions . make " ocamlc . byte " ( compile Ocaml_compilers . ocamlc_byte )
let ocamlc_opt = native_action ( Actions . make " ocamlc . opt " ( compile Ocaml_compilers . ocamlc_opt ) )
let ocamlopt_byte = native_action ( Actions . make " ocamlopt . byte " ( compile Ocaml_compilers . ocamlopt_byte ) )
let ocamlopt_opt = native_action ( Actions . make " ocamlopt . opt " ( compile Ocaml_compilers . ocamlopt_opt ) )
let env_with_lib_unix env = let libunixdir = Ocaml_directories . libunix in let newlibs = match Environments . lookup Ocaml_variables . caml_ld_library_path env with | None -> libunixdir | Some libs -> libunixdir ^ " " ^ libs in Environments . add Ocaml_variables . caml_ld_library_path newlibs en...
let debug log env = let program = Environments . safe_lookup Builtin_variables . program env in let what = Printf . sprintf " Debugging program % s " program in Printf . fprintf log " % s \ n " %! what ; let commandline = [ Ocaml_commands . ocamlrun_ocamldebug ; Ocaml_flags . ocamldebu...
let ocamldebug = Actions . make " ocamldebug " debug
let objinfo log env = let tools_directory = Ocaml_directories . tools in let program = Environments . safe_lookup Builtin_variables . program env in let what = Printf . sprintf " Running ocamlobjinfo on % s " program in Printf . fprintf log " % s \ n " %! what ; let commandline = [ Ocaml_...
let ocamlobjinfo = Actions . make " ocamlobjinfo " objinfo
let mklib log env = let program = Environments . safe_lookup Builtin_variables . program env in let what = Printf . sprintf " Running ocamlmklib to produce % s " program in Printf . fprintf log " % s \ n " %! what ; let ocamlc_command = String . concat " " [ Ocaml_commands . ocamlrun...
let ocamlmklib = Actions . make " ocamlmklib " mklib
let finalise_codegen_cc test_basename _log env = let test_module = Filename . make_filename test_basename " s " in let archmod = Ocaml_files . asmgen_archmod in let modules = test_module ^ " " ^ archmod in let program = Filename . make_filename test_basename " out " in let env = Environments ...
let finalise_codegen_msvc test_basename log env = let obj = Filename . make_filename test_basename Ocamltest_config . objext in let src = Filename . make_filename test_basename " s " in let what = " Running Microsoft assembler " in Printf . fprintf log " % s \ n " %! what ; let commandline ...
let run_codegen log env = let testfile = Actions_helpers . testfile env in let testfile_basename = Filename . chop_extension testfile in let what = Printf . sprintf " Running codegen on % s " testfile in Printf . fprintf log " % s \ n " %! what ; let test_build_directory = Actions_helpers . ...
let codegen = Actions . make " codegen " run_codegen
let run_cc log env = let program = Environments . safe_lookup Builtin_variables . program env in let what = Printf . sprintf " Running C compiler to build % s " program in Printf . fprintf log " % s \ n " %! what ; let output_exe = if Ocamltest_config . ccomptype " = msvc " then " / ...
let cc = Actions . make " cc " run_cc
let run_expect_once input_file principal log env = let expect_flags = Sys . safe_getenv " EXPECT_FLAGS " in let repo_root = " - repo - root " ^ Ocaml_directories . srcdir in let principal_flag = if principal then " - principal " else " " in let commandline = [ Ocaml_commands . ocamlrun_...
let run_expect_twice input_file log env = let corrected filename = Filename . make_filename filename " corrected " in let ( result1 , env1 ) = run_expect_once input_file false log env in if Result . is_pass result1 then begin let intermediate_file = corrected input_file in let ( result2 , env2 ) ...
let run_expect log env = let input_file = Actions_helpers . testfile env in run_expect_twice input_file log env
let run_expect = Actions . make " run - expect " run_expect
let make_check_tool_output name tool = Actions . make name ( Actions_helpers . check_output tool # family tool # output_variable tool # reference_variable )
let check_ocamlc_byte_output = make_check_tool_output " check - ocamlc . byte - output " Ocaml_compilers . ocamlc_byte
let check_ocamlc_opt_output = native_action ( make_check_tool_output " check - ocamlc . opt - output " Ocaml_compilers . ocamlc_opt )
let check_ocamlopt_byte_output = native_action ( make_check_tool_output " check - ocamlopt . byte - output " Ocaml_compilers . ocamlopt_byte )
let check_ocamlopt_opt_output = native_action ( make_check_tool_output " check - ocamlopt . opt - output " Ocaml_compilers . ocamlopt_opt )
let really_compare_programs backend comparison_tool log env = let program = Environments . safe_lookup Builtin_variables . program env in let program2 = Environments . safe_lookup Builtin_variables . program2 env in let what = Printf . sprintf " Comparing % s programs % s and % s " ( Ocaml_backen...
let compare_programs backend comparison_tool log env = let compare_programs = Environments . lookup_as_bool Ocaml_variables . compare_programs env in if compare_programs = Some false then begin let reason = " program comparison disabled " in ( Result . pass_with_reason reason , env ) end else really...
let compare_bytecode_programs_code _log env : Result . t * Environments . t = Result . pass_with_reason " comparing of bytecode programs is disabled " , env
let compare_bytecode_programs = native_action ( Actions . make " compare - bytecode - programs " compare_bytecode_programs_code )
let compare_binary_files = native_action ( Actions . make " compare - binary - files " ( compare_programs Ocaml_backends . Native native_programs_comparison_tool ) )
let compile_module compiler compilername compileroutput log env ( module_basename , module_filetype ) = let backend = compiler # target in let filename = Ocaml_filetypes . make_filename ( module_basename , module_filetype ) in let expected_exit_status = Ocaml_tools . expected_exit_status env ( co...
let compile_modules compiler compilername compileroutput modules_with_filetypes log initial_env = let compile_mod env mod_ = compile_module compiler compilername compileroutput log env mod_ in let rec compile_mods env = function | [ ] -> ( Result . pass , env ) | m :: ms -> ( let ( result , ne...
let run_test_program_in_toplevel ( toplevel : Ocaml_toplevels . toplevel ) log env = let backend = toplevel # backend in let libraries = libraries backend env in let toplevel_supports_dynamic_loading = Config . supports_shared_libraries || backend <> Ocaml_backends . Bytecode in match cmas_need_dynami...
let ocaml = Actions . make " ocaml " ( run_test_program_in_toplevel Ocaml_toplevels . ocaml )
let ocamlnat = native_action ( Actions . make " ocamlnat " ( run_test_program_in_toplevel Ocaml_toplevels . ocamlnat ) )
let check_ocaml_output = make_check_tool_output " check - ocaml - output " Ocaml_toplevels . ocaml
let check_ocamlnat_output = native_action ( make_check_tool_output " check - ocamlnat - output " Ocaml_toplevels . ocamlnat )
let config_variables _log env = Environments . add_bindings [ Ocaml_variables . arch , Ocamltest_config . arch ; Ocaml_variables . ocamlrun , Ocaml_files . ocamlrun ; Ocaml_variables . ocamlc_byte , Ocaml_files . ocamlc ; Ocaml_variables . ocamlopt_byte , Ocaml_files . ocamlopt ; O...
let flat_float_array = Actions . make " flat - float - array " ( Actions_helpers . pass_or_skip Ocamltest_config . flat_float_array " compiler configured with - flat - float - array " " compiler configured with - no - flat - float - array " )
let no_flat_float_array = make " no - flat - float - array " ( Actions_helpers . pass_or_skip ( not Ocamltest_config . flat_float_array ) " compiler configured with - no - flat - float - array " " compiler configured with - flat - float - array " )
let flambda = Actions . make " flambda " ( Actions_helpers . pass_or_skip Ocamltest_config . flambda " support for flambda enabled " " support for flambda disabled " )
let no_flambda = make " no - flambda " ( Actions_helpers . pass_or_skip ( not Ocamltest_config . flambda ) " support for flambda disabled " " support for flambda enabled " )
let shared_libraries = Actions . make " shared - libraries " ( Actions_helpers . pass_or_skip Ocamltest_config . shared_libraries " Shared libraries are supported . " " Shared libraries are not supported . " )
let no_shared_libraries = Actions . make " no - shared - libraries " ( Actions_helpers . pass_or_skip ( not Ocamltest_config . shared_libraries ) " Shared libraries are not supported . " " Shared libraries are supported . " )
let native_compiler = Actions . make " native - compiler " ( Actions_helpers . pass_or_skip Ocamltest_config . native_compiler " native compiler available " " native compiler not available " )
let native_dynlink = Actions . make " native - dynlink " ( Actions_helpers . pass_or_skip ( Ocamltest_config . native_dynlink ) " native dynlink support available " " native dynlink support not available " )
let debugger = Actions . make " debugger " ( Actions_helpers . pass_or_skip Ocamltest_config . ocamldebug " debugger available " " debugger not available " )
let csharp_compiler = Actions . make " csharp - compiler " ( Actions_helpers . pass_or_skip ( Ocamltest_config . csc " " ) <> " C # compiler available " " C # compiler not available " )
let windows_unicode = Actions . make " windows - unicode " ( Actions_helpers . pass_or_skip ( Ocamltest_config . windows_unicode ) " Windows Unicode support available " " Windows Unicode support not available " )
let afl_instrument = Actions . make " afl - instrument " ( Actions_helpers . pass_or_skip Ocamltest_config . afl_instrument " AFL instrumentation enabled " " AFL instrumentation disabled " )
let no_afl_instrument = Actions . make " no - afl - instrument " ( Actions_helpers . pass_or_skip ( not Ocamltest_config . afl_instrument ) " AFL instrumentation disabled " " AFL instrumentation enabled " )
let stack_allocation = Actions . make " stack - allocation " ( Actions_helpers . pass_or_skip Ocamltest_config . stack_allocation " Stack allocation enabled " " Stack allocation disabled " )
let no_stack_allocation = Actions . make " no - stack - allocation " ( Actions_helpers . pass_or_skip ( not Ocamltest_config . stack_allocation ) " Stack allocation disabled " " Stack allocation enabled " )
let ocamldoc_output_file env prefix = let backend = Environments . safe_lookup Ocaml_variables . ocamldoc_backend env in let suffix = match backend with | " latex " -> " . tex " | " html " -> " . html " | " man " -> " . 3o " | _ -> " . result " in prefix ^ suffix
let check_ocamldoc_output = make_check_tool_output " check - ocamldoc - output " ocamldoc
let ocamldoc_flags env = Environments . safe_lookup Ocaml_variables . ocamldoc_flags env
let compiled_doc_name input = input ^ " . odoc "
let compiler_for_ocamldoc = let compiler = Ocaml_compilers . ocamlc_byte in compile_modules compiler compiler # name compiler # output_variable
let compile_ocamldoc ( basename , filetype as module_ ) log env = let expected_exit_status = Ocaml_tools . expected_exit_status env ( ocamldoc :> Ocaml_tools . tool ) in let what = Printf . sprintf " Compiling documentation for module % s " basename in Printf . fprintf log " % s \ n " ...
let rec ocamldoc_compile_all log env = function | [ ] -> ( Result . pass , env ) | a :: q -> let ( r , env ) = compile_ocamldoc a log env in if Result . is_pass r then ocamldoc_compile_all log env q else ( r , env )
let setup_ocamldoc_build_env = Actions . make " setup_ocamldoc_build_env " @@ fun log env -> let ( r , env ) = setup_tool_build_env ocamldoc log env in if not ( Result . is_pass r ) then ( r , env ) else let source_directory = Actions_helpers . test_source_directory env in let root_file ...