diff mbox series

[1/4] meson: Fixes the ninjatool issue that E$$: are generated in Makefile.ninja

Message ID 20200825165341.520-1-luoyonggang@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/4] meson: Fixes the ninjatool issue that E$$: are generated in Makefile.ninja | expand

Commit Message

Yonggang Luo Aug. 25, 2020, 4:53 p.m. UTC
From: Yonggang Luo <luoyonggang@gmail.com>

SIMPLE_PATH_RE should match the full path token.
Or the $ and : contained in path would not matched if the path are start with C:/ and E:/
---
 scripts/ninjatool.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Cave-Ayland Aug. 25, 2020, 9:26 p.m. UTC | #1
On 25/08/2020 17:53, luoyonggang@gmail.com wrote:

> From: Yonggang Luo <luoyonggang@gmail.com>
> 
> SIMPLE_PATH_RE should match the full path token.
> Or the $ and : contained in path would not matched if the path are start with C:/ and E:/
> ---
>  scripts/ninjatool.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/ninjatool.py b/scripts/ninjatool.py
> index cc77d51aa8..6ca8be6f10 100755
> --- a/scripts/ninjatool.py
> +++ b/scripts/ninjatool.py
> @@ -55,7 +55,7 @@ else:
>  
>  PATH_RE = r"[^$\s:|]+|\$[$ :]|\$[a-zA-Z0-9_-]+|\$\{[a-zA-Z0-9_.-]+\}"
>  
> -SIMPLE_PATH_RE = re.compile(r"[^$\s:|]+")
> +SIMPLE_PATH_RE = re.compile(r"^[^$\s:|]+$")
>  IDENT_RE = re.compile(r"[a-zA-Z0-9_.-]+$")
>  STRING_RE = re.compile(r"(" + PATH_RE + r"|[\s:|])(?:\r?\n)?|.")
>  TOPLEVEL_RE = re.compile(r"([=:#]|\|\|?|^ +|(?:" + PATH_RE + r")+)\s*|.")

I've tested this and it changes build.ninja so instead of Windows paths beginning C$$
they now begin C$ instead e.g.:

build qemu-version.h: CUSTOM_COMMAND  |
C$:/msys64/home/Mark/qemu/scripts/qemu-version.sh PHONY

I was expecting this not to work, however it seems in the next stage of
transformation from build.ninja to Makefile.ninja the extra $ is removed correctly:

qemu-version.h: qemu-version.h.stamp; @:
qemu-version.h.stamp: C:/msys64/home/Mark/qemu/scripts/qemu-version.sh PHONY | ;
${ninja-command-restat}

It feels like the extra $ shouldn't be present in build.ninja, but the patch does
generate a Makefile.ninja that works.


ATB,

Mark.
Eric Blake Aug. 25, 2020, 9:42 p.m. UTC | #2
On 8/25/20 11:53 AM, luoyonggang@gmail.com wrote:
> From: Yonggang Luo <luoyonggang@gmail.com>
> 
> SIMPLE_PATH_RE should match the full path token.
> Or the $ and : contained in path would not matched if the path are start with C:/ and E:/
> ---

Missing a Signed-off-by tag.  Without that, we cannot apply it.

Also missing a 0/4 cover letter; less essential, but useful for 
continuous integration tools and for replying to the series as a whole.

More patch submission hints can be found at 
https://wiki.qemu.org/Contribute/SubmitAPatch
Paolo Bonzini Aug. 26, 2020, 6:45 a.m. UTC | #3
On Tue, Aug 25, 2020 at 11:26 PM Mark Cave-Ayland
<mark.cave-ayland@ilande.co.uk> wrote:
> I've tested this and it changes build.ninja so instead of Windows paths beginning C$$
> they now begin C$ instead e.g.:
>
> build qemu-version.h: CUSTOM_COMMAND  |
> C$:/msys64/home/Mark/qemu/scripts/qemu-version.sh PHONY

The patch should not change build.ninja in any way, but indeed it will
fix the transformation so that the (correct) ninja quoting is removed.

Paolo
Mark Cave-Ayland Aug. 27, 2020, 4:05 p.m. UTC | #4
On 26/08/2020 07:45, Paolo Bonzini wrote:

> On Tue, Aug 25, 2020 at 11:26 PM Mark Cave-Ayland
> <mark.cave-ayland@ilande.co.uk> wrote:
>> I've tested this and it changes build.ninja so instead of Windows paths beginning C$$
>> they now begin C$ instead e.g.:
>>
>> build qemu-version.h: CUSTOM_COMMAND  |
>> C$:/msys64/home/Mark/qemu/scripts/qemu-version.sh PHONY
> 
> The patch should not change build.ninja in any way, but indeed it will
> fix the transformation so that the (correct) ninja quoting is removed.

It definitely changes build.ninja here, with the escaping changing from C$$:\ to C$:\
in my tests. But if you're saying that $: with just a single $ is the correct
escaping for colon then I guess the patch is fine (and indeed it works for me with
the $ now being removed in the transformation to Makefile.ninja).


ATB,

Mark.
Paolo Bonzini Aug. 27, 2020, 4:43 p.m. UTC | #5
Il gio 27 ago 2020, 18:05 Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
ha scritto:

> On 26/08/2020 07:45, Paolo Bonzini wrote:
>
> > On Tue, Aug 25, 2020 at 11:26 PM Mark Cave-Ayland
> > <mark.cave-ayland@ilande.co.uk> wrote:
> >> I've tested this and it changes build.ninja so instead of Windows paths
> beginning C$$
> >> they now begin C$ instead e.g.:
> >>
> >> build qemu-version.h: CUSTOM_COMMAND  |
> >> C$:/msys64/home/Mark/qemu/scripts/qemu-version.sh PHONY
> >
> > The patch should not change build.ninja in any way, but indeed it will
> > fix the transformation so that the (correct) ninja quoting is removed.
>
> It definitely changes build.ninja here, with the escaping changing from
> C$$:\ to C$:\
> in my tests.


Yes, the ^ makes no difference but I missed that it also adds a $.

Thanks for testing!!

Paolo

if you're saying that $: with just a single $ is the correct
> escaping for colon then I guess the patch is fine (and indeed it works for
> me with
> the $ now being removed in the transformation to Makefile.ninja).
>
>
> ATB,
>
> Mark.
>
>
diff mbox series

Patch

diff --git a/scripts/ninjatool.py b/scripts/ninjatool.py
index cc77d51aa8..6ca8be6f10 100755
--- a/scripts/ninjatool.py
+++ b/scripts/ninjatool.py
@@ -55,7 +55,7 @@  else:
 
 PATH_RE = r"[^$\s:|]+|\$[$ :]|\$[a-zA-Z0-9_-]+|\$\{[a-zA-Z0-9_.-]+\}"
 
-SIMPLE_PATH_RE = re.compile(r"[^$\s:|]+")
+SIMPLE_PATH_RE = re.compile(r"^[^$\s:|]+$")
 IDENT_RE = re.compile(r"[a-zA-Z0-9_.-]+$")
 STRING_RE = re.compile(r"(" + PATH_RE + r"|[\s:|])(?:\r?\n)?|.")
 TOPLEVEL_RE = re.compile(r"([=:#]|\|\|?|^ +|(?:" + PATH_RE + r")+)\s*|.")