aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r--mesonbuild/scripts/coverage.py4
-rw-r--r--mesonbuild/scripts/depfixer.py2
-rw-r--r--mesonbuild/scripts/depscan.py6
-rw-r--r--mesonbuild/scripts/externalproject.py6
-rw-r--r--mesonbuild/scripts/gettext.py2
-rw-r--r--mesonbuild/scripts/symbolextractor.py10
-rw-r--r--mesonbuild/scripts/uninstall.py2
-rw-r--r--mesonbuild/scripts/vcstagger.py6
8 files changed, 19 insertions, 19 deletions
diff --git a/mesonbuild/scripts/coverage.py b/mesonbuild/scripts/coverage.py
index f8a4924..b60d5d1 100644
--- a/mesonbuild/scripts/coverage.py
+++ b/mesonbuild/scripts/coverage.py
@@ -68,11 +68,11 @@ def coverage(outputs: T.List[str], source_root: str, subproject_root: str, build
# Create a shim to allow using llvm-cov as a gcov tool.
if mesonlib.is_windows():
llvm_cov_shim_path = os.path.join(log_dir, 'llvm-cov.bat')
- with open(llvm_cov_shim_path, 'w') as llvm_cov_bat:
+ with open(llvm_cov_shim_path, 'w', encoding='utf-8') as llvm_cov_bat:
llvm_cov_bat.write(f'@"{llvm_cov_exe}" gcov %*')
else:
llvm_cov_shim_path = os.path.join(log_dir, 'llvm-cov.sh')
- with open(llvm_cov_shim_path, 'w') as llvm_cov_sh:
+ with open(llvm_cov_shim_path, 'w', encoding='utf-8') as llvm_cov_sh:
llvm_cov_sh.write(f'#!/usr/bin/env sh\nexec "{llvm_cov_exe}" gcov $@')
os.chmod(llvm_cov_shim_path, os.stat(llvm_cov_shim_path).st_mode | stat.S_IEXEC)
gcov_tool_args = ['--gcov-tool', llvm_cov_shim_path]
diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py
index c215749..52c7ba9 100644
--- a/mesonbuild/scripts/depfixer.py
+++ b/mesonbuild/scripts/depfixer.py
@@ -468,7 +468,7 @@ def fix_darwin(fname: str, new_rpath: str, final_path: str, install_name_mapping
def fix_jar(fname: str) -> None:
subprocess.check_call(['jar', 'xfv', fname, 'META-INF/MANIFEST.MF'])
- with open('META-INF/MANIFEST.MF', 'r+') as f:
+ with open('META-INF/MANIFEST.MF', 'r+', encoding='utf-8') as f:
lines = f.readlines()
f.seek(0)
for line in lines:
diff --git a/mesonbuild/scripts/depscan.py b/mesonbuild/scripts/depscan.py
index 207bbc6..9fc435b 100644
--- a/mesonbuild/scripts/depscan.py
+++ b/mesonbuild/scripts/depscan.py
@@ -57,7 +57,7 @@ class DependencyScanner:
def scan_fortran_file(self, fname: str) -> None:
fpath = pathlib.Path(fname)
modules_in_this_file = set()
- for line in fpath.read_text().split('\n'):
+ for line in fpath.read_text(encoding='utf-8').split('\n'):
import_match = FORTRAN_USE_RE.match(line)
export_match = FORTRAN_MODULE_RE.match(line)
submodule_export_match = FORTRAN_SUBMOD_RE.match(line)
@@ -108,7 +108,7 @@ class DependencyScanner:
def scan_cpp_file(self, fname: str) -> None:
fpath = pathlib.Path(fname)
- for line in fpath.read_text().split('\n'):
+ for line in fpath.read_text(encoding='utf-8').split('\n'):
import_match = CPP_IMPORT_RE.match(line)
export_match = CPP_EXPORT_RE.match(line)
if import_match:
@@ -150,7 +150,7 @@ class DependencyScanner:
def scan(self) -> int:
for s in self.sources:
self.scan_file(s)
- with open(self.outfile, 'w') as ofile:
+ with open(self.outfile, 'w', encoding='utf-8') as ofile:
ofile.write('ninja_dyndep_version = 1\n')
for src in self.sources:
objfilename = self.objname_for(src)
diff --git a/mesonbuild/scripts/externalproject.py b/mesonbuild/scripts/externalproject.py
index 657ef2f..a8e3bfe 100644
--- a/mesonbuild/scripts/externalproject.py
+++ b/mesonbuild/scripts/externalproject.py
@@ -34,7 +34,7 @@ class ExternalProject:
self.make = options.make
def write_depfile(self) -> None:
- with open(self.depfile, 'w') as f:
+ with open(self.depfile, 'w', encoding='utf-8') as f:
f.write(f'{self.stampfile}: \\\n')
for dirpath, dirnames, filenames in os.walk(self.src_dir):
dirnames[:] = [d for d in dirnames if not d.startswith('.')]
@@ -45,7 +45,7 @@ class ExternalProject:
f.write(' {} \\\n'.format(path.as_posix().replace(' ', '\\ ')))
def write_stampfile(self) -> None:
- with open(self.stampfile, 'w') as f:
+ with open(self.stampfile, 'w', encoding='utf-8') as f:
pass
def gnu_make(self) -> bool:
@@ -78,7 +78,7 @@ class ExternalProject:
log_filename = Path(self.log_dir, f'{self.name}-{step}.log')
output = None
if not self.verbose:
- output = open(log_filename, 'w')
+ output = open(log_filename, 'w', encoding='utf-8')
output.write(m + '\n')
output.flush()
else:
diff --git a/mesonbuild/scripts/gettext.py b/mesonbuild/scripts/gettext.py
index 92b55d3..b1ce6af 100644
--- a/mesonbuild/scripts/gettext.py
+++ b/mesonbuild/scripts/gettext.py
@@ -34,7 +34,7 @@ def read_linguas(src_sub: str) -> T.List[str]:
linguas = os.path.join(src_sub, 'LINGUAS')
try:
langs = []
- with open(linguas) as f:
+ with open(linguas, encoding='utf-8') as f:
for line in f:
line = line.strip()
if line and not line.startswith('#'):
diff --git a/mesonbuild/scripts/symbolextractor.py b/mesonbuild/scripts/symbolextractor.py
index 728d5e2..17501e2 100644
--- a/mesonbuild/scripts/symbolextractor.py
+++ b/mesonbuild/scripts/symbolextractor.py
@@ -38,18 +38,18 @@ RELINKING_WARNING = 'Relinking will always happen on source changes.'
def dummy_syms(outfilename: str) -> None:
"""Just touch it so relinking happens always."""
- with open(outfilename, 'w'):
+ with open(outfilename, 'w', encoding='utf-8'):
pass
def write_if_changed(text: str, outfilename: str) -> None:
try:
- with open(outfilename) as f:
+ with open(outfilename, encoding='utf-8') as f:
oldtext = f.read()
if text == oldtext:
return
except FileNotFoundError:
pass
- with open(outfilename, 'w') as f:
+ with open(outfilename, 'w', encoding='utf-8') as f:
f.write(text)
def print_tool_warning(tools: T.List[str], msg: str, stderr: T.Optional[str] = None) -> None:
@@ -61,7 +61,7 @@ def print_tool_warning(tools: T.List[str], msg: str, stderr: T.Optional[str] = N
m += '\n' + stderr
mlog.warning(m)
# Write it out so we don't warn again
- with open(TOOL_WARNING_FILE, 'w'):
+ with open(TOOL_WARNING_FILE, 'w', encoding='utf-8'):
pass
def get_tool(name: str) -> T.List[str]:
@@ -309,7 +309,7 @@ def gen_symbols(libfilename: str, impfilename: str, outfilename: str, cross_host
mlog.warning('Symbol extracting has not been implemented for this '
'platform. ' + RELINKING_WARNING)
# Write it out so we don't warn again
- with open(TOOL_WARNING_FILE, 'w'):
+ with open(TOOL_WARNING_FILE, 'w', encoding='utf-8'):
pass
dummy_syms(outfilename)
diff --git a/mesonbuild/scripts/uninstall.py b/mesonbuild/scripts/uninstall.py
index 8db04dd..f08490f 100644
--- a/mesonbuild/scripts/uninstall.py
+++ b/mesonbuild/scripts/uninstall.py
@@ -20,7 +20,7 @@ logfile = 'meson-logs/install-log.txt'
def do_uninstall(log: str) -> None:
failures = 0
successes = 0
- for line in open(log):
+ for line in open(log, encoding='utf-8'):
if line.startswith('#'):
continue
fname = line.strip()
diff --git a/mesonbuild/scripts/vcstagger.py b/mesonbuild/scripts/vcstagger.py
index 64985f6..18cf5f7 100644
--- a/mesonbuild/scripts/vcstagger.py
+++ b/mesonbuild/scripts/vcstagger.py
@@ -22,15 +22,15 @@ def config_vcs_tag(infile: str, outfile: str, fallback: str, source_dir: str, re
except Exception:
new_string = fallback
- with open(infile, encoding='utf8') as f:
+ with open(infile, encoding='utf-8') as f:
new_data = f.read().replace(replace_string, new_string)
if os.path.exists(outfile):
- with open(outfile, encoding='utf8') as f:
+ with open(outfile, encoding='utf-8') as f:
needs_update = (f.read() != new_data)
else:
needs_update = True
if needs_update:
- with open(outfile, 'w', encoding='utf8') as f:
+ with open(outfile, 'w', encoding='utf-8') as f:
f.write(new_data)