-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
meson does not add /utf-8
if vc backend is used
#13860
Comments
Hi, looked into this. The following patch should fix the issue: diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index 08a19c659..7df0b270b 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -843,8 +843,44 @@ class Vs2010Backend(backends.Backend):
return True
return entry[1:].startswith('M')
+ def get_utf8_options(self, lang, file_args):
+ def have_arg(args, name):
+ name = name.lower()
+ for a in args:
+ start = a[:len(name)+1].lower()
+ if (start[0] == '/' or start[0] == '-') and start[1:] == name:
+ return True
+ return False
+
+ args = file_args[lang].to_native()
+
+ # Already added by user?
+ if have_arg(args, "utf-8"):
+ return []
+
+ have_execution_charset = have_arg(args, 'execution-charset:')
+ have_source_charset = have_arg(args, 'source-charset:')
+ have_validate_charset = have_arg(args, 'validate-charset')
+
+ options: T.List[str] = []
+ if not have_execution_charset and not have_source_charset and not have_validate_charset:
+ options = ['/utf-8']
+ else:
+ if not have_execution_charset:
+ options += ['/execution-charset:utf-8']
+ if not have_source_charset:
+ options += ['/source-charset:utf-8']
+ if not have_validate_charset:
+ options += ['/validate-charset']
+ return options
+
def add_additional_options(self, lang, parent_node, file_args):
args = []
+
+ # /utf-8 is supported starting with VS 2015
+ if int(self.vs_version) >= 2015:
+ args += self.get_utf8_options(lang, file_args)
+
for arg in file_args[lang].to_native():
if self.is_argument_with_msbuild_xml_entry(arg):
continue
The VS generator sets most compiler arguments for each source file, I believe that was done becuase C and C++ source files can end up having different arguments. It would be great to set arguments in a toplevel so that it applies to all items |
That seems to imply that the VS backend is not injecting |
Hi @dcbaker, I have now converted #13929 to get and apply compiler's always args. This works and we get If one does: add_project_arguments('/source-charset:.1252', language: ['c', 'cpp'])
# or
static_library(..., c_args: ['/execution-charset:.1252']) We get a clash of compiler arguments. I don't know if maybe I can do something like 3729b6b to fix this? |
I'd like to have something like |
When using the vc backend, /utf-8 does not appear to be automatically added despite https://mesonbuild.com/Release-notes-for-0-60-0.html#msvc-compiler-now-assumes-utf8-source-code-by-default saying it should; I tested 1.2.2 and 1.6.0, both exhibit this behavior.
Using the ninja backend does output /utf-8, but for development reasons I prefer to use the vc backend.
Repository for testing: https://github.com/Paril/q2pro
command line used:
meson setup -Dwrap_mode=forcefallback --wipe --buildtype debug --pkg-config-path D:\vcpkg\installed\x64-windows\debug\lib\pkgconfig --backend vs build
(adjust the vcpkg folder as appropriate)The text was updated successfully, but these errors were encountered: