Commit 8bf3b9f4 authored by Andrea Valassi's avatar Andrea Valassi
Browse files

Further fixes and improvements in runtime environment scripts as for CORAL

(CORALCOOL-2874 and CORALCOOL-2873).


git-svn-id: file:///git/lcgcool.svndb/cool/trunk@19933 4525493e-7705-40b1-a816-d608a930855b
parent 30763a0d
......@@ -155,7 +155,6 @@ endif()
coral_generate_env_conf()
get_filename_component(PYTHON_EXECUTABLE_REALPATH ${PYTHON_EXECUTABLE} REALPATH)
configure_file(cmake/cc-run.in cc-run @ONLY)
configure_file(cmake/cc-sh.in cc-sh @ONLY)
execute_process(COMMAND chmod +x ${CMAKE_BINARY_DIR}/cc-run ${CMAKE_BINARY_DIR}/cc-sh)
......
......@@ -239,12 +239,17 @@ test: $(BUILDDIR)/$(BUILD_CONF_FILE)
+$(BUILD_CMD) HTMLSummary
ifeq ($(VERBOSE),)
# less verbose install (see GAUDI-1018)
# (emulate the default CMake install target)
# More quiet install (see GAUDI-1018): emulate the default CMake install target
# Note that the default verbose install will be used if VERBOSE is set
install: all
cd $(BUILDDIR) && $(CMAKE) -P cmake_install.cmake| grep -v "^-- Up-to-date:"
cd $(BUILDDIR) && $(CMAKE) -P cmake_install.cmake | grep -v "^-- Up-to-date:"
endif
# Set CMAKE_INSTALL_LOCAL_ONLY (see cmake_install.cmake in the build directory)
# to skip lib/bin build in make install for cc-cacherebuild (CORALCOOL-2874)
install_local_only: $(BUILDDIR)/$(BUILD_CONF_FILE)
cd $(BUILDDIR) && $(CMAKE) -DCMAKE_INSTALL_LOCAL_ONLY=ON -P cmake_install.cmake
# Ensure that the target are always passed to the CMake Makefile
FORCE:
@ # dummy target
......
......@@ -92,10 +92,10 @@ if [ "$status" != "0" ]; then
exit $status
fi
date >> $out
echo "=== make install"
echo "=== make ${makevars} install"
echo "Output is $out"
if [ "$out" == "/dev/stdout" ]; then
time make ${makevars} install | grep -v 'Up-to-date'
time make ${makevars} install | grep -v "^-- Up-to-date:"
else
time make ${makevars} install >> $out #2>&1
fi
......@@ -123,8 +123,8 @@ fi
if [ -d /afs ] || [ -d /cvmfs ]; then
pushd cmake > /dev/null
if [ -f .internal/compare_env.sh ]; then
.internal/compare_env.sh -i > .internal/env_comparison_install.txt
.internal/compare_env.sh > .internal/env_comparison_build.txt
.internal/compare_env.sh -i > .internal/env_comparison_install.txt
fi
popd > /dev/null
fi
......@@ -31,19 +31,21 @@ fi
# TEMPORARY! Create directories with dummy files to ensure they are added to env
echo "=== make ${makevars} configure"
\rm -rf $blddir $insdir
if [ -f .internal/compare_env.sh ]; then
for dir in $blddir/bin $blddir/lib $insdir/bin $insdir/lib $insdir/python $insdir/tests/bin $insdir/tests/lib $insdir/CoralTest/qmtest; do mkdir -p $dir; touch $dir/dummy; done
if [ -f cmake/.internal/compare_env.sh ]; then
for dir in $blddir/bin $blddir/lib $blddir/python $blddir/tests/bin $blddir/tests/lib $blddir/CoralTest/qmtest $insdir/bin $insdir/lib $insdir/python $insdir/tests/bin $insdir/tests/lib $insdir/CoralTest/qmtest; do mkdir -p $dir; touch $dir/dummy; done
fi
if [ "$trace" == "1" ]; then CMAKEFLAGS="--trace $CMAKEFLAGS"; fi
make ${makevars} configure 2>&1
echo "=== make ${makevars} install_local_only"
make ${makevars} install_local_only 2>&1
# TEMPORARY! Compare CMT and CMake based environments
# Skip this step if neither AFS nor CVMFS are available (e.g. on ARM)
if [ -d /afs ] || [ -d /cvmfs ]; then
pushd cmake > /dev/null
if [ -f .internal/compare_env.sh ]; then
.internal/compare_env.sh -i > .internal/env_comparison_install.txt
.internal/compare_env.sh > .internal/env_comparison_build.txt
.internal/compare_env.sh -i > .internal/env_comparison_install.txt
fi
popd > /dev/null
fi
......@@ -8,19 +8,6 @@ contains() {
return 1
}
# Check arguments
if [ "$1" == "-i" ] || [ "$1" == "--install" ]; then
xenv=install
optdir=TMP.install
shift
elif [ "$1" == "" ]; then
xenv=build
optdir=.
else
echo "Usage: $0 [-i|--install]"
exit 1
fi
# Check if BINARY_TAG is set (do not take it from CMTCONFIG)
if [ "$BINARY_TAG" == "" ]; then
echo "ERROR! BINARY_TAG is not set"
......@@ -30,6 +17,7 @@ fi
# Optionally override build directory location
cd $intdir/../..
blddir=build.${BINARY_TAG}
insdir=${BINARY_TAG}
if [ "$CORALCOOL_CMAKE_BUILDDIR" != "" ]; then
blddir=$CORALCOOL_CMAKE_BUILDDIR
fi
......@@ -38,13 +26,31 @@ if [ ! -d $blddir ]; then
exit 1
fi
blddir=`cd $blddir; pwd`
if [ ! -d $insdir ]; then
echo "ERROR! Directory $insdir does not exist in `pwd`"
exit 1
fi
insdir=`cd $insdir; pwd`
# Check arguments
if [ "$1" == "-i" ] || [ "$1" == "--install" ]; then
xenv=install
shift
envdir=$insdir
elif [ "$1" == "" ]; then
xenv=build
envdir=$blddir
else
echo "Usage: $0 [-i|--install]"
exit 1
fi
# Dump runtime environments to files
# Use "env -i" to start with a fresh environment
# See http://unix.stackexchange.com/questions/48994
cd $intdir
env -i CMTCONFIG=$BINARY_TAG BINARY_TAG=$BINARY_TAG ./cc-run-cmt env | sort > envCMT
env -i PATH=`env -i bash --norc --noprofile -c 'echo $PATH'` USER=$USER ${blddir}/${optdir}/cc-run env | sort > envCMake.${xenv}
env -i PATH=`env -i bash --norc --noprofile -c 'echo $PATH'` USER=$USER ${envdir}/cc-run env | sort > envCMake.${xenv}
# Read runtime environments from files and compare them
files="envCMT envCMake.${xenv}"
......
......@@ -16,7 +16,7 @@ macro(coral_enable_env)
set(env_release_xml ${CMAKE_BINARY_DIR}/TMP.install/env/${env_xml_basename}
CACHE STRING "full path to the XML file for the environment to be used once the project is installed")
mark_as_advanced(env_xml_basename env_build_xml env_release_xml)
mark_as_advanced(env_xml_basename)
find_package(PythonInterp REQUIRED) # Needed to define PYTHON_EXECUTABLE
......@@ -67,7 +67,7 @@ endfunction()
#-------------------------------------------------------------------------------
# _env_conf_pop_instruction(...)
#
# helper macro used by coral_generate_env_conf.
# Helper macro used by coral_generate_env_conf.
#-------------------------------------------------------------------------------
macro(_env_conf_pop_instruction instr lst)
list(LENGTH ${lst} _lst_len0) # FIX CORALCOOL-2793
......@@ -94,7 +94,7 @@ endmacro()
#-------------------------------------------------------------------------------
# _env_package(...)
#
# helper macro used by _env_line.
# Helper macro used by _env_line.
#-------------------------------------------------------------------------------
function(_env_package pack output)
message(STATUS "Requested env for PACKAGE ${pack}")
......@@ -205,7 +205,7 @@ endfunction()
#-------------------------------------------------------------------------------
# _env_target(...)
#
# helper macro used by _env_line.
# Helper macro used by _env_line.
#-------------------------------------------------------------------------------
function(_env_target tgt output)
message(STATUS "Requested env for TARGET ${tgt}")
......@@ -233,11 +233,12 @@ function(_env_target tgt output)
endfunction()
#-------------------------------------------------------------------------------
# _env_line(...)
# _root_vars_replace(...)
#
# helper macro used by coral_generate_env_conf.
# Helper macro used by _env_line (used in coral_generate_env_conf).
# This is now also used to set pythonExecutable in cc-run (CORALCOOL-2873).
#-------------------------------------------------------------------------------
macro(_env_line cmd var val output)
macro(_root_vars_replace val output)
set(val_ ${val})
foreach(root_var ${root_vars})
if(${root_var})
......@@ -247,6 +248,17 @@ macro(_env_line cmd var val output)
endif()
endif()
endforeach()
#message(STATUS "_root_vars_replace(): ${val} -> ${val_}")
set (${output} ${val_})
endmacro()
#-------------------------------------------------------------------------------
# _env_line(...)
#
# Helper macro used by coral_generate_env_conf.
#-------------------------------------------------------------------------------
macro(_env_line cmd var val output)
_root_vars_replace (${val} val_)
if("${cmd}_" STREQUAL "SET_")
set(${output} "<env:set variable=\"${var}\">${val_}</env:set>")
elseif("${cmd}_" STREQUAL "UNSET_")
......@@ -271,24 +283,22 @@ macro(_env_line cmd var val output)
endmacro()
#-------------------------------------------------------------------------------
# _coral_write_env_conf(filename [ROOT_VARS var1 var2...] <env>)
# _coral_write_env_conf(filename <env>)
#
# Generate the XML file describing the changes to the environment required by
# this project.
#
# The variable names passed to ROOT_VARS are used to allow relocation of the
# The variable names in ${root_vars} are used to allow relocation of the
# resulting environment.
#-------------------------------------------------------------------------------
include(CMakeParseArguments)
function(_coral_write_env_conf filename)
cmake_parse_arguments(ARG "" "" "ROOT_VARS" ${ARGN})
cmake_parse_arguments(ARG "" "" "" ${ARGN})
set(data "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<env:config xmlns:env=\"EnvSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"EnvSchema EnvSchema.xsd \">\n")
# variables that need to be used to make the environment relative
set(root_vars ${ARG_ROOT_VARS}) # needed by _env_line (CORALCOOL-2829)
foreach(root_var ${ARG_ROOT_VARS})
foreach(root_var ${root_vars})
get_filename_component(_path ${${root_var}} REALPATH) # see CORALCOOL-2836
set(data "${data} <env:default variable=\"${root_var}\">${_path}</env:default>\n")
endforeach()
......@@ -319,14 +329,17 @@ endfunction()
function(coral_generate_env_conf)
get_property(_build_env GLOBAL PROPERTY CORAL_BUILD_ENVIRONMENT)
get_property(_release_env GLOBAL PROPERTY CORAL_RELEASE_ENVIRONMENT)
set(${CMAKE_PROJECT_NAME}SYS ${CMAKE_BINARY_DIR}) # local and child scope
set(${CMAKE_PROJECT_NAME}SYS ${CMAKE_INSTALL_PREFIX}) # local and child scope
IF(NOT "$ENV{LCG_releases_base} " STREQUAL " ")
set(LCG_releases_base $ENV{LCG_releases_base}) # local and child scope
_coral_write_env_conf(${env_build_xml} ${_build_env} ROOT_VARS ${CMAKE_PROJECT_NAME}SYS LCG_releases_base)
_coral_write_env_conf(${env_release_xml} ${_release_env} ROOT_VARS ${CMAKE_PROJECT_NAME}SYS LCG_releases_base)
set(root_vars ${CMAKE_PROJECT_NAME}SYS;LCG_releases_base)
ELSE()
_coral_write_env_conf(${env_build_xml} ${_build_env} ROOT_VARS ${CMAKE_PROJECT_NAME}SYS)
_coral_write_env_conf(${env_release_xml} ${_release_env} ROOT_VARS ${CMAKE_PROJECT_NAME}SYS)
set(root_vars ${CMAKE_PROJECT_NAME}SYS)
ENDIF()
set(${CMAKE_PROJECT_NAME}SYS ${CMAKE_BINARY_DIR}) # local and child scope
_coral_write_env_conf(${env_build_xml} ${_build_env})
set(${CMAKE_PROJECT_NAME}SYS ${CMAKE_INSTALL_PREFIX}) # local and child scope
_coral_write_env_conf(${env_release_xml} ${_release_env})
_root_vars_replace (${PYTHON_EXECUTABLE} PYTHON_EXECUTABLE_CCPATH)
string(REPLACE "\$" "" PYTHON_EXECUTABLE_CCPATH ${PYTHON_EXECUTABLE_CCPATH})
set(PYTHON_EXECUTABLE_CCPATH ${PYTHON_EXECUTABLE_CCPATH} PARENT_SCOPE)
endfunction()
......@@ -25,46 +25,46 @@ fi
# Override CORALSYS/COOLSYS and LCG_releases_base if this installation
# was relocated (CORALCOOL-2829; new relocation replacing CORALCOOL-2787)
# [Do not relocate in build.x86/TMP.install (i.e. if envxmlnew == envxmlold)]
# Relocate also python and all other externals for relocations out of lcgcmake
# If pythonExecutable is not found, try appending LCG_VERSION (CORALCOOL-2856)
envxmlold=@env_release_xml@
envxmlnew=$topdirp/env/@env_xml_basename@
pythonExecutable=@PYTHON_EXECUTABLE_REALPATH@
envxml=$topdirp/env/@env_xml_basename@
pythonExecutable=@PYTHON_EXECUTABLE_CCPATH@ # may start by {LCG_releases_base}
lcgversion=@LCG_VERSION@
lcgrelold=`more $envxml | grep variable=\"LCG_releases_base\" | tr "<" " " | tr ">" " " | awk '{print $3}'`
if [ "$msg" == "v" ]; then
echo "[DEBUG] envxmlold is $envxmlold"
echo "[DEBUG] envxmlnew is $envxmlnew"
echo "[DEBUG] envxml is $envxml"
echo "[DEBUG] lcgrelold is $lcgrelold"
fi
project=`basename $envxmlnew .xenv`
projsysold=`more $envxmlnew | grep variable=\"${project}SYS\" | tr "<" " " | tr ">" " " | awk '{print $3}'`
if [ "$LCG_releases_base" != "" ]; then
if [ "$msg" == "v" ]; then
echo "[DEBUG] LCG_releases_base is $LCG_releases_base"
fi
pythonExecutable=`echo ${pythonExecutable} | sed "s|{LCG_releases_base}|${LCG_releases_base}|"`
else
pythonExecutable=`echo ${pythonExecutable} | sed "s|{LCG_releases_base}|${lcgrelold}|"`
fi
project=`basename $envxml .xenv`
projsysold=`more $envxml | grep variable=\"${project}SYS\" | tr "<" " " | tr ">" " " | awk '{print $3}'`
if [ -d $projsysold ]; then projsysold=`cd $projsysold; pwd -P`; fi
projsysnew=$topdirl
if [ "$msg" == "v" ]; then
echo "[DEBUG] projsysold is $projsysold"
echo "[DEBUG] projsysnew is $projsysnew"
fi
if [ "$envxmlnew" != "$envxmlold" ] && [ "$projsysnew" != "$projsysold" ]; then # project was relocated
if [ "$projsysnew" != "$projsysold" ]; then # project was relocated
if [ "$project" == "CORAL" ]; then
export CORALSYS=$projsysnew
else
export COOLSYS=$projsysnew
fi
lcgrelold_lcgcmake=`dirname $projsysold`
lcgrelold_lcgcmake=`dirname $lcgrelold_lcgcmake`
lcgrelold_lcgcmake=`dirname $lcgrelold_lcgcmake`
lcgrelold=`more $envxmlnew | grep variable=\"LCG_releases_base\" | tr "<" " " | tr ">" " " | awk '{print $3}'`
if [ "$msg" == "v" ]; then
echo "[DEBUG] lcgrelold_lcgcmake is $lcgrelold_lcgcmake"
echo "[DEBUG] lcgrelold is $lcgrelold"
fi
if [ "$lcgrelold" == "$lcgrelold_lcgcmake" ]; then # lcgcmake dir structure
if [ "$LCG_releases_base" != "" ]; then
if [ "$msg" == "v" ]; then
echo "[DEBUG] LCG_releases_base is $LCG_releases_base"
fi
pythonExecutable=`echo ${pythonExecutable} | sed "s|${lcgrelold_lcgcmake}|${LCG_releases_base}|"`
else
if [ "$LCG_releases_base" == "" ]; then
lcgrelold_lcgcmake=`dirname $projsysold`
lcgrelold_lcgcmake=`dirname $lcgrelold_lcgcmake`
lcgrelold_lcgcmake=`dirname $lcgrelold_lcgcmake`
if [ "$msg" == "v" ]; then
echo "[DEBUG] lcgrelold_lcgcmake is $lcgrelold_lcgcmake"
fi
if [ "$lcgrelold" == "$lcgrelold_lcgcmake" ]; then # lcgcmake dir structure
lcgrelnew_lcgcmake=`dirname $projsysnew`
lcgrelnew_lcgcmake=`dirname $lcgrelnew_lcgcmake`
lcgrelnew_lcgcmake=`dirname $lcgrelnew_lcgcmake`
......@@ -81,9 +81,14 @@ if [ "$envxmlnew" != "$envxmlold" ] && [ "$projsysnew" != "$projsysold" ]; then
export LCG_releases_base=$lcgrelnew_lcgcmake2
pythonExecutable=`echo ${pythonExecutable} | sed "s|${lcgrelnew_lcgcmake}|${lcgrelnew_lcgcmake2}|"`
fi
else
: # noop (e.g. relocated local CORAL build against fixed LCG_release_base)
fi
fi
fi
if [ "$msg" == "v" ]; then
echo "[DEBUG] pythonExecutable is $pythonExecutable"
fi
# Old workaround for CORALCOOL-2803 on cc7
# [This was wrong as it did not identify and fix the real issue!]
......@@ -95,7 +100,7 @@ unset PYTHONPATH
# Run the specified command in the correct runtime environment
# [Make sure the minimum PATH is defined in case this is run through 'env -i']
PATH=$PATH:/usr/local/bin:/bin:/usr/bin ${pythonExecutable} $topdirl/env/xenv --xml=$envxmlnew "$@"
PATH=$PATH:/usr/local/bin:/bin:/usr/bin ${pythonExecutable} $topdirl/env/xenv --xml=$envxml "$@"
status=$?
if [ "$msg" != "q" ] && [ "$status" != "0" ]; then
echo "ERROR! Failed to execute command \"$*\""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment