~lattis/muon

install targets: add support for install_mode everywhere v1 APPLIED

Eli Schwartz: 1
 install targets: add support for install_mode everywhere

 4 files changed, 24 insertions(+), 3 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~lattis/muon/patches/25434/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] install targets: add support for install_mode everywhere Export this patch

`muon install` may not be implemented, but let's at least recognize the
kwargs and keep track of them.

We need to use obj_any, because elements 2 and 3 support integer uid/gid.
---
 src/functions/default.c                | 8 +++++++-
 src/functions/default/configure_file.c | 9 ++++++++-
 src/functions/default/custom_target.c  | 9 ++++++++-
 src/lang/workspace.c                   | 1 +
 4 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/functions/default.c b/src/functions/default.c
index af24e24..16908d0 100644
--- a/src/functions/default.c
+++ b/src/functions/default.c
@@ -369,6 +369,7 @@ tgt_common(struct workspace *wk, uint32_t args_node, obj *res, enum tgt_type typ
		kw_dependencies,
		kw_install,
		kw_install_dir,
		kw_install_mode,
		kw_link_with,
		kw_link_whole, // TODO
		kw_version,
@@ -388,6 +389,7 @@ tgt_common(struct workspace *wk, uint32_t args_node, obj *res, enum tgt_type typ
		[kw_dependencies] = { "dependencies", ARG_TYPE_ARRAY_OF | obj_any },
		[kw_install] = { "install", obj_bool },
		[kw_install_dir] = { "install_dir", obj_string },
		[kw_install_mode] = { "install_mode", ARG_TYPE_ARRAY_OF | obj_any },
		[kw_link_with] = { "link_with", ARG_TYPE_ARRAY_OF | obj_any },
		[kw_link_whole] = { "link_whole", ARG_TYPE_ARRAY_OF | obj_any },
		[kw_version] = { "version", obj_string },
@@ -535,9 +537,13 @@ tgt_common(struct workspace *wk, uint32_t args_node, obj *res, enum tgt_type typ
		if (akw[kw_install_dir].set) {
			install_dir = get_obj(wk, akw[kw_install_dir].val)->dat.str;
		}
		uint32_t install_mode_id = 0;
		if (akw[kw_install_mode].set) {
			install_mode_id = akw[kw_install_mode].val;
		}

		push_install_target(wk, tgt->dat.tgt.build_dir,
			tgt->dat.tgt.build_name, install_dir, 0);
			tgt->dat.tgt.build_name, install_dir, install_mode_id);
	}

	obj_array_push(wk, current_project(wk)->targets, *res);
diff --git a/src/functions/default/configure_file.c b/src/functions/default/configure_file.c
index 3d089c9..63c686b 100644
--- a/src/functions/default/configure_file.c
+++ b/src/functions/default/configure_file.c
@@ -413,6 +413,7 @@ func_configure_file(struct workspace *wk, uint32_t _, uint32_t args_node, uint32
		kw_capture,
		kw_install,
		kw_install_dir,
		kw_install_mode,
		kw_copy,
		kw_encoding, // TODO: ignored
		kw_depfile, // TODO: ignored
@@ -425,6 +426,7 @@ func_configure_file(struct workspace *wk, uint32_t _, uint32_t args_node, uint32
		[kw_capture] = { "capture", obj_bool },
		[kw_install] = { "install", obj_bool },
		[kw_install_dir] = { "install_dir", obj_string },
		[kw_install_mode] = { "install_mode", ARG_TYPE_ARRAY_OF | obj_any },
		[kw_copy] = { "copy", obj_bool },
		[kw_encoding] = { "encoding", obj_string },
		[kw_depfile] = { "depfile", obj_string },
@@ -552,7 +554,12 @@ func_configure_file(struct workspace *wk, uint32_t _, uint32_t args_node, uint32
			return false;
		}

		push_install_target(wk, 0, output_str, get_obj(wk, akw[kw_install_dir].val)->dat.str, 0);
		uint32_t install_mode_id = 0;
		if (akw[kw_install_mode].set) {
			install_mode_id = akw[kw_install_mode].val;
		}

		push_install_target(wk, 0, output_str, get_obj(wk, akw[kw_install_dir].val)->dat.str, install_mode_id);
	}

	return true;
diff --git a/src/functions/default/custom_target.c b/src/functions/default/custom_target.c
index 18fe1f9..75726a1 100644
--- a/src/functions/default/custom_target.c
+++ b/src/functions/default/custom_target.c
@@ -251,6 +251,7 @@ func_custom_target(struct workspace *wk, uint32_t _, uint32_t args_node, uint32_
		kw_capture,
		kw_install,
		kw_install_dir,
		kw_install_mode,
		kw_build_by_default,
		kw_depfile,
	};
@@ -261,6 +262,7 @@ func_custom_target(struct workspace *wk, uint32_t _, uint32_t args_node, uint32_
		[kw_capture]     = { "capture", obj_bool },
		[kw_install]     = { "install", obj_bool },
		[kw_install_dir] = { "install_dir", obj_any }, // TODO
		[kw_install_mode] = { "install_mode", ARG_TYPE_ARRAY_OF | obj_any },
		[kw_build_by_default] = { "build_by_default", obj_bool },
		[kw_depfile]     = { "depfile", obj_string },
		0
@@ -311,7 +313,12 @@ func_custom_target(struct workspace *wk, uint32_t _, uint32_t args_node, uint32_
			return false;
		}

		if (!push_install_targets(wk, 0, output, akw[kw_install_dir].val, 0)) {
		uint32_t install_mode_id = 0;
		if (akw[kw_install_mode].set) {
			install_mode_id = akw[kw_install_mode].val;
		}

		if (!push_install_targets(wk, 0, output, akw[kw_install_dir].val, install_mode_id)) {
			return false;
		}
	}
diff --git a/src/lang/workspace.c b/src/lang/workspace.c
index 33446a6..3c71694 100644
--- a/src/lang/workspace.c
+++ b/src/lang/workspace.c
@@ -323,6 +323,7 @@ push_install_target(struct workspace *wk, uint32_t base_path, uint32_t filename,
	tgt->dat.install_target.base_path = base_path;
	tgt->dat.install_target.filename = filename;
	tgt->dat.install_target.install_dir = install_dir;
	// TODO this has a mode [, user, group]
	tgt->dat.install_target.install_mode = install_mode;

	obj_array_push(wk, wk->install, id);
-- 
2.33.0
LGTM!

Stone