#!/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. ############################################################## build_version="trunk" unset LANG unset LC_CTYPE user=`whoami` date=`date +"%a, %d %b %Y %H:%M:%S %Z"` hostname=`hostname` cwd=`pwd` if [ -z ${DORIS_HOME+x} ] then ROOT=`dirname "$0"` ROOT=`cd "$ROOT"; 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 \ -a -e ${DORIS_HOME}/gensrc/build/gen_cpp/version.h ]; then exit fi fi cd ${DORIS_HOME} if [ -d .svn ]; then revision=`svn info | sed -n -e 's/Last Changed Rev: \(.*\)/\1/p'` short_revision="${revision}" url=`svn info | sed -n -e 's/^URL: \(.*\)/\1/p'` if echo ${url} | grep '\/tags\/' > /dev/null then build_version="`echo ${url} | sed 's/.*_\([0-9-]\+\)_PD_BL.*/\1/g' | sed 's/-/\./g'`" fi elif [ -d .git ]; then revision=`git log -1 --pretty=format:"%H"` short_revision=`git log -1 --pretty=format:"%h"` url="git://${hostname}${DORIS_HOME}" else revision="Unknown" short_revision="${revision}" url="file://${DORIS_HOME}" fi cd ${cwd} build_hash="${url}@${revision}" build_short_hash="${short_revision}" build_time="${date}" build_info="${user}@${hostname}" java_cmd= if [[ (-n "$JAVA_HOME") && (-x "$JAVA_HOME/bin/java") ]]; then java_cmd="$JAVA_HOME/bin/java" else echo "JAVA_HOME is not set, or java bin is not found" exit -1 fi java_version_str=`$java_cmd -fullversion 2>&1` java_version_str=$(echo $java_version_str | 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" <