Skip to content

Commit

Permalink
Merge pull request #11 from ami-iit/alignwithblockfactory
Browse files Browse the repository at this point in the history
 Align shlibpp with the version vendored in blockfactory  and add support for loading plugins by looking in SHLIBPP_PLUGIN_PATH  env variable
  • Loading branch information
traversaro authored Nov 3, 2024
2 parents 6192cc3 + 5acf076 commit a5e2aad
Show file tree
Hide file tree
Showing 15 changed files with 4,102 additions and 40 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/test-pixi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Run tests with pixi

on:
workflow_dispatch:
pull_request:

jobs:
pixi-test:
name: '[pixi:${{ matrix.os }}]'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [
ubuntu-22.04,
macos-latest,
windows-2019
]
steps:
- uses: actions/checkout@v4

- name: Set up pixi
uses: prefix-dev/[email protected]
with:
run-install: true
cache: false

- name: Print pixi info
run: pixi info

- name: Build and test the project
run: pixi run test
42 changes: 42 additions & 0 deletions .github/workflows/update-pixi-lockfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Update lockfiles

permissions:
contents: write
pull-requests: write

on:
workflow_dispatch:
schedule:
- cron: 0 5 1 * *

jobs:
pixi-update:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Set up pixi
uses: prefix-dev/[email protected]
with:
run-install: false

- name: Install pixi-diff-to-markdown
run: pixi global install pixi-diff-to-markdown

- name: Update lockfiles
run: |
set -o pipefail
pixi update --json | pixi exec pixi-diff-to-markdown >> diff.md
- name: Create pull request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update pixi lockfile
title: Update pixi lockfile
body-path: diff.md
branch: update-pixi
base: main
labels: pixi
delete-branch: true
add-paths: pixi.lock
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build
*.*~
.pixi
.build
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
cmake_minimum_required(VERSION 3.5)

project(shlibpp
VERSION 0.0.1
VERSION 0.0.2
DESCRIPTION "Tiny cross-platform plug-in system (dll, so, dylib)"
LANGUAGES CXX)

Expand Down
33 changes: 12 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Simple cross platform plug-in system
====================================

The sharedlibpp is a tiny cross-platform library to create and load shared
libraries for different platform (Linux/Mac/Windows). The sharedlibpp provide
`shlibpp` is a tiny cross-platform library to create and load shared
libraries for different platform (Linux/Mac/Windows). `shlibpp` provides
an easy and portable way to create plug-ins which encapsulate your c++ classes
inside a shared library (so, dylib, dll).
The original code is taken and from
Expand All @@ -13,33 +13,24 @@ added to report the native OS error messages on failures.

Building on Linux/Mac
---------------------
$ cd sharedlibpp
$ mkdir build; cd build
$ cmake ../; make
$ cd shlibpp
$ cmake -Bbuild -S. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./install
$ cmake --build . --config Release
$ cmake --install .


Building on Windows
-------------------
The easiest way is to use Cmake to create VStudio project. To do that:

* download and install [cmake](http://www.cmake.org/download/) for windows.
* open the cmake gui and set the source path to `sharedlibpp` and set the
build path (for example `sharedlibpp/build`).
* configure and generate visual studio project.
* open the project and built it.

Running example
---------------
The build system by defualt compiles and build the examples.
The build system by default compiles and build the examples.

* On Linux/Mac
```
$ cd sharedlibpp/build/examples
$ ./math_test mymath.so
$ ./math_test_custom mymathcustom.so
$ cd shlibpp/build/examples
$ ./math_test mymath
$ ./math_test_custom mymathcustom
```
* On Windows first switch to directory where example is created and then
```
> math_test mymath.dll
> math_test_custom mymathcustom.dll
> math_test mymath
> math_test_custom mymathcustom
```
2 changes: 0 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@

add_library(mymath MODULE MyMath.cpp MyMath.h)
target_include_directories(mymath PRIVATE $<TARGET_PROPERTY:shlibpp::shlibpp,INTERFACE_INCLUDE_DIRECTORIES>)
set_property(TARGET mymath PROPERTY PREFIX "")

add_executable(math_test math_test.cpp)
target_link_libraries(math_test PRIVATE shlibpp::shlibpp)

add_library(mymathcustom MODULE MyMathCustom.cpp MyMathCustom.h)
target_include_directories(mymathcustom PRIVATE $<TARGET_PROPERTY:shlibpp::shlibpp,INTERFACE_INCLUDE_DIRECTORIES>)
set_property(TARGET mymathcustom PROPERTY PREFIX "")

add_executable(math_test_custom math_test_custom.cpp)
target_link_libraries(math_test_custom PRIVATE shlibpp::shlibpp)
2 changes: 1 addition & 1 deletion examples/math_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char *argv[])

if(argc < 2) {
printf("Usage: %s <library file name>\n", argv[0]);
printf("for example: %s libmymath.so\n", argv[0]);
printf("for example: %s mymath\n", argv[0]);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/math_test_custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char *argv[])

if(argc < 2) {
printf("Usage: %s <library file name>\n", argv[0]);
printf("for example: %s libmymath.so\n", argv[0]);
printf("for example: %s mymath\n", argv[0]);
return 0;
}

Expand Down
Loading

0 comments on commit a5e2aad

Please sign in to comment.