From 75b9fafa30f6eade748565b5cb7b9dd2316b5f35 Mon Sep 17 00:00:00 2001
From: Sylvester Joosten <sjoosten@anl.gov>
Date: Sat, 30 Jan 2021 23:52:06 +0000
Subject: [PATCH] fix root build dir initialization

---
 benchmarks/dis/config.yml  |  1 +
 benchmarks/dvmp/config.yml |  1 +
 util/compile_analyses.py   | 13 ++++++++-----
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/benchmarks/dis/config.yml b/benchmarks/dis/config.yml
index fedc4229..6331fd56 100644
--- a/benchmarks/dis/config.yml
+++ b/benchmarks/dis/config.yml
@@ -20,6 +20,7 @@ dis:process:
   needs: ["detector", "dis:generate"]
   timeout: 1 hour
   script:
+    - source options/env.sh
     - ./util/compile_analyses.py dis
     - ./benchmarks/dis/dis.sh --config barrel --ebeam 18 --pbeam 275
   artifacts:
diff --git a/benchmarks/dvmp/config.yml b/benchmarks/dvmp/config.yml
index c3056c05..941bafd4 100644
--- a/benchmarks/dvmp/config.yml
+++ b/benchmarks/dvmp/config.yml
@@ -26,6 +26,7 @@ dvmp:process:
   needs: ["detector", "dvmp:generate"]
   timeout: 1 hour
   script:
+    - source options/env.sh
     - ./util/compile_analyses.py dvmp
     - ./util/run_many.py ./benchmarks/dvmp/dvmp.sh 
           -c jpsi_barrel 
diff --git a/util/compile_analyses.py b/util/compile_analyses.py
index d24783c7..153f2ea2 100755
--- a/util/compile_analyses.py
+++ b/util/compile_analyses.py
@@ -73,7 +73,7 @@ def compile_analyses(benchmark):
     print("Compiling all analyis scripts for '{}'".format(benchmark))
 
     ## Ensure our build directory exists
-    _init_build_dir()
+    _init_build_dir(benchmark)
 
     ## Get a list of all analysis scripts
     _compile_all(benchmark)
@@ -81,13 +81,16 @@ def compile_analyses(benchmark):
     ## All done!
     print('All analyses for', benchmark, 'compiled successfully')
 
-def _init_build_dir():
+def _init_build_dir(benchmark):
     '''Initialize our ROOT build directory (if using one).'''
     print(' --> Initializing ROOT build directory ...')
-    build_dir = os.getenv('ROOT_BUILD_DIR')
-    if build_dir is None:
+    build_prefix = os.getenv('ROOT_BUILD_DIR')
+    if build_prefix is None:
         print('    --> ROOT_BUILD_DIR not set, no action needed.')
         return
+    ## deduce the root build directory
+    pwd = os.getenv('PWD')
+    build_dir = '{}/{}/{}'.format(build_prefix, pwd, ANALYSIS_PATH.format(benchmark))
     print("    --> Ensuring directory '{}' exists".format(build_dir))
     os.system('mkdir -p {}'.format(build_dir))
 
@@ -109,7 +112,7 @@ def _compile_all(benchmark):
 
 def _compile_cmd(file):
     '''Return a one-line shell command to compile an analysis script.'''
-    return r'bash -c "source options/env.sh && root -q -b -e \".L {}+\""'.format(file)
+    return r'bash -c "root -q -b -e \".L {}+\""'.format(file)
 
 if __name__ == "__main__":
     args = parser.parse_args()
-- 
GitLab