Repository navigation
Expand file tree
/
Copy pathpremake
More file actions
125 lines (110 loc) · 5.15 KB
/
Copy pathpremake
File metadata and controls
125 lines (110 loc) · 5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/sh
#
# This script allows the sketcher repo to be built using buildinger
# (the Schrodinger internal build system)
#
# Parse command line arguments
BUILD_TYPE="Release"
while [ $# -gt 0 ]; do
case "$1" in
-g) BUILD_TYPE="Debug"; shift ;;
*) echo "Unrecognized option $1"; exit 1 ;;
esac
done
# Source build environment and set error handling
. $SCHRODINGER_SRC/mmshare/build_env
set -euo pipefail
# Define directory paths
SRC_DIR=$SCHRODINGER_SRC/sketcher
BUILD_DIR=$SCHRODINGER/sketcher
# SCHRODINGER_LIB is exported by build_env and points at the package factory
# environment selected for this build (e.g. schrodinger, schrodinger-gfortran).
PF_DIR=$SCHRODINGER_LIB
if [[ "$OSTYPE" == "msys" ]]; then
PF_DIR=$(cygpath -m $PF_DIR)
fi
ZLIB_DIR=$(ls -d $PF_DIR/zlib-*)
EIGEN_DIR=$(ls -d $PF_DIR/share/eigen3)
COORDGEN_DIR=$(ls -d $PF_DIR/coordgenlibs-*/lib/cmake)
# Some environments install maeparser into its own versioned directory, while
# others install it flat into the environment's top level lib directory.
MAEPARSER_DIR=$(ls -d $PF_DIR/maeparser-*/lib/cmake 2>/dev/null || echo $PF_DIR/lib/cmake)
SQLITE_DIR=$(ls -d $PF_DIR/sqlite-*)
XZ_DIR=$(ls -d $PF_DIR/xz-*)
ZSTD_DIR=$(ls -d $PF_DIR/zstd-*)
# Build CMake prefix path
CMAKE_PREFIX_PATH="$PF_DIR;$ZLIB_DIR;$EIGEN_DIR;$COORDGEN_DIR;$MAEPARSER_DIR;$SQLITE_DIR"
# Some package factory libraries record install names pointing at the build
# machine's staging paths, so dyld needs to be told where they really are.
# macOS strips DYLD_* across /bin/sh, which both $SCHRODINGER/run and the
# pytest console script are, so re-inject it and start pytest from python.
PYTEST_CMD="$SCHRODINGER/run pytest"
if [[ "$OSTYPE" == darwin* ]]; then
PYTEST_CMD="$SCHRODINGER/run /usr/bin/env DYLD_LIBRARY_PATH=$ZLIB_DIR/lib:$XZ_DIR/lib:$SQLITE_DIR/lib python3 $SCHRODINGER/internal/bin/pytest"
fi
# The prebuilt RDKit libraries have transitive dependencies (e.g. libexpat)
# that live in the environment's top level lib directory. CMake only derives
# rpaths from the directories we link against, so add it explicitly; libzstd
# likewise, from its own versioned directory.
BUILD_RPATH="$PF_DIR/lib;$ZSTD_DIR/lib"
# Configure compiler for Windows
CXX_COMPILER=""
if [[ "$OSTYPE" == "msys" ]]; then
CXX_COMPILER=$(cygpath `which cl.exe`)
fi
# Ensure build directory exists
mkdir -p "$BUILD_DIR"
# Update rpaths for shared libraries on MacOS
POST_BUILD_COMMANDS=""
if [[ "$OSTYPE" == darwin* ]]; then
# zlib, xz and sqlite ship install names pointing at build staging paths,
# which rpath cannot redirect; rewrite them to the macOS copies. Read them
# from the packages as rebuilds change them. grep avoids re-signing
# libraries that need nothing.
ZLIB_ID=$(otool -D $ZLIB_DIR/lib/libz.1.dylib | tail -1)
XZ_ID=$(otool -D $XZ_DIR/lib/liblzma.5.dylib | tail -1)
SQLITE_ID=$(otool -D $SQLITE_DIR/lib/libsqlite3.dylib | tail -1)
POST_BUILD_COMMANDS="@{ find $BUILD_DIR \\( -name '*.dylib' -o -type f -perm +111 \\) ! -type l; find $PF_DIR/lib -maxdepth 1 -name '*.dylib' ! -type l; } | while read target; do grep -q placehold \"\$\$target\" 2>/dev/null || continue; install_name_tool -change $ZLIB_ID /usr/lib/libz.1.dylib \"\$\$target\"; install_name_tool -change $XZ_ID /usr/lib/liblzma.5.dylib \"\$\$target\"; install_name_tool -change $SQLITE_ID /usr/lib/libsqlite3.dylib \"\$\$target\"; done; true"
fi
# Start with a fresh CMake cache if the compiler has moved, since CMake
# considers the compiler immutable after the build tree has been configured.
# Without this, incremental Windows builds will fail whenever mmshare's
# dependencies change, as that causes buildinger to create a new buildvenv
# with a slightly different path, meaning that the path to MSVC will change.
ADDITIONAL_CMAKE_CONFIGURE_ARGS=""
if [ -n "$CXX_COMPILER" ]; then
CACHED_CXX_COMPILER=$(sed -n 's/^CMAKE_CXX_COMPILER:[^=]*=//p' \
"$BUILD_DIR/CMakeCache.txt" 2>/dev/null || true)
NORMALIZED_CXX_COMPILER=$(cygpath -m "$CXX_COMPILER")
NORMALIZED_CACHED_CXX_COMPILER=""
if [ -n "$CACHED_CXX_COMPILER" ]; then
NORMALIZED_CACHED_CXX_COMPILER=$(cygpath -m "$CACHED_CXX_COMPILER")
fi
if [ "$NORMALIZED_CACHED_CXX_COMPILER" != "$NORMALIZED_CXX_COMPILER" ]; then
ADDITIONAL_CMAKE_CONFIGURE_ARGS="--fresh"
fi
fi
# Generate Makefile wrapper
cat > "$BUILD_DIR/Makefile" << EOF
.PHONY: all test memtest
all:
cmake -B "$BUILD_DIR" \\
-S "$SRC_DIR" \\
-G Ninja \\
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \\
-DENFORCE_DEPENDENCY_VERSIONS=OFF \\
-DBUILD_SHARED_LIBS=ON \\
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \\
-DCMAKE_BUILD_RPATH="$BUILD_RPATH" \\
${CXX_COMPILER:+-DCMAKE_CXX_COMPILER="$CXX_COMPILER"} \\
$ADDITIONAL_CMAKE_CONFIGURE_ARGS
cmake --build $BUILD_DIR --config $BUILD_TYPE
cmake --install $BUILD_DIR --config $BUILD_TYPE --prefix $BUILD_DIR
$POST_BUILD_COMMANDS
test:
SKETCHER_SOURCE_DIR=$SRC_DIR $PYTEST_CMD --rootdir=$BUILD_DIR -n auto \$(TEST_ARGS)
memtest:
$SCHRODINGER/run ctest --build-config $BUILD_TYPE --test-dir $SCHRODINGER/sketcher -L memtest --output-on-failure
EOF
# buildinger expects stdout to define variables
echo "BUILD_DIR: $BUILD_DIR"