Skip to content

Commit

Permalink
Attempt to build 32bit binaries for windows (pyocd#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
mstarecek committed Aug 10, 2022
1 parent 66cca39 commit 6386c0f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci-build-wheel-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
matrix:
os: [windows-latest]
env:
CIBW_SKIP: "cp27-* cp34-* cp35-* cp36-* pp* *-win32"
CIBW_SKIP: "cp27-* cp34-* cp35-* cp36-* pp*"
CIBW_BEFORE_BUILD: "python -m pip install --upgrade pip wheel setuptools setuptools_scm"
CIBW_BUILD_VERBOSITY: 1
RUSTFLAGS: "-Ctarget-feature=+crt-static"
Expand All @@ -23,11 +23,12 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc]

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.7'
python-version: "3.7"

- name: Build wheels
uses: pypa/[email protected]
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ci-build-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ jobs:
with:
platforms: arm64

# Assuming 64bit version is installed as default
- name: Install Rust i686-pc-windows-msvc
if: runner.os == 'Windows'
run: rustup target add i686-pc-windows-msvc

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.7'
python-version: "3.7"

- name: Build wheels
uses: pypa/[email protected]
Expand Down
17 changes: 14 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
# limitations under the License.

import os
from setuptools import setup
import platform
from pathlib import Path

from setuptools import setup

# Get the directory containing this setup.py. Even though full paths are used below, we must
# chdir in order for setuptools-scm to successfully pick up the version.
SCRIPT_DIR = Path(__file__).resolve().parent
Expand Down Expand Up @@ -51,15 +53,24 @@ def build_native(spec):
header_filename=lambda: build.find_header('cmsis.h', in_path='cmsis-cffi')
)
else:
cmd_extras = []
target_infix = ''
if platform.system() == 'Windows':
if platform.architecture()[0] == '64bit':
target_infix = 'x86_64-pc-windows-msvc'
else:
target_infix = 'i686-pc-windows-msvc'
cmd_extras.append(f'--target={target_infix}')

build = spec.add_external_build(
cmd=['cargo', 'build', '--release', '--lib'],
cmd=['cargo', 'build', '--release', '--lib'] + cmd_extras,
path=RUST_DIR
)

spec.add_cffi_module(
module_path='cmsis_pack_manager._native',
dylib=lambda: build.find_dylib('cmsis_cffi',
in_path='target/release/deps'),
in_path=f'target/{target_infix}/release/deps'),
header_filename=lambda: build.find_header('cmsis.h', in_path='cmsis-cffi')
)

Expand Down

0 comments on commit 6386c0f

Please sign in to comment.