---
src/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main.c b/src/main.c
index a864884..fa2f5d0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -484,7 +484,7 @@ cmd_main(uint32_t argc, uint32_t argi, char *const argv[])
static const struct command commands[] = {
{ "auto", cmd_auto, "build the project with default options" },
{ "check", cmd_check, "check if a meson file parses" },
- { "subprojects", cmd_subprojects, "check if a meson wrap is valid" },
+ { "subprojects", cmd_subprojects, "manage subprojects" },
{ "install", cmd_install, "install project" },
{ "internal", cmd_internal, "internal subcommands" },
{ "samu", cmd_samu, "run samurai" },
--
2.33.0
project_source_root() is easy as this information is already stored in
the project struct.
project_build_root() requires adding a new attribute when first
initializing the subproject.
---
include/lang/workspace.h | 2 +-
src/functions/meson.c | 24 ++++++++++++++++++++++++
src/lang/workspace.c | 1 +
3 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/include/lang/workspace.h b/include/lang/workspace.h
index d1fb4e7..8c50d24 100644
--- a/include/lang/workspace.h
+++ b/include/lang/workspace.h
@@ -16,7 +16,7 @@
struct project {
struct hash scope;
- str source_root, cwd, build_dir, subproject_name;
+ str source_root, build_root, cwd, build_dir, subproject_name;
obj opts, compilers, targets, tests, summary;
struct {
diff --git a/src/functions/meson.c b/src/functions/meson.c
index ef211ef..252d365 100644
--- a/src/functions/meson.c
+++ b/src/functions/meson.c
@@ -86,6 +86,28 @@ func_meson_current_build_dir(struct workspace *wk, uint32_t _, uint32_t args_nod
return true;
}
+static bool
+func_meson_project_source_root(struct workspace *wk, uint32_t _, uint32_t args_node, uint32_t *obj)
+{
+ if (!interp_args(wk, args_node, NULL, NULL, NULL)) {
+ return false;
+ }
+
+ make_obj(wk, obj, obj_string)->dat.str = current_project(wk)->source_root;
+ return true;
+}
+
+static bool
+func_meson_project_build_root(struct workspace *wk, uint32_t _, uint32_t args_node, uint32_t *obj)
+{
+ if (!interp_args(wk, args_node, NULL, NULL, NULL)) {
+ return false;
+ }
+
+ make_obj(wk, obj, obj_string)->dat.str = current_project(wk)->build_root;
+ return true;
+}
+
static bool
func_meson_global_source_root(struct workspace *wk, uint32_t _, uint32_t args_node, uint32_t *obj)
{
@@ -145,8 +167,10 @@ const struct func_impl_name impl_tbl_meson[] = {
{ "current_source_dir", func_meson_current_source_dir },
{ "current_build_dir", func_meson_current_build_dir },
{ "source_root", func_meson_global_source_root },
+ { "project_source_root", func_meson_project_source_root },
{ "global_source_root", func_meson_global_source_root },
{ "build_root", func_meson_global_build_root },
+ { "project_build_root", func_meson_project_build_root },
{ "global_build_root", func_meson_global_build_root },
{ "is_subproject", func_meson_is_subproject },
{ "override_dependency", func_meson_override_dependency },
diff --git a/src/lang/workspace.c b/src/lang/workspace.c
index 38a9996..7acb004 100644
--- a/src/lang/workspace.c
+++ b/src/lang/workspace.c
@@ -162,6 +162,7 @@ make_project(struct workspace *wk, uint32_t *id, const char *subproject_name,
proj->cwd = wk_str_push(wk, cwd);
proj->source_root = proj->cwd;
proj->build_dir = wk_str_push(wk, build_dir);
+ proj->build_root = proj->build_dir;
return proj;
}
--
2.33.0