summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-07-18 12:34:39 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2020-10-09 02:04:26 +0530
commite38b8b9356ffbe5dd7d80af193d2b42a98053079 (patch)
treecdaaafe2c86e5bb9188d61e233f0474a9f9f19f1
parent8b479f0cac25a1042da2cde97ac6be6aaf62d02d (diff)
cerbero: Read/write meson config files as utf-8
The cross and native files should be written as utf-8 because that is what Meson expects, and we should read meson_options.txt as utf-8, because that is what it will always be. Fixes the following error on macOS while reading meson_options.txt: ``` Traceback (most recent call last): File "cerbero/build/oven.py", line 451, in _cook_recipe_step await ret File "cerbero/build/recipe.py", line 82, in async_wrapped await stepfunc() File "cerbero/build/build.py", line 63, in async_call res = await func(*args) File "cerbero/build/build.py", line 1011, in configure self._set_option({'introspection', 'gir'}, 'gi') File "cerbero/build/build.py", line 771, in _set_option options = f.read() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 12: ordinal not in range(128) ``` Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/634>
-rw-r--r--cerbero/build/build.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/cerbero/build/build.py b/cerbero/build/build.py
index 66dbbafb..48ebf265 100644
--- a/cerbero/build/build.py
+++ b/cerbero/build/build.py
@@ -661,7 +661,7 @@ class Meson (Build, ModifyEnvBase) :
return
opt_name = None
opt_type = None
- with open(meson_options, 'r') as f:
+ with open(meson_options, 'r', encoding='utf-8') as f:
options = f.read()
# iterate over all option()s individually
option_regex = "option\s*\(\s*(?:'(?P<name>[^']+)')\s*,\s*(?P<entry>(?P<identifier>[a-zA-Z0-9]+)\s*:\s*(?:(?P<string>'[^']+')|[^'\),\s]+)\s*,?\s*)+\)"
@@ -765,7 +765,7 @@ class Meson (Build, ModifyEnvBase) :
WINDRES=windres,
extra_binaries=extra_binaries,
extra_properties=extra_properties)
- with open(cross_file, 'w') as f:
+ with open(cross_file, 'w', encoding='utf-8') as f:
f.write(contents)
return cross_file
@@ -783,7 +783,7 @@ class Meson (Build, ModifyEnvBase) :
native_file = os.path.join(self.meson_dir, 'meson-native-file.txt')
contents = MESON_NATIVE_FILE_TPL.format(extra_binaries=extra_binaries)
- with open(native_file, 'w') as f:
+ with open(native_file, 'w', encoding='utf-8') as f:
f.write(contents)
return native_file