From a029ecea18154eaac72ce4fdc64c856a0325df19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Hinderer?= Date: Sat, 27 Jan 2018 16:10:27 +0100 Subject: [PATCH] ocamltest: introduce the ocaml_directories module --- ocamltest/.depend | 21 +++++++++++++-------- ocamltest/Makefile | 1 + ocamltest/ocaml_actions.ml | 25 ++++++++----------------- ocamltest/ocaml_directories.ml | 31 +++++++++++++++++++++++++++++++ ocamltest/ocaml_directories.mli | 24 ++++++++++++++++++++++++ ocamltest/ocaml_files.ml | 6 +----- ocamltest/ocaml_files.mli | 4 +--- 7 files changed, 79 insertions(+), 33 deletions(-) create mode 100644 ocamltest/ocaml_directories.ml create mode 100644 ocamltest/ocaml_directories.mli diff --git a/ocamltest/.depend b/ocamltest/.depend index b7e77d349..d6c188a15 100644 --- a/ocamltest/.depend +++ b/ocamltest/.depend @@ -45,19 +45,24 @@ main.cmx : tsl_semantics.cmx tsl_parser.cmx tsl_lexer.cmx tests.cmx \ actions_helpers.cmx actions.cmx main.cmi main.cmi : ocaml_actions.cmo : variables.cmi ocamltest_stdlib.cmi ocamltest_config.cmi \ - ocaml_variables.cmi ocaml_files.cmi ocaml_backends.cmi filetype.cmi \ - filecompare.cmi environments.cmi builtin_variables.cmi \ - actions_helpers.cmi actions.cmi ocaml_actions.cmi + ocaml_variables.cmi ocaml_files.cmi ocaml_directories.cmi \ + ocaml_backends.cmi filetype.cmi filecompare.cmi environments.cmi \ + builtin_variables.cmi actions_helpers.cmi actions.cmi ocaml_actions.cmi ocaml_actions.cmx : variables.cmx ocamltest_stdlib.cmx ocamltest_config.cmx \ - ocaml_variables.cmx ocaml_files.cmx ocaml_backends.cmx filetype.cmx \ - filecompare.cmx environments.cmx builtin_variables.cmx \ - actions_helpers.cmx actions.cmx ocaml_actions.cmi + ocaml_variables.cmx ocaml_files.cmx ocaml_directories.cmx \ + ocaml_backends.cmx filetype.cmx filecompare.cmx environments.cmx \ + builtin_variables.cmx actions_helpers.cmx actions.cmx ocaml_actions.cmi ocaml_actions.cmi : actions.cmi ocaml_backends.cmo : ocamltest_stdlib.cmi ocaml_backends.cmi ocaml_backends.cmx : ocamltest_stdlib.cmx ocaml_backends.cmi ocaml_backends.cmi : ocamltest_stdlib.cmi -ocaml_files.cmo : ocamltest_stdlib.cmi ocamltest_config.cmi ocaml_files.cmi -ocaml_files.cmx : ocamltest_stdlib.cmx ocamltest_config.cmx ocaml_files.cmi +ocaml_directories.cmo : ocamltest_stdlib.cmi ocamltest_config.cmi \ + ocaml_directories.cmi +ocaml_directories.cmx : ocamltest_stdlib.cmx ocamltest_config.cmx \ + ocaml_directories.cmi +ocaml_directories.cmi : +ocaml_files.cmo : ocamltest_stdlib.cmi ocaml_files.cmi +ocaml_files.cmx : ocamltest_stdlib.cmx ocaml_files.cmi ocaml_files.cmi : ocaml_modifiers.cmo : ocamltest_stdlib.cmi ocamltest_config.cmi \ ocaml_variables.cmi environments.cmi builtin_variables.cmi \ diff --git a/ocamltest/Makefile b/ocamltest/Makefile index eb5e0cc7c..3be707aa2 100644 --- a/ocamltest/Makefile +++ b/ocamltest/Makefile @@ -64,6 +64,7 @@ ocaml_plugin := \ ocaml_backends.mli ocaml_backends.ml \ ocaml_variables.mli ocaml_variables.ml \ ocaml_modifiers.mli ocaml_modifiers.ml \ + ocaml_directories.mli ocaml_directories.ml \ ocaml_files.mli ocaml_files.ml \ ocaml_actions.mli ocaml_actions.ml \ ocaml_tests.mli ocaml_tests.ml diff --git a/ocamltest/ocaml_actions.ml b/ocamltest/ocaml_actions.ml index b76e97e46..cfa0ea758 100644 --- a/ocamltest/ocaml_actions.ml +++ b/ocamltest/ocaml_actions.ml @@ -40,24 +40,15 @@ let expect_command ocamlsrcdir = let expect_test = Ocaml_files.expect_test ocamlsrcdir in ocamlrun ^ " " ^ expect_test -let stdlib ocamlsrcdir = - Filename.make_path [ocamlsrcdir; "stdlib"] - let stdlib_flags ocamlsrcdir = - let stdlib_path = stdlib ocamlsrcdir in + let stdlib_path = Ocaml_directories.stdlib ocamlsrcdir in "-nostdlib -I " ^ stdlib_path -let toplevel_directory ocamlsrcdir = - Filename.make_path [ocamlsrcdir; "toplevel"] - let include_toplevel_directory ocamlsrcdir = - "-I " ^ (toplevel_directory ocamlsrcdir) - -let c_includes ocamlsrcdir = - Filename.make_path [ocamlsrcdir; "byterun"] + "-I " ^ (Ocaml_directories.toplevel ocamlsrcdir) let c_includes_flags ocamlsrcdir = - let dir = c_includes ocamlsrcdir in + let dir = Ocaml_directories.runtime ocamlsrcdir in "-ccopt -I" ^ dir let use_runtime backend ocamlsrcdir = match backend with @@ -388,7 +379,7 @@ let compile_test_program program_variable compiler log env = ] env in if Sys.file_exists compiler_output_filename then Sys.remove compiler_output_filename; - let ocamlsrcdir = Ocaml_files.ocamlsrcdir () in + let ocamlsrcdir = Ocaml_directories.srcdir () in let compilername = compiler.compiler_name ocamlsrcdir in let source_modules = Actions_helpers.words_of_variable env Ocaml_variables.source_modules in @@ -461,7 +452,7 @@ let run_expect_twice ocamlsrcdir input_file log env = ) let run_expect log env = - let ocamlsrcdir = Ocaml_files.ocamlsrcdir () in + let ocamlsrcdir = Ocaml_directories.srcdir () in let input_file = Actions_helpers.testfile env in run_expect_twice ocamlsrcdir input_file log env @@ -544,7 +535,7 @@ let make_bytecode_programs_comparison_tool ocamlsrcdir = let native_programs_comparison_tool = Filecompare.default_comparison_tool let compare_bytecode_programs_code log env = - let ocamlsrcdir = Ocaml_files.ocamlsrcdir () in + let ocamlsrcdir = Ocaml_directories.srcdir () in let bytecode_programs_comparison_tool = make_bytecode_programs_comparison_tool ocamlsrcdir in compare_programs Sys.Bytecode bytecode_programs_comparison_tool log env @@ -661,7 +652,7 @@ let run_test_program_in_toplevel toplevel log env = end in if Sys.file_exists compiler_output then Sys.remove compiler_output; - let ocamlsrcdir = Ocaml_files.ocamlsrcdir () in + let ocamlsrcdir = Ocaml_directories.srcdir () in let compiler = match toplevel.compiler_backend with | Sys.Native -> ocamlopt_byte_compiler | Sys.Bytecode -> ocamlc_byte_compiler @@ -727,7 +718,7 @@ let config_variables _log env = Environments.add_bindings Ocamltest_config.ocamlc_default_flags; Ocaml_variables.ocamlopt_default_flags, Ocamltest_config.ocamlopt_default_flags; - Ocaml_variables.ocamlsrcdir, Ocaml_files.ocamlsrcdir(); + Ocaml_variables.ocamlsrcdir, Ocaml_directories.srcdir(); Ocaml_variables.os_type, Sys.os_type; ] env diff --git a/ocamltest/ocaml_directories.ml b/ocamltest/ocaml_directories.ml new file mode 100644 index 000000000..064fd57cb --- /dev/null +++ b/ocamltest/ocaml_directories.ml @@ -0,0 +1,31 @@ +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Sebastien Hinderer, projet Gallium, INRIA Paris *) +(* *) +(* Copyright 2018 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +(* Locations of directories in the OCaml source tree *) + +open Ocamltest_stdlib + +let srcdir () = + try Sys.getenv "OCAMLSRCDIR" + with Not_found -> Ocamltest_config.ocamlsrcdir + +let stdlib ocamlsrcdir = + Filename.make_path [ocamlsrcdir; "stdlib"] + +let toplevel ocamlsrcdir = + Filename.make_path [ocamlsrcdir; "toplevel"] + +let runtime ocamlsrcdir = + Filename.make_path [ocamlsrcdir; "byterun"] diff --git a/ocamltest/ocaml_directories.mli b/ocamltest/ocaml_directories.mli new file mode 100644 index 000000000..2d25d64f5 --- /dev/null +++ b/ocamltest/ocaml_directories.mli @@ -0,0 +1,24 @@ +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Sebastien Hinderer, projet Gallium, INRIA Paris *) +(* *) +(* Copyright 2018 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +(* Locations of directories in the OCaml source tree *) + +val srcdir : unit -> string + +val stdlib : string -> string + +val toplevel : string -> string + +val runtime : string -> string diff --git a/ocamltest/ocaml_files.ml b/ocamltest/ocaml_files.ml index 6ff3497f4..e16bcc345 100644 --- a/ocamltest/ocaml_files.ml +++ b/ocamltest/ocaml_files.ml @@ -13,14 +13,10 @@ (* *) (**************************************************************************) -(* Locations of files and directories inside the OCaml source tree *) +(* Locations of files in the OCaml source tree *) open Ocamltest_stdlib -let ocamlsrcdir () = - try Sys.getenv "OCAMLSRCDIR" - with Not_found -> Ocamltest_config.ocamlsrcdir - type runtime_variant = | Normal | Debug diff --git a/ocamltest/ocaml_files.mli b/ocamltest/ocaml_files.mli index 143b84eaf..cfa806b89 100644 --- a/ocamltest/ocaml_files.mli +++ b/ocamltest/ocaml_files.mli @@ -13,9 +13,7 @@ (* *) (**************************************************************************) -(* Locations of files and directories inside the OCaml source tree *) - -val ocamlsrcdir : unit -> string +(* Locations of files in the OCaml source tree *) type runtime_variant = | Normal