Skip to content

Commit

Permalink
Compile executable
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCBrammer committed Sep 20, 2024
1 parent 9d88ae5 commit 08dcd9c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ INCHI-1-TEST/config/
INCHI-1-TEST/data/
INCHI-1-TEST/docs/
INCHI-1-TEST/libs/
INCHI-1-TEST/exes/
INCHI-1-TEST/tests/
**/__pycache__/
2 changes: 1 addition & 1 deletion .github/actions/compile_inchi_lib/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ runs:
- run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE" # https://github.com/actions/runner-images/issues/6775
mkdir "$GITHUB_WORKSPACE/$LIB_DIR"
./INCHI-1-TEST/compile_inchi_lib.sh $COMMIT "$GITHUB_WORKSPACE/$LIB_DIR"
./INCHI-1-TEST/compile_inchi.sh $COMMIT "$GITHUB_WORKSPACE/$LIB_DIR" lib
# Rename library to libinchi.so.main, since that's the name the tests expect.
mv "$GITHUB_WORKSPACE/$LIB_DIR/libinchi.so.$COMMIT" "$GITHUB_WORKSPACE/$LIB_DIR/libinchi.so.main"
shell: bash
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
INCHI-1-TEST/**/*.so*
INCHI-1-TEST/exes
INCHI-1-TEST/data/**/*.html
INCHI-1-TEST/data/**/*.log
INCHI-1-TEST/data/pubchem/compound
Expand Down
2 changes: 1 addition & 1 deletion INCHI-1-TEST/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN git config user.name "inchi" && \
ENV inchi_versions="v1.05 v1.06 v1.07.0 main"
ENV lib_dir="/inchi/INCHI-1-TEST/libs"
RUN mkdir $lib_dir && for version in $inchi_versions; do \
/inchi/INCHI-1-TEST/compile_inchi_lib.sh "$version" "$lib_dir" || exit 1; \
/inchi/INCHI-1-TEST/compile_inchi.sh "$version" "$lib_dir" lib || exit 1; \
done

FROM gcc:14-bookworm AS inchi_test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,30 @@

set -e

inchi_version=$1 # Must be one of the tags in `git tag`, branches in `git branch`, or a commit hash.
inchi_lib_dir=$2 # Path must be absolute.
inchi_version=$1 # Must be one of the tags in `git tag`, branches in `git branch`, or a commit hash.
inchi_dir=$2 # Must be absolute.
artifact=$3 # Must be "exe" or "lib".

if [ "$artifact" == "exe" ]; then
makefile_dir="INCHI-1-SRC/INCHI_EXE/inchi-1/gcc"
make_args="BIN_DIR=$inchi_dir"
elif [ "$artifact" == "lib" ]; then
makefile_dir="INCHI-1-SRC/INCHI_API/libinchi/gcc"
make_args="LIB_DIR=$inchi_dir VERSION=.$inchi_version"
else
echo "Invalid artifact type: $artifact. Must be 'exe' or 'lib'."
exit 1
fi

current_branch=$(git rev-parse --abbrev-ref HEAD)
makefile_dir="INCHI-1-SRC/INCHI_API/libinchi/gcc"
checkout_successful=0
cleanup() {
# Starting with v1.07.0 there's a clean target in the makefile (`make -C $makefile_dir clean`).
# However, for consistency across versions we're manually removing the object files
# that are left over from compilation.
find $makefile_dir -name "*.o" -type f -delete
# Switch back to the branch that was checked out prior to checking out <inchi_version>.
git checkout $current_branch
git checkout "$current_branch"
}
# Register cleanup to be called on EXIT.
trap cleanup EXIT
Expand All @@ -24,15 +36,15 @@ if [ -n "$(git status --porcelain)" ]; then
exit 1
fi

if git rev-parse --verify --quiet refs/tags/$inchi_version; then
if git rev-parse --verify --quiet refs/tags/"$inchi_version"; then
echo "Checking out version tag '$inchi_version'."
git checkout "tags/$inchi_version"
checkout_successful=1
fi

if git rev-parse --verify --quiet $inchi_version; then
if git rev-parse --verify --quiet "$inchi_version"; then
echo "Checking out branch or commit '$inchi_version'."
git checkout $inchi_version
git checkout "$inchi_version"
checkout_successful=1
fi

Expand All @@ -41,5 +53,4 @@ if [ $checkout_successful -eq 0 ]; then
exit 1
fi

# Generate libinchi.so.<inchi_version>.
make -C $makefile_dir -j LIB_DIR=$inchi_lib_dir VERSION=.$inchi_version
echo "$make_args" | xargs make -C $makefile_dir -j
2 changes: 1 addition & 1 deletion INCHI-1-TEST/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You can now run the commands that are mentioned in the remainder of this README.

If you prefer, run the tests in the [Visual Studio Code devcontainer](https://code.visualstudio.com/docs/devcontainers/containers)
that's specified under [.devcontainer.json](../../.devcontainer.json).
Note that in the devcontainer, you'll have to compile the InChI libraries yourself, see `INCHI-1-TEST/compile_inchi_lib.sh` for details.
Note that in the devcontainer, you'll have to compile the InChI libraries yourself, see `INCHI-1-TEST/compile_inchi.sh` for details.
The test pipeline expects the library under `INCHI-1-TEST/libs`, see `INCHI-1-TEST/src/inchi_tests/run_tests.py`.

## Datasets
Expand Down

0 comments on commit 08dcd9c

Please sign in to comment.