Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(rules): remove support for patch back into source tree #10771

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/changes/10771.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Remove all remnants of the experimental `patch-back-source-tree`. (#10771,
@rgrinberg)
33 changes: 0 additions & 33 deletions src/dune_rules/rule_mode_decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -64,38 +64,5 @@ let mode_decoders =
]
;;

module Extended = struct
type t =
| Normal of Rule.Mode.t
| Patch_back_source_tree

let patch_back_from_source_tree_syntax =
Dune_lang.Syntax.create
~experimental:true
~name:"patch-back-source-tree"
~desc:"experimental support for (mode patch-back-source-tree)"
[ (0, 1), `Since (3, 0) ]
;;

let () =
Dune_project.Extension.register_simple
patch_back_from_source_tree_syntax
(Dune_lang.Decoder.return [])
;;

let decode =
sum
(( "patch-back-source-tree"
, let+ () = Dune_lang.Syntax.since patch_back_from_source_tree_syntax (0, 1) in
Patch_back_source_tree )
:: List.map mode_decoders ~f:(fun (name, dec) ->
( name
, let+ x = dec in
Normal x )))
;;

let field = field "mode" decode ~default:(Normal Standard)
end

let decode = sum mode_decoders
let field = field "mode" decode ~default:Rule.Mode.Standard
8 changes: 0 additions & 8 deletions src/dune_rules/rule_mode_decoder.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,5 @@ module Promote : sig
val into_decode : Rule.Promote.Into.t Dune_lang.Decoder.t
end

module Extended : sig
type t =
| Normal of Rule.Mode.t
| Patch_back_source_tree

val field : t Dune_lang.Decoder.fields_parser
end

val decode : Rule.Mode.t Dune_lang.Decoder.t
val field : Rule.Mode.t Dune_lang.Decoder.fields_parser
34 changes: 9 additions & 25 deletions src/dune_rules/simple_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -106,31 +106,15 @@ let user_rule sctx ?extra_bindings ~dir ~expander (rule : Rule_conf.t) =
| Some bindings -> Expander.add_bindings expander ~bindings
in
let* action =
let+ (action : _ Action_builder.With_targets.t) =
let chdir = Expander.dir expander in
Action_unexpanded.expand
(snd rule.action)
~loc:(fst rule.action)
~chdir
~expander
~deps:rule.deps
~targets
~targets_dir:dir
in
if rule.patch_back_source_tree
then
Action_builder.With_targets.map action ~f:(fun action ->
(* Here we expect that [action.sandbox] is [Sandbox_config.default]
because the parsing of [rule] stanzas forbids having both a
sandboxing setting in [deps] and a [patch_back_source_tree] field
at the same time.

If we didn't have this restriction and [action.sandbox] was
something that didn't permit [Some Patch_back_source_tree], Dune
would crash in a way that would be difficult for the user to
understand. *)
Action.Full.add_sandbox Sandbox_mode.Set.patch_back_source_tree_only action)
else action
let chdir = Expander.dir expander in
Action_unexpanded.expand
(snd rule.action)
~loc:(fst rule.action)
~chdir
~expander
~deps:rule.deps
~targets
~targets_dir:dir
in
(match rule_kind ~rule ~action with
| No_alias ->
Expand Down
35 changes: 2 additions & 33 deletions src/dune_rules/stanzas/rule_conf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type t =
; deps : Dep_conf.t Bindings.t
; action : Loc.t * Dune_lang.Action.t
; mode : Rule.Mode.t
; patch_back_source_tree : bool
; locks : Locks.t
; loc : Loc.t
; enabled_if : Blang.t
Expand Down Expand Up @@ -73,7 +72,6 @@ let short_form =
; deps = Bindings.empty
; action = loc, action
; mode = Standard
; patch_back_source_tree = false
; locks = []
; loc
; enabled_if = Blang.true_
Expand Down Expand Up @@ -117,7 +115,7 @@ let long_form =
to provide a nice error message for people switching from jbuilder
to dune. *)
assert (not fallback)
and+ mode = Mode.Extended.field
and+ mode = Mode.field
and+ enabled_if = Enabled_if.decode ~allowed_vars:Any ~since:(Some (1, 4)) ()
and+ package =
field_o
Expand All @@ -136,23 +134,6 @@ let long_form =
)
]
in
let mode, patch_back_source_tree =
match mode with
| Normal mode -> mode, false
| Patch_back_source_tree ->
if List.exists (Bindings.to_list deps) ~f:(function
| Dep_conf.Sandbox_config _ -> true
| _ -> false)
then
User_error.raise
~loc
[ Pp.text
"Rules with (mode patch-back-source-tree) cannot have an explicit \
sandbox configuration because it is implied by (mode \
patch-back-source-tree)."
];
Standard, true
in
let action =
match action_o with
| Some action -> action
Expand All @@ -165,17 +146,7 @@ let long_form =
in
field_missing ~hints loc "action"
in
{ targets
; deps
; action
; mode
; locks
; loc
; enabled_if
; aliases
; package
; patch_back_source_tree
})
{ targets; deps; action; mode; locks; loc; enabled_if; aliases; package })
;;

let decode =
Expand Down Expand Up @@ -243,7 +214,6 @@ let ocamllex_to_rule loc { modules; mode; enabled_if } =
; S.virt_pform __POS__ (Var Deps)
] ) )
; mode
; patch_back_source_tree = false
; locks = []
; loc
; enabled_if
Expand Down Expand Up @@ -273,7 +243,6 @@ let ocamlyacc_to_rule loc { modules; mode; enabled_if } =
(S.virt_text __POS__ "ocamlyacc")
[ S.virt_pform __POS__ (Var Deps) ] ) )
; mode
; patch_back_source_tree = false
; locks = []
; loc
; enabled_if
Expand Down
1 change: 0 additions & 1 deletion src/dune_rules/stanzas/rule_conf.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ type t =
; deps : Dep_conf.t Bindings.t
; action : Loc.t * Dune_lang.Action.t
; mode : Rule.Mode.t
; patch_back_source_tree : bool
; locks : Locks.t
; loc : Loc.t
; enabled_if : Blang.t
Expand Down
1 change: 0 additions & 1 deletion src/dune_rules/test_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
, Action_unexpanded.Redirect_out (Stdout, diff.file2, Normal, run_action)
)
; mode = Standard
; patch_back_source_tree = false
; locks = t.locks
; loc
; enabled_if = t.enabled_if
Expand Down
Loading
Loading