Skip to content

Commit

Permalink
Merge branch 'main' into greg-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks authored May 28, 2024
2 parents 1c54f8c + c93f421 commit 2de3bb0
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 21 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,13 @@ jobs:
###### fortran
- run: iguana-example-fortran test_data.hipo ${{ env.num_events }}
if: ${{ matrix.id == 'fortran' }}
### test ROOT macro
- name: test iguana_example_ROOT_macro.C interpreted
run: root -b -q iguana_src/examples/iguana_example_ROOT_macro.C
if: ${{ matrix.id == 'cpp' }}
- name: test iguana_example_ROOT_macro.C compiled
run: root -b -q iguana_src/examples/iguana_example_ROOT_macro.C+
if: ${{ matrix.id == 'cpp' }}
### test consumers
- name: consumer test make
if: ${{ matrix.id == 'cpp' }}
Expand Down
2 changes: 1 addition & 1 deletion doc/gen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ INPUT_FILE_ENCODING =
# provided as doxygen C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
# *.f18, *.f, *.for, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice.

FILE_PATTERNS = *.h iguana-example-*.cc Bindings.cc *.f
FILE_PATTERNS = *.h iguana-example-*.cc Bindings.cc *.f *.C

# The RECURSIVE tag can be used to specify whether or not subdirectories should
# be searched for input files as well.
Expand Down
4 changes: 3 additions & 1 deletion doc/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ source bin/this_iguana.sh # for 'bash' and 'zsh' only; use the --help argumen
source bin/this_iguana.tcsh # for 'tcsh' only; has no --help option and spawns a 'tcsh' sub-shell
```
The following environment variables are set or modified:
The following environment variables are set or modified; not all of them are needed for all users:
| Variable | Modification |
| --- | --- |
| `PKG_CONFIG_PATH` | adds paths to the `pkg-config` files (`.pc`) for dependencies and Iguana; see [note on dependency resolution](dependency_resolution.md) |
| `LD_LIBRARY_PATH` (Linux) or `DYLD_LIBRARY_PATH` (macOS) | adds paths to dependency and Iguana libraries |
| `PYTHONPATH` | adds paths to dependency and Iguana Python packages, if Python bindings are installed |
| `ROOT_INCLUDE_PATH` | adds paths to dependency and Iguana header files, for usage in ROOT |
| `IGUANA` | the path to the Iguana installation prefix, equivalent to `pkg-config iguana --variable prefix`; this is only for consumers that do not use `pkg-config` or the other standard environment variables, however usage of this variable is _discouraged_ since the installation layout may vary |
5 changes: 5 additions & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ACLiC artifacts
*.so
*.dylib
*.d
*.pcm
2 changes: 1 addition & 1 deletion examples/iguana-example-bank-rows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int main(int argc, char** argv)
int const numEvents = argc > argi ? std::stoi(argv[argi++]) : 1;

// read input file
hipo::reader reader(inFileName);
hipo::reader reader(inFileName,{0});

// set banks
hipo::banklist banks = reader.getBanks({"REC::Particle", "RUN::config"});
Expand Down
2 changes: 1 addition & 1 deletion examples/iguana-example-basic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(int argc, char** argv)
int const numEvents = argc > argi ? std::stoi(argv[argi++]) : 1;

// read input file
hipo::reader reader(inFileName);
hipo::reader reader(inFileName,{0});

// set banks
hipo::banklist banks = reader.getBanks({"RUN::config",
Expand Down
29 changes: 29 additions & 0 deletions examples/iguana_example_ROOT_macro.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/// @begin_doc_example
/// @file iguana_example_ROOT_macro.C
/// @brief Very simple example showing how to load and use an Iguana algorithm in a ROOT macro; this example
/// only runs the algorithm and does not require any input data.
/// @par Usage
/// ```bash
/// root -b -q iguana_example_ROOT_macro.C
/// ```
/// @end_doc_example

#include <TSystem.h>
#include <iguana/algorithms/physics/InclusiveKinematics/Algorithm.h>

/// example ROOT macro function
void iguana_example_ROOT_macro() {

// load the iguana algorithms library
gSystem->Load("libIguanaAlgorithms");

// run the inclusive kinematics action function
iguana::physics::InclusiveKinematics algo;
algo.Start();
auto result = algo.ComputeFromLepton(0.3, 0.3, 5.0);
std::cout << "kinematics:"
<< "\n Q2 = " << result.Q2
<< "\n x = " << result.x
<< "\n W = " << result.W
<< std::endl;
}
35 changes: 25 additions & 10 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@ foreach dep : [ hipo_dep, fmt_dep, yamlcpp_dep, ROOT_dep ]
endif
endforeach

# make a list of dependency library and include directories
dep_lib_paths = []
dep_inc_paths = []
# pkgconfig configuration: make a list of dependency library and include directories
dep_lib_dirs = []
dep_include_dirs = []
dep_pkgconfig_dirs = []
foreach dep : dep_list
### skip ROOT (handled differently, and most ROOT users already have it in their environment)
if dep.name() == 'ROOT'
continue
endif
### handle pkg-config deps
if dep.type_name() == 'pkgconfig'
libdirs = [ dep.get_variable(pkgconfig: 'libdir') ]
Expand All @@ -80,15 +85,23 @@ foreach dep : dep_list
else
error('Cannot determine how dependency "' + dep.name() + '" was found')
endif
### append to `dep_lib_paths` and `dep_inc_paths`, omitting duplicates
### append to `dep_lib_dirs`
foreach libdir : libdirs
if not dep_lib_paths.contains(libdir)
dep_lib_paths += libdir
if not dep_lib_dirs.contains(libdir)
dep_lib_dirs += libdir
endif
### append to `dep_pkgconfig_dirs`
if dep.type_name() == 'pkgconfig'
pkgconfigdir = libdir / 'pkgconfig'
if not dep_pkgconfig_dirs.contains(pkgconfigdir)
dep_pkgconfig_dirs += pkgconfigdir
endif
endif
endforeach
### append to `dep_include_dirs`
foreach incdir : incdirs
if not dep_inc_paths.contains(incdir)
dep_inc_paths += incdir
if not dep_include_dirs.contains(incdir)
dep_include_dirs += incdir
endif
endforeach
endforeach
Expand Down Expand Up @@ -131,8 +144,9 @@ project_etc = get_option('sysconfdir') / meson.project_name()
project_test_env = environment()
project_pkg_vars = [
'bindir=' + '${prefix}' / get_option('bindir'),
'dep_pkgconfigdirs=' + ':'.join(get_option('pkg_config_path')),
'dep_libdirs=' + ':'.join(dep_lib_paths),
'dep_pkgconfigdirs=' + ':'.join(dep_pkgconfig_dirs),
'dep_libdirs=' + ':'.join(dep_lib_dirs),
'dep_includedirs=' + ':'.join(dep_include_dirs),
]

# sanitizer settings
Expand Down Expand Up @@ -203,6 +217,7 @@ if get_option('z_install_envfile')
'ld_path': host_machine.system() != 'darwin' ? 'LD_LIBRARY_PATH' : 'DYLD_LIBRARY_PATH',
'python': get_option('bind_python') ? 'true' : 'false',
'libdir': get_option('libdir'),
'root': ROOT_dep.found() ? 'true' : 'false',
},
)
foreach shell : ['csh', 'tcsh']
Expand Down
34 changes: 27 additions & 7 deletions meson/this_iguana.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,28 @@ get_realpath() {
echo $(cd $1 && pwd -P)
}

# append to PKG_CONFIG_PATH
this_dir=$(get_realpath $(dirname ${BASH_SOURCE[0]:-$0})/..)
export PKG_CONFIG_PATH=$this_dir/@libdir@/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
# set IGUANA prefix
export IGUANA=$(get_realpath $(dirname ${BASH_SOURCE[0]:-$0})/..)

# prepend to PKG_CONFIG_PATH
export PKG_CONFIG_PATH=$IGUANA/@libdir@/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
dep_pkgconfigdirs=$(pkg-config --variable dep_pkgconfigdirs iguana)
[ -n "${dep_pkgconfigdirs-}" ] && export PKG_CONFIG_PATH=$dep_pkgconfigdirs${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
unset this_dir
unset dep_pkgconfigdirs

# append to PATH
# prepend to PATH
iguana_path=$(pkg-config --variable bindir iguana)
[ -n "${iguana_path-}" ] && export PATH=$(get_realpath $iguana_path)${PATH:+:${PATH}}
unset iguana_path

# append to PYTHONPATH
# prepend to PYTHONPATH
if @python@; then
iguana_pythonpath=$(pkg-config --variable pythonpath iguana)
[ -n "${iguana_pythonpath-}" ] && export PYTHONPATH=$iguana_pythonpath${PYTHONPATH:+:${PYTHONPATH}}
unset iguana_pythonpath
fi

# append to LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
# prepend to LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
# FIXME: this won't work well if a user already has all dependency libraries
# in, for example, `/opt/lib`, but has custom built and installed one
# elsewhere, e.g., `/tmp/lib`; if `/opt/lib` is listed before `/tmp/lib` in
Expand All @@ -71,13 +72,26 @@ for var in dep_libdirs libdir; do
done
unset var

# prepend to ROOT_INCLUDE_PATH
if @root@; then
for var in dep_includedirs includedir; do
dir=$(pkg-config --variable $var iguana)
[ -n "${dir-}" ] && export ROOT_INCLUDE_PATH=$dir${ROOT_INCLUDE_PATH:+:${ROOT_INCLUDE_PATH}}
unset dir
done
unset var
fi

# print environment variables
if $arg_verbose; then
print_var() { echo "$@" | sed 's/:/\n /g'; }
echo """
Iguana Environment Variables
----------------------------
IGUANA -- SET
$IGUANA
PKG_CONFIG_PATH -- ADDED iguana and dependency pkg-config paths:
$(print_var ${PKG_CONFIG_PATH-})
Expand All @@ -87,6 +101,9 @@ PATH -- ADDED iguana executables:
@ld_path@ -- ADDED iguana and dependency library paths:
$(print_var ${@ld_path@-})
ROOT_INCLUDE_PATH -- $(if @root@; then echo 'ADDED iguana and dependency include paths:'; else echo 'has NOT been changed'; fi)
$(print_var ${ROOT_INCLUDE_PATH-})
PYTHONPATH -- $(if @python@; then echo 'ADDED iguana python bindings:'; else echo 'has NOT been changed'; fi)
$(print_var ${PYTHONPATH-})
Expand All @@ -103,6 +120,9 @@ if $arg_githubCI; then
if @python@; then
echo PYTHONPATH=$PYTHONPATH >> $GITHUB_ENV
fi
if @root@; then
echo ROOT_INCLUDE_PATH=$ROOT_INCLUDE_PATH >> $GITHUB_ENV
fi
fi

# cleanup
Expand Down

0 comments on commit 2de3bb0

Please sign in to comment.