[1/2] build: fix list_dir_globs failure in MSYS2

Message ID TYAP286MB0300609982071AF15679FD8ACCF5A@TYAP286MB0300.JPNP286.PROD.OUTLOOK.COM (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [1/2] build: fix list_dir_globs failure in MSYS2 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ric Li Sept. 16, 2023, 1:15 p.m. UTC
  When running 'meson build' in MSYS2,
"list-dir-globs.py * failed with status 1".

Signed-off-by: Ric Li <ricmli@outlook.com>
---
 app/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Bruce Richardson Sept. 19, 2023, 8:12 a.m. UTC | #1
On Sat, Sep 16, 2023 at 09:15:19PM +0800, Ric Li wrote:
> When running 'meson build' in MSYS2,
> "list-dir-globs.py * failed with status 1".
> 
> Signed-off-by: Ric Li <ricmli@outlook.com>
> ---
>  app/meson.build | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/meson.build b/app/meson.build
> index e4bf5c531c..73e5138301 100644
> --- a/app/meson.build
> +++ b/app/meson.build
> @@ -11,7 +11,7 @@ disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().s
>  enable_apps = ',' + get_option('enable_apps')
>  enable_apps = run_command(list_dir_globs, enable_apps, check: true).stdout().split()
>  if enable_apps.length() == 0
> -    enable_apps = run_command(list_dir_globs, '*', check: true).stdout().split()
> +    enable_apps = run_command(list_dir_globs, '*/', check: true).stdout().split()
>  endif
>  

Do we know more about why this particular failure is happening with MSYS2?
Can you try running the script manually to see what the specific python
error is, and if we can make the script more robust generally?

In terms of the fix, I actually think we should not be using a glob here at
all. Since we already have the list of apps present in the file, I think
that we should move the app list to the top of the file and then change the
code to be:

if enable_apps.length() == 0
    enable_apps = apps
endif

This sidesteps any issues with globbing, and also makes the code a bit
faster as we don't have to shell-out to a python script.

/Bruce
  
Ric Li Sept. 19, 2023, 12:19 p.m. UTC | #2
On 2023/9/19 16:12, Bruce Richardson wrote:
> On Sat, Sep 16, 2023 at 09:15:19PM +0800, Ric Li wrote:
>> When running 'meson build' in MSYS2,
>> "list-dir-globs.py * failed with status 1".
>>
>> Signed-off-by: Ric Li <ricmli@outlook.com>
>> ---
>>  app/meson.build | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/app/meson.build b/app/meson.build
>> index e4bf5c531c..73e5138301 100644
>> --- a/app/meson.build
>> +++ b/app/meson.build
>> @@ -11,7 +11,7 @@ disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().s
>>  enable_apps = ',' + get_option('enable_apps')
>>  enable_apps = run_command(list_dir_globs, enable_apps, check: true).stdout().split()
>>  if enable_apps.length() == 0
>> -    enable_apps = run_command(list_dir_globs, '*', check: true).stdout().split()
>> +    enable_apps = run_command(list_dir_globs, '*/', check: true).stdout().split()
>>  endif
>>  
> 
> Do we know more about why this particular failure is happening with MSYS2?
> Can you try running the script manually to see what the specific python
> error is, and if we can make the script more robust generally?
> 

Running the script manually showed nothing but the Usage log.
The arguments here are not accepted by this python script.

MSYS2 does mention some command line parsing issues, see:
https://www.msys2.org/wiki/Porting/
"Windows programs parse the command line themselves,
it isn't parsed for them by the calling process, as on Linux.
This means that if wildcards (glob patterns) are to be accepted by the program,
it has to be able to expand them somehow."

> In terms of the fix, I actually think we should not be using a glob here at
> all. Since we already have the list of apps present in the file, I think
> that we should move the app list to the top of the file and then change the
> code to be:
> 
> if enable_apps.length() == 0
>     enable_apps = apps
> endif
> 
> This sidesteps any issues with globbing, and also makes the code a bit
> faster as we don't have to shell-out to a python script.
> 
> /Bruce

That sounds reasonable. I'll test it and provide an update to the patch.

Thanks,
Ric
  

Patch

diff --git a/app/meson.build b/app/meson.build
index e4bf5c531c..73e5138301 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -11,7 +11,7 @@  disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().s
 enable_apps = ',' + get_option('enable_apps')
 enable_apps = run_command(list_dir_globs, enable_apps, check: true).stdout().split()
 if enable_apps.length() == 0
-    enable_apps = run_command(list_dir_globs, '*', check: true).stdout().split()
+    enable_apps = run_command(list_dir_globs, '*/', check: true).stdout().split()
 endif
 
 apps = [