-
Notifications
You must be signed in to change notification settings - Fork 21
Build matrix based on cmake #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b0f9fc8
9ca7c52
cfad5c6
44ab095
0132296
db8b4a0
a0820b8
645a151
ac2faec
c56bb9b
c240c04
80955ae
3bdb6b6
9037464
de05b50
55b504a
9eda303
c7a52e5
97be7b1
b1cbf5f
7ce130f
1f53408
5054824
6fee980
6e61b45
4211a6d
9f493e2
84171eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
|
|
||
| name: InChI build matrix | ||
|
|
||
| on: | ||
| push: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| define-matrix: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| matrix: ${{ steps.define-matrix.outputs.matrix }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Define build matrix | ||
| id: define-matrix | ||
| run: | | ||
| echo "matrix=$(cat .github/workflows/matrix.json| jq -c .)" >> $GITHUB_OUTPUT | ||
|
|
||
| build-inchi: | ||
| needs: define-matrix | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| ${{ fromJson(needs.define-matrix.outputs.matrix) }} | ||
|
|
||
| name: ${{ matrix.name }} | ||
| runs-on: ${{ matrix.os }} | ||
| container: | ||
| image: ${{ matrix.image || '' }} | ||
|
|
||
| steps: | ||
| - name: Install build dependencies | ||
| run: ${{ matrix.prebuild }} | ||
|
|
||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Visual Studio shell | ||
| if: runner.os == 'Windows' | ||
| uses: egor-tensin/vs-shell@v2 | ||
| with: | ||
| arch: x64 | ||
|
|
||
| - name: Build InChI | ||
| run: | | ||
| cmake -B builddir -G Ninja | ||
| cmake --build builddir | ||
|
|
||
| - name: save artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: inchi-${{ matrix.slug }}-${{ github.sha }} | ||
| path: builddir | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| if: matrix.slug != 'alpine' | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Install test dependencies | ||
| if: matrix.slug != 'alpine' | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -e INCHI-1-TEST[invariance-tests] | ||
|
|
||
| - name: Run executable tests | ||
| if: matrix.slug != 'alpine' | ||
| run: cmake --build builddir --target run-tests |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| [ | ||
| { | ||
| "os": "ubuntu-22.04", | ||
| "slug": "ubuntu", | ||
| "name": "Ubuntu 22.04", | ||
| "prebuild": "sudo apt update && sudo apt install -y cmake ninja-build" | ||
| }, | ||
| { | ||
| "os": "windows-2019", | ||
| "slug": "windows", | ||
| "name": "Windows Server 2019", | ||
| "prebuild": "choco install ninja" | ||
| }, | ||
| { | ||
| "os": "macos-14", | ||
| "slug": "macos", | ||
| "name": "MacOS 14", | ||
| "prebuild": "brew install ninja" | ||
| }, | ||
| { | ||
| "os": "ubuntu-22.04", | ||
| "slug": "alpine", | ||
| "name": "Alpine Linux", | ||
| "prebuild": "apk add bash git musl-dev gcc g++ make python3 py-pip cmake ninja", | ||
| "image": "python:3.12-alpine" | ||
| }, | ||
| { | ||
| "os": "ubuntu-22.04", | ||
| "slug": "gcc_latest", | ||
| "name": "GCC latest", | ||
| "prebuild": "apt update && apt install -y cmake ninja-build", | ||
| "image": "gcc:latest" | ||
| } | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| cmake_minimum_required(VERSION 3.18) | ||
|
|
||
| project( | ||
| inchi | ||
| VERSION 1.07 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have to think about how to parametrize the version. Preferably we would have a single source of truth for the version. But maybe outside of this PR's scope.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree on the single source for the version string; I guess it is possible to use several approaches, depending on how the release is handled: it can be read from a file, an env variable, from a workflow context variable, etc. I would just avoid putting it in the sources, it's harder to extract for other tools and usually harder to find. |
||
| ) | ||
|
|
||
| option(BUILD_SHARED_LIBS "Build using shared libraries" ON) | ||
|
|
||
| set( CMAKE_C_STANDARD 11 ) | ||
|
|
||
| # this works but maybe it's preferable to only export | ||
| # the symbols that are needed to consume the library | ||
| set( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON ) | ||
|
|
||
| add_subdirectory( INCHI-1-SRC/INCHI_BASE/src ) | ||
| add_subdirectory( INCHI-1-SRC/INCHI_API/libinchi/src ) | ||
| add_subdirectory( INCHI-1-SRC/INCHI_API/demos/inchi_main/src ) | ||
| add_subdirectory( INCHI-1-SRC/INCHI_API/demos/mol2inchi/src ) | ||
| add_subdirectory( INCHI-1-SRC/INCHI_API/demos/test_ixa/src ) | ||
| add_subdirectory( INCHI-1-SRC/INCHI_EXE/inchi-1/src ) | ||
|
|
||
| add_custom_target( run-tests | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add a target for running the tests against the shared library as well. |
||
| COMMAND pytest INCHI-1-TEST/tests/test_executable --exe-path $<TARGET_FILE:inchi-1> -vv | ||
| WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| add_executable( | ||
| inchi_main | ||
|
|
||
| e_0dstereo.c | ||
| e_ichimain.c | ||
| e_ichi_io.c | ||
| e_ichi_parms.c | ||
| e_inchi_atom.c | ||
| e_mol2atom.c | ||
| e_readinch.c | ||
| e_readmol.c | ||
| e_readstru.c | ||
| e_util.c | ||
| e_ichimain_a.c | ||
|
|
||
| ) | ||
|
|
||
| target_compile_definitions( | ||
| inchi_main | ||
| PRIVATE | ||
| BUILD_LINK_AS_DLL | ||
| TARGET_EXE_USING_API | ||
| ) | ||
|
|
||
| target_link_libraries( | ||
| inchi_main | ||
| PRIVATE | ||
| inchi | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| add_executable( | ||
| mol2inchi | ||
|
|
||
| mol2inchi.c | ||
| moreutil.c | ||
| ) | ||
|
|
||
| target_compile_definitions( | ||
| mol2inchi | ||
| PRIVATE | ||
| BUILD_LINK_AS_DLL | ||
| TARGET_EXE_USING_API | ||
| ) | ||
|
|
||
| target_link_libraries( | ||
| mol2inchi | ||
| PRIVATE | ||
| inchi | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| add_executable( | ||
| test_ixa | ||
|
|
||
| moreutil.c | ||
| test_ixa.c | ||
| ) | ||
| target_compile_definitions( | ||
| test_ixa | ||
| PRIVATE | ||
| BUILD_LINK_AS_DLL | ||
| TARGET_EXE_USING_API | ||
| ) | ||
|
|
||
| target_link_libraries( | ||
| test_ixa | ||
| PRIVATE | ||
| inchi | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| target_sources( | ||
| inchi | ||
| PRIVATE | ||
| ixa/ixa_inchikey_builder.c | ||
| ixa/ixa_read_mol.c | ||
| ixa/ixa_status.c | ||
| ixa/ixa_builder.c | ||
| ixa/ixa_mol.c | ||
| ixa/ixa_read_inchi.c | ||
|
|
||
| ichilnct.c | ||
| inchi_dll.c | ||
| inchi_dll_main.c | ||
| inchi_dll_a.c | ||
| inchi_dll_a2.c | ||
| inchi_dll_b.c | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| add_library( | ||
| inchi | ||
|
|
||
| ichican2.c | ||
| ichicano.c | ||
| ichi_io.c | ||
| ichierr.c | ||
| ichicans.c | ||
| ichiisot.c | ||
| ichimak2.c | ||
| ichimake.c | ||
| ichimap1.c | ||
| ichimap2.c | ||
| ichimap4.c | ||
| ichinorm.c | ||
| ichiparm.c | ||
| ichiprt1.c | ||
| ichiprt2.c | ||
| ichiprt3.c | ||
| ichiqueu.c | ||
| ichiring.c | ||
| ichisort.c | ||
| ichister.c | ||
| ichitaut.c | ||
| ichi_bns.c | ||
| ichiread.c | ||
| ichirvr1.c | ||
| ichirvr2.c | ||
| ichirvr3.c | ||
| ichirvr4.c | ||
| ichirvr5.c | ||
| ichirvr6.c | ||
| ichirvr7.c | ||
| ikey_dll.c | ||
| ikey_base26.c | ||
| mol_fmt1.c | ||
| mol_fmt2.c | ||
| mol_fmt3.c | ||
| mol2atom.c | ||
| mol_fmt4.c | ||
| readinch.c | ||
| runichi.c | ||
| runichi2.c | ||
| runichi3.c | ||
| runichi4.c | ||
| sha2.c | ||
| strutil.c | ||
| util.c | ||
| bcf_s.c | ||
| ) | ||
|
|
||
| target_link_libraries( | ||
| inchi | ||
| PUBLIC | ||
| # link libm in linux | ||
| $<$<BOOL:${LINUX}>:m> | ||
| ) | ||
|
|
||
| # not sure this can stay PRIVATE | ||
| target_compile_definitions( | ||
| inchi | ||
| PRIVATE | ||
| TARGET_API_LIB | ||
| COMPILE_ANSI_ONLY # why would one want to compile without this? | ||
| ) | ||
|
|
||
| set_target_properties( | ||
| inchi | ||
| PROPERTIES | ||
| VERSION ${inchi_VERSION} | ||
| SOVERSION 1 | ||
| ) | ||
|
|
||
| # makefile in INCHI-1-INCHI_API/libinchi/gcc | ||
| # applies a libinchi.map file to the linker (line 52 and bejond) | ||
| # is that necessary? can we do that with cmake? | ||
| # maybe we can acvhieve the same effect with another method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gcc_crash_report.txtused to be onmainat the timebuild_matrixwas branched off. It has since been removed.