From 0ab223aeffad34abda36de3487c768e30f261c85 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 26 Jul 2023 18:00:00 +0200 Subject: [PATCH] refactor: do not pass [default_cxx_link_flags] (#8279) It's the same for every node Signed-off-by: Rudi Grinberg --- src/dune_rules/env_node.ml | 13 +++++++++---- src/dune_rules/env_node.mli | 4 ++-- src/dune_rules/super_context.ml | 23 ++++++++--------------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/dune_rules/env_node.ml b/src/dune_rules/env_node.ml index 7c2cd033cd9..8101e1b377b 100644 --- a/src/dune_rules/env_node.ml +++ b/src/dune_rules/env_node.ml @@ -69,9 +69,9 @@ let expand_str_lazy expander sw = let* expander = Memo.Lazy.force expander in Expander.No_deps.expand_str expander sw -let make ~dir ~inherit_from ~scope ~config_stanza ~profile ~expander - ~expander_for_artifacts ~default_context_flags ~default_env - ~default_bin_artifacts ~default_cxx_link_flags ~default_bin_annot = +let make build_context ~dir ~inherit_from ~scope ~config_stanza ~profile + ~expander ~expander_for_artifacts ~default_context_flags ~default_env + ~default_bin_artifacts ~default_bin_annot = let open Memo.O in let config = Dune_env.Stanza.find config_stanza ~profile in let inherited ~field ~root extend = @@ -170,7 +170,12 @@ let make ~dir ~inherit_from ~scope ~config_stanza ~profile ~expander Foreign_language.Dict.make ~c:(foreign_flags C) ~cxx:(foreign_flags Cxx) in let link_flags = - let default_link_flags = Link_flags.default ~default_cxx_link_flags in + let default_link_flags = + let default_cxx_link_flags = + Cxx_flags.get_flags ~for_:Link build_context + in + Link_flags.default ~default_cxx_link_flags + in inherited ~field:link_flags ~root:default_link_flags (fun link_flags -> let+ expander = Memo.Lazy.force expander in Link_flags.make ~spec:config.link_flags ~default:link_flags diff --git a/src/dune_rules/env_node.mli b/src/dune_rules/env_node.mli index 19a878e7190..861c19995e0 100644 --- a/src/dune_rules/env_node.mli +++ b/src/dune_rules/env_node.mli @@ -17,7 +17,8 @@ end type t val make : - dir:Path.Build.t + Build_context.t + -> dir:Path.Build.t -> inherit_from:t Memo.Lazy.t option -> scope:Scope.t -> config_stanza:Dune_env.Stanza.t @@ -27,7 +28,6 @@ val make : -> default_context_flags:string list Action_builder.t Foreign_language.Dict.t -> default_env:Env.t -> default_bin_artifacts:Artifacts.Bin.t - -> default_cxx_link_flags:string list Action_builder.t -> default_bin_annot:bool -> t diff --git a/src/dune_rules/super_context.ml b/src/dune_rules/super_context.ml index da1b70f1120..6aa2096a23b 100644 --- a/src/dune_rules/super_context.ml +++ b/src/dune_rules/super_context.ml @@ -168,14 +168,10 @@ end = struct extend_expander t ~dir ~expander_for_artifacts >>| Expander.set_dir ~dir) in - let default_cxx_link_flags = - Cxx_flags.get_flags ~for_:Link t.context.build_context - in - Env_node.make ~dir ~scope ~config_stanza ~inherit_from:(Some inherit_from) - ~profile:t.context.profile ~expander ~expander_for_artifacts - ~default_context_flags ~default_env:t.context_env - ~default_bin_artifacts:t.bin_artifacts ~default_cxx_link_flags - ~default_bin_annot:true + Env_node.make t.context.build_context ~dir ~scope ~config_stanza + ~inherit_from:(Some inherit_from) ~profile:t.context.profile ~expander + ~expander_for_artifacts ~default_context_flags ~default_env:t.context_env + ~default_bin_artifacts:t.bin_artifacts ~default_bin_annot:true (* Here we jump through some hoops to construct [t] as well as create a memoization table that has access to [t] and is used in [t.get_node]. @@ -504,16 +500,13 @@ let create ~(context : Context.t) ~host ~packages ~stanzas = in let profile = context.profile in Dune_env.Stanza.fire_hooks config_stanza ~profile; - let default_cxx_link_flags = - Cxx_flags.get_flags ~for_:Link context.build_context - in let expander = Memo.Lazy.of_val (Expander.set_dir ~dir root_expander) in - Env_node.make ~dir ~scope ~inherit_from ~config_stanza ~profile - ~expander ~expander_for_artifacts ~default_context_flags - ~default_env:context_env ~default_bin_artifacts:artifacts.bin - ~default_cxx_link_flags ~default_bin_annot:true + Env_node.make context.build_context ~dir ~scope ~inherit_from + ~config_stanza ~profile ~expander ~expander_for_artifacts + ~default_context_flags ~default_env:context_env + ~default_bin_artifacts:artifacts.bin ~default_bin_annot:true in make ~config_stanza:context.env_nodes.context ~inherit_from: