Skip to content

Commit

Permalink
Merge pull request #483 from rdkit/fix/debug-build
Browse files Browse the repository at this point in the history
Fix/debug build
  • Loading branch information
MichelML authored Aug 23, 2024
2 parents 5dc75eb + 6c57030 commit 57bc26c
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 17 deletions.
69 changes: 56 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
FROM debian:buster as build-stage
# Example usage of this Dockerfile:
# (the build-arg arguments are all optional)
#
# 1. cd to Code/MinimalLib/docker
# cd Code/MinimalLib/docker
#
# 2. build the JS and WASM libraries
# (the build-arg arguments are all optional)
# docker build -t rdkit-minimallib --network=host \
# --build-arg "RDKIT_GIT_URL=https://github.com/myfork/rdkit.git" \
# --build-arg "RDKIT_BRANCH=mybranch" .
#
# 3. create a temporary container and copy built libraries
# from the container to your local filesystem, then destroy
# the temporary container
# docker create --name=rdkit-minimallib-container rdkit-minimallib:latest --entrypoint /
# docker cp rdkit-minimallib-container:/RDKit_minimal.js ../demo
# docker cp rdkit-minimallib-container:/RDKit_minimal.wasm ../demo
# docker rm rdkit-minimallib-container


ARG RDKIT_GIT_URL="https://github.com/rdkit/rdkit.git"
ARG RDKIT_BRANCH="master"
ARG EMSDK_VERSION="latest"
ARG BOOST_MAJOR_VERSION="1"
ARG BOOST_MINOR_VERSION="84"
ARG BOOST_PATCH_VERSION="0"

FROM debian:bookworm as build-stage
ARG RDKIT_GIT_URL
ARG RDKIT_BRANCH
ARG EMSDK_VERSION
ARG BOOST_MAJOR_VERSION
ARG BOOST_MINOR_VERSION
ARG BOOST_PATCH_VERSION

LABEL maintainer="Greg Landrum <[email protected]>"

RUN apt-get update && apt-get upgrade -y && apt install -y \
Expand All @@ -9,15 +44,17 @@ RUN apt-get update && apt-get upgrade -y && apt install -y \
g++ \
libeigen3-dev \
git \
nodejs \
libfreetype6-dev
xz-utils \
nodejs

ENV LANG C

WORKDIR /opt
RUN wget -q https://boostorg.jfrog.io/artifactory/main/release/1.67.0/source/boost_1_67_0.tar.gz && \
tar xzf boost_1_67_0.tar.gz
WORKDIR /opt/boost_1_67_0
ARG BOOST_DOT_VERSION="${BOOST_MAJOR_VERSION}.${BOOST_MINOR_VERSION}.${BOOST_PATCH_VERSION}"
ARG BOOST_UNDERSCORE_VERSION="${BOOST_MAJOR_VERSION}_${BOOST_MINOR_VERSION}_${BOOST_PATCH_VERSION}"
RUN wget -q https://boostorg.jfrog.io/artifactory/main/release/${BOOST_DOT_VERSION}/source/boost_${BOOST_UNDERSCORE_VERSION}.tar.gz && \
tar xzf boost_${BOOST_UNDERSCORE_VERSION}.tar.gz
WORKDIR /opt/boost_${BOOST_UNDERSCORE_VERSION}
RUN ./bootstrap.sh --prefix=/opt/boost --with-libraries=system && \
./b2 install

Expand All @@ -26,21 +63,21 @@ WORKDIR /opt
RUN git clone https://github.com/emscripten-core/emsdk.git

WORKDIR /opt/emsdk
RUN ./emsdk update-tags && \
./emsdk install latest && \
./emsdk activate latest
RUN ./emsdk install ${EMSDK_VERSION} && \
./emsdk activate ${EMSDK_VERSION}

#RUN source ./emsdk_env.sh

RUN mkdir /src
WORKDIR /src
ENV RDBASE=/src/rdkit
ARG RDKIT_BRANCH=${RDKIT_BRANCH:-master}
RUN git clone https://github.com/rdkit/rdkit.git
RUN git clone ${RDKIT_GIT_URL}
WORKDIR $RDBASE
RUN git fetch --all --tags && \
git checkout $RDKIT_BRANCH
git checkout ${RDKIT_BRANCH}

RUN mkdir build
WORKDIR build
WORKDIR $RDBASE/build

RUN echo "source /opt/emsdk/emsdk_env.sh > /dev/null 2>&1" >> ~/.bashrc
SHELL ["/bin/bash", "-c", "-l"]
Expand All @@ -60,6 +97,12 @@ RUN emcmake cmake -DBoost_INCLUDE_DIR=/opt/boost/include -DRDK_BUILD_FREETYPE_SU
RUN cp /src/rdkit/External/INCHI-API/src/INCHI_BASE/src/util.c /src/rdkit/External/INCHI-API/src/INCHI_BASE/src/util.c.bak && \
sed 's/&& defined(__APPLE__)//' /src/rdkit/External/INCHI-API/src/INCHI_BASE/src/util.c.bak > /src/rdkit/External/INCHI-API/src/INCHI_BASE/src/util.c

# comment out a line which causes a compilation error on some platforms
# (based on the change which has already been applied to the RapidJSON master branch, see
# https://github.com/Tencent/rapidjson/blob/ab1842a2dae061284c0a62dca1cc6d5e7e37e346/include/rapidjson/document.h#L414)
RUN sed -i 's|^\( *\)\(GenericStringRef\& operator=(const GenericStringRef\& rhs) { s = rhs.s; length = rhs.length; } *\)$|\1//\2|' \
/src/rdkit/External/rapidjson-1.1.0/include/rapidjson/document.h

# build and "install"
RUN make -j2 RDKit_minimal && \
cp Code/MinimalLib/RDKit_minimal.* ../Code/MinimalLib/demo/
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@rdkit/rdkit",
"version": "2023.9.2-1.0.0",
"private": true,
"version": "2024.3.5-1.0.0",
"private": false,
"description": "JavaScript distribution of cheminformatics functionality from the RDKit - a C++ library for cheminformatics.",
"main": "dist/RDKit_minimal.js",
"types": "dist/index.d.ts",
Expand Down
21 changes: 19 additions & 2 deletions scripts/build_rdkitjs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,27 @@ mkdir -p $MINIMALLIB_OUTPUT_PATH
# legacy minimallib output path
LEGACY_MINIMALLIB_OUTPUT_PATH="Code/MinimalLib/dist"
rm -rf $LEGACY_MINIMALLIB_OUTPUT_PATH
mkdir -p $LEGACY_MINIMALLIB_OUTPUT_PATH
mkdir -p $LEGACY_MINIMALLIB_OUTPUT_PATH

# Build distribution files
DOCKER_BUILDKIT=1 docker build --no-cache -f Dockerfile --build-arg RDKIT_BRANCH=$RDKIT_BRANCH -o $MINIMALLIB_OUTPUT_PATH .
DOCKER_BUILDKIT=1 docker build --no-cache --platform=linux/amd64 -f Dockerfile --build-arg RDKIT_BRANCH=$RDKIT_BRANCH -o $MINIMALLIB_OUTPUT_PATH .

# Make dist files executable
chmod a+rwx $MINIMALLIB_OUTPUT_PATH/RDKit_minimal.js
chmod a+rwx $MINIMALLIB_OUTPUT_PATH/RDKit_minimal.wasm

# Add a copy of the distribution files at the original rdkit location
# for backwards compatibility
cp $MINIMALLIB_OUTPUT_PATH/RDKit_minimal.js $LEGACY_MINIMALLIB_OUTPUT_PATH/RDKit_minimal.js
cp $MINIMALLIB_OUTPUT_PATH/RDKit_minimal.wasm $LEGACY_MINIMALLIB_OUTPUT_PATH/RDKit_minimal.wasm

# Move docs file in dist folder for demos to work properly
cp docs/demo.html $MINIMALLIB_OUTPUT_PATH/demo.html
cp docs/GettingStartedInJS.html $MINIMALLIB_OUTPUT_PATH/GettingStartedInJS.html

# Log build completed
echo "Build completed"
echo "MinimalLib distribution files are at $MINIMALLIB_OUTPUT_PATH"

# Make dist files executable
chmod a+rwx $MINIMALLIB_OUTPUT_PATH/RDKit_minimal.js
Expand Down
8 changes: 8 additions & 0 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set -e

# Set branch to release
RDKIT_BRANCH="$RDKIT_BRANCH"
MINIMALLIB_OUTPUT_PATH="dist"

# Build distribution files
DOCKER_BUILDKIT=1 docker build --no-cache --platform=linux/amd64 -f Dockerfile --build-arg RDKIT_BRANCH=$RDKIT_BRANCH -o $MINIMALLIB_OUTPUT_PATH .

0 comments on commit 57bc26c

Please sign in to comment.