aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2021-06-22 22:59:16 +0200
committerDaniel Mensinger <daniel@mensinger-ka.de>2021-06-29 11:28:08 +0200
commit3e396b3782813d36d46195564cd0e111422bcaf5 (patch)
treef315e990f71984745fcb8f22dac2f0e400fecadb /mesonbuild/compilers
parent28175bbee2c111cf41b80c97bbadd7dbabaa8990 (diff)
downloadmeson-3e396b3782813d36d46195564cd0e111422bcaf5.zip
meson-3e396b3782813d36d46195564cd0e111422bcaf5.tar.gz
meson-3e396b3782813d36d46195564cd0e111422bcaf5.tar.bz2
fix: Always explicitly set encoding for text files (fixes #8263)
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/compilers.py4
-rw-r--r--mesonbuild/compilers/cs.py2
-rw-r--r--mesonbuild/compilers/cuda.py2
-rw-r--r--mesonbuild/compilers/d.py2
-rw-r--r--mesonbuild/compilers/fortran.py2
-rw-r--r--mesonbuild/compilers/java.py2
-rw-r--r--mesonbuild/compilers/mixins/clike.py2
-rw-r--r--mesonbuild/compilers/rust.py2
-rw-r--r--mesonbuild/compilers/swift.py2
9 files changed, 10 insertions, 10 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index ff87819..52529f7 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -765,14 +765,14 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
if isinstance(code, str):
srcname = os.path.join(tmpdirname,
'testfile.' + self.default_suffix)
- with open(srcname, 'w') as ofile:
+ with open(srcname, 'w', encoding='utf-8') as ofile:
ofile.write(code)
# ccache would result in a cache miss
no_ccache = True
contents = code
elif isinstance(code, mesonlib.File):
srcname = code.fname
- with open(code.fname) as f:
+ with open(code.fname, encoding='utf-8') as f:
contents = f.read()
# Construct the compiler command-line
diff --git a/mesonbuild/compilers/cs.py b/mesonbuild/compilers/cs.py
index 218942c..7ebb66d 100644
--- a/mesonbuild/compilers/cs.py
+++ b/mesonbuild/compilers/cs.py
@@ -87,7 +87,7 @@ class CsCompiler(BasicLinkerIsCompilerMixin, Compiler):
src = 'sanity.cs'
obj = 'sanity.exe'
source_name = os.path.join(work_dir, src)
- with open(source_name, 'w') as ofile:
+ with open(source_name, 'w', encoding='utf-8') as ofile:
ofile.write(textwrap.dedent('''
public class Sanity {
static public void Main () {
diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py
index 145b7c8..4c0d0a6 100644
--- a/mesonbuild/compilers/cuda.py
+++ b/mesonbuild/compilers/cuda.py
@@ -504,7 +504,7 @@ class CudaCompiler(Compiler):
binname += '_cross' if self.is_cross else ''
source_name = os.path.join(work_dir, sname)
binary_name = os.path.join(work_dir, binname + '.exe')
- with open(source_name, 'w') as ofile:
+ with open(source_name, 'w', encoding='utf-8') as ofile:
ofile.write(code)
# The Sanity Test for CUDA language will serve as both a sanity test
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py
index 78d0f62..b5ec905 100644
--- a/mesonbuild/compilers/d.py
+++ b/mesonbuild/compilers/d.py
@@ -535,7 +535,7 @@ class DCompiler(Compiler):
def sanity_check(self, work_dir: str, environment: 'Environment') -> None:
source_name = os.path.join(work_dir, 'sanity.d')
output_name = os.path.join(work_dir, 'dtest')
- with open(source_name, 'w') as ofile:
+ with open(source_name, 'w', encoding='utf-8') as ofile:
ofile.write('''void main() { }''')
pc = subprocess.Popen(self.exelist + self.get_output_args(output_name) + self._get_target_arch_args() + [source_name], cwd=work_dir)
pc.wait()
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index 8264638..925eff6 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -71,7 +71,7 @@ class FortranCompiler(CLikeCompiler, Compiler):
if binary_name.is_file():
binary_name.unlink()
- source_name.write_text('print *, "Fortran compilation is working."; end')
+ source_name.write_text('print *, "Fortran compilation is working."; end', encoding='utf-8')
extra_flags: T.List[str] = []
extra_flags += environment.coredata.get_external_args(self.for_machine, self.language)
diff --git a/mesonbuild/compilers/java.py b/mesonbuild/compilers/java.py
index 77e1a9b..ab82450 100644
--- a/mesonbuild/compilers/java.py
+++ b/mesonbuild/compilers/java.py
@@ -70,7 +70,7 @@ class JavaCompiler(BasicLinkerIsCompilerMixin, Compiler):
src = 'SanityCheck.java'
obj = 'SanityCheck'
source_name = os.path.join(work_dir, src)
- with open(source_name, 'w') as ofile:
+ with open(source_name, 'w', encoding='utf-8') as ofile:
ofile.write(textwrap.dedent(
'''class SanityCheck {
public static void main(String[] args) {
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index 3210dd7..09ad837 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -306,7 +306,7 @@ class CLikeCompiler(Compiler):
binname += '.exe'
# Write binary check source
binary_name = os.path.join(work_dir, binname)
- with open(source_name, 'w') as ofile:
+ with open(source_name, 'w', encoding='utf-8') as ofile:
ofile.write(code)
# Compile sanity check
# NOTE: extra_flags must be added at the end. On MSVC, it might contain a '/link' argument
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py
index 6a7bd04..2b566c8 100644
--- a/mesonbuild/compilers/rust.py
+++ b/mesonbuild/compilers/rust.py
@@ -65,7 +65,7 @@ class RustCompiler(Compiler):
def sanity_check(self, work_dir: str, environment: 'Environment') -> None:
source_name = os.path.join(work_dir, 'sanity.rs')
output_name = os.path.join(work_dir, 'rusttest')
- with open(source_name, 'w') as ofile:
+ with open(source_name, 'w', encoding='utf-8') as ofile:
ofile.write(textwrap.dedent(
'''fn main() {
}
diff --git a/mesonbuild/compilers/swift.py b/mesonbuild/compilers/swift.py
index 7b18591..2d52e21 100644
--- a/mesonbuild/compilers/swift.py
+++ b/mesonbuild/compilers/swift.py
@@ -107,7 +107,7 @@ class SwiftCompiler(Compiler):
extra_flags += self.get_compile_only_args()
else:
extra_flags += environment.coredata.get_external_link_args(self.for_machine, self.language)
- with open(source_name, 'w') as ofile:
+ with open(source_name, 'w', encoding='utf-8') as ofile:
ofile.write('''print("Swift compilation is working.")
''')
pc = subprocess.Popen(self.exelist + extra_flags + ['-emit-executable', '-o', output_name, src], cwd=work_dir)