Skip to content
Snippets Groups Projects
build_eicrecon.sh 1.86 KiB
#!/bin/bash

## =============================================================================
## Build and install the EICrecon package into our local prefix
## =============================================================================

## =============================================================================
## Load the environment variables. To build the detector we need the following
## variables:
##
## - LOCAL_PREFIX:     location where local packages should be installed

if [ -n "${LOCAL_PREFIX}" ] ; then 
  source .local/bin/env.sh
else
  source ${LOCAL_PREFIX}/bin/env.sh
fi


## =============================================================================
## Step 1: download/update the detector definitions (if needed)
pushd "$(mktemp -d)"

echo "Fetching EICrecon"
if [ -n "${DETECTOR_DEPLOY_TOKEN_USERNAME:-}" -a -n "${DETECTOR_DEPLOY_TOKEN_PASSWORD:-}" ]; then
  DEPLOY_TOKEN="${DETECTOR_DEPLOY_TOKEN_USERNAME}:${DETECTOR_DEPLOY_TOKEN_PASSWORD}@"
  echo "Deploy token for ${DETECTOR_DEPLOY_TOKEN_USERNAME} is masked in the next line."
else
  DEPLOY_TOKEN=""
fi
echo "git clone -b ${EICRECON_VERSION} --depth 1 ${EICRECON_REPOSITORYURL:-https://eicweb.phy.anl.gov/EIC/eicrecons/EICrecon.git} EICrecon"
git clone -b ${EICRECON_VERSION} --depth 1 ${EICRECON_REPOSITORYURL:-https://${DEPLOY_TOKEN}eicweb.phy.anl.gov/EIC/eicrecons/EICrecon.git} EICrecon
rm -rf "EICrecon/.git"

## =============================================================================
## Step 2: Compile and install the detector definition
echo "Building and installing the ${DETECTOR} package"

cd EICrecon
cmake -DCMAKE_INSTALL_PREFIX=${LOCAL_PREFIX} && make -j$(($(nproc)/4+1)) install || exit 1
TO_REMOVE="$PWD"
popd
rm -rf "$TO_REMOVE"
unset TO_REMOVE

## =============================================================================
## Step 3: That's all!
echo "Detector build/install complete!"