ocamltest: introduce the ocaml_directories module

master
Sébastien Hinderer 2018-01-27 16:10:27 +01:00
parent a828e36d37
commit a029ecea18
7 changed files with 79 additions and 33 deletions

View File

@ -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 \

View File

@ -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

View File

@ -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

View File

@ -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"]

View File

@ -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

View File

@ -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

View File

@ -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