diff --git a/bin/main.ml b/bin/main.ml index 77347898..3f493c73 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -218,7 +218,11 @@ let common = let root, to_cwd = match root with | Some dn -> (dn, []) - | None -> find_root () + | None -> + if Config.inside_dune then + (".", []) + else + find_root () in let orig_args = List.concat diff --git a/src/config.ml b/src/config.ml index 72392e32..f877248e 100644 --- a/src/config.ml +++ b/src/config.ml @@ -19,6 +19,9 @@ let dev_null = Path.of_string (if Sys.win32 then "nul" else "/dev/null") let jbuilder_keep_fname = ".jbuilder-keep" +let inside_emacs = Option.is_some (Env.get Env.initial "INSIDE_EMACS") +let inside_dune = Option.is_some (Env.get Env.initial "INSIDE_DUNE") + open Sexp.Of_sexp module Display = struct @@ -61,8 +64,8 @@ let merge t (partial : Partial.t) = } let default = - { display = Progress - ; concurrency = 4 + { display = if inside_dune then Quiet else Progress + ; concurrency = if inside_dune then 1 else 4 } let t = @@ -86,11 +89,6 @@ let load_user_config_file () = else default -let inside_emacs = - match Env.get Env.initial "INSIDE_EMACS" with - | Some _ -> true - | None -> false - let adapt_display config ~output_is_a_tty = if config.display = Progress && not output_is_a_tty && diff --git a/src/config.mli b/src/config.mli index c5c8cb5d..2f50db62 100644 --- a/src/config.mli +++ b/src/config.mli @@ -18,6 +18,9 @@ val jbuilder_keep_fname : string (** Are we running inside an emacs shell? *) val inside_emacs : bool +(** Are we running insinde Dune? *) +val inside_dune : bool + (** Jbuilder configuration *) module Display : sig diff --git a/src/main.ml b/src/main.ml index 9e1ab887..c23e3fd4 100644 --- a/src/main.ml +++ b/src/main.ml @@ -20,10 +20,13 @@ let package_install_file { packages; _ } pkg = (Utils.install_file ~package:p.name ~findlib_toolchain:None)) let setup_env ~capture_outputs = - if capture_outputs || not (Lazy.force Colors.stderr_supports_colors) then - Env.initial - else - Colors.setup_env_for_colors Env.initial + let env = + if capture_outputs || not (Lazy.force Colors.stderr_supports_colors) then + Env.initial + else + Colors.setup_env_for_colors Env.initial + in + Env.add env ~var:"INSIDE_DUNE" ~value:"1" let setup ?(log=Log.no_log) ?filter_out_optional_stanzas_with_missing_deps diff --git a/src/main.mli b/src/main.mli index bd5fc74a..4497bef9 100644 --- a/src/main.mli +++ b/src/main.mli @@ -40,5 +40,6 @@ val setup_env : capture_outputs:bool -> Env.t (**/**) -(* This is used to bootstrap jbuilder itself. It is not part of the public API. *) +(* This is used to bootstrap jbuilder itself. It is not part of the + public API. *) val bootstrap : unit -> unit