From c290ad288f137cda4bf993860d2d0024e99202aa Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 6 Jul 2018 00:43:32 +0700 Subject: [PATCH] Rename scope_root to project_root Signed-off-by: Rudi Grinberg --- src/super_context.ml | 46 +++++++++++++------ test/blackbox-tests/test-cases/misc/blah/dune | 2 +- test/unit-tests/dune | 42 ++++++++--------- 3 files changed, 53 insertions(+), 37 deletions(-) diff --git a/src/super_context.ml b/src/super_context.ml index d7632d44..72a4498e 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -88,10 +88,18 @@ let expand_var_no_root t var = String.Map.find t.vars var let (expand_vars, expand_vars_path) = let expand t ~scope ~dir ?(extra_vars=String.Map.empty) s = - String_with_vars.expand ~mode:Single ~dir s ~f:(fun v _syntax_version -> + String_with_vars.expand ~mode:Single ~dir s ~f:(fun v syntax_version -> match String_with_vars.Var.full_name v with | "ROOT" -> Some [Value.Path t.context.build_dir] - | "SCOPE_ROOT" -> Some [Value.Path (Scope.root scope)] + | "SCOPE_ROOT" -> + if syntax_version >= (1, 0) then + Loc.fail (String_with_vars.Var.loc v) + "Variable %%{SCOPE_ROOT} has been renamed to %%{project_root} \ + in dune files" + else + Some [Value.Path (Scope.root scope)] + | "project_root" when syntax_version >= (1, 0) -> + Some [Value.Path (Scope.root scope)] | var -> (match expand_var_no_root t var with | Some _ as x -> x @@ -641,12 +649,12 @@ module Action = struct | Pair ("dep", s) when syntax_version >= (1, 0) -> path_with_dep s | Pair ("dep", s) -> - Loc.fail - loc - "${dep:%s} is not supported in jbuild files.\n\ - Hint: Did you mean ${path:%s} instead?" - s - s + Loc.fail + loc + "${dep:%s} is not supported in jbuild files.\n\ + Hint: Did you mean ${path:%s} instead?" + s + s | Pair ("bin", s) -> begin let sctx = host sctx in match Artifacts.binary (artifacts sctx) s with @@ -745,7 +753,15 @@ module Action = struct let loc = String_with_vars.Var.loc var in match var_name with | "ROOT" -> Some (path_exp sctx.context.build_dir) - | "SCOPE_ROOT" -> Some (path_exp (Scope.root scope)) + | "SCOPE_ROOT" -> + if syntax_version >= (1, 0) then + Loc.fail (String_with_vars.Var.loc var) + "Variable %%{SCOPE_ROOT} has been renamed to %%{project_root} \ + in dune files" + else + Some (path_exp (Scope.root scope)) + | "project_root" when syntax_version >= (1, 0) -> + Some (path_exp (Scope.root scope)) | "@" -> begin match targets_written_by_user with | Infer -> Loc.fail loc "You cannot use ${@} with inferred rules." @@ -755,12 +771,12 @@ module Action = struct | _ -> match String_with_vars.Var.destruct var with | Pair ("path-no-dep", s) -> - if syntax_version < (1, 0) then - Some (path_exp (Path.relative dir s)) - else - Loc.fail - loc - "The ${path-no-dep:...} syntax has been removed from dune." + if syntax_version < (1, 0) then + Some (path_exp (Path.relative dir s)) + else + Loc.fail + loc + "The ${path-no-dep:...} syntax has been removed from dune." | _ -> let exp = expand var syntax_version in Option.iter exp ~f:(fun vs -> diff --git a/test/blackbox-tests/test-cases/misc/blah/dune b/test/blackbox-tests/test-cases/misc/blah/dune index b7c3feae..a355e215 100644 --- a/test/blackbox-tests/test-cases/misc/blah/dune +++ b/test/blackbox-tests/test-cases/misc/blah/dune @@ -1,3 +1,3 @@ (alias (name runtest) - (deps %{SCOPE_ROOT}/023e1a58-4d08-11e7-a041-aa000008c8a6)) + (deps %{project_root}/023e1a58-4d08-11e7-a041-aa000008c8a6)) diff --git a/test/unit-tests/dune b/test/unit-tests/dune index b5355c99..cb279b8e 100644 --- a/test/unit-tests/dune +++ b/test/unit-tests/dune @@ -19,11 +19,11 @@ (alias (name runtest) (deps tests.mlt - (glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) - (glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi) + (glob_files %{project_root}/src/.dune.objs/*.cmi) + (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi) (source_tree toolchain.d) (source_tree findlib-db)) - (action (chdir %{SCOPE_ROOT} + (action (chdir %{project_root} (progn (run %{exe:expect_test.exe} %{<}) (diff? %{<} %{<}.corrected))))) @@ -31,9 +31,9 @@ (alias (name runtest) (deps filename.mlt - (glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) - (glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi)) - (action (chdir %{SCOPE_ROOT} + (glob_files %{project_root}/src/.dune.objs/*.cmi) + (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi)) + (action (chdir %{project_root} (progn (run %{exe:expect_test.exe} %{<}) (diff? %{<} %{<}.corrected))))) @@ -41,9 +41,9 @@ (alias (name runtest) (deps import_dot_map.mlt - (glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) - (glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi)) - (action (chdir %{SCOPE_ROOT} + (glob_files %{project_root}/src/.dune.objs/*.cmi) + (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi)) + (action (chdir %{project_root} (progn (run %{exe:expect_test.exe} %{<}) (diff? %{<} %{<}.corrected))))) @@ -51,9 +51,9 @@ (alias (name runtest) (deps action.mlt - (glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) - (glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi)) - (action (chdir %{SCOPE_ROOT} + (glob_files %{project_root}/src/.dune.objs/*.cmi) + (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi)) + (action (chdir %{project_root} (progn (run %{exe:expect_test.exe} %{<}) (diff? %{<} %{<}.corrected))))) @@ -61,9 +61,9 @@ (alias (name runtest) (deps path.mlt - (glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) - (glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi)) - (action (chdir %{SCOPE_ROOT} + (glob_files %{project_root}/src/.dune.objs/*.cmi) + (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi)) + (action (chdir %{project_root} (progn (run %{exe:expect_test.exe} %{<}) (diff? %{<} %{<}.corrected))))) @@ -71,9 +71,9 @@ (alias (name runtest) (deps sexp.mlt - (glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) - (glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi)) - (action (chdir %{SCOPE_ROOT} + (glob_files %{project_root}/src/.dune.objs/*.cmi) + (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi)) + (action (chdir %{project_root} (progn (run %{exe:expect_test.exe} %{<}) (diff? %{<} %{<}.corrected))))) @@ -81,9 +81,9 @@ (alias (name runtest) (deps jbuild.mlt - (glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) - (glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi)) - (action (chdir %{SCOPE_ROOT} + (glob_files %{project_root}/src/.dune.objs/*.cmi) + (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi)) + (action (chdir %{project_root} (progn (run %{exe:expect_test.exe} %{<}) (diff? %{<} %{<}.corrected)))))