diff --git a/doc/changes/10771.md b/doc/changes/10771.md new file mode 100644 index 00000000000..22530364df3 --- /dev/null +++ b/doc/changes/10771.md @@ -0,0 +1,2 @@ +- Remove all remnants of the experimental `patch-back-source-tree`. (#10771, + @rgrinberg) diff --git a/src/dune_rules/rule_mode_decoder.ml b/src/dune_rules/rule_mode_decoder.ml index d741edfe771..bde455a688c 100644 --- a/src/dune_rules/rule_mode_decoder.ml +++ b/src/dune_rules/rule_mode_decoder.ml @@ -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 diff --git a/src/dune_rules/rule_mode_decoder.mli b/src/dune_rules/rule_mode_decoder.mli index 49068933460..f50443d9412 100644 --- a/src/dune_rules/rule_mode_decoder.mli +++ b/src/dune_rules/rule_mode_decoder.mli @@ -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 diff --git a/src/dune_rules/simple_rules.ml b/src/dune_rules/simple_rules.ml index 212ff787eb5..7823eb60a8f 100644 --- a/src/dune_rules/simple_rules.ml +++ b/src/dune_rules/simple_rules.ml @@ -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 -> diff --git a/src/dune_rules/stanzas/rule_conf.ml b/src/dune_rules/stanzas/rule_conf.ml index 4dd95351ff7..1d74e542005 100644 --- a/src/dune_rules/stanzas/rule_conf.ml +++ b/src/dune_rules/stanzas/rule_conf.ml @@ -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 @@ -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_ @@ -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 @@ -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 @@ -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 = @@ -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 @@ -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 diff --git a/src/dune_rules/stanzas/rule_conf.mli b/src/dune_rules/stanzas/rule_conf.mli index 62893d31a81..c42f8654e61 100644 --- a/src/dune_rules/stanzas/rule_conf.mli +++ b/src/dune_rules/stanzas/rule_conf.mli @@ -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 diff --git a/src/dune_rules/test_rules.ml b/src/dune_rules/test_rules.ml index 53ea8b62a51..a0ceb978d3c 100644 --- a/src/dune_rules/test_rules.ml +++ b/src/dune_rules/test_rules.ml @@ -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 diff --git a/test/blackbox-tests/test-cases/patch-back-source-tree.t b/test/blackbox-tests/test-cases/patch-back-source-tree.t deleted file mode 100644 index 231b322ffed..00000000000 --- a/test/blackbox-tests/test-cases/patch-back-source-tree.t +++ /dev/null @@ -1,209 +0,0 @@ -Test for (mode patch-back-source-tree) - -It's experimental and requires enabling explicitly --------------------------------------------------- - - $ cat >dune-project< (lang dune 3.0) - > EOF - - $ cat >dune< (rule - > (mode patch-back-source-tree) - > (action (with-stdout-to x (progn)))) - > EOF - - $ dune build - File "dune", line 2, characters 7-29: - 2 | (mode patch-back-source-tree) - ^^^^^^^^^^^^^^^^^^^^^^ - Error: 'patch-back-source-tree' is available only when patch-back-source-tree - is enabled in the dune-project file. You must enable it using (using - patch-back-source-tree 0.1) in your dune-project file. - Note however that patch-back-source-tree is experimental and might change - without notice in the future. - [1] - ------ - - $ cat >dune-project< (lang dune 3.0) - > (using patch-back-source-tree 0.1) - > EOF - -All targets are promoted ------------------------- - - $ cat >dune< (rule - > (mode patch-back-source-tree) - > (targets x) - > (action (system "echo 'Hello, world!' > x"))) - > EOF - - $ dune build x - $ cat x - Hello, world! - -All modified dependencies are promoted --------------------------------------- - - $ cat >dune< (rule - > (mode patch-back-source-tree) - > (alias default) - > (deps x) - > (action (system "echo 'Hello, world!' > x"))) - > EOF - - $ echo blah > x - $ dune build - $ cat x - Hello, world! - -Non-modified dependencies are not promoted ------------------------------------------- - - $ rm -f x - $ cat >dune< (rule - > (mode patch-back-source-tree) - > (alias default) - > (deps x) - > (action (system "echo 'Hello, world!'"))) - > (rule (with-stdout-to x (progn))) - > EOF - - $ dune build - Hello, world! - $ if ! test -f x; then echo ok; fi - ok - -All other new files are copied ------------------------------- - - $ cat >dune< (rule - > (mode patch-back-source-tree) - > (alias default) - > (action (system "echo 'Hello, world!' > y"))) - > EOF - - $ dune build - $ cat y - Hello, world! - -Directories are created if needed ---------------------------------- - - $ cat >dune< (rule - > (mode patch-back-source-tree) - > (alias default) - > (action (system "mkdir z; echo 'Hello, world!' > z/z"))) - > EOF - - $ dune build - $ cat z/z - Hello, world! - -Interaction with explicit sandboxing ------------------------------------- - - $ cat >dune< (rule - > (mode patch-back-source-tree) - > (deps (sandbox none)) - > (alias default) - > (action (system "echo 'Hello, world!'"))) - > EOF - - $ dune build - File "dune", lines 1-5, characters 0-119: - 1 | (rule - 2 | (mode patch-back-source-tree) - 3 | (deps (sandbox none)) - 4 | (alias default) - 5 | (action (system "echo 'Hello, world!'"))) - Error: Rules with (mode patch-back-source-tree) cannot have an explicit - sandbox configuration because it is implied by (mode patch-back-source-tree). - [1] - -Selecting an explicit sandbox mode via the command line doesn't affect -the rule: - - $ cat >dune< (rule - > (mode patch-back-source-tree) - > (alias default) - > (action (system "echo 'Hello, world!' > x"))) - > EOF - - $ test_with () - > { - > rm -f x - > dune clean - > dune build --sandbox $1 - > cat x - > } - - $ test_with copy - Hello, world! - $ test_with hardlink - Hello, world! - $ test_with symlink - Hello, world! - -Interaction with files writable status --------------------------------------- - -If a source file is read-only, the action sees it as writable: - - $ cat >dune< (rule - > (mode patch-back-source-tree) - > (alias default) - > (deps x) - > (action (system "if test -w x; then echo writable; else echo non-writable; fi; echo blah > x"))) - > EOF - - $ echo xx > x - $ chmod -w x - - $ if test -w x; then echo writable; else echo non-writable; fi - non-writable - - $ dune build - writable - -And as the action modified `x`, its permissions have now changed -inside the source tree: - - $ if test -w x; then echo writable; else echo non-writable; fi - writable - -Reproduction case for copying the action stamp file ---------------------------------------------------- - -There used to be a bug causing the internal action stamp file to be -produced in the sandbox and copied back: - - $ cat >dune< (rule - > (mode patch-back-source-tree) - > (alias blah) - > (action (system "echo 'Hello, world!'"))) - > EOF - - $ dune build @blah - Hello, world! - -This is the internal stamp file: - - $ ls _build/.actions/default/blah* - _build/.actions/default/blah-98b715ceb840414fcdd2546357b09ca0 - -And we check that it isn't copied in the source tree: - - $ if [ -d default ]; then echo "Failure"; else echo "Success"; fi - Success