Fix win32/msys2 shader compilation
cover Fix win32/msys2 shader compilation
From: Marc-André Lureau <[email protected]>
Hi,
Fix the shader compilation error on win32/msys2 and convert the related script from perl to python.
Marc-André Lureau (2):
build-sys: fix crlf-ending C code
.gitlab-ci.d/windows: do not disable opengl
meson.build | 2 +- .gitlab-ci.d/windows.yml | 5 ++--- scripts/shaderinclude.pl | 16 ---------------- scripts/shaderinclude.py | 22 ++++++++++++++++++++++ 4 files changed, 25 insertions(+), 20 deletions(-) delete mode 100644 scripts/shaderinclude.pl create mode 100755 scripts/shaderinclude.py
Signature · 1 line
2.39.0
PATCH 1/2 build-sys: fix crlf-ending C code
From: Marc-André Lureau <[email protected]>
On msys2, the shader-to-C script produces bad C:./ui/shader/texture-blit-vert.h:2:5: error: missing terminating " character [-Werror]
Fix it by changing the line ending from crlf to lf, and convert the script to Python (qemu build seems perl-free after that).
--- meson.build | 2 +- scripts/shaderinclude.pl | 16 ---------------- scripts/shaderinclude.py | 22 ++++++++++++++++++++++ 3 files changed, 23 insertions(+), 17 deletions(-) delete mode 100644 scripts/shaderinclude.pl create mode 100755 scripts/shaderinclude.py
meson.build +1 -1
@@ -2781,7 +2781,7 @@ config_host_data.set('CONFIG_SLIRP', slirp.found()) genh += configure_file(output: 'config-host.h', configuration: config_host_data) hxtool = find_program('scripts/hxtool') -shaderinclude = find_program('scripts/shaderinclude.pl') +shaderinclude = find_program('scripts/shaderinclude.py') qapi_gen = find_program('scripts/qapi-gen.py') qapi_gen_depends = [ meson.current_source_dir() / 'scripts/qapi/__init__.py', meson.current_source_dir() / 'scripts/qapi/commands.py',
scripts/shaderinclude.pl deleted +0 -16
@@ -1,16 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; - -my $file = shift; -open FILE, "<", $file or die "open $file: $!"; -my $name = $file; -$name =~ s|.*/||; -$name =~ s/[-.]/_/g; -print "static GLchar ${name}_src[] =\n"; -while (<FILE>) { - chomp; - printf " \"%s\\n\"\n", $_; -} -print " \"\\n\";\n"; -close FILE;
scripts/shaderinclude.py new file +22 -0
@@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import sys +import os + + +def main(args): + file_path = args[1] + basename = os.path.basename(file_path) + varname = basename.replace('-', '_').replace('.', '_') + + with os.fdopen(sys.stdout.fileno(), "wt", closefd=False, newline='\n') as stdout: + with open(file_path, "r", encoding='utf-8') as file: + print(f'static GLchar {varname}_src[] =', file=stdout) + for line in file: + line = line.rstrip() + print(f' "{line}\\n"', file=stdout) + print(' "\\n";', file=stdout) + + +if __name__ == '__main__': + sys.exit(main(sys.argv))
Signature · 1 line
2.39.0
Re: [PATCH 1/2] build-sys: fix crlf-ending C code
Quoted 7 lines · On 09/01/2023 12.21, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
On msys2, the shader-to-C script produces bad C:
./ui/shader/texture-blit-vert.h:2:5: error: missing terminating " character [-Werror]Fix it by changing the line ending from crlf to lf, and convert the script to Python (qemu build seems perl-free after that).
If the build process does not depend on Perl anymore, would it make sense to also add a patch that removes perl from most of the containers (the ones that don't use check_patch.pl etc.)? ... that way we would make sure that the dependency does not creep in again later...
Quoted 8 lines
Signed-off-by Marc-André Lureau <[email protected]>--- meson.build | 2 +- scripts/shaderinclude.pl | 16 ---------------- scripts/shaderinclude.py | 22 ++++++++++++++++++++++ 3 files changed, 23 insertions(+), 17 deletions(-)delete mode 100644
scripts/shaderinclude.pl
create mode 100755scripts/shaderinclude.py
Re: [PATCH 1/2] build-sys: fix crlf-ending C code
Hi
Quoted 7 lines · Thomas Huth
Quoted 4 lines · On 09/01/2023 12.21, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
On msys2, the shader-to-C script produces bad C:
./ui/shader/texture-blit-vert.h:2:5: error: missing terminating "character [-Werror]
Quoted 1 line
Quoted 9 lines
Quoted 2 lines
Fix it by changing the line ending from crlf to lf, and convert the script to Python (qemu build seems perl-free after that).
If the build process does not depend on Perl anymore, would it make sense to
also add a patch that removes perl from most of the containers (the ones that don't use check_patch.pl etc.)? ... that way we would make sure that the dependency does not creep in again later...
Let's try that. A quick check reveals that configure already still has perl usage. I will take a look.
Quoted 13 lines
Quoted 9 lines
Signed-off-by Marc-André Lureau <[email protected]>--- meson.build | 2 +- scripts/shaderinclude.pl | 16 ---------------- scripts/shaderinclude.py | 22 ++++++++++++++++++++++ 3 files changed, 23 insertions(+), 17 deletions(-)delete mode 100644
scripts/shaderinclude.pl
create mode 100755scripts/shaderinclude.pyAcked-by Thomas Huth <[email protected]>
Re: [PATCH 1/2] build-sys: fix crlf-ending C code
Quoted 1 line · Marc-André Lureau
Let's try that. A quick check reveals that configure already still has perl usage. I will take a look.
There's already a patch planned to remove it ("configure: remove backwards-compatibility code").
Paolo
Re: [PATCH 1/2] build-sys: fix crlf-ending C code
Hi
Quoted 7 lines · Paolo Bonzini
Quoted 2 lines · Marc-André Lureau
Let's try that. A quick check reveals that configure already still has perl usage. I will take a look.
There's already a patch planned to remove it ("configure: remove backwards-compatibility code").
Ok, in the meantime, I replaced it with sed :) The remaining one seems to be some sphinx workaround.
We'll need to update lcitool, my test CI branch is currently running from:
https://gitlab.com/marcandre.lureau/qemu/-/commits/test
Signature · 1 line
Marc-André Lureau
Re: [PATCH 1/2] build-sys: fix crlf-ending C code
In reply to [email protected]scripts/shaderinclude.py
Quoted 24 lines · On 9/1/23 12:21, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
On msys2, the shader-to-C script produces bad C:
./ui/shader/texture-blit-vert.h:2:5: error: missing terminating " character [-Werror]Fix it by changing the line ending from crlf to lf, and convert the script to Python (qemu build seems perl-free after that).
Signed-off-by Marc-André Lureau <[email protected]>--- meson.build | 2 +- scripts/shaderinclude.pl | 16 ---------------- scripts/shaderinclude.py | 22 ++++++++++++++++++++++ 3 files changed, 23 insertions(+), 17 deletions(-)delete mode 100644
scripts/shaderinclude.pl
create mode 100755scripts/shaderinclude.pyscripts/shaderinclude.py new file +0
-0@@ -0,0 +1,22 @@
Missing license boilerplate.
Quoted 18 lines
scripts/shaderinclude.py new file +18
-0+#!/usr/bin/env python3 + +import sys +import os + + +def main(args): + file_path = args[1] + basename = os.path.basename(file_path) + varname = basename.replace('-', '_').replace('.', '_') + + with os.fdopen(sys.stdout.fileno(), "wt", closefd=False, newline='\n') as stdout: + with open(file_path, "r", encoding='utf-8') as file: + print(f'static GLchar {varname}_src[] =', file=stdout) + for line in file: + line = line.rstrip() + print(f' "{line}\\n"', file=stdout) + print(' "\\n";', file=stdout)
PATCH 2/2 .gitlab-ci.d/windows: do not disable opengl
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The previous patch should fix shader compilation.
--- .gitlab-ci.d/windows.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
.gitlab-ci.d/windows.yml +2 -3
@@ -71,7 +71,7 @@ msys2-64bit: # for the msys2 64-bit job, due to the build could not complete within # the project timeout. - ..\msys64\usr\bin\bash -lc '../configure --target-list=x86_64-softmmu - --without-default-devices --disable-opengl' + --without-default-devices' - ..\msys64\usr\bin\bash -lc 'make' # qTests don't run successfully with "--without-default-devices", # so let's exclude the qtests from CI for now.
@@ -113,7 +113,6 @@ msys2-32bit: - $env:MSYS = 'winsymlinks:native' # Enable native Windows symlink - mkdir output - cd output - - ..\msys64\usr\bin\bash -lc '../configure --target-list=ppc64-softmmu - --disable-opengl' + - ..\msys64\usr\bin\bash -lc '../configure --target-list=ppc64-softmmu' - ..\msys64\usr\bin\bash -lc 'make' - ..\msys64\usr\bin\bash -lc 'make check || { cat meson-logs/testlog.txt; exit 1; } ;'
Signature · 1 line
2.39.0
Re: [PATCH 2/2] .gitlab-ci.d/windows: do not disable opengl
Quoted 23 lines · On 09/01/2023 12.21, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The previous patch should fix shader compilation.
Signed-off-by Marc-André Lureau <[email protected]>--- .gitlab-ci.d/windows.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-).gitlab-ci.d/windows.yml +1
-1@@ -71,7 +71,7 @@ msys2-64bit: # for the msys2 64-bit job, due to the build could not complete within # the project timeout. - ..\msys64\usr\bin\bash -lc '../configure --target-list=x86_64-softmmu - --without-default-devices --disable-opengl' + --without-default-devices' - ..\msys64\usr\bin\bash -lc 'make' # qTests don't run successfully with "--without-default-devices", # so let's exclude the qtests from CI for now.
.gitlab-ci.d/windows.yml msys2-32bit: · line 118
Quoted 8 lines
.gitlab-ci.d/windows.yml +1
-2@@ -113,7 +113,6 @@ msys2-32bit: - $env:MSYS = 'winsymlinks:native' # Enable native Windows symlink - mkdir output - cd output - - ..\msys64\usr\bin\bash -lc '../configure --target-list=ppc64-softmmu - --disable-opengl' + - ..\msys64\usr\bin\bash -lc '../configure --target-list=ppc64-softmmu' - ..\msys64\usr\bin\bash -lc 'make' - ..\msys64\usr\bin\bash -lc 'make check || { cat meson-logs/testlog.txt; exit 1; } ;'