-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Shebang doesn't work on Windows, need way of adding executable (e.g. python.exe for Python scripts) #7362
Description
I'm trying to build gstreamer-1.17.1 with gobject-introspection on Windows using MSYS2 shell and MinGW-w64 (personal build from http://winlibs.com/).
The meson.build file contains the following line:
gir = find_program('g-ir-scanner', required : get_option('introspection'))
The file is found, however running g-ir-scanner on Windows (using the CreateProcess() call as Ninja does) won't work as it's not a Windows .exe file.
So I'm looking for a way to tell Meson that this file needs to be run with python.exe with g-ir-scanner as the first parameter.
This didn't work:
gir = find_program('python.exe g-ir-scanner', required : get_option('introspection'))
Is there another way I can make this work?
Or even better: Would it be possible to make a structural solution by having find_program() check for a shebang line on Windows by reading the first line, checking if it starts with #! and if it's there strip that and use the rest of the line as the executable with the name of the script as first command line argument?
Maybe something like this?
patch -ulbf mesonbuild/scripts/meson_exe.py << EOF
@@ -48,2 +48,11 @@
cmd_args = exe.cmd_args
+ if is_windows():
+ try:
+ with open(cmd_args[0], 'r') as exefile:
+ if exefile.read(2) == '#!':
+ cmd_args = exefile.readline().split() + cmd_args
+ if cmd_args[0] == '/usr/bin/env':
+ cmd_args.pop(0)
+ except:
+ pass
child_env = os.environ.copy()
EOF
With the above patch I was able to build gstreamer-1.17.1 with gobject-introspection.