~lattis/muon

6 3

[PATCH 1/2] add 'meson compile' compatibility

Details
Message ID
<D2ZL200N71EY.JX8LOKT12HSQ@posteo.net>
DKIM signature
pass
Download raw message
Patch: +46 -0
translate 'meson compile' into 'muon samu'. The --ninja-args and --clean
options are still missing but the common options work.

---
 src/meson_opts.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/src/meson_opts.c b/src/meson_opts.c
index 0f4a19f3..a10cdf14 100644
--- a/src/meson_opts.c
+++ b/src/meson_opts.c
@@ -331,6 +331,51 @@ translate_meson_opts_install(struct workspace *wk, char *argv[], uint32_t argc,
	return true;
}

enum meson_opts_compile {
	opt_compile_chdir = 1,
	opt_compile_jobs,
};

static bool
translate_meson_opts_compile_callback(struct workspace *wk,
	const struct meson_option_spec *spec,
	const char *val,
	struct translate_meson_opts_ctx *ctx)
{
	switch ((enum meson_opts_compile)(spec->handle_as)) {
	case opt_compile_chdir: obj_array_push(wk, ctx->prepend_args, make_strf(wk, "-C%s", val)); break;
	case opt_compile_jobs: obj_array_push(wk, ctx->argv, make_strf(wk, "-j%s", val)); break;
	default: UNREACHABLE;
	}

	return true;
}

static bool
translate_meson_opts_compile(struct workspace *wk, char *argv[], uint32_t argc, struct translate_meson_opts_ctx *ctx)
{
	struct meson_option_spec opts[] = {
		{ "h", .help = true },
		{ "help", .help = true },
		{ "C", true, .handle_as = opt_compile_chdir },
		{ "j", true, .handle_as = opt_compile_jobs },
		{ "jobs", true, .handle_as = opt_compile_jobs },
		{ "l", true, .ignore = true },
		{ "load-average", true, .ignore = true },
		{ "vs-args", true, .ignore = true },
		{ "xcode-args", true, .ignore = true },
	};

	obj_array_push(wk, ctx->argv, make_str(wk, "samu"));

	if (!translate_meson_opts_parser(
		    wk, argv, argc, ctx, opts, ARRAY_LEN(opts), translate_meson_opts_compile_callback)) {
		return false;
	}

	return true;
}

enum meson_opts_setup {
	opt_setup_version = 1,
	opt_setup_define,
@@ -477,6 +522,7 @@ static const struct {
} meson_opts_subcommands[] = {
	{ "setup", translate_meson_opts_setup },
	{ "configure", translate_meson_opts_setup },
	{ "compile", translate_meson_opts_compile },
	{
		"install",
		translate_meson_opts_install,
-- 
2.45.2
Details
Message ID
<2cd9ea79-1340-493f-9184-63cddfe5800e@gmail.com>
In-Reply-To
<D2ZL200N71EY.JX8LOKT12HSQ@posteo.net> (view parent)
DKIM signature
pass
Download raw message
On 7/26/24 11:41 AM, Sertonix wrote:
> 
> translate 'meson compile' into 'muon samu'. The --ninja-args and --clean
> options are still missing but the common options work.


I oppose this patch.

The `meson compile` command should, generally, not be used. It
implements an incompatible interface to building your code, and
arguments valid for ninja/samurai are *invalid* for passing to `meson
compile` -- and vice versa.

It is not possible for you to implement a compatible interface unless
you do one of:

- unilaterally ban passing targets
- implement the entirety of meson's IDE json introspection tooling, then
  use that to look up and cross-verify targets to build, remembering
  that any targets which are created by the backend rather than defined
  in meson.build (e.g. coverage targets) are fatal errors


Keep in mind that `meson compile` only exists to serve as a command
which is an alternative to ninja that also works for msbuild. If you
always use ninja anyways, simply run the relevant ninja commands and you
will have a compatible interface (ninja) that works with both meson and
muon already.


-- 
Eli Schwartz
Details
Message ID
<D2ZNP5XZOCMV.EXRG9NRM4BDX@posteo.net>
In-Reply-To
<2cd9ea79-1340-493f-9184-63cddfe5800e@gmail.com> (view parent)
DKIM signature
pass
Download raw message
> > translate 'meson compile' into 'muon samu'. The --ninja-args and --clean
> > options are still missing but the common options work.
>
>
> I oppose this patch.
>
> The `meson compile` command should, generally, not be used. It
> implements an incompatible interface to building your code, and
> arguments valid for ninja/samurai are *invalid* for passing to `meson
> compile` -- and vice versa.

My goal was to test building alpine linux packages with muon without
requiring too many muon specific changes. Most alpine packages use `meson
compile` so with this compatibility a lot of packages build out of the box.

Do you consider `meson compile` also bad when no target is specified?

> It is not possible for you to implement a compatible interface unless
> you do one of:
>
> - unilaterally ban passing targets
> - implement the entirety of meson's IDE json introspection tooling, then
>   use that to look up and cross-verify targets to build, remembering
>   that any targets which are created by the backend rather than defined
>   in meson.build (e.g. coverage targets) are fatal errors

No alpine linux package needs targets with `meson compile` and I would
think that most common uses of `meson compile` don't need targets ether so
I would be fine with banning them.

> Keep in mind that `meson compile` only exists to serve as a command
> which is an alternative to ninja that also works for msbuild. If you
> always use ninja anyways, simply run the relevant ninja commands and you
> will have a compatible interface (ninja) that works with both meson and
> muon already.
Details
Message ID
<f7147196-c1c1-4c0f-b28c-7b875baae551@gmail.com>
In-Reply-To
<D2ZNP5XZOCMV.EXRG9NRM4BDX@posteo.net> (view parent)
DKIM signature
pass
Download raw message
On 7/26/24 1:45 PM, Sertonix wrote:
>>> translate 'meson compile' into 'muon samu'. The --ninja-args and --clean
>>> options are still missing but the common options work.
>>
>>
>> I oppose this patch.
>>
>> The `meson compile` command should, generally, not be used. It
>> implements an incompatible interface to building your code, and
>> arguments valid for ninja/samurai are *invalid* for passing to `meson
>> compile` -- and vice versa.
> 
> My goal was to test building alpine linux packages with muon without
> requiring too many muon specific changes. Most alpine packages use `meson
> compile` so with this compatibility a lot of packages build out of the box.
> 
> Do you consider `meson compile` also bad when no target is specified?


`meson compile` starts off by loading a few hundred *.py files from disk
into memory, compiling them to bytecode on demand, and importing them as
code objects.

When no arguments are passed to it, it then immediately forks and
executes `ninja` with no arguments. When arguments are passed to it, it
preprocesses those arguments, builds the list of arguments to pass to
`ninja`, and then... forks and executes ninja.


If you are not passing arguments to `meson compile` then there is no
reason you cannot simply, unconditionally, in all cases without exception:

```
find . -name APKBUILD -exec sed -i "s/meson compile/ninja/" {} +
```

If the only arguments being passed are -C -j -l -v, then the same still
applies.

If you tell me there are real life cases of people using --ninja-args I
may politely laugh really hard. :) I describe my reasoning at

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=66011abd663671947fe07835f0d9cc360f5de317


-- 
Eli Schwartz
Details
Message ID
<D2ZOBKY7107S.2IRELY8743P3C@posteo.net>
In-Reply-To
<f7147196-c1c1-4c0f-b28c-7b875baae551@gmail.com> (view parent)
DKIM signature
pass
Download raw message
> >>> translate 'meson compile' into 'muon samu'. The --ninja-args and --clean
> >>> options are still missing but the common options work.
> >>
> >>
> >> I oppose this patch.
> >>
> >> The `meson compile` command should, generally, not be used. It
> >> implements an incompatible interface to building your code, and
> >> arguments valid for ninja/samurai are *invalid* for passing to `meson
> >> compile` -- and vice versa.
> > 
> > My goal was to test building alpine linux packages with muon without
> > requiring too many muon specific changes. Most alpine packages use `meson
> > compile` so with this compatibility a lot of packages build out of the box.
> > 
> > Do you consider `meson compile` also bad when no target is specified?
>
>
> `meson compile` starts off by loading a few hundred *.py files from disk
> into memory, compiling them to bytecode on demand, and importing them as
> code objects.
>
> When no arguments are passed to it, it then immediately forks and
> executes `ninja` with no arguments. When arguments are passed to it, it
> preprocesses those arguments, builds the list of arguments to pass to
> `ninja`, and then... forks and executes ninja.
>
>
> If you are not passing arguments to `meson compile` then there is no
> reason you cannot simply, unconditionally, in all cases without exception:
>
> ```
> find . -name APKBUILD -exec sed -i "s/meson compile/ninja/" {} +
> ```
>
> If the only arguments being passed are -C -j -l -v, then the same still
> applies.
>
> If you tell me there are real life cases of people using --ninja-args I
> may politely laugh really hard. :) I describe my reasoning at
>
> https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=66011abd663671947fe07835f0d9cc360f5de317


Thanks for the info! I will consider suggesting the removal of `meson
compile` for alpine packages. Regardless I still think providing very
basic `meson compile` compatibility would be benefitial. Especially
since muon doesn't have the problem of loading hundreds of python files.
Details
Message ID
<ryyllelcxax7kit2ardb25jw76ypq5pkse2sjygchygcn37aq5@zdgvdfo7afxg>
In-Reply-To
<D2ZOBKY7107S.2IRELY8743P3C@posteo.net> (view parent)
DKIM signature
pass
Download raw message
Hey,

Sorry for not replying to this for quite awhile.  I think it is okay for
muon to support `muon meson compile`, but I don't like the modification
of `muon samu`.  I think `muon meson compile` should point to its own
subcommand, perhaps `muon internal meson-compile`, that simply calls
ninja.

Thanks,
Stone
Details
Message ID
<D4FNVEBCDHZL.QWKQMGETS1NU@posteo.net>
In-Reply-To
<ryyllelcxax7kit2ardb25jw76ypq5pkse2sjygchygcn37aq5@zdgvdfo7afxg> (view parent)
DKIM signature
pass
Download raw message
> Hey,
>
> Sorry for not replying to this for quite awhile.  I think it is okay for
> muon to support `muon meson compile`, but I don't like the modification
> of `muon samu`.  I think `muon meson compile` should point to its own
> subcommand, perhaps `muon internal meson-compile`, that simply calls
> ninja.

Sounds reasonable. The change was a bit of a hack. Unfortunatly I currently
don't have time to change the patch. Feel free to change the patch if you
want. Otherwise I may finish it some day.

> Thanks,
> Stone
Reply to thread Export thread (mbox)