diff --git a/binaryen/binaryen_build.py b/binaryen/binaryen_build.py index 98ddb03..25c2905 100644 --- a/binaryen/binaryen_build.py +++ b/binaryen/binaryen_build.py @@ -9,6 +9,9 @@ host_machine = platform.machine().lower() +if host_platform == "windows" and host_machine == "amd64": + host_machine = "x86_64" + root_path_override = os.environ.get("BINARYEN_PY_ROOT") print("==== BUILD ====") diff --git a/pyproject.toml b/pyproject.toml index f174b18..a6512ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,6 +57,7 @@ archs = ["x86_64"] [tool.cibuildwheel.windows] archs = ["AMD64"] +# before-build = ["bash scripts/build_libbinaryen.sh"] [[tool.cibuildwheel.overrides]] select = "*-musllinux*" diff --git a/scripts/build_libbinaryen.sh b/scripts/build_libbinaryen.sh index 2e055d0..250e4bf 100644 --- a/scripts/build_libbinaryen.sh +++ b/scripts/build_libbinaryen.sh @@ -1,5 +1,7 @@ #!/bin/bash +arch=$(uname -m) + case "$(uname -sr)" in Darwin*) @@ -12,6 +14,10 @@ Linux*) CYGWIN* | MINGW* | MINGW32* | MSYS*) platform='windows' + if [[ "$arch" == "amd-64"]] + then + arch="x86_64" + fi ;; *) @@ -33,7 +39,6 @@ then wildcards="" fi -arch=$(uname -m) lib_path="./binaryen/libbinaryen/$arch-$platform/" mkdir -p $lib_path diff --git a/scripts/create_cdef.py b/scripts/create_cdef.py index 53bcd7e..de002a7 100644 --- a/scripts/create_cdef.py +++ b/scripts/create_cdef.py @@ -9,6 +9,9 @@ host_machine = platform.machine().lower() +if host_platform == "windows" and host_machine == "amd64": + host_machine = "x86_64" + include_dir = (Path(__file__).parent.parent / f"./binaryen/libbinaryen/{host_machine}-{host_platform}/include") header_path = (include_dir /"./binaryen-c.h") output_path =(include_dir / "./binaryen-c.c") @@ -32,6 +35,7 @@ ) header = pre_processor.stdout.decode(encoding="utf-8") + header = "\n".join([line.strip() for line in header.splitlines()]) # Clean up build artifacts & comments header = re.sub(r"//.*\n", "", header)