Skip to content

Commit

Permalink
Conan package manager, build.py and Neuland calibration rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
YanzhaoW committed Jan 8, 2024
1 parent 44b690e commit cb61dbc
Show file tree
Hide file tree
Showing 161 changed files with 7,557 additions and 366 deletions.
2 changes: 0 additions & 2 deletions .github/actions/pre-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ runs:
echo "cacheSHA=$([[ ${{github.event_name}} = "push" ]] && git rev-parse --short HEAD || git rev-parse --short HEAD^)" >> $GITHUB_ENV
shell: bash


- name: mount cvmfs
run: |
apt-get install -y ccache
Expand All @@ -33,5 +32,4 @@ runs:
mount -t cvmfs fairsoft.gsi.de ${CVMDIR}
mkdir -p ${UCESB_DIR}
mkdir -p ${CCACHE_DIR}
echo $PATH
shell: bash
10 changes: 7 additions & 3 deletions .github/actions/r3bbuild-steps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ runs:
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git clone https://github.com/R3BRootGroup/macros.git
cmake . -B build -C cmake/CI_CD/configure_options.cmake
echo ""
echo "path environment variable: $PATH\n"
echo ""
./build.py -p -c --cmake-extra-args="-DBUILD_GEOMETRY=OFF;-C $GITHUB_WORKSPACE/cmake/CI_CD/configure_options.cmake"
shell: bash

- name: ctest ${{ matrix.repos }}
- name: build ${{ matrix.repos }}
if: inputs.build-needed == 'true'
run: |
cmake --build ./build -- -j ${NUM_THREADS}
./build.py -b -j ${NUM_THREADS}
# ./build_thisr3broot.sh -b build -j ${NUM_THREADS}
shell: bash
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
# tool-kits for the building, such as clang-tidy and cvmfs. For more
# information, please visit the Docker repository at Dockerhub.
container:
image: yanzhaowang/cvmfs_clang:v15
image: yanzhaowang/cvmfs_clang:latest
volumes:
- /tmp:/cvmfs
env:
Expand All @@ -133,7 +133,7 @@ jobs:
# the speed of the run.
NUM_THREADS: 2
# Options for the Docker container to be run with cvmfs.
options: --user root --privileged --ulimit nofile=10000:10000 --cap-add SYS_ADMIN --device /dev/fuse
options: --user root --privileged --ulimit nofile=10000:10000 -it --cap-add SYS_ADMIN --device /dev/fuse

# Each job contains different steps that are executed sequentially. Each
# step could be multiple shell commands or a composite action either from
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
clang-tidy:
runs-on: ubuntu-latest
container:
image: yanzhaowang/cvmfs_clang:v15
image: yanzhaowang/cvmfs_clang:latest
volumes:
- /tmp:/cvmfs
env:
Expand All @@ -45,7 +45,7 @@ jobs:
id: restore-caching
uses: './.github/actions/install-deps'
with:
repo: 'false'
cache-name: 'false'

- name: configure r3broot
uses: './.github/actions/r3bbuild-steps'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ CMakeUserPresets.json

# Local configuration
c3w.conf
CMakeUserPresets.json
30 changes: 13 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ endif()
include(FairFindPackage2)
include(FairFormattedOutput)

find_package2(PUBLIC FairRoot REQUIRED)
find_package2(PUBLIC FairRoot REQUIRED MODULE)

# FairRoot_VERSION is eventually set by find_package, for now let's set it explicitly
execute_process(
Expand All @@ -113,20 +113,10 @@ include(FairMacros)
list(APPEND required_root_components RIO)
list(APPEND optional_root_components opengl)
list(APPEND optional_root_components gdml vmc)

# TODO: ROOT package should be found with CONFIG mode
find_package2(
PUBLIC
ROOT
VERSION
6.16.00
MODULE
REQUIRED
COMPONENTS
${required_root_components}
OPTIONAL_COMPONENTS
${optional_root_components})

find_package2(PUBLIC ROOT REQUIRED MODULE
COMPONENTS ${required_root_components}
OPTIONAL_COMPONENTS ${optional_root_components})

if("${ROOT_vmc_FOUND}" MATCHES "no")
find_package2(PUBLIC VMC REQUIRED)
set(VMCLIB VMCLibrary)
Expand Down Expand Up @@ -250,6 +240,12 @@ else()
REQUIRED)
endif()

find_package(range-v3 REQUIRED)
find_package(Microsoft.GSL REQUIRED)
find_package(nlohmann_json REQUIRED)
set(JSON_ImplicitConversions OFF CACHE BOOL "disable implicit conversion of JSON" FORCE)
find_package(GTest REQUIRED)

find_package2(PUBLIC Pythia6)
find_package2(PUBLIC Pythia8)
find_package2(PUBLIC Protobuf)
Expand Down Expand Up @@ -344,7 +340,7 @@ if(yaml-cpp_FOUND
"${YAML_CPP_INCLUDE_DIR}")
endif()

include(${CMAKE_SOURCE_DIR}/cmake/scripts/fetchGTest.cmake)
# include(${CMAKE_SOURCE_DIR}/cmake/scripts/fetchGTest.cmake)

setbasicvariables()

Expand All @@ -370,7 +366,7 @@ else(${IS_XCODE})
set(LD_LIBRARY_PATH ${R3BLIBDIR} ${LD_LIBRARY_PATH})
endif(${IS_XCODE})

find_package(ucesb)
find_package(ucesb MODULE)
if(ucesb_FOUND)
set(WITH_UCESB ON)
set(UCESBPATH $ENV{UCESB_DIR})
Expand Down
4 changes: 2 additions & 2 deletions atima/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#set(GTEST_ROOT ${SIMPATH})
#find_package(GTest)

#if(GTEST_FOUND)
#if(GTest_FOUND)
#file(GLOB TEST_SRC_FILES ${PROJECT_SOURCE_DIR}/atima/test/*.cxx)

#include_directories(${GTEST_INCLUDE_DIRS}
Expand All @@ -39,4 +39,4 @@
#add_executable(${PROJECT_TEST_NAME} ${TEST_SRC_FILES})
#target_link_libraries(${PROJECT_TEST_NAME} ${TEST_DEPENDENCIES})
#add_test(${PROJECT_TEST_NAME} ${EXECUTABLE_OUTPUT_PATH}/${PROJECT_TEST_NAME})
#endif(GTEST_FOUND)
#endif()
133 changes: 133 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#! /usr/bin/env python3
import argparse
import os
import subprocess
import sys

# import sys


class Build:
def __init__(self):
self.source_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
self.define_options()
self.args = self.parser.parse_args()

def launch(self):
if not os.path.isdir(self.args.build_dir):
os.mkdir(self.args.build_dir)
self.install_conan_packages()
self.cmake_configure()
self.build_source()

def define_options(self):
self.parser = argparse.ArgumentParser(
prog="R3BRoot builder",
description="Building R3BRoot source files with conan package manager",
epilog="If any issue occurs, please report it to the R3BRoot github webpage.",
)
self.parser.add_argument(
"-j",
type=int,
nargs="?",
default=1,
const=1,
dest="build_thread",
help="number of threads for the building (default: 1)",
)
self.parser.add_argument(
"--fresh",
dest="is_fresh_configure",
action="store_true",
help="fresh build for cmake",
)
self.parser.add_argument(
"-a",
"--all",
dest="is_all",
action="store_true",
help="run all processes specified with -p, -c, -b",
)
self.parser.add_argument(
"-p",
"--only-packages",
dest="is_only_package",
action="store_true",
help="only install all conan packages",
)
self.parser.add_argument(
"-c",
"--only-configure",
dest="is_only_configure",
action="store_true",
help="only run the cmake configuration",
)
self.parser.add_argument(
"-b",
"--only-build",
dest="is_only_build",
action="store_true",
help="only build the source files",
)
self.parser.add_argument(
"--build-dir",
default=f"{self.source_dir}/build",
help='specify the build folder (default: "./build")',
)
self.parser.add_argument(
"--build-type",
default="RelWithDebInfo",
help='specify the build type for cmake (default: "RelWithDebInfo")',
)
self.parser.add_argument(
"--cmake-extra-args",
default="-DBUILD_GEOMETRY=OFF",
dest="cmake_args",
help='extra colon separated arguments for cmake configurations (default: "-DBUILD_GEOMETRY=OFF")',
)
self.parser.add_argument(
"--conan-dir",
default="conan-packages",
help='specify the folder name for conan packages (default: "conan-packages")',
)

def install_conan_packages(self):
if self.args.is_only_package or self.args.is_all:
subprocess.run(["conan", "profile", "detect", "--force"], check=True)
subprocess.run(
[
"conan",
"install",
self.source_dir,
f"--output-folder={self.args.build_dir}/{self.args.conan_dir}",
"--build=missing",
f"--settings=build_type={self.args.build_type}",
],
check=True,
)

def cmake_configure(self):
if self.args.is_only_configure or self.args.is_all:
cmake_args = ["--fresh"] if self.args.is_fresh_configure else []
cmake_args.append(f"-S {self.source_dir}")
cmake_args.append(f"-B {self.args.build_dir}")
cmake_args.append("-DUSE_DIFFERENT_COMPILER=TRUE")
cmake_args.append(
f"-DCMAKE_TOOLCHAIN_FILE={self.args.build_dir}/{self.args.conan_dir}/conan_toolchain.cmake"
)
cmake_args.append(f"-DCMAKE_BUILD_TYPE={self.args.build_type}")
extra_args = self.args.cmake_args.split(";")
cmake_args.extend(extra_args)
print(f"build.py: cmake {cmake_args}")
subprocess.run(["cmake"] + cmake_args, check=True)

def build_source(self):
if self.args.is_only_build or self.args.is_all:
subprocess.run(
["cmake", "--build", self.args.build_dir, "--", "-j", str(self.args.build_thread)], check=True
)


if __name__ == "__main__":
builder = Build()
builder.launch()
7 changes: 7 additions & 0 deletions cmake/modules/Finducesb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ if(ucesb_FOUND)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${ucesb_LIBRARY_DIR})
endif(NOT ucesb_FIND_QUIETLY)
message(STATUS "${BBlue}UCESB was FOUND${CR}")
add_library(UCESB SHARED IMPORTED)
set_property(TARGET UCESB PROPERTY
IMPORTED_LOCATION "${ucesb_LIBRARY_DIR}/lib${ucesb_LIBRARY_SHARED}.so")
set_property(TARGET UCESB PROPERTY
INCLUDE_DIRECTORIES "${ucesb_INCLUDE_DIR}")
# set_property(TARGET UCESB PROPERTY
# LINK_DIRECTORIES "${ucesb_LIBRARY_DIR}")
else(ucesb_FOUND)
if(NOT ucesb_FIND_QUIETLY)
if(ucesb_FIND_REQUIRED)
Expand Down
9 changes: 9 additions & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[requires]
ms-gsl/4.0.0
range-v3/0.12.0
gtest/cci.20210126
nlohmann_json/3.11.2

[generators]
CMakeDeps
CMakeToolchain
9 changes: 8 additions & 1 deletion config/clang_tidy/neuland.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Checks: >
hicpp-*,
-hicpp-vararg,
misc-*,
-misc-no-recursion,
modernize-*,
performance-*,
readability-*
Expand All @@ -36,8 +37,14 @@ CheckOptions:
value: 1
- key: readability-identifier-length.IgnoredVariableNames
value: '^it$'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues
value: "0.5;1.0;2.0;10.0;100.0;1000.0;"
- key: readability-magic-numbers.IgnoredFloatingPointValues
value: '1.0;2.0;10.0;100.0;1000.0'
value: "0.5;1.0;2.0;10.0;100.0;1000.0;"
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues
value: "1;2;3;4;5;6;7;8;"
- key: readability-magic-numbers.IgnoredIntegerValues
value: "1;2;3;4;5;6;7;8;"
- key: readability-function-cognitive-complexity.Threshold
value: 40
- key: readability-function-cognitive-complexity.IgnoreMacros
Expand Down
1 change: 1 addition & 0 deletions los/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ Set(DEPENDENCIES
R3BBase R3BData R3BTracking R3BTCal)

GENERATE_LIBRARY()
target_include_directories(R3BLos PUBLIC calib online params ${CMAKE_CURRENT_SOURCE_DIR})
47 changes: 47 additions & 0 deletions neuland/.cmake-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# See https://github.com/cheshirekow/cmake_format

with section("format"):
# How wide to allow formatted cmake files
line_width = 100

# How many spaces to tab for indent
tab_size = 4

# If true, separate flow control names from their parentheses with a space
separate_ctrl_name_with_space = False

# If true, separate function names from parentheses with a space
separate_fn_name_with_space = False

# If a statement is wrapped to more than one line, than dangle the closing
# parenthesis on it's own line
dangle_parens = False

# What character to use for bulleted lists
bullet_char = u'*'

# What character to use as punctuation after numerals in an enumerated list
enum_char = u'.'

# What style line endings to use in the output.
line_ending = u'unix'

# Format command names consistently as 'lower' or 'upper' case
command_case = u'lower'

# Format keywords consistently as 'lower' or 'upper' case
keyword_case = u'unchanged'

# A list of command names which should always be wrapped
always_wrap = []

# Don't reformat comments
enable_markup = False

# If true, the argument lists which are known to be sortable will be sorted
# lexicographicall
enable_sort = True

autosort = True

max_pargs_hwrap = 3
Loading

0 comments on commit cb61dbc

Please sign in to comment.