diff --git a/scripts/checklibs.sh b/scripts/checklibs.sh index 119ead0a4855eb5c9a40d480436548113f78d938..25553ce95d489926fc0fad8af0a45fb87bf2b4cb 100755 --- a/scripts/checklibs.sh +++ b/scripts/checklibs.sh @@ -15,16 +15,33 @@ LIBDIR=${2:-../lib} # libraries are real files with the extensions .so and for macosx .dylib all_libs=$(find $LIBDIR -type f -o -type l | grep -e \.dylib$ -e \.so$) +# Token used to find the first line with a class definition in the .rootmap files +start_token_class="class " + tmpfile=$(mktemp) -ok=true +okay=true for lib in $all_libs; do - echo "Loading the library $lib" - root -l -q -b $SCRIPTDIR/loadlib.C\(\"$lib\"\) &> $tmpfile + first_class="" + rootmap_file="${lib%%".so"}".rootmap + if [ -f "${rootmap_file}" ]; then + rootmap_defs_token="\[ lib" + if [[ ${rootmap_file} == *"libHal"* ]]; then + # Commented out for now as lead to missing headers detection in 60% of HAL libraries (9/14) + # rootmap_defs_token="\[ Hal" + fi + + first_class=$(awk -v token="${rootmap_defs_token}" '$0 ~ token ,0' ${rootmap_file} | grep -m1 "${start_token_class}" | tr -d ';') + first_class="${first_class##"${start_token_class}"}" + fi + + # echo "Loading the library ${lib} and parsing it for class ${first_class}" + + root -l -q -b "${SCRIPTDIR}/loadlib.C(\"${lib}\", \"${first_class}\")" &> ${tmpfile} retval=$? if [[ retval -ne 0 ]]; then echo "" - echo "Problem loading the library $lib" + echo "Problem loading or parsing the library $lib: ${retval}" cat $tmpfile echo "" okay=false @@ -35,7 +52,7 @@ rm $tmpfile if [[ "$okay" = "false" ]]; then echo "" - echo "Not all libraries could be loaded" + echo "Not all libraries could be loaded and parsed" echo "Test failed" exit 1 else diff --git a/scripts/loadlib.C b/scripts/loadlib.C index ca8b0b4d518d1f048067b4908bbaefa3d34c0b39..8fd8b5cc0de68e48bbeeaf962b039252d5e19518 100644 --- a/scripts/loadlib.C +++ b/scripts/loadlib.C @@ -1,9 +1,20 @@ -/* Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2020-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Florian Uhlig [committer] */ + Authors: Florian Uhlig [committer], Pierre-Alain Loizeau */ -Int_t loadlib(TString libname) +Int_t loadlib(TString libname, TString classname = "") { + // This method returns 0 if it succeed, 1 if already loaded, -1 if lib not found and -2 if failed Int_t retval = gSystem->Load(libname); + if (0 == retval && "" != classname) { + // This one returns 1 in case of success and 0 in case of failure + // => Remap to next negative code after those used by the Load thod above + if (1 == gInterpreter->AutoParse(classname)) { + retval = 0; + } + else { + retval = -3; + } + } return retval; }