Skip to content

Commit 8db3091

Browse files
authored
Merge pull request #70 from supertone-inc/fix-win32-build
Fix win32 build
2 parents 01bba59 + 57a71a4 commit 8db3091

File tree

11 files changed

+1660
-785
lines changed

11 files changed

+1660
-785
lines changed

.github/workflows/general.yml

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ jobs:
5454
args: --target x86_64-apple-darwin
5555
- name: Verify prebuilt archive downloaded (CPU, x86_64-apple-darwin)
5656
run: ls -lh target/x86_64-apple-darwin/debug/build/onnxruntime-sys-*/out/onnxruntime-osx-x64-1.*.tgz
57-
# # ******************************************************************
58-
# - name: Download prebuilt archive (CPU, i686-pc-windows-msvc)
59-
# uses: actions-rs/cargo@v1
60-
# with:
61-
# command: build
62-
# args: --target i686-pc-windows-msvc
63-
# - name: Verify prebuilt archive downloaded (CPU, i686-pc-windows-msvc)
64-
# run: ls -lh target/i686-pc-windows-msvc/debug/build/onnxruntime-sys-*/out/onnxruntime-win-x86-1.*.zip
57+
# ******************************************************************
58+
- name: Download prebuilt archive (CPU, i686-pc-windows-msvc)
59+
uses: actions-rs/cargo@v1
60+
with:
61+
command: build
62+
args: --target i686-pc-windows-msvc
63+
- name: Verify prebuilt archive downloaded (CPU, i686-pc-windows-msvc)
64+
run: ls -lh target/i686-pc-windows-msvc/debug/build/onnxruntime-sys-*/out/onnxruntime-win-x86-1.*.zip
6565
# ******************************************************************
6666
- name: Download prebuilt archive (CPU, x86_64-pc-windows-msvc)
6767
uses: actions-rs/cargo@v1
@@ -97,20 +97,22 @@ jobs:
9797
strategy:
9898
fail-fast: false
9999
matrix:
100-
os: [
101-
ubuntu-latest,
102-
macos-latest,
103-
windows-latest
104-
]
100+
target:
101+
[
102+
x86_64-unknown-linux-gnu,
103+
x86_64-apple-darwin,
104+
x86_64-pc-windows-msvc,
105+
i686-pc-windows-msvc,
106+
]
105107
include:
106-
- os: ubuntu-latest
107-
target: x86_64-unknown-linux-gnu
108-
- os: macos-latest
109-
target: x86_64-apple-darwin
110-
- os: windows-latest
111-
target: x86_64-pc-windows-msvc
112-
# - os: windows-latest
113-
# target: i686-pc-windows-msvc
108+
- target: x86_64-unknown-linux-gnu
109+
os: ubuntu-latest
110+
- target: x86_64-apple-darwin
111+
os: macos-latest
112+
- target: x86_64-pc-windows-msvc
113+
os: windows-latest
114+
- target: i686-pc-windows-msvc
115+
os: windows-latest
114116
env:
115117
CARGO_BUILD_TARGET: ${{ matrix.target }}
116118
steps:

onnxruntime-sys/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ fn generate_bindings(include_dir: &Path) {
9494
// Tell cargo to invalidate the built crate whenever any of the
9595
// included header files changed.
9696
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
97+
// Set `size_t` to be translated to `usize` for win32 compatibility.
98+
.size_t_is_usize(true)
9799
// Format using rustfmt
98100
.rustfmt_bindings(true)
99101
.rustified_enum("*")

onnxruntime-sys/examples/c_api_sample.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn main() {
103103
assert_ne!(allocator_ptr, std::ptr::null_mut());
104104

105105
// print number of model input nodes
106-
let mut num_input_nodes: onnxruntime_sys::size_t = 0;
106+
let mut num_input_nodes: usize = 0;
107107
let status = unsafe {
108108
g_ort.as_ref().unwrap().SessionGetInputCount.unwrap()(session_ptr, &mut num_input_nodes)
109109
};
@@ -255,7 +255,7 @@ fn main() {
255255
.unwrap()(
256256
memory_info_ptr,
257257
input_tensor_values_ptr,
258-
(input_tensor_size * std::mem::size_of::<f32>()) as onnxruntime_sys::size_t,
258+
input_tensor_size * std::mem::size_of::<f32>(),
259259
shape,
260260
4,
261261
ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT,

0 commit comments

Comments
 (0)