From 46ffb70952aec1ed661bd2ec4d9f7e98fb032182 Mon Sep 17 00:00:00 2001 From: Bart Janssens Date: Sun, 14 Apr 2024 14:02:17 +0200 Subject: [PATCH] Fix for https://github.com/JuliaInterop/CxxWrap.jl/issues/419 (#148) * Fix for https://github.com/JuliaInterop/CxxWrap.jl/issues/419 * Fall back to CxxWrap as package in CI * Don't build JLL in CI --- .github/workflows/build-binary.yml | 44 ---------------------------- .github/workflows/test-linux-mac.yml | 6 +++- .github/workflows/test-win.yml | 6 +++- examples/types.cpp | 2 ++ include/jlcxx/stl.hpp | 2 +- 5 files changed, 13 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/build-binary.yml diff --git a/.github/workflows/build-binary.yml b/.github/workflows/build-binary.yml deleted file mode 100644 index 26ad8f8..0000000 --- a/.github/workflows/build-binary.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: testjll -on: - - push - -defaults: - run: - shell: bash - -jobs: - buildjll: - name: Build JLL - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@latest - with: - version: '1.8' - arch: x64 - - name: Cache artifacts - uses: actions/cache@v2 - env: - cache-name: cache-artifacts - with: - path: ~/.julia/artifacts - key: ${{ runner.os }}-jll-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} - restore-keys: | - ${{ runner.os }}-jll-${{ env.cache-name }}- - ${{ runner.os }}-jll- - ${{ runner.os }}- - - uses: fusion-engineering/setup-git-credentials@v2 - with: - credentials: https://cxxwrapdeploy:${{secrets.DEPLOY_KEY}}@github.com/ - - name: Build JLLs - env: - GITHUB_TOKEN: ${{ secrets.DEPLOY_KEY }} - BINARYBUILDER_RUNNER: privileged - BINARYBUILDER_USE_SQUASHFS: true - BINARYBUILDER_AUTOMATIC_APPLE: true - run: | - cd .. - git config --global user.name "cxxwrapdeploy" - git config --global user.email "cxxwrapdeploy@bartjanssens.org" - julia --project=./libcxxwrap-julia/binarybuilder -e "using Pkg; Pkg.instantiate()" - julia --project=./libcxxwrap-julia/binarybuilder ./libcxxwrap-julia/binarybuilder/build_tarballs.jl diff --git a/.github/workflows/test-linux-mac.yml b/.github/workflows/test-linux-mac.yml index 47e85a0..2181362 100644 --- a/.github/workflows/test-linux-mac.yml +++ b/.github/workflows/test-linux-mac.yml @@ -32,9 +32,13 @@ jobs: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - name: Build and test + env: + body: ${{ github.event.pull_request.body }} run: | - body="${{github.event.pull_request.body}}" package="$(echo "$body" | sed -n '1p')" + if [ -z "${package}" ]; then + package="CxxWrap" + fi if [[ "$OSTYPE" != "darwin"* ]]; then rm -f /opt/hostedtoolcache/julia/1.6*/x64/lib/julia/libstdc++.so.6 fi diff --git a/.github/workflows/test-win.yml b/.github/workflows/test-win.yml index de1cf08..d63fab0 100644 --- a/.github/workflows/test-win.yml +++ b/.github/workflows/test-win.yml @@ -33,12 +33,16 @@ jobs: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - name: Config and Test + env: + body: ${{ github.event.pull_request.body }} run: | mkdir build cd build cmake -G "Visual Studio 17 2022" -A x64 -DOVERRIDES_PATH=$HOMEDRIVE/$HOMEPATH/.julia/artifacts/Overrides.toml -DOVERRIDE_ROOT=./ -DAPPEND_OVERRIDES_TOML=ON .. - body="${{github.event.pull_request.body}}" package="$(echo "$body" | sed -n '1p')" + if [ -z "${package}" ]; then + package="CxxWrap" + fi cmake --build . --config Release julia -e "using Pkg; Pkg.Registry.add(\"General\"); Pkg.Registry.add(RegistrySpec(url = \"https://github.com/barche/CxxWrapTestRegistry.git\"))" julia -e "using Pkg; pkg\"add ${package}\"; using CxxWrap" diff --git a/examples/types.cpp b/examples/types.cpp index 41f6173..eda37f7 100644 --- a/examples/types.cpp +++ b/examples/types.cpp @@ -353,6 +353,8 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& types) return {std::shared_ptr(new World("shared vector const hello"))}; }); + types.method("world_ptr_vector", []() { static World w; return std::vector({&w}); }); + types.method("get_shared_vector_msg", [](const std::vector>& v) { return v[0]->greet(); diff --git a/include/jlcxx/stl.hpp b/include/jlcxx/stl.hpp index 32f41d0..11fa439 100644 --- a/include/jlcxx/stl.hpp +++ b/include/jlcxx/stl.hpp @@ -198,7 +198,7 @@ struct WrapQueueImpl wrapped.module().set_override_module(StlWrappers::instance().module()); wrapped.method("cppsize", &WrappedT::size); wrapped.method("push_back!", [] (WrappedT& v, const T& val) { v.push(val); }); - wrapped.method("front", [] (WrappedT& v) -> const T { return v.front(); }); + wrapped.method("front", [] (WrappedT& v) { return v.front(); }); wrapped.method("pop_front!", [] (WrappedT& v) { v.pop(); }); wrapped.module().unset_override_module(); }