diff --git a/.github/install-dependencies.sh b/.github/install-dependencies.sh new file mode 100755 index 0000000..3b35497 --- /dev/null +++ b/.github/install-dependencies.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +[ $# -ne 1 ] && exit 1 +runner=$1 + +case "$runner" in + 'ubuntu-latest') + python -m pip install meson ninja + ;; + 'macos-latest') + brew install meson ninja tree + # install fortran compiler: + brew install gcc + brew unlink gcc + brew link gcc + ;; + *) + exit 1 + ;; +esac diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09a1736..566007e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,8 +16,8 @@ defaults: jobs: - build_cmake: - name: CMake build + build: + name: Build strategy: fail-fast: false matrix: @@ -25,42 +25,28 @@ jobs: runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v4 - - name: build + - name: install dependencies + run: .github/install-dependencies.sh ${{ matrix.runner }} + - name: meson setup run: | - cmake -S . -B build -DCMAKE_INSTALL_PREFIX=install - cmake --build build -j4 - cmake --install build - - run: brew install tree - if: ${{ matrix.runner == 'macos-latest' }} + meson setup build . \ + --prefix=`pwd`/install \ + -D install_examples=true \ + -D test_file=`pwd`/test_data.hipo \ + -D test_fortran=true + - run: meson install + working-directory: build + - name: dump build log + if: always() + run: cat build/meson-logs/meson-log.txt - run: tree install - - build_make: - name: Makefile build - strategy: - fail-fast: false - matrix: - runner: [ ubuntu-latest, macos-latest ] - runs-on: ${{ matrix.runner }} - steps: - - uses: actions/checkout@v4 - with: - path: hipo_src - submodules: recursive # FIXME: need `lz4` submoudle for Makefile, whereas `cmake` does not - - name: build - working-directory: hipo_src - run: | - make -j4 - make -j4 -C examples - - run: brew install tree - if: ${{ matrix.runner == 'macos-latest' }} - - run: tree hipo_src - name: tar - run: tar cavf hipo_src{.tar.zst,} + run: tar cavf build{.tar.zst,} - uses: actions/upload-artifact@v4 with: - name: build_make_${{ matrix.runner }} + name: build-${{ matrix.runner }} retention-days: 5 - path: hipo_src.tar.zst + path: build.tar.zst download_test_data: name: Download test data @@ -82,35 +68,35 @@ jobs: tar xvf validation_files_${{ env.type }}.tar.zst mv -v $(find validation_files -type f -name "*.hipo" | head -n1) test_data.hipo - examples: - name: Run examples - needs: [ download_test_data, build_make ] + test: + name: Test + needs: [ download_test_data, build ] strategy: fail-fast: false matrix: runner: [ ubuntu-latest, macos-latest ] runs-on: ${{ matrix.runner }} steps: - - uses: actions/download-artifact@v4 + - uses: actions/checkout@v4 + - name: install dependencies + run: .github/install-dependencies.sh ${{ matrix.runner }} + - name: download build + uses: actions/download-artifact@v4 with: - name: build_make_${{ matrix.runner }} + name: build-${{ matrix.runner }} - name: untar artifacts - run: | - ls *.tar.zst | xargs -I{} tar xvf {} - rm *.tar.zst - mv -v hipo_src/* ./ - rm -rf hipo_src + run: ls *.tar.zst | xargs -I{} tar xvf {} - name: get test data uses: actions/cache/restore@v4 with: key: test_data path: test_data.hipo - - run: examples/writeFile.exe - - run: examples/readFile.exe example_output.hipo - - run: examples/readFileTags.exe - - run: examples/showFile.exe example_output.hipo event::particle - - run: examples/readJson.exe test_data.hipo - - run: examples/tupleFile.exe - - run: examples/writeUserHeader.exe - - run: examples/bankRowList.exe test_data.hipo - - run: examples/histograms.exe test_data.hipo + - run: meson test + working-directory: build + - name: upload test logs + uses: actions/upload-artifact@v4 + if: always() + with: + name: test-${{ matrix.runner }} + retention-days: 5 + path: build/meson-logs/* diff --git a/.gitignore b/.gitignore index cbb5545..fb1184b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ lib slib __pycache__ -build +/build*/ +/install*/ +/.cache diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 08157af..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "lz4"] - path = lz4 - url = https://github.com/lz4/lz4 diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 39b4bf3..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,194 +0,0 @@ -########################################################## -# CMake configuration for Hipo # -# # -# @author Maurik Holtrop, University of New Hampshire # -# # -########################################################## - -# minimum version of CMake, which is determined by Geant4's requirements -cmake_minimum_required(VERSION 3.20) - -project(HIPO VERSION 4.1.0) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -# -# Set a default build type if none was specified -# -set(default_build_type "RELEASE") -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Setting build type to '${default_build_type}' as none was specified.") - set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) - # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Release" "MinSizeRel" "RelWithDebInfo") -endif() - -#if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) -# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib ) -#endif() - - -if(APPLE) - # use, i.e. don't skip the full RPATH for the build tree - set(CMAKE_SKIP_BUILD_RPATH FALSE) - - # when building, don't use the install RPATH already - # (but later on when installing) - set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) - - set(CMAKE_INSTALL_RPATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") - - # add the automatically determined parts of the RPATH - # which point to directories outside the build tree to the install RPATH - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - - # the RPATH to be used when installing, but only if it's not a system directory - list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" isSystemDir) - if("${isSystemDir}" STREQUAL "-1") - set(CMAKE_INSTALL_RPATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") - endif("${isSystemDir}" STREQUAL "-1") - -endif(APPLE) - -# -# Dependencies -# -# add path containing CMake macros for this project -list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) -find_package(LZ4 QUIET CONFIG PATHS ${PROJECT_SOURCE_DIR}/cmake ) - -if(NOT LZ4_FOUND) - message(STATUS "**LZ4********************************************************************") - message(STATUS "* We did not find a system (or local build) LZ4 package. *") - message(STATUS "* Please install lz4 (Centos: yum install lz4 MacOS: brew install lz4) *") - message(STATUS "* Or build lz4 from the included sources. *") - message(STATUS "* *") - message(STATUS "* To make this possible, please make sure you initialized the submodule.*") - message(STATUS "* If you did not include --recurse-submodules at initial clone do: *") - message(STATUS "* git submodule init *") - message(STATUS "* git submodule update *") - message(STATUS "* Then: 'cd lz4' followed by: *") - message(STATUS "* make PREFIX=${CMAKE_INSTALL_PREFIX} CFLAGS='-fPIC' install ") - message(STATUS "*************************************************************************") - message(FATAL_ERROR "stop processing until lz4 is available") -endif() - -add_compile_definitions(__LZ4__) - -set(HIPO_SOURCE_FILES - hipo4/bank.cpp - hipo4/datastream.cpp - hipo4/dictionary.cpp - hipo4/event.cpp - hipo4/fusion.cpp - hipo4/node.cpp - hipo4/parser.cpp - hipo4/reader.cpp - hipo4/recordbuilder.cpp - hipo4/record.cpp - hipo4/tuple.cpp - hipo4/utils.cpp - hipo4/wrapper.cpp - hipo4/writer.cpp - ) - -set(HIPO_HEADERS - hipo4/bank.h - hipo4/datastream.h - hipo4/dictionary.h - hipo4/event.h - hipo4/fizika.h - hipo4/fusion.h - hipo4/hipoexceptions.h - hipo4/json.h - hipo4/jsonutil.h - hipo4/node.h - hipo4/parser.h - hipo4/reaction.h - hipo4/reader.h - hipo4/recordbuilder.h - hipo4/record.h - hipo4/tuple.h - hipo4/twig.h - hipo4/utils.h - hipo4/writer.h - ) - -add_library(hipo4_objs OBJECT ${HIPO_SOURCE_FILES}) -add_library(hipo4 SHARED $) -add_library(hipo4_static STATIC $) -set_target_properties(hipo4_static PROPERTIES OUTPUT_NAME hipo4) # So that the lib is not called libhipo4_static.a - -# Required on Unix OS family to be able to be linked into shared libraries. -set_target_properties(hipo4_objs PROPERTIES POSITION_INDEPENDENT_CODE ON) -# Note: Neither add_dependencies(hipo4_objs PkgConfig::LZ4) nor target_include_directories(hipo4_objs PUBLIC PkgConfig::LZ4) -# work in an Intel Mac. -target_include_directories(hipo4_objs PUBLIC ${LZ4_INCLUDE_DIRS}) - -# Include the macros for creating export package. -include(CMakePackageConfigHelpers) -# Write a package versioning file based on the project version (see top) -write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/hipo4ConfigVersion.cmake" - VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion) - -target_include_directories(hipo4 PUBLIC - $ - $ - $ - ) - -target_link_libraries(hipo4 PUBLIC PkgConfig::LZ4 ) -target_link_libraries(hipo4_static PUBLIC PkgConfig::LZ4) - -list(APPEND PKGCONFIG_LIBS hipo4) - -# build extensions -option(BUILD_DATAFRAMES "Build dataframes extension" ON) -set(WITH_DATAFRAMES FALSE) -if(BUILD_DATAFRAMES) - set(DATAFRAME_IN_MAIN TRUE) - add_subdirectory(extensions/dataframes) -endif() - -install(TARGETS hipo4 - EXPORT hipo4-export - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) - -install(TARGETS hipo4_static - EXPORT hipo4-export - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) - -install(FILES ${HIPO_HEADERS} - DESTINATION ${CMAKE_INSTALL_PREFIX}/include/hipo4) - -install(EXPORT hipo4-export - FILE hipo4Targets.cmake - DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/hipo4) - -install(FILES cmake/LZ4Config.cmake - DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/hipo4) - -export(TARGETS hipo4 - FILE "${PROJECT_BINARY_DIR}/hipo4Targets.cmake") - -configure_package_config_file( cmake/hipo4Config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/hipo4Config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/hipo4 - ) - -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hipo4Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/hipo4ConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/hipo4) - -# pkgconfig file -list(TRANSFORM PKGCONFIG_LIBS PREPEND -l) -list(JOIN PKGCONFIG_LIBS " " PKGCONFIG_LIB_ARGS) -configure_file(${PROJECT_SOURCE_DIR}/cmake/hipo4.pc.in - ${PROJECT_BINARY_DIR}/hipo4.pc - @ONLY) -install(FILES ${PROJECT_BINARY_DIR}/hipo4.pc - DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) diff --git a/Makefile b/Makefile deleted file mode 100644 index 6e9a164..0000000 --- a/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -#*********************************************************** -# MAKEFILE for BUILDING EXAMPLES FOR HIPO4 LIBRARY * -# AUTHOR: GAVALIAN DATE: 10/24/2018 * -#*********************************************************** -# ██╗ ██╗██╗██████╗ ██████╗ ██╗ ██╗ ██████╗ * -# ██║ ██║██║██╔══██╗██╔═══██╗ ██║ ██║ ██╔═████╗ * -# ███████║██║██████╔╝██║ ██║ ███████║ ██║██╔██║ * -# ██╔══██║██║██╔═══╝ ██║ ██║ ╚════██║ ████╔╝██║ * -# ██║ ██║██║██║ ╚██████╔╝ ██║██╗╚██████╔╝ * -# ╚═╝ ╚═╝╚═╝╚═╝ ╚═════╝ ╚═╝╚═╝ ╚═════╝ * -# === Jefferson National Lab (2017) * -#*********************************************************** -# - -### Detect OS -ifeq ($(OS),Windows_NT) - $(info OS detection: Windows) - $(error Windows is not supported for make, try cmake) -endif -UNAME_S := $(shell uname -s) -ifeq ($(UNAME_S),Linux) - $(info OS detection: Linux) - SHAREDEXT = so -endif -ifeq ($(UNAME_S),Darwin) - $(info OS detection: Darwin) - SHAREDEXT = dylib -endif -ifeq ($(SHAREDEXT),) - $(warning OS detection failed; assuming Linux) - SHAREDEXT = so -endif - - -all: lib shlib - -lib: - @test -d lib || mkdir -p lib - @cd lz4 ; make lz4 - @cp lz4/lib/liblz4.a lib/. - @cd hipo4; make -shlib: - @echo compiling shared library - @test -d slib || mkdir -p slib - @cd lz4 ; make - @test -f lz4/lib/liblz4.$(SHAREDEXT) && cp lz4/lib/liblz4.$(SHAREDEXT) slib/. -# @test -f lz4/lib/liblz4.so && cp lz4/lib/liblz4.so lib/. - @cd hipo4 ; make slibhipo - @test -f slib/liblz4.dylib && mv slib/liblz4.dylib slib/liblz4.so || echo 'all done....' - -clean: - @cd lz4; make clean - @cd hipo4; make clean - @cd examples; make clean - @cd examples/root ; make clean - @echo "Cleaning lib directory" - @rm -rf lib/* slib lib diff --git a/README.md b/README.md index 7ba41de..8baedcd 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,107 @@ functionality that exists in C++ and Java libraries. ## Installing the Package -Package has a dependency on LZ4 compression library, which is a submodule. -Use command: +### Dependencies +Click each for details +
+🔸 Meson and Ninja + +> - Meson: +> - Ninja: +> +> Likely available in your package manager (`apt`, `brew`, `dnf`, _etc_.), +> but the versions may be too old, in which case, use `pip` (`python -m pip install meson ninja`) +
+ +
+🔸 LZ4 + +> - LZ4: +> +> Likely available in your package manager, but if you do not have it, it will be installed locally for you +
+ +
+🔸 ROOT (optional) + +> - ROOT: +> +> ROOT is _optional_ and _only_ needed for certain extensions and examples, such as [`HipoDataFrame`](/extensions/dataframes); +> if you do not have ROOT, the complete HIPO library will still be built. +
+ +### Building + +Use standard [Meson commands](https://mesonbuild.com/Quick-guide.html) to build HIPO. + +For example, first create a **build** directory; let's name it `./build`, set the installation location to `./install`, and +run the following command from the source code directory: +```bash +meson setup build --prefix=`pwd`/install +``` +
+Click here for more details + +> - you may run this command from _any_ directory; in that case, provide the path to the source code directory (_e.g._, +> `meson setup build /path/to/source`) +> - the installation prefix must be an _absolute path_; you can change it later (`meson configure`) +
+ +The build directory is where you can compile, test, and more: +```bash +cd build +ninja # compiles +ninja install # installs to your specified prefix (../install/, in the example) +ninja test # runs the tests +ninja clean # clean the build directory, if you need to start over +``` + +### Integrating HIPO with Your Analysis Code +To build your analysis code with the HIPO installation, whether the one in `./install` or an installation on `ifarm` in `$HIPO`, use `pkg-config`. The installation's `lib/pkgconfig` directory +must be in your `$PKG_CONFIG_PATH`, or use your build automation tool's options. +For convenience, you may set `$PKG_CONFIG_PATH` by one of: +```bash +source install/libexec/this_hipo.sh # for bash or zsh +source install/libexec/this_hipo.tcsh # for tcsh ``` - git clone --recurse-submodules git@github.com:gavalian/hipo.git +On the `ifarm` installation, this is already set for you (by `module load hipo`). + +Here is how to use ("consume") HIPO with common build automation tools (click each to see details): + +
+🔸 CMake + +```cmake +find_package(PkgConfig REQUIRED) +pkg_check_modules(hipo4 REQUIRED IMPORTED_TARGET hipo4) +# this creates the target 'PkgConfig::hipo4', so for example: +target_link_libraries(my_analysis_lib PUBLIC PkgConfig::hipo4) ``` +
-to clone the distribution. Then compile using 'make', or 'cmake', and start using. +
+🔸 Meson + +```meson +hipo_dep = dependency('hipo4') +``` +
+ +
+🔸 Makefile or Command Line + +You need the compiler and linker flags, which you can get from running `pkg-config` +```bash +pkg-config --cflags hipo4 +pkg-config --libs hipo4 +``` +You can do this in a Makefile: +```make +HIPO_LIBS := $(shell pkg-config --cflags hipo4) +HIPO_INCS := $(shell pkg-config --libs hipo4) +``` +
## Usage diff --git a/cmake/LZ4Config.cmake b/cmake/LZ4Config.cmake deleted file mode 100644 index cfab0e3..0000000 --- a/cmake/LZ4Config.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# -# Find the LZ4 library and include files and configure target for it. -# -set(ENV{PKG_CONFIG_PATH} "${PKG_CONFIG_PATH}:${CMAKE_INSTALL_PREFIX}/lib/pkgconfig") -find_package(PkgConfig REQUIRED) -pkg_check_modules(LZ4 IMPORTED_TARGET "liblz4") - -if (NOT LZ4_FOUND) - message(STATUS "No system version of LZ4 found.") -else() - add_library(LZ4 INTERFACE IMPORTED) - set_target_properties(LZ4 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LZ4_INCLUDE_DIR}") - message(STATUS "Found LZ4: ${LZ4_LIBRARIES}") - mark_as_advanced(LZ4_INCLUDE_DIRS LZ4_INCLUDE_DIR LZ4_LIBRARIES LZ4_LIBRARY) -endif (NOT LZ4_FOUND) diff --git a/cmake/hipo4.pc.in b/cmake/hipo4.pc.in deleted file mode 100644 index a9f593d..0000000 --- a/cmake/hipo4.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=${pcfiledir}/../.. -includedir=${prefix}/include -libdir=${prefix}/lib - -with_dataframes=@WITH_DATAFRAMES@ - -Name: hipo4 -Description: High Performance Output data format for experimental physics -Version: @HIPO_VERSION@ -Requires: liblz4 >= @LZ4_VERSION@ -Libs: -L${libdir} @PKGCONFIG_LIB_ARGS@ -Cflags: -I${includedir} diff --git a/cmake/hipo4Config.cmake.in b/cmake/hipo4Config.cmake.in deleted file mode 100644 index c46e37e..0000000 --- a/cmake/hipo4Config.cmake.in +++ /dev/null @@ -1,8 +0,0 @@ -# -# Input for cmake to create the package configuration file: hipo4Config.cmake -# for find_package() -# -@PACKAGE_INIT@ -include(CMakeFindDependencyMacro) -find_dependency(LZ4 REQUIRED CONFIG PATHS ${CMAKE_CURRENT_LIST_DIR} ) -include("${CMAKE_CURRENT_LIST_DIR}/hipo4Targets.cmake") diff --git a/examples/Makefile b/examples/Makefile deleted file mode 100644 index 65b9c85..0000000 --- a/examples/Makefile +++ /dev/null @@ -1,90 +0,0 @@ -#******************************************************** -# MAKEFILE for BUILDING EXAMPLES FOR HIPO4 LIBRARY -# AUTHOR: GAVALIAN DATE: 10/24/2018 -#******************************************************** -HIPOCFLAGS := -I../hipo4 -I../hipo4/chart -HIPOLIBS := -L../lib -lhipo4 - -LZ4LIBS := -L../lz4/lib -llz4 -LZ4INCLUDES := -I../lz4/lib - -CXX := g++ -CXXFLAGS += -Wall -fPIC -std=c++17 -LD := g++ -LDFLAGS := - - -all: writeFile readFile readFileTags showFile schema writeUserHeader tupleFile readJson dataframe histograms bankRowList multithread - -histograms: histograms.o - $(CXX) -o histograms.exe $< $(HIPOLIBS) $(LZ4LIBS) - -multithread: multithread.o - $(CXX) -o multithread.exe $< $(HIPOLIBS) $(LZ4LIBS) - -bankRowList: bankRowList.o - $(CXX) -o bankRowList.exe $< $(HIPOLIBS) $(LZ4LIBS) - -readEvents: readEvents.o - $(CXX) -o readEvents.exe $< $(HIPOLIBS) $(LZ4LIBS) - -node: node.o - $(CXX) -o node.exe $< $(HIPOLIBS) $(LZ4LIBS) - -dataframe: dataframe.o - $(CXX) -o dataframe.exe $< $(HIPOLIBS) $(LZ4LIBS) - -readHist: readHist.o - $(CXX) -o readHist.exe $< $(HIPOLIBS) $(LZ4LIBS) - -writeEvents: writeEvents.o - $(CXX) -o writeEvents.exe $< $(HIPOLIBS) $(LZ4LIBS) - -writeUserHeader: writeUserHeader.o - $(CXX) -o writeUserHeader.exe $< $(HIPOLIBS) $(LZ4LIBS) - -showFile: showFile.o - $(CXX) -o showFile.exe $< $(HIPOLIBS) $(LZ4LIBS) - -readFileDebug: readFileDebug.o - $(CXX) -o readFileDebug.exe $< $(HIPOLIBS) $(LZ4LIBS) - -readJson: readJson.o - $(CXX) -o readJson.exe $< $(HIPOLIBS) $(LZ4LIBS) - -readFile: readFile.o - $(CXX) -o readFile.exe $< $(HIPOLIBS) $(LZ4LIBS) - -readFusion: readFusion.o - $(CXX) -o readFusion.exe $< $(HIPOLIBS) $(LZ4LIBS) - -readFileTags: readFileTags.o - $(CXX) -o readFileTags.exe $< $(HIPOLIBS) $(LZ4LIBS) - -tupleFile: tupleFile.o - $(CXX) -o tupleFile.exe $< $(HIPOLIBS) $(LZ4LIBS) - -writeFile: writeFile.o - $(CXX) -o writeFile.exe $< $(HIPOLIBS) $(LZ4LIBS) - -writeFileComposite: writeFileComposite.o - $(CXX) -o writeFileComposite.exe $< $(HIPOLIBS) $(LZ4LIBS) - -schema: schema.o - $(CXX) -o schema.exe $< $(HIPOLIBS) $(LZ4LIBS) - -builder: builder.o - $(CXX) -o builder.exe $< $(HIPOLIBS) $(LZ4LIBS) - -#analysis: analysis.o -# $(CXX) -o analysis $< $(HIPOLIBS) $(LZ4LIBS) - -#clas12event_example: clas12event_example.o -# $(CXX) -o clas12event_example $< $(HIPOLIBS) $(LZ4LIBS) - -clean: - @echo 'Removing all build files' - @rm -rf *.o *~ *.exe example*hipo - -%.o: %.cc - $(CXX) -c $< -O2 $(CXXFLAGS) $(HIPOCFLAGS) $(LZ4INCLUDES) diff --git a/examples/benchmarks/Makefile b/examples/benchmarks/Makefile deleted file mode 100644 index de0fad1..0000000 --- a/examples/benchmarks/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#******************************************************** -# MAKEFILE for BUILDING EXAMPLES FOR HIPO4 LIBRARY -# AUTHOR: GAVALIAN DATE: 10/24/2018 -#******************************************************** -HIPOCFLAGS := -I../../hipo4 -HIPOLIBS := -L../../lib -lhipo4 - -LZ4LIBS := -L../../lz4/lib -llz4 -LZ4INCLUDES := -I../../lz4/lib - -CXX := g++ -CXXFLAGS += -Wall -fPIC -std=c++11 -LD := g++ -LDFLAGS := - - -all: map - -map: map_benchmark.o - $(CXX) -o map_benchmark.exe $< $(HIPOLIBS) $(LZ4LIBS) - -ana: ana_benchmark.o - $(CXX) -o ana_benchmark.exe $< $(HIPOLIBS) $(LZ4LIBS) -#analysis: analysis.o -# $(CXX) -o analysis $< $(HIPOLIBS) $(LZ4LIBS) - -#clas12event_example: clas12event_example.o -# $(CXX) -o clas12event_example $< $(HIPOLIBS) $(LZ4LIBS) - -clean: - @echo 'Removing all build files' - @rm -rf *.o *~ *.exe - -%.o: %.cc - $(CXX) -O2 -c $< $(CXXFLAGS) $(HIPOCFLAGS) $(LZ4INCLUDES) diff --git a/examples/benchmarks/ana_benchmark.cc b/examples/benchmarks/ana_benchmark.cc index e5c0ca4..995790c 100644 --- a/examples/benchmarks/ana_benchmark.cc +++ b/examples/benchmarks/ana_benchmark.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include "utils.h" #include "reader.h" @@ -85,7 +86,7 @@ int main(int argc, char** argv) { float px = particles.getFloat(1,row); float py = particles.getFloat(2,row); float pz = particles.getFloat(3,row); - double p = sqrt(px*px+py*py+pz*pz); + double p = std::sqrt(px*px+py*py+pz*pz); double energy = 0.0; if(responses.count(row)>0){ c3++; diff --git a/examples/fortran/Makefile b/examples/fortran/Makefile deleted file mode 100644 index 7c0b13e..0000000 --- a/examples/fortran/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -##################################################################### -## EXAMPLE MAKEFILE FOR COMPILING FORTRAN INTERFACE -##################################################################### -HIPOLIBS := -L../../lib -lhipo4 -LZ4LIBS := -L../../lz4/lib -llz4 - -F77 = gfortran -CXX := g++ -CXXFLAGS += -Wall -fPIC -LD := g++ -LDFLAGS := - -#CERNINCLUDES = -I$(CERN_ROOT)/include/cfortran -#CERNLIBS = -L$(CERN_ROOT)/lib -lpacklib -lgfortran -#CERNFLAGS = -w -Df2cFortran - -all: freader - -freader: freader.o - $(F77) -o freader.exe freader.o -lgcc -lstdc++ $(HIPOLIBS) $(LZ4LIBS) - -clean: - @echo 'Removing all build files....' - @rm -rf *.o *~ freader.exe -#===================================================================== -# COMPILE RULES -#===================================================================== -%.o: %.cc - $(CXX) -c $< -O2 $(ROOTCFLAGS) $(HIPOCFLAGS) $(LZ4INCLUDES) - -%.o:%.F - $(F77) -c $< diff --git a/examples/fortran/freader.F b/examples/fortran/freader.F index 8f7464b..67400f0 100644 --- a/examples/fortran/freader.F +++ b/examples/fortran/freader.F @@ -5,7 +5,16 @@ PROGRAM HIPOREADER REAL PX(50) INTEGER PID(50) INTEGER CHARGE(50) - CALL HIPO_FILE_OPEN('infile.hipo') + + INTEGER*4 ARGC + CHARACTER*1024 IN_FILE + ARGC = IARGC() + IF(ARGC.lt.1) THEN + PRINT *, 'USAGE: freader.exe [HIPO_FILE]' + STOP + END IF + CALL GETARG(1, IN_FILE) + CALL HIPO_FILE_OPEN(TRIM(IN_FILE)) STATUS = 0 COUNTER = 0 diff --git a/examples/meson.build b/examples/meson.build new file mode 100644 index 0000000..e1e7a69 --- /dev/null +++ b/examples/meson.build @@ -0,0 +1,62 @@ +external_test_file = get_option('test_file') +test_external = external_test_file != '' # true if a user specified a test file + +example_sources = [ + ### { + ### 'sources': list of source code files; the example name will be based off the first one + ### 'test_this': boolean, whether or not to run this example as a test + ### 'test_args': list of arguments for this example, used for testing + ### 'first': boolean, whether this test should be run before any others (default = false) + ### 'build_this': whether or not to build this (default = true) + ### 'deps': additional dependencies (default = []) + ### }, + { 'sources': [ 'bankRowList.cc' ], 'test_this': test_external, 'test_args': [ external_test_file ] }, + { 'sources': [ 'builder.cc' ], 'test_this': false, 'test_args': [] }, + { 'sources': [ 'dataframe.cc' ], 'test_this': false, 'test_args': [] }, + { 'sources': [ 'histograms.cc' ], 'test_this': test_external, 'test_args': [ external_test_file ] }, + { 'sources': [ 'multithread.cc' ], 'test_this': false, 'test_args': [], 'deps': [ thread_dep ], 'build_this': thread_dep.found() }, + { 'sources': [ 'readEvents.cc' ], 'test_this': false, 'test_args': [] }, + { 'sources': [ 'readFile.cc' ], 'test_this': true, 'test_args': [ 'example_output.hipo' ] }, + { 'sources': [ 'readFileDebug.cc' ], 'test_this': false, 'test_args': [] }, + { 'sources': [ 'readFileTags.cc' ], 'test_this': true, 'test_args': [] }, + { 'sources': [ 'readFusion.cc' ], 'test_this': false, 'test_args': [] }, + { 'sources': [ 'readHist.cc' ], 'test_this': false, 'test_args': [] }, + { 'sources': [ 'readJson.cc' ], 'test_this': test_external, 'test_args': [ external_test_file ] }, + { 'sources': [ 'schema.cc' ], 'test_this': false, 'test_args': [] }, + { 'sources': [ 'showFile.cc' ], 'test_this': true, 'test_args': [ 'example_output.hipo', 'event::particle' ] }, + { 'sources': [ 'tupleFile.cc' ], 'test_this': true, 'test_args': [] }, + { 'sources': [ 'writeEvents.cc' ], 'test_this': false, 'test_args': [] }, + { 'sources': ['writeFile.cc' ], 'test_this': true, 'test_args': [], 'first': true }, + { 'sources': [ 'writeFileComposite.cc' ], 'test_this': false, 'test_args': [], 'build_this': false }, # FIXME: does not compile + { 'sources': [ 'writeUserHeader.cc' ], 'test_this': true, 'test_args': [] }, + ##### benchmarks/ + { 'sources': [ 'benchmarks/ana_benchmark.cc' ], 'test_this': false, 'test_args': [] }, + { 'sources': [ 'benchmarks/map_benchmark.cc' ], 'test_this': false, 'test_args': [] }, + ##### fortran/ + { 'sources': [ 'fortran/freader.F' ], 'test_this': test_external, 'test_args': [ external_test_file ], 'build_this': get_option('test_fortran') }, +] + +foreach ex : example_sources + example_name = 'hipo_' + fs.stem(ex['sources'][0]) + if(ex.get('build_this', true)) + example_exe = executable( + example_name, + sources: ex['sources'], + include_directories: [ hipo_inc ], + link_with: project_libs, + dependencies: ex.get('deps', []), + install: get_option('install_examples'), + cpp_args: [ '-Wno-sign-compare' ], # FIXME: fix the warnings; they are suppressed by these args + ) + if(ex.get('test_this', true)) + test( + example_name, + example_exe, + suite: [ 'example' ], + args: ex.get('test_args', []), + priority: ex.get('first', false) ? 1 : 0, # make sure 'first' tests start before any other + is_parallel: ex.get('first', false) ? false : true, # make sure 'first' tests finish before any other + ) + endif + endif +endforeach diff --git a/examples/root/Makefile b/examples/root/Makefile deleted file mode 100644 index 2a763c5..0000000 --- a/examples/root/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -#===================================================================== -# MAKEFILE for building ROOT CONVERTER -#===================================================================== -ROOTCFLAGS := $(shell root-config --cflags) -ROOTLDFLAGS := $(shell root-config --ldflags) -ROOTLIBS := $(shell root-config --libs) -lEG -ROOTGLIBS := $(shell root-config --glibs) - -HIPOCFLAGS := -I../../hipo4 -HIPOLIBS := -L../../lib -lhipo4 - -LZ4LIBS := -L../../lz4/lib -llz4 -LZ4INCLUDES := -I../../lz4/lib - -F77 = gfortran -CXX := g++ -CXXFLAGS += -Wall -fPIC $(ROOTCFLAGS) -LD := g++ -LDFLAGS := $(ROOTLDFLAGS) - - -all: converter benchmark - -hist2root: hist2root.o - $(CXX) -o hist2root.exe $< $(ROOTCFLAGS) $(ROOTLDFLAGS) $(HIPOLIBS) $(LZ4LIBS) $(ROOTLIBS) - -converter: converter.o - $(CXX) -o converter.exe $< $(ROOTCFLAGS) $(ROOTLDFLAGS) $(HIPOLIBS) $(LZ4LIBS) $(ROOTLIBS) - -simulation2hipo: simulation2hipo.o - $(CXX) -o simulation2hipo.exe $< $(ROOTCFLAGS) $(ROOTLDFLAGS) $(HIPOLIBS) $(LZ4LIBS) $(ROOTLIBS) - -#benchmark_root: benchmark_root.o -# $(CXX) -o benchmark_root.exe $< $(ROOTCFLAGS) $(ROOTLDFLAGS) $(HIPOLIBS) $(LZ4LIBS) $(ROOTLIBS) -# -#benchmark_hipo: benchmark_hipo.o -# $(CXX) -o benchmark_hipo.exe $< $(ROOTCFLAGS) $(ROOTLDFLAGS) $(HIPOLIBS) $(LZ4LIBS) $(ROOTLIBS) - -benchmark: benchmark.o - $(CXX) -o benchmark.exe $< $(ROOTCFLAGS) $(ROOTLDFLAGS) $(HIPOLIBS) $(LZ4LIBS) $(ROOTLIBS) -# -#benchmark_hipo_ana: benchmark_hipo_ana.o -# $(CXX) -o benchmark_hipo_ana.exe $< $(ROOTCFLAGS) $(ROOTLDFLAGS) $(HIPOLIBS) $(LZ4LIBS) $(ROOTLIBS) - -clean: - @echo 'Removing all build files' - @rm -rf *.o converter.exe *~ benchmark*.exe *.class -#===================================================================== -# COMPILE RULES -#===================================================================== -%.o: %.cc - $(CXX) -c $< -O3 $(ROOTCFLAGS) $(HIPOCFLAGS) $(LZ4INCLUDES) - -%.o:%.F - $(F77) -c $< diff --git a/examples/root/meson.build b/examples/root/meson.build new file mode 100644 index 0000000..0456369 --- /dev/null +++ b/examples/root/meson.build @@ -0,0 +1,19 @@ +example_root_sources = [ + { 'sources': [ 'benchmark.cc' ], 'install_this': false }, + { 'sources': [ 'converter.cc' ], 'install_this': get_option('install_root_tools') }, + { 'sources': [ 'hist2root.cc' ], 'install_this': get_option('install_root_tools') }, + { 'sources': [ 'simulation2hipo.cc' ], 'install_this': get_option('install_root_tools') }, +] + +foreach ex : example_root_sources + example_name = 'hipo_' + fs.stem(ex['sources'][0]) + example_exe = executable( + example_name, + sources: ex['sources'], + include_directories: [ hipo_inc, include_directories(ROOT_incdir) ], + link_with: [ hipo_lib ], + link_args: [ '-L' + ROOT_libdir, '-lCore', '-lRIO', '-lHist', '-lTree', '-lPhysics' ], + install: ex['install_this'], + cpp_args: [ '-Wno-unused-variable', '-Wno-unused-but-set-variable', '-Wno-sign-compare' ], # FIXME: fix the warnings + ) +endforeach diff --git a/examples/xrootd/Makefile b/examples/xrootd/Makefile index 630f7bc..b0777ce 100644 --- a/examples/xrootd/Makefile +++ b/examples/xrootd/Makefile @@ -2,11 +2,8 @@ # MAKEFILE for BUILDING EXAMPLES FOR HIPO4 LIBRARY # AUTHOR: GAVALIAN DATE: 10/24/2018 #******************************************************** -HIPOCFLAGS := -I../../hipo4 -HIPOLIBS := -L../../lib -lhipo4 -LZ4LIBS := -L../../lz4/lib -llz4 -LZ4INCLUDES := -I../../lz4/lib +include ../../meson/Makefile_config.mk XROOTDINCLUDES := -I/opt/homebrew/Cellar/xrootd/5.4.3/include/xrootd XROOTDLIBS := -L/opt/homebrew/Cellar/xrootd/5.4.3/lib -lXrdClient diff --git a/extensions/coda/Makefile b/extensions/coda/Makefile index 60c6121..f34a91a 100644 --- a/extensions/coda/Makefile +++ b/extensions/coda/Makefile @@ -2,11 +2,10 @@ # MAKEFILE for BUILDING EXAMPLES FOR HIPO4 LIBRARY # AUTHOR: GAVALIAN DATE: 10/24/2018 #******************************************************** -HIPOCFLAGS := -I../../hipo4 -Ievio -HIPOLIBS := -L../../lib -lhipo4 -LZ4LIBS := -L../../lz4/lib -llz4 -LZ4INCLUDES := -I../../lz4/lib +include ../../meson/Makefile_config.mk + +EVIOCFLAGS := -Ievio CXX := g++ CC := gcc @@ -32,6 +31,6 @@ clean: @rm -rf *.o *~ *.exe example*hipo %.o: %.cc - $(CXX) -c $< -O3 $(CXXFLAGS) $(HIPOCFLAGS) $(LZ4INCLUDES) + $(CXX) -c $< -O3 $(CXXFLAGS) $(HIPOCFLAGS) $(EVIOCFLAGS) $(LZ4INCLUDES) %.o: %.c - $(CC) -c $< -O3 $(HIPOCFLAGS) $(LZ4INCLUDES) + $(CC) -c $< -O3 $(HIPOCFLAGS) $(EVIOCFLAGS) $(LZ4INCLUDES) diff --git a/extensions/dataframes/CMakeLists.txt b/extensions/dataframes/CMakeLists.txt deleted file mode 100644 index 5b4be09..0000000 --- a/extensions/dataframes/CMakeLists.txt +++ /dev/null @@ -1,138 +0,0 @@ -########################################################## -# CMake configuration for Hipo # -# # -# @author Maurik Holtrop, University of New Hampshire # -# # -########################################################## - -cmake_minimum_required(VERSION 3.22) - -project(HipoDataFrame VERSION 0.1) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -# -# Set a default build type if none was specified -# -set(default_build_type "RELEASE") -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Setting build type to '${default_build_type}' as none was specified.") - set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) - # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Release" "MinSizeRel" "RelWithDebInfo") -endif() - -if(APPLE) - # use, i.e. don't skip the full RPATH for the build tree - set(CMAKE_SKIP_BUILD_RPATH FALSE) - - # when building, don't use the install RPATH already - # (but later on when installing) - set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) - - set(CMAKE_INSTALL_RPATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") - - # add the automatically determined parts of the RPATH - # which point to directories outside the build tree to the install RPATH - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - - # the RPATH to be used when installing, but only if it's not a system directory - list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" isSystemDir) - if("${isSystemDir}" STREQUAL "-1") - set(CMAKE_INSTALL_RPATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") - endif("${isSystemDir}" STREQUAL "-1") - -endif(APPLE) - -if(NOT DATAFRAME_IN_MAIN) - find_package(hipo4 REQUIRED) - if( ${hipo4_FOUND}) - message(STATUS "Hipo4 found. ") - endif() -endif() - -find_package(ROOT COMPONENTS Core ROOTDataFrame ROOTVecOps) -if(NOT ROOT_FOUND) - message(STATUS "**ROOT*******************************************************************") - message(STATUS "* We did not find a compatible version of the ROOT libraries. *") - message(STATUS "* These libraries are needed to compile the RDataFrame funcionality of *") - message(STATUS "* HIPO, which allows you to do fast and efficient data analysis with *") - message(STATUS "* ROOT. *") - message(STATUS "* To enable this, please make sure you have initialized a ROOT version *") - message(STATUS "* that was compiled with -DCMAKE_CXX_STANDARD=17 *") - message(STATUS "*************************************************************************") -else() - message(STATUS "ROOT found at: ${ROOT_DIR}") - #---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY) - - include(${ROOT_USE_FILE}) - - set(DS_HEADERS - RHipoDS.hxx) - - set(DS_SOURCE_FILES - RHipoDS.cxx) - - set(DS_LINKDEF_FILES - RHipoDS_LinkDef.h) - - add_library(HipoDataFrame SHARED ${DS_SOURCE_FILES} ) - target_link_libraries(HipoDataFrame PUBLIC hipo4 ROOT::ROOTDataFrame ROOT::ROOTVecOps ) # ${ROOT_LIBRARIES} - - ROOT_GENERATE_DICTIONARY(HipoDataFrame_Dict ${DS_HEADERS} LINKDEF ${DS_LINKDEF_FILES} MODULE HipoDataFrame) - # See this discussion why ROOT_GENERATE_DICTIONARY come *after* add_library() -- https://github.com/root-project/root/issues/8308 - list(APPEND ADDITIONAL_CLEAN_FILES HipoDataFrame_Dict.cxx) - - add_executable(test_hipo_ds test_hipo_ds.cxx) - target_link_libraries(test_hipo_ds HipoDataFrame ROOT::Core ROOT::Hist) - - add_executable(test_hipo_speed test_hipo_speed.cxx) - target_link_libraries(test_hipo_speed HipoDataFrame ROOT::Core ROOT::Hist) - - add_executable(test_root_speed test_root_speed.cxx) - target_link_libraries(test_root_speed ROOT::Core ROOT::Hist ROOT::ROOTDataFrame ROOT::ROOTVecOps) - - - include(CMakePackageConfigHelpers) - # Write a package versioning file based on the project version (see top) - write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/HipoDataFrameConfigVersion.cmake" - VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion) - - target_include_directories(HipoDataFrame PUBLIC - $ - $ - $ - ) - - install(TARGETS HipoDataFrame - EXPORT HipoDataFrame-export - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) - - install(FILES ${DS_HEADERS} - DESTINATION include/hipo4) - - install(FILES ${PROJECT_BINARY_DIR}/libHipoDataFrame_rdict.pcm DESTINATION lib) - install(FILES ${PROJECT_BINARY_DIR}/libHipoDataFrame.rootmap DESTINATION lib) - - install(EXPORT HipoDataFrame-export - FILE HipoDataFrameTargets.cmake - DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/HipoDataFrame) - - export(TARGETS HipoDataFrame - FILE "${PROJECT_BINARY_DIR}/HipoDataFrameTargets.cmake") - - configure_package_config_file( cmake/HipoDataFrameConfig.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/HipoDataFrameConfig.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/HipoDataFrame - ) - - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/HipoDataFrameConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/HipoDataFrameConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/HipoDataFrame) - - list(APPEND PKGCONFIG_LIBS HipoDataFrame) - set(PKGCONFIG_LIBS ${PKGCONFIG_LIBS} PARENT_SCOPE) - set(WITH_DATAFRAMES TRUE PARENT_SCOPE) -endif() diff --git a/extensions/dataframes/README.md b/extensions/dataframes/README.md index b8f2809..5f78341 100644 --- a/extensions/dataframes/README.md +++ b/extensions/dataframes/README.md @@ -16,17 +16,8 @@ flag -DCMAKE_CXX_STANDARD=17, so that it has the RDataFrame library. ### Recommended Way It is recommended that you build the libHipoDataFrame.so -(.dylib on Mac) library together with the HIPO library using "cmake". - -Here are the steps: -```bash -git clone https://github.com/gavalian/hipo.git -cd hipo -mkdir build -cd build -cmake -DCMAKE_INSTALL_PREFIX=/path/to/install/location .. -make -j8 install -``` +(.dylib on Mac) library together with the HIPO library using Meson. +See the [main README](/README.md) for guidance. This will install the hipo4 and HipoDataFrame libraries in `/path/to/install/location/lib` @@ -75,4 +66,4 @@ The result would be a histogram of the REC::Particle.px, i.e the x component of for all particles in the events. The ROOT RDataFrame is very versatile and is intended by the ROOT team as the future of -data analysis. [See more details on the ROOT website](https://root.cern/doc/master/classROOT_1_1RDataFrame.html). \ No newline at end of file +data analysis. [See more details on the ROOT website](https://root.cern/doc/master/classROOT_1_1RDataFrame.html). diff --git a/extensions/dataframes/cmake/HipoDataFrameConfig.cmake.in b/extensions/dataframes/cmake/HipoDataFrameConfig.cmake.in deleted file mode 100644 index c778bd3..0000000 --- a/extensions/dataframes/cmake/HipoDataFrameConfig.cmake.in +++ /dev/null @@ -1,8 +0,0 @@ -# -# Input for cmake to create the package configuration file: HipoDataFrameConfig.cmake -# for find_package() -# -@PACKAGE_INIT@ -include(CMakeFindDependencyMacro) -find_dependency(hipo4 REQUIRED CONFIG PATHS ${CMAKE_CURRENT_LIST_DIR} ) -include("${CMAKE_CURRENT_LIST_DIR}/HipoDataFrameTargets.cmake") diff --git a/extensions/dataframes/meson.build b/extensions/dataframes/meson.build index 782ee3e..19482e3 100644 --- a/extensions/dataframes/meson.build +++ b/extensions/dataframes/meson.build @@ -1,45 +1,55 @@ -dataframe_headers = files('RHipoDS.hxx') +dataframe_headers = [ # NOTE: headers must be absolute paths, for rootcling's generated `#include` directives to work correctly + meson.current_source_dir() / 'RHipoDS.hxx', +] dataframe_sources = files('RHipoDS.cxx') dataframe_linkdef = files('RHipoDS_LinkDef.h') -# ROOT stuff -ROOT_config = find_program('root-config') -ROOT_cling = find_program('rootcling') -ROOT_libdir = run_command(ROOT_config, '--libdir', check: true).stdout().strip() -ROOT_incdir = run_command(ROOT_config, '--incdir', check: true).stdout().strip() -ROOT_inc = include_directories(ROOT_incdir) - # generate ROOT dictionary -dataframe_dict = 'HipoDataFrame_Dict.cxx' -dataframe_lib_file = meson.current_build_dir() / 'libHipoDataFrame.so' # FIXME: file extension is platform dependent +dataframe_basename = 'HipoDataFrame' +dataframe_lib_ext = host_machine.system() == 'darwin' ? 'dylib' : 'so' # FIXME: platform dependence is meson's job, not ours +dataframe_lib_file = f'lib@dataframe_basename@.@dataframe_lib_ext@' dataframe_dict_tgt = custom_target( - 'HipoDataFrameDict', - input: dataframe_headers + hipo_headers + hipo_sources + [ dataframe_linkdef ], - output: [ dataframe_dict ], + '@dataframe_basename@Dict', + input: dataframe_headers + hipo_headers + hipo_sources + dataframe_linkdef, + output: [ + f'@dataframe_basename@_Dict.cxx', + f'lib@dataframe_basename@_rdict.pcm', + f'lib@dataframe_basename@.rootmap', + ], + install_dir: [ + false, # generated .cxx file, don't install + get_option('libdir'), # generated .pcm file + get_option('libdir'), # generated .rootmap file + ], + install: true, command: [ ROOT_cling, '-v2', - '-f', meson.current_build_dir() / dataframe_dict, - '-s', dataframe_lib_file, - '-rml', fs.name(dataframe_lib_file), - '-rmf', fs.parent(dataframe_lib_file) / fs.stem(dataframe_lib_file) + '.rootmap', + '-f', '@OUTPUT0@', + '-s', meson.current_build_dir() / dataframe_lib_file, + '-rml', dataframe_lib_file, + '-rmf', '@OUTPUT2@', lz4_preproc_def, '-I' + ROOT_incdir, '-I' + hipo_incdir, - ] + dataframe_sources + dataframe_linkdef, + ] + dataframe_headers + dataframe_linkdef, ) # library dataframe_lib = library( - 'HipoDataFrame', + dataframe_basename, dataframe_sources + [ dataframe_dict_tgt[0] ], - include_directories: [ hipo_inc, ROOT_inc ], - link_with: [ hipo_lib ], - link_args: [ '-L' + ROOT_libdir, '-lCore', '-lROOTDataFrame', '-lROOTVecOps'], - build_rpath: ROOT_libdir, - cpp_args: [ '-Wno-sign-compare' ], # FIXME: fix these warnings + include_directories: [ hipo_inc, include_directories(ROOT_incdir) ], + link_with: [ hipo_lib ], + link_args: [ '-L' + ROOT_libdir, '-lCore', '-lROOTDataFrame', '-lROOTVecOps' ], + build_rpath: ROOT_libdir, + cpp_args: [ '-Wno-sign-compare' ], # FIXME: fix these warnings install: true ) install_headers(dataframe_headers, subdir: meson.project_name()) project_libs += dataframe_lib +# make sure the library name used in rootcling matches that of `dataframe_lib` (see above 'FIXME' regarding platform dependence) +if(dataframe_lib_file != fs.name(dataframe_lib.full_path())) + error(f'dataframe library name mismatch; perhaps you are not building on Linux of macOS; please contact the maintainers') +endif diff --git a/extensions/dc/Makefile b/extensions/dc/Makefile index 5a2141b..2606699 100644 --- a/extensions/dc/Makefile +++ b/extensions/dc/Makefile @@ -2,11 +2,10 @@ # MAKEFILE for BUILDING EXAMPLES FOR HIPO4 LIBRARY # AUTHOR: GAVALIAN DATE: 10/24/2018 #******************************************************** -HIPOCFLAGS := -I../../hipo4 -I./submodules/install/include -HIPOLIBS := -L../../lib -lhipo4 -LZ4LIBS := -L../../lz4/lib -llz4 -lpthread -LZ4INCLUDES := -I../../lz4/lib +include ../../meson/Makefile_config.mk + +SUBMODULECFLAGS := -I./submodules/install/include CXX := g++ CXXFLAGS += -Wall -fPIC -std=c++14 -Wunknown-pragmas @@ -40,5 +39,5 @@ submodules: $(MAKE) -C submodules all %.o: %.cc - $(CXX) -c $< -O3 $(CXXFLAGS) $(HIPOCFLAGS) $(LZ4INCLUDES) + $(CXX) -c $< -O3 $(CXXFLAGS) $(HIPOCFLAGS) $(SUBMODULECFLAGS) $(LZ4INCLUDES) diff --git a/extensions/julia/lib/Makefile b/extensions/julia/lib/Makefile deleted file mode 100644 index 26d74f6..0000000 --- a/extensions/julia/lib/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -SOURCES := $(wildcard *.cc) -OBJECTS := $(SOURCES:.cc=.o) - -LIBDIR = ../lib -SLIBDIR = ../slib -BINDIR = ../bin - -#LZ4INCLUDES := -I../Lz4/lib/ -HIPOINCLUDES := -I../../../hipo4 -LZ4INCLUDES := -I../../../lz4/lib/ - -HIPOLIBS := -L../../../lib -lhipo4 -LZ4LIBS := -L../../../lz4/lib -llz4 - -CXXFLAGS = -std=c++17 - - -slibhipo: $(OBJECTS) - $(CXX) -shared $(OBJECTS) -o ../libjulia.so $(HIPOLIBS) $(LZ4LIBS) - -show: - @echo $(OBJECTS) - -clean: - @echo 'Removing the build files....' - @rm -rf *~ *.o lib*.so - -%.o: %.cc - $(CXX) -fPIC -c $< -O3 $(CXXFLAGS) $(LZ4INCLUDES) $(HIPOINCLUDES) diff --git a/extensions/julia/modules/Reaction.jl b/extensions/julia/modules/Reaction.jl index e7c9fc2..00bc379 100644 --- a/extensions/julia/modules/Reaction.jl +++ b/extensions/julia/modules/Reaction.jl @@ -19,7 +19,7 @@ export Descriptor function __init__() @printf("loading the Julia interface library\n") - libjulia = dlopen("libjulia.so") + libjulia = dlopen("libhipo4.so") # FIXME: how to find this library; use get(ENV, "HIPO") ? end function extract_braces_content(input_string::String) diff --git a/extensions/machine/Makefile b/extensions/machine/Makefile index 8ebf45b..ba3fdbf 100644 --- a/extensions/machine/Makefile +++ b/extensions/machine/Makefile @@ -1,13 +1,10 @@ +include ../../meson/Makefile_config.mk SOURCES := $(wildcard *.cpp) OBJECTS := $(SOURCES:.cpp=.o) LIBDIR = ../lib SLIBDIR = ../slib -BINDIR = ../bin - -#LZ4INCLUDES := -I../Lz4/lib/ -LZ4INCLUDES := -I../lz4/lib/ -I../hipo4 CXXFLAGS = -std=c++11 @@ -38,6 +35,6 @@ clean: @rm -rf *~ *.o *.exe %.o: %.cpp - $(CXX) -fPIC -c $< -O2 -D__LZ4__ $(CXXFLAGS) $(LZ4INCLUDES) + $(CXX) -fPIC -c $< -O2 -D__LZ4__ $(CXXFLAGS) $(LZ4INCLUDES) $(HIPOCFLAGS) %.o: %.cc $(CXX) -fPIC -c $< -O2 -D__LZ4__ $(CXXFLAGS) $(LZ4INCLUDES) diff --git a/hipo4/Makefile b/hipo4/Makefile deleted file mode 100644 index 5d076bd..0000000 --- a/hipo4/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -SOURCES := $(wildcard *.cpp) -OBJECTS := $(SOURCES:.cpp=.o) - -LIBDIR = ../lib -SLIBDIR = ../slib -BINDIR = ../bin - -#LZ4INCLUDES := -I../Lz4/lib/ -LZ4INCLUDES := -I../lz4/lib/ -LZ4INCLUDES := -I../lz4/lib/ - -CXXFLAGS = -std=c++17 - -libhipo: checkdirs $(OBJECTS) - ar cr ../lib/libhipo4.a $(OBJECTS) -# $(CXX) -shared -fPIC -o ../lib/libhipo.so $(OBJECTS) -llz4 - -slibhipo: checkdirs $(OBJECTS) - $(CXX) -shared $(OBJECTS) -L ../slib -llz4 -o ../slib/libhipo4.so - -show: - @echo $(OBJECTS) - -checkdirs: $(LIBDIR) $(SLIBDIR) - -$(LIBDIR): - @mkdir -p $(LIBDIR) - -$(SLIBDIR): - @mkdir -p $(SLIBDIR) -clean: - @echo 'Removing the build files....' - @rm -rf *~ *.o - -%.o: %.cpp - $(CXX) -fPIC -c $< -O3 -D__LZ4__ $(CXXFLAGS) $(LZ4INCLUDES) diff --git a/hipo4/fizika.h b/hipo4/fizika.h index c4ca9b7..cc550d5 100644 --- a/hipo4/fizika.h +++ b/hipo4/fizika.h @@ -22,7 +22,6 @@ #ifndef __VECTOR_LIB__ #define __VECTOR_LIB__ -namespace fizika { #include #include @@ -31,6 +30,8 @@ namespace fizika { #include #include +namespace fizika { + class vector3 { private: double cX; @@ -278,4 +279,4 @@ inline lorentz4 &lorentz4::operator -= (const lorentz4 & q) { } } -#endif \ No newline at end of file +#endif diff --git a/hipo4/meson.build b/hipo4/meson.build index 2c6307e..db3375e 100644 --- a/hipo4/meson.build +++ b/hipo4/meson.build @@ -6,9 +6,10 @@ hipo_sources = files( 'fusion.cpp', 'node.cpp', 'parser.cpp', + 'reaction.cpp', 'reader.cpp', - 'recordbuilder.cpp', 'record.cpp', + 'recordbuilder.cpp', 'tuple.cpp', 'utils.cpp', 'wrapper.cpp', @@ -28,8 +29,8 @@ hipo_headers = files( 'parser.h', 'reaction.h', 'reader.h', - 'recordbuilder.h', 'record.h', + 'recordbuilder.h', 'tuple.h', 'twig.h', 'utils.h', @@ -39,13 +40,14 @@ hipo_headers = files( hipo_lib = library( meson.project_name(), hipo_sources, - dependencies: [lz4_dep], + dependencies: [ lz4_dep ], cpp_args: [ # FIXME: fix the warnings; they are suppressed by these args '-Wno-sign-compare', '-Wno-unused-variable', '-Wno-unused-but-set-variable', '-Wno-misleading-indentation', '-Wno-format', + '-Wno-stringop-overflow', ], install: true ) diff --git a/extensions/julia/lib/reaction.cc b/hipo4/reaction.cpp similarity index 100% rename from extensions/julia/lib/reaction.cc rename to hipo4/reaction.cpp diff --git a/lz4 b/lz4 deleted file mode 160000 index 4032c8c..0000000 --- a/lz4 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4032c8c787e640f6cb217b89ee8057949bea1b01 diff --git a/meson.build b/meson.build index eb38087..b6ae55b 100644 --- a/meson.build +++ b/meson.build @@ -3,44 +3,79 @@ project( 'cpp', meson_version: '>=1.2', default_options: { - 'cpp_std': 'c++17', - 'buildtype': 'release', - 'libdir': 'lib', + 'cpp_std': 'c++17', + 'buildtype': 'release', + 'libdir': 'lib', + 'libexecdir': 'libexec', 'default_library': 'both', 'pkgconfig.relocatable': 'true', }, version: '4.2.0', ) +add_languages('fortran', native: false, required: get_option('test_fortran')) # modules -fs = import('fs') +fs = import('fs') pkg = import('pkgconfig') # dependencies -lz4_dep = dependency('liblz4', method: 'pkg-config', version: '>=1.9', fallback: ['lz4', 'liblz4']) -ROOT_dep = dependency('ROOT', method: 'cmake', version: '>=6.28', required: false) +lz4_minver = '1.9' +lz4_dep = dependency( + 'liblz4', + method: 'pkg-config', + version: f'>=@lz4_minver@', + fallback: ['lz4', 'liblz4_dep'], +) +ROOT_dep = dependency( + 'ROOT', + method: 'cmake', + version: '>=6.28', + required: false, + not_found_message: 'ROOT not found; tools which depend on ROOT will not be built.', +) +thread_dep = dependency( + 'threads', + required: false, +) + +# handle ROOT +# NOTE: hipo library does NOT depend on ROOT, but some extensions and examples do +ROOT_config = find_program('root-config', required: ROOT_dep.found()) +ROOT_cling = find_program('rootcling', required: ROOT_dep.found()) +ROOT_libdir = ROOT_dep.found() ? run_command(ROOT_config, '--libdir', check: true).stdout().strip() : '' +ROOT_incdir = ROOT_dep.found() ? run_command(ROOT_config, '--incdir', check: true).stdout().strip() : '' # preprocessor lz4_preproc_def = '-D__LZ4__' add_project_arguments(lz4_preproc_def, language: ['cpp']) -# main project builds +# build main project project_libs = [] subdir('hipo4') -# extensions -if(get_option('dataframes')) - if(ROOT_dep.found()) - subdir('extensions' / 'dataframes') - else - warning('ROOT dependency not found; dataframes extension will NOT be built') - endif +# build examples +if(get_option('build_examples')) + subdir('examples') +endif +if(ROOT_dep.found() and get_option('install_root_tools')) + subdir('examples/root') +endif + +# build extensions +build_dataframes = get_option('dataframes') and ROOT_dep.found() +if(build_dataframes) + subdir('extensions' / 'dataframes') endif # packaging pkg.generate( - name: meson.project_name(), - description: 'High Performance Output Data format for experimental Physics', - libraries: project_libs, - requires: [ lz4_dep ], + name: meson.project_name(), + description: 'High Performance Output Data format for experimental physics', + libraries: project_libs, + requires: [ f'liblz4 >= @lz4_minver@' ], # FIXME: can't use `lz4_dep` here when WrapDB is used; this string is a workaround + variables: [ + 'bindir=${prefix}' / get_option('bindir'), + f'with_dataframes=@build_dataframes@', + ], ) +subdir('meson') diff --git a/meson.options b/meson.options index 276ff08..212cbbb 100644 --- a/meson.options +++ b/meson.options @@ -1 +1,11 @@ -option('dataframes', type: 'boolean', value: true, description: 'install HIPO dataframes extension') +# examples +option('build_examples', type: 'boolean', value: true, description: 'build examples; see also "install_examples"') +option('install_examples', type: 'boolean', value: false, description: 'install examples; requires "build_examples" to be true') + +# ROOT extensions and tools +option('dataframes', type: 'boolean', value: true, description: 'install HIPO dataframes extension') +option('install_root_tools', type: 'boolean', value: false, description: 'install ROOT tools such as "hipo_hist2root"') + +# testing +option('test_file', type: 'string', value: '', description: 'sample HIPO file to use for certain tests; if unspecified, those tests will not run; must be an absolute path') +option('test_fortran', type: 'boolean', value: false, description: 'test Fortran example; you must have a Fortran compiler and build option "test_file" must be set') diff --git a/meson/Makefile_config.mk b/meson/Makefile_config.mk new file mode 100644 index 0000000..279e1e1 --- /dev/null +++ b/meson/Makefile_config.mk @@ -0,0 +1,9 @@ +ifndef HIPO +$(error "ERROR: HIPO environment variable not set; please source one of 'libexec/this_hipo.*', found within your installation prefix") +endif + +HIPOCFLAGS := -I${HIPO}/include/hipo4 +HIPOLIBS := -L${HIPO}/lib -lhipo4 + +LZ4LIBS := -L$(shell pkg-config liblz4 --variable libdir) -llz4 -pthread +LZ4INCLUDES := -I$(shell pkg-config liblz4 --variable includedir) diff --git a/meson/meson.build b/meson/meson.build new file mode 100644 index 0000000..c4f5c2d --- /dev/null +++ b/meson/meson.build @@ -0,0 +1,21 @@ +configure_file( + input: 'this_hipo.sh.in', + output: 'this_hipo.sh', + install: true, + install_dir: get_option('libexecdir'), + configuration: { + 'ld_path': host_machine.system() != 'darwin' ? 'LD_LIBRARY_PATH' : 'DYLD_LIBRARY_PATH', + 'libdir': get_option('libdir'), + 'root': ROOT_dep.found() ? 'true' : 'false', + }, +) + +foreach shell : [ 'csh', 'tcsh' ] + configure_file( + input: 'this_hipo.csh.in', + output: f'this_hipo.@shell@', + install: true, + install_dir: get_option('libexecdir'), + configuration: {'shell': shell}, + ) +endforeach diff --git a/meson/this_hipo.csh.in b/meson/this_hipo.csh.in new file mode 100644 index 0000000..dbe78f1 --- /dev/null +++ b/meson/this_hipo.csh.in @@ -0,0 +1,18 @@ +#!/usr/bin/env @shell@ +set user_command = ($_) +set HIPO_CSH_ENV_FILE=`readlink -f $user_command[2]` +unset user_command +echo 'Creating `@shell@` sub-shell for HIPO environment.' +echo '' +echo 'NOTE: using HIPO with this sub-shell is not well-tested; please report' +echo ' any problems or consider using `bash` or `zsh` and sourcing' +echo ' `this_hipo.sh` instead.' +echo '' +echo 'NOTE: to preserve the history of commands run in this sub-shell, `$savehist`' +echo ' should be set to enable merging, e.g. in your `~/.cshrc` file:' +echo ' set history=10000' +echo ' set savehist=(10000 merge)' +echo '' +bash -c "source `dirname $HIPO_CSH_ENV_FILE`/this_hipo.sh && exec @shell@" +echo 'Exited HIPO `@shell@` sub-shell.' +unset HIPO_CSH_ENV_FILE diff --git a/meson/this_hipo.sh.in b/meson/this_hipo.sh.in new file mode 100644 index 0000000..97a4cd8 --- /dev/null +++ b/meson/this_hipo.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# +# `source` this file to set environment variables relevant for this `hipo` installation +# NOTE: this file is only needed if you are testing HIPO installations and consumers; for +# all other testing, just use your build directory +# + +# workaround older versions of macOS not having `realpath` +get_realpath() { + echo $(cd $1 && pwd -P) +} + +# installation prefix +export HIPO=$(get_realpath $(dirname ${BASH_SOURCE[0]:-$0})/..) + +# prepend to PKG_CONFIG_PATH +export PKG_CONFIG_PATH=$HIPO/@libdir@/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} + +# prepend to PATH +hipo_path=$(pkg-config --variable bindir hipo4) +[ -n "${hipo_path-}" ] && export PATH=$(get_realpath $hipo_path)${PATH:+:${PATH}} +unset hipo_path + +# prepend to @ld_path@ +hipo_libdir=$(pkg-config --variable libdir hipo4) +[ -n "${hipo_libdir-}" ] && export @ld_path@=$hipo_libdir${@ld_path@:+:${@ld_path@}} +unset hipo_libdir + +# prepend to ROOT_INCLUDE_PATH +if @root@; then + hipo_incdir=$(pkg-config --variable includedir hipo4) + [ -n "${hipo_incdir-}" ] && export ROOT_INCLUDE_PATH=$hipo_incdir${ROOT_INCLUDE_PATH:+:${ROOT_INCLUDE_PATH}} + unset hipo_incdir +fi + +# cleanup +unset -f get_realpath diff --git a/subprojects/.gitignore b/subprojects/.gitignore new file mode 100644 index 0000000..355164c --- /dev/null +++ b/subprojects/.gitignore @@ -0,0 +1 @@ +*/