Eli Schwartz: 3 implement meson.project_name() implement meson.version() builtin options: define all the standard directory options 5 files changed, 38 insertions(+), 2 deletions(-)
Copy & paste the following snippet into your terminal to import this patchset into git:
curl -s https://lists.sr.ht/~lattis/muon/patches/24919/mbox | git am -3Learn more about email & git
--- src/functions/meson.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/functions/meson.c b/src/functions/meson.c index fdbc06d..c8ba108 100644 --- a/src/functions/meson.c +++ b/src/functions/meson.c @@ -30,6 +30,17 @@ func_meson_get_compiler(struct workspace *wk, uint32_t _, uint32_t args_node, ui return true; } +static bool +func_meson_project_name(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)->cfg.name; + return true; +} + static bool func_meson_project_version(struct workspace *wk, uint32_t _, uint32_t args_node, uint32_t *obj) { @@ -76,6 +87,7 @@ func_meson_global_build_root(struct workspace *wk, uint32_t _, uint32_t args_nod const struct func_impl_name impl_tbl_meson[] = { { "get_compiler", func_meson_get_compiler }, + { "project_name", func_meson_project_name }, { "project_version", func_meson_project_version }, { "current_source_dir", func_meson_current_source_dir }, { "current_build_dir", func_meson_current_build_dir }, -- 2.33.0
Hey, thanks for the patches. Everything looks good to me. I did have some related work at `muon/src/platform/dirs.c`, but at this stage I think it is OK to hardcode these value. Stone
Track the version in the muon_version struct as a separate value from the application version. Defer actually declaring a compatibility level for now. --- include/version.h | 3 ++- src/functions/meson.c | 13 +++++++++++++ src/version.c.in | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/version.h b/include/version.h index e4070e1..8abeef1 100644 --- a/include/version.h +++ b/include/version.h @@ -1,7 +1,8 @@ #ifndef MUON_VERSION_H #define MUON_VERSION_H struct muon_version { - const char *const version, *const vcs_tag; + const char *const version, *const vcs_tag, *const meson_compat; }; extern const struct muon_version muon_version; + #endif diff --git a/src/functions/meson.c b/src/functions/meson.c index c8ba108..bd3a298 100644 --- a/src/functions/meson.c +++ b/src/functions/meson.c @@ -5,6 +5,7 @@ #include "functions/meson.h" #include "lang/interpreter.h" #include "log.h" +#include "version.h" static bool func_meson_get_compiler(struct workspace *wk, uint32_t _, uint32_t args_node, uint32_t *obj) @@ -52,6 +53,17 @@ func_meson_project_version(struct workspace *wk, uint32_t _, uint32_t args_node, return true; } +static bool +func_meson_version(struct workspace *wk, uint32_t _, uint32_t args_node, uint32_t *obj) +{ + if (!interp_args(wk, args_node, NULL, NULL, NULL)) { + return false; + } + + *obj = make_str(wk, muon_version.meson_compat); + return true; +} + static bool func_meson_current_source_dir(struct workspace *wk, uint32_t _, uint32_t args_node, uint32_t *obj) { @@ -89,6 +101,7 @@ const struct func_impl_name impl_tbl_meson[] = { { "get_compiler", func_meson_get_compiler }, { "project_name", func_meson_project_name }, { "project_version", func_meson_project_version }, + { "version", func_meson_version }, { "current_source_dir", func_meson_current_source_dir }, { "current_build_dir", func_meson_current_build_dir }, { "global_build_root", func_meson_global_build_root }, diff --git a/src/version.c.in b/src/version.c.in index 21a5dfe..611c063 100644 --- a/src/version.c.in +++ b/src/version.c.in @@ -5,4 +5,5 @@ const struct muon_version muon_version = { .version = "@version@", .vcs_tag = "@vcs_tag@", + .meson_compat = "0.0.0", /* declare this sensibly once complete */ }; -- 2.33.0
A couple of them are actually dynamically calculated in the meson reference implementation, do not bother with this here. - libdir can be lib, lib64, or shell out to dpkg-architecture -qDEB_HOST_MULTIARCH - /etc and /var try to be clever based on whether prefix is /usr --- src/functions/default/options.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/functions/default/options.c b/src/functions/default/options.c index c164ae6..2a993e7 100644 --- a/src/functions/default/options.c +++ b/src/functions/default/options.c @@ -512,8 +512,17 @@ set_default_options(struct workspace *wk) "\tchoices: ['none', 'c89', 'c99', 'c11', 'c17', 'c18', 'c2x', 'gnu89', 'gnu99'," " 'gnu11', 'gnu17', 'gnu18', 'gnu2x'])\n" "option('prefix', yield: true, type: 'string', value: '/usr/local')\n" - "option('mandir', yield: true, type: 'string', value: 'share/man')\n" + "option('bindir', yield: true, type: 'string', value: 'bin')\n" "option('datadir', yield: true, type: 'string', value: 'share')\n" + "option('includedir', yield: true, type: 'string', value: 'include')\n" + "option('infodir', yield: true, type: 'string', value: 'share/info')\n" + "option('libdir', yield: true, type: 'string', value: 'lib')\n" + "option('libexecdir', yield: true, type: 'string', value: 'libexec')\n" + "option('localedir', yield: true, type: 'string', value: 'share/locale')\n" + "option('localstatedir', yield: true, type: 'string', value: '/var')\n" + "option('mandir', yield: true, type: 'string', value: 'share/man')\n" + "option('sbindir', yield: true, type: 'string', value: 'sbin')\n" + "option('sysconfdir', yield: true, type: 'string', value: '/etc')\n" , &obj); } -- 2.33.0