diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2021-06-22 22:59:16 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2021-06-29 11:28:08 +0200 |
commit | 3e396b3782813d36d46195564cd0e111422bcaf5 (patch) | |
tree | f315e990f71984745fcb8f22dac2f0e400fecadb /mesonbuild/cmake | |
parent | 28175bbee2c111cf41b80c97bbadd7dbabaa8990 (diff) | |
download | meson-3e396b3782813d36d46195564cd0e111422bcaf5.zip meson-3e396b3782813d36d46195564cd0e111422bcaf5.tar.gz meson-3e396b3782813d36d46195564cd0e111422bcaf5.tar.bz2 |
fix: Always explicitly set encoding for text files (fixes #8263)
Diffstat (limited to 'mesonbuild/cmake')
-rw-r--r-- | mesonbuild/cmake/fileapi.py | 6 | ||||
-rw-r--r-- | mesonbuild/cmake/toolchain.py | 8 | ||||
-rw-r--r-- | mesonbuild/cmake/traceparser.py | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/mesonbuild/cmake/fileapi.py b/mesonbuild/cmake/fileapi.py index 6773e9a..5d4d01a 100644 --- a/mesonbuild/cmake/fileapi.py +++ b/mesonbuild/cmake/fileapi.py @@ -51,7 +51,7 @@ class CMakeFileAPI: } query_file = self.request_dir / 'query.json' - query_file.write_text(json.dumps(query, indent=2)) + query_file.write_text(json.dumps(query, indent=2), encoding='utf-8') def load_reply(self) -> None: if not self.reply_dir.is_dir(): @@ -75,7 +75,7 @@ class CMakeFileAPI: # Debug output debug_json = self.build_dir / '..' / 'fileAPI.json' debug_json = debug_json.resolve() - debug_json.write_text(json.dumps(index, indent=2)) + debug_json.write_text(json.dumps(index, indent=2), encoding='utf-8') mlog.cmd_ci_include(debug_json.as_posix()) # parse the JSON @@ -313,7 +313,7 @@ class CMakeFileAPI: if not real_path.exists(): raise CMakeException(f'File "{real_path}" does not exist') - data = json.loads(real_path.read_text()) + data = json.loads(real_path.read_text(encoding='utf-8')) assert isinstance(data, dict) for i in data.keys(): assert isinstance(i, str) diff --git a/mesonbuild/cmake/toolchain.py b/mesonbuild/cmake/toolchain.py index f3e487d..1a6dcf0 100644 --- a/mesonbuild/cmake/toolchain.py +++ b/mesonbuild/cmake/toolchain.py @@ -66,8 +66,8 @@ class CMakeToolchain: def write(self) -> Path: if not self.toolchain_file.parent.exists(): self.toolchain_file.parent.mkdir(parents=True) - self.toolchain_file.write_text(self.generate()) - self.cmcache_file.write_text(self.generate_cache()) + self.toolchain_file.write_text(self.generate(), encoding='utf-8') + self.cmcache_file.write_text(self.generate_cache(), encoding='utf-8') mlog.cmd_ci_include(self.toolchain_file.as_posix()) return self.toolchain_file @@ -215,11 +215,11 @@ class CMakeToolchain: build_dir = Path(self.env.scratch_dir) / '__CMake_compiler_info__' build_dir.mkdir(parents=True, exist_ok=True) cmake_file = build_dir / 'CMakeLists.txt' - cmake_file.write_text(cmake_content) + cmake_file.write_text(cmake_content, encoding='utf-8') # Generate the temporary toolchain file temp_toolchain_file = build_dir / 'CMakeMesonTempToolchainFile.cmake' - temp_toolchain_file.write_text(CMakeToolchain._print_vars(self.variables)) + temp_toolchain_file.write_text(CMakeToolchain._print_vars(self.variables), encoding='utf-8') # Configure trace = CMakeTraceParser(self.cmakebin.version(), build_dir) diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py index 23a1852..42ceec6 100644 --- a/mesonbuild/cmake/traceparser.py +++ b/mesonbuild/cmake/traceparser.py @@ -158,7 +158,7 @@ class CMakeTraceParser: if not self.requires_stderr(): if not self.trace_file_path.exists and not self.trace_file_path.is_file(): raise CMakeException('CMake: Trace file "{}" not found'.format(str(self.trace_file_path))) - trace = self.trace_file_path.read_text(errors='ignore') + trace = self.trace_file_path.read_text(errors='ignore', encoding='utf-8') if not trace: raise CMakeException('CMake: The CMake trace was not provided or is empty') |