Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b0f9fc8
add support for cmake builds
giallu Jul 24, 2024
9ca7c52
fix OSX compilation
giallu Jul 24, 2024
cfad5c6
fix windows compilation
giallu Jul 24, 2024
44ab095
allow building static library
giallu Jul 24, 2024
0132296
ignore default vscode/cmake build directory
giallu Jul 24, 2024
db8b4a0
Add library SOVERSION based on project version
giallu Jul 26, 2024
a0820b8
add workflow to test builds on all platforms
giallu Aug 5, 2024
645a151
run apt with sudo
giallu Aug 5, 2024
ac2faec
use ninja to build on all platforms
giallu Aug 5, 2024
c56bb9b
Update build.yml
giallu Aug 8, 2024
c240c04
build inchi-1 executable
giallu Aug 4, 2024
80955ae
move inchi-1 specific functions out of library
giallu Sep 19, 2024
3bdb6b6
inline macro strings to fix link errors
giallu Sep 27, 2024
9037464
add Alpine linux build
giallu Sep 28, 2024
de05b50
fix moreutil.c compilation in alpine
giallu Sep 28, 2024
55b504a
add gcc:latest build
giallu Oct 11, 2024
9eda303
create a proper build matrix
giallu Oct 19, 2024
c7a52e5
save builddir as artifact
giallu Oct 21, 2024
97be7b1
move matrix definition to JSON file
giallu Oct 21, 2024
b1cbf5f
add exe tests
giallu Oct 21, 2024
7ce130f
run everything in the same job for now
giallu Oct 21, 2024
1f53408
don't interrupt other builds on first failure
giallu Oct 22, 2024
5054824
run tests from cmake so it knows the exe path
giallu Oct 22, 2024
6fee980
show verbose otuput from tests
giallu Oct 23, 2024
6e61b45
build inchi-1 statically
giallu Nov 11, 2024
4211a6d
try python:3.12-alpine image
giallu Nov 18, 2024
9f493e2
install deps before checkout
giallu Nov 18, 2024
84171eb
skip tests on alpine, they are going to fail anyway
giallu Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/build.yml
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
34 changes: 34 additions & 0 deletions .github/workflows/matrix.json
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"
}
]
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ __pycache__
*.egg-info/
# Ignore core dump files
core.*[0-9]
gcc_crash_report.txt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcc_crash_report.txt used to be on main at the time build_matrix was branched off. It has since been removed.


# default vscode/cmake build directory
build/
26 changes: 26 additions & 0 deletions CMakeLists.txt
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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.
Since this will require some refactoring of the test environment I'd prefer to do so in another PR in order to not bloat the present one.

COMMAND pytest INCHI-1-TEST/tests/test_executable --exe-path $<TARGET_FILE:inchi-1> -vv
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
29 changes: 29 additions & 0 deletions INCHI-1-SRC/INCHI_API/demos/inchi_main/src/CMakeLists.txt
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
)
19 changes: 19 additions & 0 deletions INCHI-1-SRC/INCHI_API/demos/mol2inchi/src/CMakeLists.txt
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
)
3 changes: 1 addition & 2 deletions INCHI-1-SRC/INCHI_API/demos/mol2inchi/src/mol2inchi.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ int m2i_WorkPool_wait_and_print_all( m2i_WorkPool *pool, THREAD_PTR *Thread );

#ifdef _WIN32
#define M2I_THREADFUNC unsigned __stdcall
#endif
#if ( !defined(_WIN32) && defined(__linux__) )
#else
#define M2I_THREADFUNC void *
#endif

Expand Down
4 changes: 2 additions & 2 deletions INCHI-1-SRC/INCHI_API/demos/mol2inchi/src/moreutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#ifdef _WIN32
#include <windows.h>
#else
#include <sys/time.h>
#endif

#include "moreutil.h"
Expand Down Expand Up @@ -764,8 +765,7 @@ unsigned int get_msec_timer( void )

#if ( defined(_WIN32) && defined(_MSC_VER) )
t = GetTickCount( );
#endif
#if ( !defined(_WIN32) && defined(__linux__) )
#else
/* NB: not reboot/date-change safe */
struct timeval tv;
gettimeofday( &tv, NULL );
Expand Down
18 changes: 18 additions & 0 deletions INCHI-1-SRC/INCHI_API/demos/test_ixa/src/CMakeLists.txt
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
)
17 changes: 17 additions & 0 deletions INCHI-1-SRC/INCHI_API/libinchi/src/CMakeLists.txt
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
)
77 changes: 77 additions & 0 deletions INCHI-1-SRC/INCHI_BASE/src/CMakeLists.txt
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
2 changes: 0 additions & 2 deletions INCHI-1-SRC/INCHI_BASE/src/ichimain.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,6 @@ void EditINCHI_HidePolymerZz( INCHI_IOSTREAM *out, int n_pzz, int n_zy );

/* MISCELLANEOUS */


void SplitTime( unsigned long ulTotalTime, int *hours, int *minutes, int *seconds, int *mseconds );
void set_line_separators( int bINChIOutputOptions, char **pLF, char **pTAB );
void save_command_line( int argc, char *argv[], INCHI_IOSTREAM *plog );
void emit_empty_inchi( INPUT_PARMS *ip, long num_inp,
Expand Down
Loading