Skip to content
Merged
Show file tree
Hide file tree
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
41 changes: 41 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.12)
project(DUNEPlotStyle VERSION 01.01 LANGUAGES CXX)

add_library(DUNEPlotStyle INTERFACE)
target_include_directories(DUNEPlotStyle INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/root/cpp/include>
$<INSTALL_INTERFACE:include>
${ROOT_INCLUDE_DIRS}
)
set_target_properties(DUNEPlotStyle PROPERTIES
PUBLIC_HEADER
src/root/cpp/include/DUNEStyle.h
)

install(TARGETS DUNEPlotStyle
EXPORT DUNEPlotStyleTargets
LIBRARY DESTINATION lib/
PUBLIC_HEADER DESTINATION include/)

find_package(ROOT)
if (ROOT_FOUND)
add_executable(DUNEPlotStyleExample examples/root/cpp/example.C)
target_link_libraries(DUNEPlotStyleExample DUNEPlotStyle ROOT::Core ROOT::Hist ROOT::Gpad ROOT::Postscript)
install(TARGETS DUNEPlotStyleExample)
endif()

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/DUNEPlotStyleConfigVersion.cmake"
VERSION ${CMAKE_PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/templates/DUNEPlotStyleConfig.cmake.in"
"${PROJECT_BINARY_DIR}/DUNEPlotStyleConfig.cmake"
INSTALL_DESTINATION share/cmake/DUNEPlotStyle
)
install(EXPORT DUNEPlotStyleTargets DESTINATION share/cmake/DUNEPlotStyle)
install(FILES "${PROJECT_BINARY_DIR}/DUNEPlotStyleConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/DUNEPlotStyleConfig.cmake"
DESTINATION share/cmake/DUNEPlotStyle)
4 changes: 4 additions & 0 deletions cmake/templates/DUNEPlotStyleConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/DUNEPlotStyleTargets.cmake")
check_required_components("@PROJECT_NAME@")
8 changes: 8 additions & 0 deletions examples/root/cpp/example.C
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,11 @@ void example()
c.SaveAs("example.root.histoverlay.png");

}

#ifndef __ROOTCLING__
int main()
{
example();
return 0;
}
#endif
1 change: 1 addition & 0 deletions ups/dune_plot_style.table
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ ACTION=SETUP
PathPrepend(PYTHONPATH, ${UPS_PROD_DIR}/python)
PathPrepend(MPLCONFIGDIR, ${UPS_PROD_DIR}/stylelib/)
PathPrepend(ROOT_INCLUDE_PATH, ${UPS_PROD_DIR}/include)
PathPrepend(CMAKE_PREFIX_PATH, ${UPS_PROD_DIR}) # CMake will search in {path}/share/cmake/<pkg_name>
100 changes: 65 additions & 35 deletions ups/make_dune_plot_style_ups_product.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,74 +3,108 @@
# heavily inspired by NOvAs ups product making script
# 2022-07-12

path=/grid/fermiapp/products/dune/

# print usage
usage() {

echo ""
echo "Usage is:"
echo " sh make_dune_plot_style_ups_product.sh <version_number>"
echo " sh make_dune_plot_style_ups_product.sh <version_number> [install dir]"
echo ""
echo "The version number should be of the form vXX_XX."
echo "The <version number> should be of the form vXX_XX."
echo "The optional [install dir] defaults to '$path'."
echo ""
exit -1
exit 1

}

# setup
# -----------------------------------------------------------------------------

if [ ${#@} != 1 ]; then
if [ ${#@} -lt 1 ] || [ ${#@} -gt 2 ]; then
usage
fi

# useful vars
path=/grid/fermiapp/products/dune/
reponame="dune_plot_style"
reponame="dune_plot_style"
version=$1
tmpdir=/tmp/${reponame}_${version}
if [ -n "$2" ]; then path="$2"; fi

if [[ ! ${version} =~ v[0-9][0-9]_[0-9][0-9] ]]; then
echo ""
echo "Version pattern not allowed."
usage
fi

echo "Tagging ${reponame} ${version}"
if ! [ -d "$path" ]; then
echo ""
echo "Requested install directory does not exist: '$path'"
usage
fi

source /grid/fermiapp/products/dune/setup_dune.sh
tmpdir="$(mktemp --directory /tmp/${reponame}_${version}.XXXXXXXXXX)"

echo "Tagging ${reponame} ${version}"
echo "workdir: ${tmpdir}"

if [[ $SETUP_UPS =~ .*products/dune ]]; then
# UPS is already set up, likely correctly
pass
elif [ -f /grid/fermiapp/products/dune/setup_dune.sh ]; then
source /grid/fermiapp/products/dune/setup_dune.sh
elif [ -f /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh ]; then
source /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh
else
echo "Can't set up DUNE UPS products!"
echo "Ensure setup_dune.sh is accessible either in /grid/fermiapp/products/dune or /cvmfs/dune.opensciencegrid.org/products/dune."
echo "Can't continue."
exit 1
fi

echo "Printing active products"
echo "-------------------------------------------"
ups active
echo "-------------------------------------------"

# check if the first argument is a valid path
if [ -d "${tmpdir}" ]; then
echo "${tmpdir} is already exists! Cannot do clean checkout!"
echo "Aborting"
exit -1
fi

# pull the latest version of the git repo and put it in the product directory
# -----------------------------------------------------------------------------

# clone to temp directory
git clone -b ${version} git@github.com:DUNE/${reponame}.git ${tmpdir}/${reponame}-preorg
preorg_dir="${tmpdir}/${reponame}-preorg"
git clone -b ${version} git@github.com:DUNE/${reponame}.git ${preorg_dir}

# the exported CMake package files need to be autogenerated by running CMake
if which cmake > /dev/null 2>&1; then
builddir="$(mktemp --directory ${tmpdir}/cmake-build.XXXXXXXXXX)"

echo "Running CMake to generate CMake package files."
echo "Build directory: $builddir"

pushd $builddir || exit 1
cmake -DCMAKE_INSTALL_PREFIX=${preorg_dir} ${preorg_dir} || exit 1
make install || exit 1
popd || exit 1
else
echo "WARNING: CMake is not available, so the CMake interface will not be installed. Check that's what you expected!"
fi

# need to do some reogranising for the ups product
mkdir -p ${tmpdir}/${reponame}/python/dunestyle/matplotlib
mkdir -p ${tmpdir}/${reponame}/python/dunestyle/root
mv ${tmpdir}/${reponame}-preorg/src/matplotlib/stylelib ${tmpdir}/${reponame}/
mv ${tmpdir}/${reponame}-preorg/src/root/cpp/include ${tmpdir}/${reponame}/
mv ${tmpdir}/${reponame}-preorg/src/__init__.py ${tmpdir}/${reponame}/python/dunestyle/
mv ${tmpdir}/${reponame}-preorg/src/matplotlib/python/* ${tmpdir}/${reponame}/python/dunestyle/matplotlib
mv ${tmpdir}/${reponame}-preorg/src/root/python/* ${tmpdir}/${reponame}/python/dunestyle/root
mv ${tmpdir}/${reponame}-preorg/examples ${tmpdir}/${reponame}/
mv ${tmpdir}/${reponame}-preorg/ups/ ${tmpdir}/${reponame}/
rm -rf ${tmpdir}/${reponame}-preorg
mv ${preorg_dir}/src/matplotlib/stylelib ${tmpdir}/${reponame}/
mv ${preorg_dir}/src/root/cpp/include ${tmpdir}/${reponame}/
mv ${preorg_dir}/src/__init__.py ${tmpdir}/${reponame}/python/dunestyle/
mv ${preorg_dir}/src/matplotlib/python/* ${tmpdir}/${reponame}/python/dunestyle/matplotlib
mv ${preorg_dir}/src/root/python/* ${tmpdir}/${reponame}/python/dunestyle/root
mv ${preorg_dir}/examples ${tmpdir}/${reponame}/
mv ${preorg_dir}/ups/ ${tmpdir}/${reponame}/
mv ${preorg_dir}/share/ ${tmpdir}/${reponame}/
rm -rf ${preorg_dir}

proddir=${path}/${reponame}
dest=${proddir}/${version}/NULL
dest=${proddir}/${version}

echo "$reponame will be created in $dest"

Expand Down Expand Up @@ -116,22 +150,18 @@ echo "Updating table file"
sed -i -e "s:XXVERSIONXX:${version}:" \
${ups_table}

echo "Declaring product ${reponame} with version ${version} to UPS."
echo
echo "Declaring product ${reponame} with version ${version} to UPS:"

# declare to ups
ups declare -f NULL -z ${path} -c \
-r ${path}/${reponame}/${version}/ \
-m ${reponame}.table \
${reponame} ${version}

# I am sure there's a nicer way to do this but for now...
mv ${path}/${reponame}/${version}.version ${path}/${reponame}/NULL
mkdir ${path}/${reponame}/${version}.version/
mv ${path}/${reponame}/NULL ${path}/${reponame}/${version}.version/
cmd="ups declare -f NULL -z ${path} -c -r ${path}/${reponame}/${version} -m ${path}/${reponame}/${version}/ups/${reponame}.table ${reponame} ${version}"
echo "$cmd"
eval $cmd

retval=$?
test $retval -ne 0 && echo "Error! 'ups declare' returned non-zero - BAILING" && exit 1

rm -rf ${tmpdir}

echo
echo "Done"
Loading