From c01df9c74973926a8323c2fec7cb0672d2670273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulysse=20G=C3=A9rard?= Date: Thu, 3 Dec 2020 17:54:57 +0100 Subject: [PATCH] Use different flags for MSVC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ulysse GĂ©rard --- src/dune_rules/cxx_rules.ml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/dune_rules/cxx_rules.ml b/src/dune_rules/cxx_rules.ml index 3c6fa74ca8f..00dc45cd975 100644 --- a/src/dune_rules/cxx_rules.ml +++ b/src/dune_rules/cxx_rules.ml @@ -28,12 +28,17 @@ let rules ~sctx ~dir = (* let tmp = Path.External.of_string (Filename.get_temp_dir_name ()) in *) let header_file = Path.Build.relative dir "header_check.h" in let write_test_file = Action.write_file header_file header_file_content in + let args = + let open Command.Args in + ( match Ocaml_config.ccomp_type ocfg with + | Msvc -> [ A "/EP" ] + | Other _ -> [ A "-E"; A "-P" ] ) + @ [ A Path.(to_absolute_filename (build header_file)) ] + in let action = let open Build.With_targets.O in let+ run_preprocessor = - Command.run ~dir:(Path.build dir) ~stdout_to:file prog - Command.Args. - [ A "-EP"; A Path.(to_absolute_filename (build header_file)) ] + Command.run ~dir:(Path.build dir) ~stdout_to:file prog args in Action.progn [ write_test_file; run_preprocessor ] in