Skip to content

Commit

Permalink
Fix cross-compilation of C++ interpreter API to 32-bit architecture (#…
Browse files Browse the repository at this point in the history
…3810)

cbindgen doesn't reliably tranfser the 64-bit/32-bit #ifdefs around ValueOpaque.
Instead, move Value onto the heap by using a Box.

Fixes #3653
  • Loading branch information
tronical authored Oct 31, 2023
1 parent 4b37d9a commit 1441719
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 278 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/yocto_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
- sdk_url: https://nextcloud.slint.dev/s/BTL5NtLACjgS7Pf/download/poky-glibc-x86_64-core-image-weston-cortexa15t2hf-neon-qemuarm-toolchain-4.0.9.sh
env_setup: environment-setup-cortexa15t2hf-neon-poky-linux-gnueabi
target: armv7-unknown-linux-gnueabihf
extra_args: -DSLINT_FEATURE_INTERPRETER=OFF
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
Expand All @@ -43,5 +42,5 @@ jobs:
# f5c3908b7ec5131b7b19ff642b5975660c7484f8
export BINDGEN_EXTRA_CLANG_ARGS=$OECORE_TUNE_CCARGS
mkdir ${{ runner.workspace }}/cppbuild
cmake -GNinja -B ${{ runner.workspace }}/cppbuild -S . -DRust_CARGO_TARGET=${{ matrix.target }} -DSLINT_BUILD_TESTING=ON -DSLINT_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Debug -DSLINT_FEATURE_RENDERER_SKIA=ON -DSLINT_FEATURE_BACKEND_QT=OFF -DSLINT_FEATURE_BACKEND_LINUXKMS=ON ${{ matrix.extra_args }}
cmake -GNinja -B ${{ runner.workspace }}/cppbuild -S . -DRust_CARGO_TARGET=${{ matrix.target }} -DSLINT_BUILD_TESTING=ON -DSLINT_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Debug -DSLINT_FEATURE_RENDERER_SKIA=ON -DSLINT_FEATURE_BACKEND_QT=OFF -DSLINT_FEATURE_BACKEND_LINUXKMS=ON -DSLINT_FEATURE_INTERPRETER=ON
cmake --build ${{ runner.workspace }}/cppbuild
5 changes: 3 additions & 2 deletions api/cpp/cbindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,13 @@ fn gen_interpreter(
dependencies: &mut Vec<PathBuf>,
) -> anyhow::Result<()> {
let mut config = default_config();
// Avoid Value, just export ValueOpaque.
config.export.exclude = IntoIterator::into_iter([
"Value",
"ValueType",
"PropertyDescriptor",
"Diagnostic",
"PropertyDescriptor",
"Box",
])
.map(String::from)
.collect();
Expand All @@ -795,7 +795,7 @@ fn gen_interpreter(
"StructIteratorOpaque",
"ComponentInstance",
"StructIteratorResult",
"ValueOpaque",
"Value",
"StructOpaque",
"ModelNotifyOpaque",
])
Expand All @@ -821,6 +821,7 @@ fn gen_interpreter(
using slint::interpreter::ValueType;
using slint::interpreter::PropertyDescriptor;
using slint::interpreter::Diagnostic;
template <typename T> using Box = T*;
}",
)
.generate()
Expand Down
Loading

0 comments on commit 1441719

Please sign in to comment.