Skip to content

Commit f24df52

Browse files
committed
Fix native release build target dir reuse
1 parent acb571f commit f24df52

5 files changed

Lines changed: 28 additions & 26 deletions

File tree

.github/workflows/template_native_build.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ jobs:
5959
build-cache: true
6060
target-cache: true
6161
cache-key-suffix: native-${{ inputs.target }}
62-
target-cache-paths: |
63-
target/${{ inputs.target }}/release
64-
target/*-unknown-linux-gnu.2.17/release
65-
target/*-unknown-linux-gnu/release
66-
target/release
6762

6863
- uses: actions/setup-python@v6
6964
with:
@@ -118,31 +113,37 @@ jobs:
118113
- name: Build Python extension
119114
shell: bash
120115
run: |
116+
PYTHON_TARGET_DIR="target/python-extension"
121117
if [ "${{ runner.os }}" = "Linux" ]; then
122118
TARGET="${{ inputs.target }}"
123119
ARCH="${TARGET%%-*}"
124120
PYO3_TARGET="${ARCH}-unknown-linux-gnu"
125121
rustup target add "$PYO3_TARGET"
126122
PYO3_NO_PYTHON=1 soldr cargo zigbuild --release \
123+
--target-dir "${PYTHON_TARGET_DIR}" \
127124
--target "${PYO3_TARGET}.2.17" -p fbuild-python \
128125
--features extension-module
129126
elif [ "${{ inputs.macos_cross }}" = "true" ]; then
130127
PYO3_NO_PYTHON=1 soldr cargo build --release \
128+
--target-dir "${PYTHON_TARGET_DIR}" \
131129
--target ${{ inputs.target }} -p fbuild-python \
132130
--features extension-module
133131
elif [ "${{ runner.os }}" = "macOS" ]; then
134-
soldr cargo build --release --target ${{ inputs.target }} \
132+
soldr cargo build --release --target-dir "${PYTHON_TARGET_DIR}" \
133+
--target ${{ inputs.target }} \
135134
-p fbuild-python \
136135
--features extension-module
137136
else
138-
soldr cargo build --release --target ${{ inputs.target }} \
137+
soldr cargo build --release --target-dir "${PYTHON_TARGET_DIR}" \
138+
--target ${{ inputs.target }} \
139139
-p fbuild-python \
140140
--features extension-module
141141
fi
142142
143143
- name: Stage artifacts
144144
shell: bash
145145
run: |
146+
PYTHON_TARGET_DIR="target/python-extension"
146147
mkdir -p staging
147148
cp target/${{ inputs.target }}/release/fbuild${{ inputs.binary_ext }} staging/
148149
cp target/${{ inputs.target }}/release/fbuild-daemon${{ inputs.binary_ext }} staging/
@@ -151,20 +152,21 @@ jobs:
151152
if [ "${{ runner.os }}" = "Linux" ]; then
152153
TARGET="${{ inputs.target }}"
153154
ARCH="${TARGET%%-*}"
154-
ext_src="target/${ARCH}-unknown-linux-gnu/release/lib_native.so"
155+
ext_src="${PYTHON_TARGET_DIR}/${ARCH}-unknown-linux-gnu.2.17/release/lib_native.so"
156+
[ -f "$ext_src" ] || ext_src="${PYTHON_TARGET_DIR}/${ARCH}-unknown-linux-gnu/release/lib_native.so"
155157
[ -f "$ext_src" ] && cp "$ext_src" staging/_native.abi3.so
156158
elif [ "${{ runner.os }}" = "macOS" ]; then
157-
ext_src="target/${{ inputs.target }}/release/lib_native.dylib"
159+
ext_src="${PYTHON_TARGET_DIR}/${{ inputs.target }}/release/lib_native.dylib"
158160
[ -f "$ext_src" ] && cp "$ext_src" staging/_native.abi3.so
159161
elif [ "${{ inputs.binary_ext }}" = ".exe" ]; then
160162
for ext_src in \
161-
"target/${{ inputs.target }}/release/_native.dll" \
162-
"target/release/_native.dll"; do
163+
"${PYTHON_TARGET_DIR}/${{ inputs.target }}/release/_native.dll" \
164+
"${PYTHON_TARGET_DIR}/release/_native.dll"; do
163165
[ -f "$ext_src" ] && cp "$ext_src" staging/_native.pyd && break
164166
done
165167
else
166168
for ext in so dylib; do
167-
src="target/release/lib_native.$ext"
169+
src="${PYTHON_TARGET_DIR}/release/lib_native.$ext"
168170
[ -f "$src" ] && cp "$src" staging/_native.abi3.so && break
169171
done
170172
fi

Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ members = [
1515
]
1616

1717
[workspace.package]
18-
version = "2.2.2"
18+
version = "2.2.3"
1919
edition = "2021"
2020
rust-version = "1.94.1"
2121
license = "MIT OR Apache-2.0"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "fbuild"
3-
version = "2.2.2"
3+
version = "2.2.3"
44
description = "PlatformIO-compatible embedded build tool (Rust implementation)"
55
readme = "README.md"
66
requires-python = ">=3.10"

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)