From 55ea461993db23c8a68053a5f499fda7f65df9b6 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 23 Sep 2020 12:14:32 -0400 Subject: Deprecate meson.build_root() and meson.source_root() Those function are common source of issue when used in a subproject because they point to the parent project root which is rarely what is expected and is a violation of subproject isolation. --- docs/markdown/Reference-manual.md | 12 ++++++------ docs/markdown/snippets/deprecate_source_build_root.md | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 docs/markdown/snippets/deprecate_source_build_root.md (limited to 'docs') diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index c289397..2f9e2de 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -1804,17 +1804,17 @@ the following methods. or `xcode`. - `build_root()`: returns a string with the absolute path to the build - root directory. Note: this function will return the build root of - the parent project if called from a subproject, which is usually + root directory. *(deprecated since 0.56.0)*: this function will return the + build root of the parent project if called from a subproject, which is usually not what you want. Try using `current_build_dir()`. - `source_root()`: returns a string with the absolute path to the source root directory. Note: you should use the `files()` function to refer to files in the root source directory instead of - constructing paths manually with `meson.source_root()`. This - function will return the source root of the parent project if called - from a subproject, which is usually not what you want. Try using - `current_source_dir()`. + constructing paths manually with `meson.source_root()`. + *(deprecated since 0.56.0)*: This function will return the source root of the + parent project if called from a subproject, which is usually not what you want. + Try using `current_source_dir()`. - `current_build_dir()`: returns a string with the absolute path to the current build directory. diff --git a/docs/markdown/snippets/deprecate_source_build_root.md b/docs/markdown/snippets/deprecate_source_build_root.md new file mode 100644 index 0000000..05b6b91 --- /dev/null +++ b/docs/markdown/snippets/deprecate_source_build_root.md @@ -0,0 +1,5 @@ +## `meson.build_root()` and `meson.source_root()` are deprecated + +Those function are common source of issue when used in a subproject because they +point to the parent project root which is rarely what is expected and is a +violation of subproject isolation. -- cgit v1.1 From 7176b74fd60fb4726826c46c545c2ed25c26cd20 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Mon, 28 Sep 2020 08:49:41 -0400 Subject: Add meson.project_build/source_root() methods --- docs/markdown/Reference-manual.md | 10 ++++++++-- docs/markdown/snippets/deprecate_source_build_root.md | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 2f9e2de..9a5ccc5 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -1806,7 +1806,7 @@ the following methods. - `build_root()`: returns a string with the absolute path to the build root directory. *(deprecated since 0.56.0)*: this function will return the build root of the parent project if called from a subproject, which is usually - not what you want. Try using `current_build_dir()`. + not what you want. Try using `current_build_dir()` or `project_build_root()`. - `source_root()`: returns a string with the absolute path to the source root directory. Note: you should use the `files()` function @@ -1814,7 +1814,13 @@ the following methods. constructing paths manually with `meson.source_root()`. *(deprecated since 0.56.0)*: This function will return the source root of the parent project if called from a subproject, which is usually not what you want. - Try using `current_source_dir()`. + Try using `current_source_dir()` or `project_source_root()`. + +- `project_build_root()` *(since 0.56.0)*: returns a string with the absolute path + to the build root directory of the current (sub)project. + +- `project_source_root()` *(since 0.56.0)*: returns a string with the absolute path + to the source root directory of the current (sub)project. - `current_build_dir()`: returns a string with the absolute path to the current build directory. diff --git a/docs/markdown/snippets/deprecate_source_build_root.md b/docs/markdown/snippets/deprecate_source_build_root.md index 05b6b91..1cebef4 100644 --- a/docs/markdown/snippets/deprecate_source_build_root.md +++ b/docs/markdown/snippets/deprecate_source_build_root.md @@ -3,3 +3,8 @@ Those function are common source of issue when used in a subproject because they point to the parent project root which is rarely what is expected and is a violation of subproject isolation. + +`meson.current_source_dir()` and `meson.current_build_dir()` should be used instead +and have been available in all Meson versions. New functions `meson.project_source_root()` +and `meson.project_build_root()` have been added in Meson 0.56.0 to get the root +of the current (sub)project. -- cgit v1.1