Skip to content

Commit 7f67ce7

Browse files
committed
Improve wat2wasm version detection (ignore version suffix).
1 parent 3b71727 commit 7f67ce7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

wasm/mx.wasm/mx_wasm.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
# SOFTWARE.
4040
#
4141
import os
42+
import re
4243
import shutil
4344
import stat
4445
import tempfile
@@ -326,11 +327,14 @@ def build(self):
326327
mx.warn("No WABT_DIR specified.")
327328
mx.abort("Could not check the wat2wasm version.")
328329

329-
wat2wasm_version = str(out.data).split(".")
330-
major = int(wat2wasm_version[0])
331-
build = int(wat2wasm_version[2])
332-
if major <= 1 and build <= 24:
333-
bulk_memory_option = "--enable-bulk-memory"
330+
try:
331+
wat2wasm_version = re.match(r'^(\d+)\.(\d+)(?:\.(\d+))?', str(out.data)).groups()
332+
333+
major, minor, build = wat2wasm_version
334+
if int(major) == 1 and int(minor) == 0 and int(build) <= 24:
335+
bulk_memory_option = "--enable-bulk-memory"
336+
except:
337+
mx.warn(f"Could not parse wat2wasm version. Output: '{out.data}'")
334338

335339
mx.log("Building files from the source dir: " + source_dir)
336340
for root, filename in self.subject.getProgramSources():

0 commit comments

Comments
 (0)