Skip to content
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

Update client build script to be source of truth for java related installations #395

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Changes from all commits
Commits
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
29 changes: 23 additions & 6 deletions src/java-api-bindings/scripts/install_dependencies_and_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ Installs Maven, Java JDK and builds Tritonserver Java bindings
-j|--jar-install-path Path to install the bindings .jar
--javacpp-branch Javacpp-presets git path, default is https://github.com/bytedeco/javacpp-presets.git
--javacpp-tag Javacpp-presets branch tag, default "master"
--enable-developer-tools-server Include C++ bindings from developer_tools repository
--enable-developer-tools-server Include C++ bindings from developer_tools repository
--keep-build-dependencies Keep build dependencies instead of deleting
"

# Get all options:
OPTS=$(getopt -l ht:b:v:c:j:,help,triton-home,build-home:,maven-version:,core-tag:,jar-install-path:,javacpp-branch:,javacpp-tag:,enable-developer-tools-server -- "$@")
OPTS=$(getopt -l ht:b:v:c:j:,help,triton-home,build-home:,maven-version:,core-tag:,jar-install-path:,javacpp-branch:,javacpp-tag:,enable-developer-tools-server,keep-build-dependencies -- "$@")

TRITON_HOME="/opt/tritonserver"
BUILD_HOME="/tmp/build"
Expand All @@ -51,7 +52,9 @@ JAVACPP_BRANCH=${JAVACPP_BRANCH:="https://github.com/bytedeco/javacpp-presets.gi
JAVACPP_BRANCH_TAG=${JAVACPP_BRANCH_TAG:="master"}
CMAKE_VERSION=${CMAKE_VERSION:="3.21.1"}
export JAR_INSTALL_PATH="/workspace/install/java-api-bindings"
# Note: Following bashscript convention where True/success == 0 and False == 1
export INCLUDE_DEVELOPER_TOOLS_SERVER=1
KEEP_BUILD_DEPENDENCIES=1

for OPTS; do
case "$OPTS" in
Expand All @@ -66,11 +69,13 @@ for OPTS; do
;;
-b|--build-home)
BUILD_HOME=$2
export MAVEN_PATH=${BUILD_HOME}/apache-maven-${MAVEN_VERSION}/bin/mvn
shift 2
echo "Build home set to: ${BUILD_HOME}"
;;
-v|--maven-version)
MAVEN_VERSION=$2
export MAVEN_PATH=${BUILD_HOME}/apache-maven-${MAVEN_VERSION}/bin/mvn
echo "Maven version is set to: ${MAVEN_VERSION}"
shift 2
;;
Expand Down Expand Up @@ -98,6 +103,10 @@ for OPTS; do
export INCLUDE_DEVELOPER_TOOLS_SERVER=0
echo "Including developer tools server C++ bindings"
;;
--keep-build-dependencies)
KEEP_BUILD_DEPENDENCIES=0
echo "Including developer tools server C++ bindings"
Copy link
Contributor

Choose a reason for hiding this comment

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

If the below comment gets addressed, we may want to review the other code for things like this which will be inconsistent (e.g. if KEEP=0, then the statement should say we are excluding developer tools bindings).

;;
esac
done
set -x
Expand Down Expand Up @@ -128,14 +137,22 @@ cd ${BUILD_HOME}
git clone --single-branch --depth=1 -b ${JAVACPP_BRANCH_TAG} ${JAVACPP_BRANCH}
cd javacpp-presets

${MAVEN_PATH} clean install --projects .,tritonserver
${MAVEN_PATH} clean install -f platform --projects ../tritonserver/platform -Djavacpp.platform=linux-x86_64
# Remove developer_tools/server related build
if [ ${INCLUDE_DEVELOPER_TOOLS_SERVER} -eq 1 ]; then
rm -r tritonserver/src/gen
rm tritonserver/src/main/java/org/bytedeco/tritonserver/presets/tritondevelopertoolsserver.java
fi

mvn clean install --projects .,tritonserver
mvn clean install -f platform --projects ../tritonserver/platform -Djavacpp.platform=linux-x86_64

# Copy over the jar to a specific location
mkdir -p ${JAR_INSTALL_PATH}
cp ${BUILD_HOME}/javacpp-presets/tritonserver/platform/target/tritonserver-platform-*shaded.jar ${JAR_INSTALL_PATH}/tritonserver-java-bindings.jar

rm -r ${BUILD_HOME}/javacpp-presets/
rm -r /root/.m2/repository
if [ ${KEEP_BUILD_DEPENDENCIES} -eq 1 ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like the reverse. Shouldn't this be if it's not equal to 1, then delete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have been pretty bad at following the guidelines for bash scripting. I would advocate for True == 0 instead of True == 1

Copy link
Contributor

Choose a reason for hiding this comment

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

Great find! Let's start a conversation offline about this. This is news to me. I don't want to block this PR, but I think we'd want to decide this on a team level and have a PR to standardize all of our tests. Otherwise, it would be inconsistent and could lead to confusion/problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this change has been propagated to the javacpp side, can we do this in a separate PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, but please let's do it ASAP. We do not want this getting forgotten and us being inconsistent.

rm -r ${BUILD_HOME}/javacpp-presets/
rm -r /root/.m2/repository
fi

set +x
Loading