#!/usr/bin/env bash # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. #################################################################### # This script is used to build Doris used in Baidu ############################################################## # the script generates src/be/src/common/version.h and # fe/src/main/java/org/apache/doris/common/Version.java which # contains the build version based on the git hash or svn revision. ############################################################## set -eo pipefail build_version_prefix="doris" build_version_major=0 build_version_minor=0 build_version_patch=0 build_version_rc_version="trunk" build_version="${build_version_prefix}-${build_version_major}.${build_version_minor}.${build_version_patch}-${build_version_rc_version}" unset LANG unset LC_CTYPE date="$(date +"%a, %d %b %Y %H:%M:%S %Z")" hostname="$(hostname)" cwd="$(pwd)" if [[ -z "${DORIS_HOME}" ]]; then ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" DORIS_HOME="${ROOT}/../.." echo "DORIS_HOME: ${DORIS_HOME}" fi if [[ -z "${DORIS_TEST_BINARY_DIR}" ]]; then if [[ -e "${DORIS_HOME}/fe/fe-core/target/generated-sources/build/org/apache/doris/common/Version.java" && -e "${DORIS_HOME}/gensrc/build/gen_cpp/version.h" ]]; then exit fi fi cd "${DORIS_HOME}" if [[ -d '.git' ]]; then revision="$(git log -1 --pretty=format:"%H")" short_revision="$(git log -1 --pretty=format:"%h")" url="git://${hostname}" else revision="Unknown" short_revision="${revision}" url="file://${hostname}" fi cd "${cwd}" build_hash="${url}@${revision}" build_short_hash="${short_revision}" build_time="${date}" build_info="${hostname}" if [[ -z "${JAVA_HOME}" ]]; then java_cmd="$(command -v java)" else java_cmd="${JAVA_HOME}/bin/java" fi if [[ ! -x "${java_cmd}" ]]; then echo "The JAVA_HOME environment variable is not defined correctly" echo "This environment variable is needed to run this program" echo "NB: JAVA_HOME should point to a JDK not a JRE" exit 1 fi java_version_str="$("${java_cmd}" -fullversion 2>&1 | sed -e 's/"/\\"/g')" echo "get java cmd: ${java_cmd}" echo "get java version: ${java_version_str}" VERSION_PACKAGE="${DORIS_HOME}/fe/fe-core/target/generated-sources/build/org/apache/doris/common" mkdir -p "${VERSION_PACKAGE}" cat >"${VERSION_PACKAGE}/Version.java" <"${GEN_CPP_DIR}/version.h" <