From 1ca74354dda35bea591331048c26b512c6d9b159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Marie=20P=C3=A9drot?= Date: Tue, 3 Dec 2024 07:47:04 +0100 Subject: [PATCH 1/2] Add an explicit include flag. --- src/malfunction_compiler.ml | 4 +++- src/malfunction_compiler.mli | 2 +- src/malfunction_main.ml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/malfunction_compiler.ml b/src/malfunction_compiler.ml index 8ae51bd..5f54835 100644 --- a/src/malfunction_compiler.ml +++ b/src/malfunction_compiler.ml @@ -652,6 +652,8 @@ let setup_options options = *) | `Shared -> Clflags.shared := true + | `Include dir -> + Clflags.include_dirs := dir :: !Clflags.include_dirs | `Package s -> let packages = String.split_on_char ',' s in let dirs = List.map Findlib.package_directory packages in @@ -759,7 +761,7 @@ let delete_temps outfiles = in List.iter Misc.remove_file temps -type options = [`Verbose | `Shared | `ForPack of string | `Package of string | `Dontlink of string | `Linkpkg | `Thread | `Optimize | `Bytecode] list +type options = [`Verbose | `Shared | `ForPack of string | `Include of string | `Package of string | `Dontlink of string | `Linkpkg | `Thread | `Optimize | `Bytecode] list let ensure_cmi ~module_name ~filename = let cmi = module_name ^ ".cmi" in diff --git a/src/malfunction_compiler.mli b/src/malfunction_compiler.mli index 3ebcac9..5e89b70 100644 --- a/src/malfunction_compiler.mli +++ b/src/malfunction_compiler.mli @@ -2,7 +2,7 @@ type outfiles val delete_temps : outfiles -> unit -type options = [`Verbose | `Shared | `ForPack of string | `Package of string | `Dontlink of string | `Linkpkg | `Thread | `Optimize | `Bytecode] list +type options = [`Verbose | `Shared | `ForPack of string | `Include of string | `Package of string | `Dontlink of string | `Linkpkg | `Thread | `Optimize | `Bytecode] list val compile_module : ?options:options -> diff --git a/src/malfunction_main.ml b/src/malfunction_main.ml index 77837dc..bdd2b68 100644 --- a/src/malfunction_main.ml +++ b/src/malfunction_main.ml @@ -72,6 +72,7 @@ let parse_args args = | "-o" :: o :: rest -> output := Some o; parse_opts mode rest | "-shared" :: rest -> opts := `Shared :: !opts; parse_opts mode rest | "-for-pack" :: o :: rest -> opts := `ForPack o :: !opts; parse_opts mode rest + | "-I" :: s :: rest -> opts := `Include s :: !opts; parse_opts mode rest | "-package" :: s :: rest -> opts := `Package s :: !opts; parse_opts mode rest | "-dontlink" :: s :: rest -> if mode = `Compile then (opts := `Dontlink s :: !opts; parse_opts mode rest) From f1448e47cba0610648c4544f09ab9a00f86fe3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Marie=20P=C3=A9drot?= Date: Fri, 6 Dec 2024 17:21:48 +0100 Subject: [PATCH 2/2] Add the debug flag. --- src/malfunction_compiler.ml | 3 ++- src/malfunction_compiler.mli | 2 +- src/malfunction_main.ml | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/malfunction_compiler.ml b/src/malfunction_compiler.ml index 5f54835..7d40df8 100644 --- a/src/malfunction_compiler.ml +++ b/src/malfunction_compiler.ml @@ -661,6 +661,7 @@ let setup_options options = | `ForPack s -> Clflags.for_package := Some s | `Dontlink _ -> () | `Linkpkg -> () + | `Debug -> Clflags.debug := true | `Thread -> () | `Optimize -> Clflags.( default_simplify_rounds := 2; @@ -761,7 +762,7 @@ let delete_temps outfiles = in List.iter Misc.remove_file temps -type options = [`Verbose | `Shared | `ForPack of string | `Include of string | `Package of string | `Dontlink of string | `Linkpkg | `Thread | `Optimize | `Bytecode] list +type options = [`Verbose | `Shared | `ForPack of string | `Include of string | `Package of string | `Dontlink of string | `Linkpkg | `Debug | `Thread | `Optimize | `Bytecode] list let ensure_cmi ~module_name ~filename = let cmi = module_name ^ ".cmi" in diff --git a/src/malfunction_compiler.mli b/src/malfunction_compiler.mli index 5e89b70..2db201f 100644 --- a/src/malfunction_compiler.mli +++ b/src/malfunction_compiler.mli @@ -2,7 +2,7 @@ type outfiles val delete_temps : outfiles -> unit -type options = [`Verbose | `Shared | `ForPack of string | `Include of string | `Package of string | `Dontlink of string | `Linkpkg | `Thread | `Optimize | `Bytecode] list +type options = [`Verbose | `Shared | `ForPack of string | `Include of string | `Package of string | `Dontlink of string | `Linkpkg | `Debug | `Thread | `Optimize | `Bytecode] list val compile_module : ?options:options -> diff --git a/src/malfunction_main.ml b/src/malfunction_main.ml index bdd2b68..4cf5487 100644 --- a/src/malfunction_main.ml +++ b/src/malfunction_main.ml @@ -80,6 +80,7 @@ let parse_args args = | "-linkpkg" :: rest -> if mode = `Compile then (opts := `Linkpkg :: !opts; parse_opts mode rest) else usage () + | "-g" :: rest -> opts := `Debug :: !opts; parse_opts mode rest | "-thread" :: rest -> if mode = `Compile then (opts := `Thread :: !opts; parse_opts mode rest) else usage ()