Blame OpenIb_Host/rpm_runmake

Packit 857059
#!/bin/bash
Packit 857059
# BEGIN_ICS_COPYRIGHT8 ****************************************
Packit 857059
# 
Packit 857059
# Copyright (c) 2015-2017, Intel Corporation
Packit 857059
# 
Packit 857059
# Redistribution and use in source and binary forms, with or without
Packit 857059
# modification, are permitted provided that the following conditions are met:
Packit 857059
# 
Packit 857059
#     * Redistributions of source code must retain the above copyright notice,
Packit 857059
#       this list of conditions and the following disclaimer.
Packit 857059
#     * Redistributions in binary form must reproduce the above copyright
Packit 857059
#       notice, this list of conditions and the following disclaimer in the
Packit 857059
#       documentation and/or other materials provided with the distribution.
Packit 857059
#     * Neither the name of Intel Corporation nor the names of its contributors
Packit 857059
#       may be used to endorse or promote products derived from this software
Packit 857059
#       without specific prior written permission.
Packit 857059
# 
Packit 857059
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit 857059
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 857059
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Packit 857059
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
Packit 857059
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 857059
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Packit 857059
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Packit 857059
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Packit 857059
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 857059
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 857059
# 
Packit 857059
# END_ICS_COPYRIGHT8   ****************************************
Packit 857059
##
Packit 857059
## rpm_runmake
Packit 857059
## -----------
Packit 857059
## Perform a full build
Packit 857059
## This is used within the FF src rpm by the ff_build.sh script
Packit 857059
## and for in-place builds its invoked directly by runmake
Packit 857059
## When this is invoked, the current directory will be the TL_DIR for
Packit 857059
## the source tree of FF
Packit 857059
##
Packit 857059
## Usage:
Packit 857059
##	rpm_runmake [-B 'build_config'] [-n]
Packit 857059
##			or
Packit 857059
##	rpm_runmake -r [-B 'build_config'] [-C] [-n]
Packit 857059
##
Packit 857059
## Arguments:
Packit 857059
##	-B build_config	release type to build, (debug/release). default is release
Packit 857059
##	-r 		rerun the build in place without doing a new checkout/tag
Packit 857059
##	-C		don't clobber prior to the rerun
Packit 857059
##	-n		No build.  Useful for checking build machine
Packit 857059
##
Packit 857059
## In addition, the following environment variables are expected to be set:
Packit 857059
##	RELEASE_TAG, BRANCH_TAG, BUILD_TARGET, PRODUCT, RELEASE_HOME, BUILD_CONFIG 
Packit 857059
##	The target command is expected to have already been run to set up the
Packit 857059
##	environment for the specified target
Packit 857059
##
Packit 857059
##	re-run can be used for 2 situations:
Packit 857059
##	1. re-run a failed build to correct incorrect weeklybuild arguments
Packit 857059
##		or other non-source code related problems (out of disk space)
Packit 857059
##	2. re-run a build for a different BUILD_TARGET_OS_VERSION while using the same
Packit 857059
##		source code image/tag
Packit 857059
##	If the source code needs to be corrected, a full weeklybuild should be run
Packit 857059
##	after the correction such that the code is properly tagged.
Packit 857059
##
Packit 857059
##	Since weeklybuild and target commands always set BUILD_CONFIG, this
Packit 857059
##	script ignores BUILD_CONFIG.  As such the BuildOptions file
Packit 857059
##	or the -B argument completely control BUILD_CONFIG for this product.
Packit 857059
Packit 857059
# A given release will be targeted for a specific version of ofed
Packit 857059
# however we allow build.config to override if needed
Packit 857059
export OFED_STACK_PREFIX=${OFED_STACK_PREFIX:-/usr}
Packit 857059
Packit 857059
Usage()
Packit 857059
{
Packit 857059
	# include "ERROR" in message so weeklybuild catches it in error log
Packit 857059
	echo "ERROR: rpm_runmake failed" >&2
Packit 857059
	echo "Usage: rpm_runmake [-B 'build_config'] [-n]" >&2
Packit 857059
	echo "            OR" >&2
Packit 857059
	echo "       rpm_runmake -r [-B 'build_config'] [-C] [-n]" >&2
Packit 857059
	exit 2
Packit 857059
}
Packit 857059
Packit 857059
showbuild()
Packit 857059
{
Packit 857059
	# output summary of what we are building to stdout
Packit 857059
	echo "Building for $SUBPRODUCT $BUILD_TARGET $BUILD_CONFIG $(date)..."
Packit 857059
	#echo "Building for $BUILD_TARGET_OS $BUILD_TARGET $BUILD_TARGET_OS_VERSION $BUILD_CONFIG $(date)..."
Packit 857059
}
Packit 857059
Packit 857059
build_config=
Packit 857059
rerun=n
Packit 857059
Cflag=n
Packit 857059
while getopts B:rCn param
Packit 857059
do
Packit 857059
	case $param in
Packit 857059
	r)
Packit 857059
		rerun=y;;
Packit 857059
	B)
Packit 857059
		build_config="$OPTARG";;
Packit 857059
	C)
Packit 857059
		Cflag=y;;
Packit 857059
	n)
Packit 857059
		nflag=y;;
Packit 857059
	?)
Packit 857059
		Usage
Packit 857059
	esac
Packit 857059
done
Packit 857059
shift $(($OPTIND -1))
Packit 857059
Packit 857059
if [ $# != 0 ]
Packit 857059
then
Packit 857059
		Usage
Packit 857059
fi
Packit 857059
Packit 857059
if [ -z "$build_config" ]
Packit 857059
then
Packit 857059
	# default to release build
Packit 857059
	export BUILD_CONFIG=release
Packit 857059
elif [ "$build_config" != debug -a "$build_config" != release ]
Packit 857059
then
Packit 857059
	Usage
Packit 857059
else
Packit 857059
	export BUILD_CONFIG="$build_config"
Packit 857059
fi
Packit 857059
Packit 857059
export PROJ_FILE_DIR=OpenIb_Host
Packit 857059
Packit 857059
if [ "$BUILD_WITH_STACK" = "OPENIB" ]
Packit 857059
then
Packit 857059
	if [ ! -d $OFED_STACK_PREFIX ]
Packit 857059
	then
Packit 857059
		echo "$0: ERROR: OFED stack not found: $OFED_STACK_PREFIX" >&2
Packit 857059
		exit 1
Packit 857059
	fi
Packit 857059
	echo "Stack to build for: $BUILD_WITH_STACK ($OFED_STACK_PREFIX)"
Packit 857059
else
Packit 857059
	echo "Stack to build for: $BUILD_WITH_STACK"
Packit 857059
fi
Packit 857059
Packit 857059
if [ "$nflag" = "y" ]
Packit 857059
then
Packit 857059
	exit 0
Packit 857059
fi
Packit 857059
Packit 857059
# when inplace developer builds have been done, the src rpm will include
Packit 857059
# prebuilt code.  if the -C option is not specified (via BUILD_ARGS)
Packit 857059
# clobber any such files if they are present (indicated by builtinplace file).
Packit 857059
# The clobber allows a src.rpm packaged with an in-place build to still
Packit 857059
# generate normally when -C not given.
Packit 857059
# No need to check rerun flag because for rpms we always start fresh from what
Packit 857059
# was inside the src rpm and for runmake we can test built* to decide if the
Packit 857059
# clobber is needed
Packit 857059
clobber_arg=
Packit 857059
if [ "$Cflag" != y ]
Packit 857059
then
Packit 857059
	# force full rebuild
Packit 857059
	if [ -e $TL_DIR/builtinplace.$PRODUCT.$BUILD_CONFIG \
Packit 857059
		-o  -e $TL_DIR/builtinclude.$PRODUCT.$BUILD_CONFIG \
Packit 857059
		-o  -e $TL_DIR/builtlibs.$PRODUCT.$BUILD_CONFIG \
Packit 857059
		-o  -e $TL_DIR/builtbin.$PRODUCT.$BUILD_CONFIG ]
Packit 857059
	then
Packit 857059
		export REMOVE_DEPENDS=yes
Packit 857059
		clobber_arg="clobber clobber_stage clobber_release"
Packit 857059
	fi
Packit 857059
fi
Packit 857059
rm -rf packaged_files dist_files
Packit 857059
Packit 857059
# export DATE for use by prep so all files get same date/time stamp
Packit 857059
DATE=${DATE:-"`date +'%m/%d/%y %H:%M'`"}
Packit 857059
Packit 857059
# Do the actual MAKE
Packit 857059
showbuild
Packit 857059
env
Packit 857059
make $clobber_arg stage
Packit 857059
echo "Done $BUILD_TARGET_OS $BUILD_TARGET Fast Fabric $SUBPRODUCT $(date)"
Packit 857059
echo "=============================================================="
Packit 857059
Packit 857059
echo "Preping Files for $BUILD_TARGET_OS $BUILD_TARGET $(date)..."
Packit 857059
# run prep and package once at end
Packit 857059
# TBD - move package into outer final_package step and remove from here
Packit 857059
# consolidate Makefile accordingly to have one package target
Packit 857059
make prepfiles package