Skip to content

Commit cd5fc3b

Browse files
authored
implementation of minimal plugin system based on runtime polymorphism + factories (#1)
* draft * draft * draft * draft * removed whitespaces * header only * testing * cleanup part1 * cleanup part1 * added unix ci * added unix ci * added env file * added missing header * added missing header * linking DL libs * added private * added xplugin_host as interface library * added emscripten related defs * added emscripten related defs * emscripten tests * got ride of unneded methods * playwright tests * rename env * source emsdk * source emsdk (part II) * activate emscripten & win * win path change * win path change II * added missing file * simplified win * powershell magic * set compiler * use cmd.exe instead of powershell * link against doctest * remove m_path * remove return type of destructor * error handling * removed unused var * use generic instead of unix specific code * use XPLUGIN_API * use XPLUGIN_API part2 * use XPLUGIN_API evertywhere * use XPLUGIN_API evertywhere * use XPLUGIN_API evertywhere ALL * use XPLUGIN_API evertywhere ALL * skip examples * only export for dll * less dllexport stuff * less dllexport stuff * inlining * inlining * less exports * removal * removal at xfactory * dedicated test * use dll export * export all symbols * added semi-global registry * cleanup * cleanup * minimal readme * more examples * improved impl of scan * renamed methods * added .precommit * removed static * formated * added cmake function to add plugins * added installation * testing install naive * testing install naive * added macro * made macro more simple * spelling * spelling * proper new lines * different dir * different dir * more examples * more examples * removal of flags * removal of flags * dont use emscripten for the external build example * more fpic * more fpic * even more fpic * testing * docs * build sphinxs * build docs * empty * empty * .nojekyll * only deploy on tags * only deploy on tags * only deploy on tags * only deploy on Releases * changed readme a bit
1 parent 17cf27b commit cd5fc3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+5473
-193
lines changed

.clang-format

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
BasedOnStyle: Microsoft
3+
AlwaysBreakTemplateDeclarations: 'Yes'
4+
...

.github/workflows/ci.yaml

+241
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
name: Build with conda
2+
on:
3+
push:
4+
pull_request:
5+
6+
jobs:
7+
unix:
8+
strategy:
9+
matrix:
10+
include:
11+
- os: ubuntu-latest
12+
- os: macos-latest
13+
14+
fail-fast: false
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Get number of CPU cores
20+
uses: SimenB/github-actions-cpu-cores@v1
21+
id: cpu-cores
22+
23+
- name: Install Conda environment from environment.yml
24+
uses: mamba-org/setup-micromamba@v1
25+
with:
26+
environment-file: environment.yml
27+
init-shell: >-
28+
bash
29+
cache-environment: true
30+
post-cleanup: 'all'
31+
32+
33+
- name: cmake configure
34+
shell: bash -l {0}
35+
run: |
36+
mkdir -p bld
37+
cd bld
38+
cmake \
39+
-DCMAKE_BUILD_TYPE=Release \
40+
-DXPLUGIN_BUILD_TESTS=ON \
41+
-DXPLUGIN_BUILD_EXAMPLES=ON \
42+
-DXPLUGIN_BUILD_DOCS=ON \
43+
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
44+
.. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
45+
46+
- name: Build
47+
shell: bash -l {0}
48+
run: |
49+
cd bld
50+
make -j ${{ steps.cpu-cores.outputs.count }}
51+
52+
- name: Run C++ tests
53+
shell: bash -l {0}
54+
run: |
55+
cd bld
56+
ctest -V
57+
58+
- name: Run examples
59+
shell: bash -l {0}
60+
run: |
61+
cd bld/examples/
62+
63+
pushd accumulator
64+
./main_accumulator .
65+
popd
66+
67+
pushd serialize
68+
./main_serialize .
69+
popd
70+
71+
pushd custom_factory_with_metadata
72+
./main_custom_factory_with_metadata .
73+
popd
74+
75+
76+
77+
- name: Install
78+
shell: bash -l {0}
79+
run: |
80+
cd bld
81+
make install
82+
83+
- name: Test installation
84+
shell: bash -l {0}
85+
run: |
86+
cd examples/serialize
87+
mkdir -p bld
88+
cd bld
89+
cmake \
90+
-DCMAKE_BUILD_TYPE=Release \
91+
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
92+
..
93+
make -j ${{ steps.cpu-cores.outputs.count }}
94+
./main_serialize .
95+
96+
windows:
97+
strategy:
98+
matrix:
99+
include:
100+
- os: windows-latest
101+
fail-fast: false
102+
runs-on: ${{ matrix.os }}
103+
104+
steps:
105+
106+
- uses: actions/checkout@v3
107+
108+
- name: Install Conda environment from environment.yml
109+
uses: mamba-org/setup-micromamba@v1
110+
with:
111+
environment-file: environment.yml
112+
init-shell: >-
113+
cmd.exe
114+
cache-environment: true
115+
post-cleanup: 'all'
116+
117+
- name: build and test
118+
shell: cmd /C CALL {0}
119+
run: |
120+
mkdir bld
121+
cd bld
122+
cmake .. ^
123+
-G Ninja ^
124+
-DCMAKE_BUILD_TYPE=Release ^
125+
-DXPLUGIN_BUILD_TESTS=ON ^
126+
-DXPLUGIN_BUILD_EXAMPLES=OFF ^
127+
-DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" ^
128+
-DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%
129+
130+
cmake --build . --config Release
131+
ctest -C Release -V
132+
133+
- name: Install
134+
shell: cmd /C CALL {0}
135+
run: |
136+
cd bld
137+
cmake --install . --config Release
138+
139+
- name: Test installation
140+
shell: cmd /C CALL {0}
141+
run: |
142+
cd examples
143+
cd serialize
144+
mkdir bld
145+
cd bld
146+
cmake .. ^
147+
-G Ninja ^
148+
-DCMAKE_BUILD_TYPE=Release ^
149+
-DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library"
150+
151+
SET thisdir=%cd%
152+
cmake --build . --config Release
153+
main_serialize.exe %thisdir%
154+
155+
emscripten:
156+
strategy:
157+
matrix:
158+
include:
159+
- emscripten_version: 3.1.27
160+
fail-fast: false
161+
runs-on: ubuntu-latest
162+
steps:
163+
- uses: actions/checkout@v3
164+
- name: Get number of CPU cores
165+
uses: SimenB/github-actions-cpu-cores@v1
166+
id: cpu-cores
167+
168+
- name: Install Conda environment from environment_emscripten.yml
169+
uses: mamba-org/setup-micromamba@v1
170+
with:
171+
environment-file: environment_emscripten.yml
172+
init-shell: >-
173+
bash
174+
cache-environment: true
175+
post-cleanup: 'all'
176+
177+
- name: install emscripten
178+
shell: bash -l {0}
179+
run: |
180+
git clone https://github.com/emscripten-core/emsdk.git
181+
cd emsdk
182+
./emsdk install ${{ matrix.emscripten_version }}
183+
source ./emsdk_env.sh
184+
185+
- name: install playwright
186+
shell: bash -l {0}
187+
run: |
188+
playwright install
189+
190+
- name: run emscripten tests
191+
shell: bash -l {0}
192+
run: |
193+
cd emsdk
194+
./emsdk activate ${{ matrix.emscripten_version }}
195+
source ./emsdk_env.sh
196+
cd ..
197+
chmod +x ./test/emscripten/test_emscripten.sh
198+
./test/emscripten/test_emscripten.sh
199+
200+
docs:
201+
strategy:
202+
matrix:
203+
include:
204+
- os: ubuntu-latest
205+
206+
fail-fast: false
207+
runs-on: ${{ matrix.os }}
208+
steps:
209+
- uses: actions/checkout@v3
210+
211+
- name: Install Conda environment from environment.yml
212+
uses: mamba-org/setup-micromamba@v1
213+
with:
214+
environment-file: environment.yml
215+
init-shell: >-
216+
bash
217+
cache-environment: true
218+
post-cleanup: 'all'
219+
220+
- name: cmake configure
221+
shell: bash -l {0}
222+
run: |
223+
mkdir -p bld
224+
cd bld
225+
cmake \
226+
-DCMAKE_BUILD_TYPE=Release \
227+
-DXPLUGIN_BUILD_TESTS=OFF \
228+
-DXPLUGIN_BUILD_EXAMPLES= \
229+
-DXPLUGIN_BUILD_DOCS=ON \
230+
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
231+
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
232+
..
233+
234+
- name: Build docs
235+
shell: bash -l {0}
236+
run: |
237+
cd bld
238+
make docs_sphinx
239+
240+
# add .nojekyll file to docs folder
241+
touch docs/html/.nojekyll

.github/workflows/docs.yaml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build and deploy docs
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
release:
9+
types:
10+
- published
11+
12+
jobs:
13+
docs:
14+
strategy:
15+
fail-fast: false
16+
runs-on: ubuntu-latest
17+
if: github.event_name == 'release' && github.event.action == 'published'
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Install Conda environment from environment.yml
22+
uses: mamba-org/setup-micromamba@v1
23+
with:
24+
environment-file: environment.yml
25+
init-shell: >-
26+
bash
27+
cache-environment: true
28+
post-cleanup: 'all'
29+
30+
- name: cmake configure
31+
shell: bash -l {0}
32+
run: |
33+
mkdir -p bld
34+
cd bld
35+
cmake \
36+
-DCMAKE_BUILD_TYPE=Release \
37+
-DXPLUGIN_BUILD_TESTS=OFF \
38+
-DXPLUGIN_BUILD_EXAMPLES= \
39+
-DXPLUGIN_BUILD_DOCS=ON \
40+
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
41+
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
42+
..
43+
44+
- name: Build docs
45+
shell: bash -l {0}
46+
run: |
47+
cd bld
48+
make docs_sphinx
49+
50+
# add .nojekyll file to docs folder
51+
touch docs/html/.nojekyll
52+
53+
- name: Deploy 🚀
54+
uses: JamesIves/[email protected]
55+
with:
56+
branch: gh-pages # The branch the action should deploy to.
57+
folder: bld/docs/html # The folder the action should deploy.

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,16 @@ docs/*.tmp
5151

5252
# Generated files
5353
*.pc
54+
55+
56+
# bld dir
57+
bld
58+
build
59+
build_emscripten
60+
bld_emscripten
61+
62+
# vscode
63+
.vscode
64+
65+
# Mac
66+
.DS_Store

.pre-commit-config.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
9+
- repo: https://github.com/pre-commit/mirrors-clang-format
10+
rev: v16.0.6
11+
hooks:
12+
- id: clang-format

0 commit comments

Comments
 (0)