aboutsummaryrefslogtreecommitdiff
path: root/tools
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 /tools
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 'tools')
-rwxr-xr-xtools/ac_converter.py2
-rwxr-xr-xtools/boost_names.py6
-rwxr-xr-xtools/cmake2meson.py6
-rwxr-xr-xtools/dircondenser.py4
-rwxr-xr-xtools/gen_data.py4
-rwxr-xr-xtools/regenerate_docs.py6
-rwxr-xr-xtools/run_with_cov.py4
7 files changed, 16 insertions, 16 deletions
diff --git a/tools/ac_converter.py b/tools/ac_converter.py
index 6c72f8d..c3b954c 100755
--- a/tools/ac_converter.py
+++ b/tools/ac_converter.py
@@ -371,7 +371,7 @@ if len(sys.argv) != 2:
print(help_message.format(sys.argv[0]))
sys.exit(0)
-with open(sys.argv[1]) as f:
+with open(sys.argv[1], encoding='utf-8') as f:
for line in f:
line = line.strip()
arr = line.split()
diff --git a/tools/boost_names.py b/tools/boost_names.py
index 89926ec..b716ccb 100755
--- a/tools/boost_names.py
+++ b/tools/boost_names.py
@@ -78,7 +78,7 @@ class BoostModule():
def get_boost_version() -> T.Optional[str]:
- raw = jamroot.read_text()
+ raw = jamroot.read_text(encoding='utf-8')
m = re.search(r'BOOST_VERSION\s*:\s*([0-9\.]+)\s*;', raw)
if m:
return m.group(1)
@@ -91,7 +91,7 @@ def get_libraries(jamfile: Path) -> T.List[BoostLibrary]:
# - compiler flags
libs: T.List[BoostLibrary] = []
- raw = jamfile.read_text()
+ raw = jamfile.read_text(encoding='utf-8')
raw = re.sub(r'#.*\n', '\n', raw) # Remove comments
raw = re.sub(r'\s+', ' ', raw) # Force single space
raw = re.sub(r'}', ';', raw) # Cheat code blocks by converting } to ;
@@ -185,7 +185,7 @@ def process_lib_dir(ldir: Path) -> T.List[BoostModule]:
libs = get_libraries(bjam_file)
# Extract metadata
- data = json.loads(meta_file.read_text())
+ data = json.loads(meta_file.read_text(encoding='utf-8'))
if not isinstance(data, list):
data = [data]
diff --git a/tools/cmake2meson.py b/tools/cmake2meson.py
index 4185b5a..a12d9cf 100755
--- a/tools/cmake2meson.py
+++ b/tools/cmake2meson.py
@@ -280,13 +280,13 @@ class Converter:
subdir = self.cmake_root
cfile = Path(subdir).expanduser() / 'CMakeLists.txt'
try:
- with cfile.open() as f:
+ with cfile.open(encoding='utf-8') as f:
cmakecode = f.read()
except FileNotFoundError:
print('\nWarning: No CMakeLists.txt in', subdir, '\n', file=sys.stderr)
return
p = Parser(cmakecode)
- with (subdir / 'meson.build').open('w') as outfile:
+ with (subdir / 'meson.build').open('w', encoding='utf-8') as outfile:
for t in p.parse():
if t.name == 'add_subdirectory':
# print('\nRecursing to subdir',
@@ -300,7 +300,7 @@ class Converter:
def write_options(self) -> None:
filename = self.cmake_root / 'meson_options.txt'
- with filename.open('w') as optfile:
+ with filename.open('w', encoding='utf-8') as optfile:
for o in self.options:
(optname, description, default) = o
if default is None:
diff --git a/tools/dircondenser.py b/tools/dircondenser.py
index 9d642d2..2a726df 100755
--- a/tools/dircondenser.py
+++ b/tools/dircondenser.py
@@ -54,11 +54,11 @@ def get_entries() -> T.List[T.Tuple[int, str]]:
return entries
def replace_source(sourcefile: str, replacements: T.List[T.Tuple[str, str]]) -> None:
- with open(sourcefile) as f:
+ with open(sourcefile, encoding='utf-8') as f:
contents = f.read()
for old_name, new_name in replacements:
contents = contents.replace(old_name, new_name)
- with open(sourcefile, 'w') as f:
+ with open(sourcefile, 'w', encoding='utf-8') as f:
f.write(contents)
def condense(dirname: str) -> None:
diff --git a/tools/gen_data.py b/tools/gen_data.py
index 9affc66..b1c62e0 100755
--- a/tools/gen_data.py
+++ b/tools/gen_data.py
@@ -107,7 +107,7 @@ def main() -> int:
def write_once(self, path: Path) -> None:
if not path.exists():
- path.write_text(self.data)
+ path.write_text(self.data, encoding='utf-8')
def write_to_private(self, env: 'Environment') -> Path:
out_file = Path(env.scratch_dir) / 'data' / self.path.name
@@ -133,7 +133,7 @@ def main() -> int:
''')
print(f'Updating {out_file}')
- out_file.write_text(data)
+ out_file.write_text(data, encoding='utf-8')
return 0
if __name__ == '__main__':
diff --git a/tools/regenerate_docs.py b/tools/regenerate_docs.py
index f5ce77b..2029314 100755
--- a/tools/regenerate_docs.py
+++ b/tools/regenerate_docs.py
@@ -114,13 +114,13 @@ def generate_hotdoc_includes(root_dir: Path, output_dir: Path) -> None:
for cmd, parsed in cmd_data.items():
for typ in parsed.keys():
- with open(output_dir / (cmd+'_'+typ+'.inc'), 'w') as f:
+ with open(output_dir / (cmd+'_'+typ+'.inc'), 'w', encoding='utf-8') as f:
f.write(parsed[typ])
def generate_wrapdb_table(output_dir: Path) -> None:
url = urlopen('https://wrapdb.mesonbuild.com/v2/releases.json')
releases = json.loads(url.read().decode())
- with open(output_dir / 'wrapdb-table.md', 'w') as f:
+ with open(output_dir / 'wrapdb-table.md', 'w', encoding='utf-8') as f:
f.write('| Project | Versions | Provided dependencies | Provided programs |\n')
f.write('| ------- | -------- | --------------------- | ----------------- |\n')
for name, info in releases.items():
@@ -147,7 +147,7 @@ def regenerate_docs(output_dir: PathLike,
generate_wrapdb_table(output_dir)
if dummy_output_file:
- with open(output_dir/dummy_output_file, 'w') as f:
+ with open(output_dir/dummy_output_file, 'w', encoding='utf-8') as f:
f.write('dummy file for custom_target output')
if __name__ == '__main__':
diff --git a/tools/run_with_cov.py b/tools/run_with_cov.py
index 17fb300..3f78efc 100755
--- a/tools/run_with_cov.py
+++ b/tools/run_with_cov.py
@@ -28,9 +28,9 @@ from mesonbuild import mesonlib
def generate_coveragerc() -> Path:
i_file = (root_path / 'data' / '.coveragerc.in')
o_file = (root_path / '.coveragerc')
- raw = i_file.read_text()
+ raw = i_file.read_text(encoding='utf-8')
raw = raw.replace('@ROOT@', root_path.as_posix())
- o_file.write_text(raw)
+ o_file.write_text(raw, encoding='utf-8')
return o_file
def main() -> int: