From 4c3a0caf16a8b05314633312f601c8fa2fa61f9c Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 08:42:48 -0500 Subject: [PATCH 01/48] #94: Updating pugixml version to 1.11.1 and fixing its build. --- ThirdParty/CMakeLists.txt | 16 +- ThirdParty/pugixml/include/pugiconfig.hpp | 11 +- ThirdParty/pugixml/include/pugixml.hpp | 105 +- ThirdParty/pugixml/source/pugixml.cpp | 1716 +++++++++++++-------- 4 files changed, 1152 insertions(+), 696 deletions(-) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index fbc8be87f..0eb591cb0 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -1,13 +1,3 @@ -#We will build a separate library for each one of the third party -#libraries/codes that we are going to use. However, we'll dump them all into -#the same folder for simplicity's sake. -# @author S.V. Paulauskas - -#Build pugixml. This software is used to parse XML files. -set(PugixmlSources pugixml/source/pugixml.cpp) -add_library(PugixmlObjects OBJECT ${PugixmlSources}) -add_library(PugixmlStatic STATIC $) -if (PAASS_BUILD_SHARED_LIBS) - add_library(Pugixml SHARED $) - install(TARGETS Pugixml DESTINATION lib) -endif (PAASS_BUILD_SHARED_LIBS) \ No newline at end of file +add_library(Pugixml-1.11.1 SHARED pugixml/source/pugixml.cpp) +target_include_directories(Pugixml-1.11.1 PUBLIC ${PROJECT_SOURCE_DIR}/ThirdParty/pugixml/include) +install(TARGETS Pugixml-1.11.1 DESTINATION lib) diff --git a/ThirdParty/pugixml/include/pugiconfig.hpp b/ThirdParty/pugixml/include/pugiconfig.hpp index 2d1e6aa8b..405a66b65 100644 --- a/ThirdParty/pugixml/include/pugiconfig.hpp +++ b/ThirdParty/pugixml/include/pugiconfig.hpp @@ -1,8 +1,8 @@ /** - * pugixml parser - version 1.8 + * pugixml parser - version 1.11 * -------------------------------------------------------- - * Copyright (C) 2006-2016, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) - * Report bugs and download new versions at http://pugixml.org/ + * Copyright (C) 2006-2020, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) + * Report bugs and download new versions at https://pugixml.org/ * * This library is distributed under the MIT License. See notice at the end * of this file. @@ -40,6 +40,9 @@ // #define PUGIXML_MEMORY_OUTPUT_STACK 10240 // #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 +// Tune this constant to adjust max nesting for XPath queries +// #define PUGIXML_XPATH_DEPTH_LIMIT 1024 + // Uncomment this to switch to header-only version // #define PUGIXML_HEADER_ONLY @@ -49,7 +52,7 @@ #endif /** - * Copyright (c) 2006-2016 Arseny Kapoulkine + * Copyright (c) 2006-2020 Arseny Kapoulkine * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation diff --git a/ThirdParty/pugixml/include/pugixml.hpp b/ThirdParty/pugixml/include/pugixml.hpp index 6288d4bd9..7e2ce7776 100644 --- a/ThirdParty/pugixml/include/pugixml.hpp +++ b/ThirdParty/pugixml/include/pugixml.hpp @@ -1,8 +1,8 @@ /** - * pugixml parser - version 1.8 + * pugixml parser - version 1.11 * -------------------------------------------------------- - * Copyright (C) 2006-2016, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) - * Report bugs and download new versions at http://pugixml.org/ + * Copyright (C) 2006-2020, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) + * Report bugs and download new versions at https://pugixml.org/ * * This library is distributed under the MIT License. See notice at the end * of this file. @@ -12,8 +12,9 @@ */ #ifndef PUGIXML_VERSION -// Define version macro; evaluates to major * 100 + minor so that it's safe to use in less-than comparisons -# define PUGIXML_VERSION 180 +// Define version macro; evaluates to major * 1000 + minor * 10 + patch so that it's safe to use in less-than comparisons +// Note: pugixml used major * 100 + minor * 10 + patch format up until 1.9 (which had version identifier 190); starting from pugixml 1.10, the minor version number is two digits +# define PUGIXML_VERSION 1110 #endif // Include user configuration file (this can define various configuration macros) @@ -81,15 +82,44 @@ # endif #endif +// If C++ is 2011 or higher, add 'noexcept' specifiers +#ifndef PUGIXML_NOEXCEPT +# if __cplusplus >= 201103 +# define PUGIXML_NOEXCEPT noexcept +# elif defined(_MSC_VER) && _MSC_VER >= 1900 +# define PUGIXML_NOEXCEPT noexcept +# else +# define PUGIXML_NOEXCEPT +# endif +#endif + +// Some functions can not be noexcept in compact mode +#ifdef PUGIXML_COMPACT +# define PUGIXML_NOEXCEPT_IF_NOT_COMPACT +#else +# define PUGIXML_NOEXCEPT_IF_NOT_COMPACT PUGIXML_NOEXCEPT +#endif + // If C++ is 2011 or higher, add 'override' qualifiers #ifndef PUGIXML_OVERRIDE # if __cplusplus >= 201103 # define PUGIXML_OVERRIDE override +# elif defined(_MSC_VER) && _MSC_VER >= 1700 +# define PUGIXML_OVERRIDE override # else # define PUGIXML_OVERRIDE # endif #endif +// If C++ is 2011 or higher, use 'nullptr' +#ifndef PUGIXML_NULL +# if __cplusplus >= 201103 +# define PUGIXML_NULL nullptr +# else +# define PUGIXML_NULL 0 +# endif +#endif + // Character interface macros #ifdef PUGIXML_WCHAR_MODE # define PUGIXML_TEXT(t) L ## t @@ -232,10 +262,19 @@ namespace pugi // Don't output empty element tags, instead writing an explicit start and end tag even if there are no children. This flag is off by default. const unsigned int format_no_empty_element_tags = 0x80; + // Skip characters belonging to range [0; 32) instead of "&#xNN;" encoding. This flag is off by default. + const unsigned int format_skip_control_chars = 0x100; + + // Use single quotes ' instead of double quotes " for enclosing attribute values. This flag is off by default. + const unsigned int format_attribute_single_quote = 0x200; + // The default set of formatting flags. // Nodes are indented depending on their depth in DOM tree, a default declaration is output if document has none. const unsigned int format_default = format_indent; + const int default_double_precision = 17; + const int default_float_precision = 9; + // Forward declarations struct xml_attribute_struct; struct xml_node_struct; @@ -383,7 +422,9 @@ namespace pugi bool set_value(long rhs); bool set_value(unsigned long rhs); bool set_value(double rhs); + bool set_value(double rhs, int precision); bool set_value(float rhs); + bool set_value(float rhs, int precision); bool set_value(bool rhs); #ifdef PUGIXML_HAS_LONG_LONG @@ -549,10 +590,16 @@ namespace pugi bool remove_attribute(const xml_attribute& a); bool remove_attribute(const char_t* name); + // Remove all attributes + bool remove_attributes(); + // Remove specified child bool remove_child(const xml_node& n); bool remove_child(const char_t* name); + // Remove all children + bool remove_children(); + // Parses buffer as an XML document fragment and appends all nodes as children of the current node. // Copies/converts the buffer, so it may be deleted or changed after the function returns. // Note: append_buffer allocates memory that has the lifetime of the owning document; removing the appended nodes does not immediately reclaim that memory. @@ -623,16 +670,16 @@ namespace pugi #ifndef PUGIXML_NO_XPATH // Select single node by evaluating XPath query. Returns first node from the resulting node set. - xpath_node select_node(const char_t* query, xpath_variable_set* variables = 0) const; + xpath_node select_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const; xpath_node select_node(const xpath_query& query) const; // Select node set by evaluating XPath query - xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = 0) const; + xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const; xpath_node_set select_nodes(const xpath_query& query) const; // (deprecated: use select_node instead) Select single node by evaluating XPath query. - xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const; - xpath_node select_single_node(const xpath_query& query) const; + PUGIXML_DEPRECATED xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const; + PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const; #endif @@ -734,7 +781,9 @@ namespace pugi bool set(long rhs); bool set(unsigned long rhs); bool set(double rhs); + bool set(double rhs, int precision); bool set(float rhs); + bool set(float rhs, int precision); bool set(bool rhs); #ifdef PUGIXML_HAS_LONG_LONG @@ -983,6 +1032,7 @@ namespace pugi void _create(); void _destroy(); + void _move(xml_document& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT; public: // Default constructor, makes empty document @@ -991,6 +1041,12 @@ namespace pugi // Destructor, invalidates all node/attribute handles to this document ~xml_document(); + #ifdef PUGIXML_HAS_MOVE + // Move semantics support + xml_document(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT; + xml_document& operator=(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT; + #endif + // Removes all nodes, leaving the empty document void reset(); @@ -1004,7 +1060,7 @@ namespace pugi #endif // (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied. - xml_parse_result load(const char_t* contents, unsigned int options = parse_default); + PUGIXML_DEPRECATED xml_parse_result load(const char_t* contents, unsigned int options = parse_default); // Load document from zero-terminated string. No encoding conversions are applied. xml_parse_result load_string(const char_t* contents, unsigned int options = parse_default); @@ -1131,8 +1187,8 @@ namespace pugi #ifdef PUGIXML_HAS_MOVE // Move semantics support - xpath_variable_set(xpath_variable_set&& rhs); - xpath_variable_set& operator=(xpath_variable_set&& rhs); + xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT; + xpath_variable_set& operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT; #endif // Add a new variable or get the existing one, if the types match @@ -1165,7 +1221,7 @@ namespace pugi public: // Construct a compiled object from XPath expression. // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on compilation errors. - explicit xpath_query(const char_t* query, xpath_variable_set* variables = 0); + explicit xpath_query(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL); // Constructor xpath_query(); @@ -1175,8 +1231,8 @@ namespace pugi #ifdef PUGIXML_HAS_MOVE // Move semantics support - xpath_query(xpath_query&& rhs); - xpath_query& operator=(xpath_query&& rhs); + xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT; + xpath_query& operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT; #endif // Get query expression return type @@ -1224,6 +1280,12 @@ namespace pugi }; #ifndef PUGIXML_NO_EXCEPTIONS + #if defined(_MSC_VER) + // C4275 can be ignored in Visual C++ if you are deriving + // from a type in the Standard C++ Library + #pragma warning(push) + #pragma warning(disable: 4275) + #endif // XPath exception class class PUGIXML_CLASS xpath_exception: public std::exception { @@ -1240,6 +1302,9 @@ namespace pugi // Get parse result const xpath_parse_result& result() const; }; + #if defined(_MSC_VER) + #pragma warning(pop) + #endif #endif // XPath node class (either xml_node or xml_attribute) @@ -1316,8 +1381,8 @@ namespace pugi #ifdef PUGIXML_HAS_MOVE // Move semantics support - xpath_node_set(xpath_node_set&& rhs); - xpath_node_set& operator=(xpath_node_set&& rhs); + xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT; + xpath_node_set& operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT; #endif // Get collection type @@ -1345,13 +1410,13 @@ namespace pugi private: type_t _type; - xpath_node _storage; + xpath_node _storage[1]; xpath_node* _begin; xpath_node* _end; void _assign(const_iterator begin, const_iterator end, type_t type); - void _move(xpath_node_set& rhs); + void _move(xpath_node_set& rhs) PUGIXML_NOEXCEPT; }; #endif @@ -1409,7 +1474,7 @@ namespace std #endif /** - * Copyright (c) 2006-2016 Arseny Kapoulkine + * Copyright (c) 2006-2020 Arseny Kapoulkine * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation diff --git a/ThirdParty/pugixml/source/pugixml.cpp b/ThirdParty/pugixml/source/pugixml.cpp index cac51a534..efdcdf699 100644 --- a/ThirdParty/pugixml/source/pugixml.cpp +++ b/ThirdParty/pugixml/source/pugixml.cpp @@ -1,8 +1,8 @@ /** - * pugixml parser - version 1.8 + * pugixml parser - version 1.11 * -------------------------------------------------------- - * Copyright (C) 2006-2016, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) - * Report bugs and download new versions at http://pugixml.org/ + * Copyright (C) 2006-2020, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) + * Report bugs and download new versions at https://pugixml.org/ * * This library is distributed under the MIT License. See notice at the end * of this file. @@ -29,9 +29,6 @@ #ifndef PUGIXML_NO_XPATH # include # include -# ifdef PUGIXML_NO_EXCEPTIONS -# include -# endif #endif #ifndef PUGIXML_NO_STL @@ -47,10 +44,13 @@ # pragma warning(push) # pragma warning(disable: 4127) // conditional expression is constant # pragma warning(disable: 4324) // structure was padded due to __declspec(align()) -# pragma warning(disable: 4611) // interaction between '_setjmp' and C++ object destruction is non-portable # pragma warning(disable: 4702) // unreachable code # pragma warning(disable: 4996) // this function or variable may be unsafe -# pragma warning(disable: 4793) // function compiled as native: presence of '_setjmp' makes a function unmanaged +#endif + +#if defined(_MSC_VER) && defined(__c2__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated" // this function or variable may be unsafe #endif #ifdef __INTEL_COMPILER @@ -76,6 +76,10 @@ # pragma diag_suppress=237 // controlling expression is constant #endif +#ifdef __TI_COMPILER_VERSION__ +# pragma diag_suppress 179 // function was declared but never referenced +#endif + // Inlining controls #if defined(_MSC_VER) && _MSC_VER >= 1300 # define PUGI__NO_INLINE __declspec(noinline) @@ -86,7 +90,7 @@ #endif // Branch weight controls -#if defined(__GNUC__) +#if defined(__GNUC__) && !defined(__c2__) # define PUGI__UNLIKELY(cond) __builtin_expect(cond, 0) #else # define PUGI__UNLIKELY(cond) (cond) @@ -102,6 +106,17 @@ # define PUGI__DMC_VOLATILE #endif +// Integer sanitizer workaround; we only apply this for clang since gcc8 has no_sanitize but not unsigned-integer-overflow and produces "attribute directive ignored" warnings +#if defined(__clang__) && defined(__has_attribute) +# if __has_attribute(no_sanitize) +# define PUGI__UNSIGNED_OVERFLOW __attribute__((no_sanitize("unsigned-integer-overflow"))) +# else +# define PUGI__UNSIGNED_OVERFLOW +# endif +#else +# define PUGI__UNSIGNED_OVERFLOW +#endif + // Borland C++ bug workaround for not defining ::memcpy depending on header include order (can't always use std::memcpy because some compilers don't have it at all) #if defined(__BORLANDC__) && !defined(__MEM_H_USING_LIST) using std::memcpy; @@ -109,11 +124,11 @@ using std::memmove; using std::memset; #endif -// Some MinGW versions have headers that erroneously omit LLONG_MIN/LLONG_MAX/ULLONG_MAX definitions in strict ANSI mode -#if defined(PUGIXML_HAS_LONG_LONG) && defined(__MINGW32__) && defined(__STRICT_ANSI__) && !defined(LLONG_MAX) && !defined(LLONG_MIN) && !defined(ULLONG_MAX) -# define LLONG_MAX 9223372036854775807LL -# define LLONG_MIN (-LLONG_MAX-1) -# define ULLONG_MAX (2ULL*LLONG_MAX+1) +// Some MinGW/GCC versions have headers that erroneously omit LLONG_MIN/LLONG_MAX/ULLONG_MAX definitions from limits.h in some configurations +#if defined(PUGIXML_HAS_LONG_LONG) && defined(__GNUC__) && !defined(LLONG_MAX) && !defined(LLONG_MIN) && !defined(ULLONG_MAX) +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define LLONG_MAX __LONG_LONG_MAX__ +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) #endif // In some environments MSVC is a compiler but the CRT lacks certain MSVC-specific features @@ -121,6 +136,16 @@ using std::memset; # define PUGI__MSVC_CRT_VERSION _MSC_VER #endif +// Not all platforms have snprintf; we define a wrapper that uses snprintf if possible. This only works with buffers with a known size. +#if __cplusplus >= 201103 +# define PUGI__SNPRINTF(buf, ...) snprintf(buf, sizeof(buf), __VA_ARGS__) +#elif defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 +# define PUGI__SNPRINTF(buf, ...) _snprintf_s(buf, _countof(buf), _TRUNCATE, __VA_ARGS__) +#else +# define PUGI__SNPRINTF sprintf +#endif + +// We put implementation details into an anonymous namespace in source mode, but have to keep it in non-anonymous namespace in header-only mode to prevent binary bloat. #ifdef PUGIXML_HEADER_ONLY # define PUGI__NS_BEGIN namespace pugi { namespace impl { # define PUGI__NS_END } } @@ -279,67 +304,37 @@ PUGI__NS_BEGIN } } - void** find(const void* key) + void* find(const void* key) { - assert(key); - if (_capacity == 0) return 0; - size_t hashmod = _capacity - 1; - size_t bucket = hash(key) & hashmod; - - for (size_t probe = 0; probe <= hashmod; ++probe) - { - item_t& probe_item = _items[bucket]; - - if (probe_item.key == key) - return &probe_item.value; - - if (probe_item.key == 0) - return 0; - - // hash collision, quadratic probing - bucket = (bucket + probe + 1) & hashmod; - } + item_t* item = get_item(key); + assert(item); + assert(item->key == key || (item->key == 0 && item->value == 0)); - assert(false && "Hash table is full"); - return 0; + return item->value; } - void** insert(const void* key) + void insert(const void* key, void* value) { - assert(key); assert(_capacity != 0 && _count < _capacity - _capacity / 4); - size_t hashmod = _capacity - 1; - size_t bucket = hash(key) & hashmod; + item_t* item = get_item(key); + assert(item); - for (size_t probe = 0; probe <= hashmod; ++probe) + if (item->key == 0) { - item_t& probe_item = _items[bucket]; - - if (probe_item.key == 0) - { - probe_item.key = key; - _count++; - return &probe_item.value; - } - - if (probe_item.key == key) - return &probe_item.value; - - // hash collision, quadratic probing - bucket = (bucket + probe + 1) & hashmod; + _count++; + item->key = key; } - assert(false && "Hash table is full"); - return 0; + item->value = value; } - bool reserve() + bool reserve(size_t extra = 16) { - if (_count + 16 >= _capacity - _capacity / 4) - return rehash(); + if (_count + extra >= _capacity - _capacity / 4) + return rehash(_count + extra); return true; } @@ -356,11 +351,34 @@ PUGI__NS_BEGIN size_t _count; - bool rehash(); + bool rehash(size_t count); + + item_t* get_item(const void* key) + { + assert(key); + assert(_capacity > 0); + + size_t hashmod = _capacity - 1; + size_t bucket = hash(key) & hashmod; + + for (size_t probe = 0; probe <= hashmod; ++probe) + { + item_t& probe_item = _items[bucket]; + + if (probe_item.key == key || probe_item.key == 0) + return &probe_item; + + // hash collision, quadratic probing + bucket = (bucket + probe + 1) & hashmod; + } + + assert(false && "Hash table is full"); // unreachable + return 0; + } - static unsigned int hash(const void* key) + static PUGI__UNSIGNED_OVERFLOW unsigned int hash(const void* key) { - unsigned int h = static_cast(reinterpret_cast(key)); + unsigned int h = static_cast(reinterpret_cast(key) & 0xffffffff); // MurmurHash3 32-bit finalizer h ^= h >> 16; @@ -373,25 +391,29 @@ PUGI__NS_BEGIN } }; - PUGI__FN_NO_INLINE bool compact_hash_table::rehash() + PUGI__FN_NO_INLINE bool compact_hash_table::rehash(size_t count) { + size_t capacity = 32; + while (count >= capacity - capacity / 4) + capacity *= 2; + compact_hash_table rt; - rt._capacity = (_capacity == 0) ? 32 : _capacity * 2; - rt._items = static_cast(xml_memory::allocate(sizeof(item_t) * rt._capacity)); + rt._capacity = capacity; + rt._items = static_cast(xml_memory::allocate(sizeof(item_t) * capacity)); if (!rt._items) return false; - memset(rt._items, 0, sizeof(item_t) * rt._capacity); + memset(rt._items, 0, sizeof(item_t) * capacity); for (size_t i = 0; i < _capacity; ++i) if (_items[i].key) - *rt.insert(_items[i].key) = _items[i].value; + rt.insert(_items[i].key, _items[i].value); if (_items) xml_memory::deallocate(_items); - _capacity = rt._capacity; + _capacity = capacity; _items = rt._items; assert(_count == rt._count); @@ -778,12 +800,12 @@ PUGI__NS_BEGIN template PUGI__FN_NO_INLINE T* compact_get_value(const void* object) { - return static_cast(*compact_get_page(object, header_offset)->allocator->_hash->find(object)); + return static_cast(compact_get_page(object, header_offset)->allocator->_hash->find(object)); } template PUGI__FN_NO_INLINE void compact_set_value(const void* object, T* value) { - *compact_get_page(object, header_offset)->allocator->_hash->insert(object) = value; + compact_get_page(object, header_offset)->allocator->_hash->insert(object, value); } template class compact_pointer @@ -830,7 +852,7 @@ PUGI__NS_BEGIN { uintptr_t base = reinterpret_cast(this) & ~(compact_alignment - 1); - return reinterpret_cast(base + ((_data - 1 + start) << compact_alignment_log2)); + return reinterpret_cast(base + (_data - 1 + start) * compact_alignment); } else return compact_get_value(this); @@ -908,7 +930,7 @@ PUGI__NS_BEGIN { uintptr_t base = reinterpret_cast(this) & ~(compact_alignment - 1); - return reinterpret_cast(base + ((_data - 1 - 65533) << compact_alignment_log2)); + return reinterpret_cast(base + (_data - 1 - 65533) * compact_alignment); } else if (_data == 65534) return static_cast(compact_get_page(this, header_offset)->compact_shared_parent); @@ -1839,7 +1861,7 @@ PUGI__NS_BEGIN enum chartypex_t { ctx_special_pcdata = 1, // Any symbol >= 0 and < 32 (except \t, \r, \n), &, <, > - ctx_special_attr = 2, // Any symbol >= 0 and < 32 (except \t), &, <, >, " + ctx_special_attr = 2, // Any symbol >= 0 and < 32, &, <, ", ' ctx_start_symbol = 4, // Any symbol > 127, a-z, A-Z, _ ctx_digit = 8, // 0-9 ctx_symbol = 16 // Any symbol > 127, a-z, A-Z, 0-9, _, -, . @@ -1847,10 +1869,10 @@ PUGI__NS_BEGIN static const unsigned char chartypex_table[256] = { - 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 2, 3, 3, 2, 3, 3, // 0-15 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 2, 3, 3, // 0-15 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 16-31 - 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 16, 16, 0, // 32-47 - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 3, 0, 3, 0, // 48-63 + 0, 0, 2, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 16, 16, 0, // 32-47 + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 3, 0, 1, 0, // 48-63 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 64-79 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 20, // 80-95 @@ -2145,7 +2167,7 @@ PUGI__NS_BEGIN if (encoding == encoding_latin1) return convert_buffer_generic(out_buffer, out_length, contents, size, latin1_decoder()); - assert(false && "Invalid encoding"); + assert(false && "Invalid encoding"); // unreachable return false; } #else @@ -2250,7 +2272,7 @@ PUGI__NS_BEGIN if (encoding == encoding_latin1) return convert_buffer_latin1(out_buffer, out_length, contents, size, is_mutable); - assert(false && "Invalid encoding"); + assert(false && "Invalid encoding"); // unreachable return false; } #endif @@ -2463,7 +2485,7 @@ PUGI__NS_BEGIN for (;;) { - if (static_cast(static_cast(ch) - '0') <= 9) + if (static_cast(ch - '0') <= 9) ucsc = 10 * ucsc + (ch - '0'); else if (ch == ';') break; @@ -2687,7 +2709,7 @@ PUGI__NS_BEGIN { PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_trim_pcdata == 0x0800); - switch (((optmask >> 4) & 3) | ((optmask >> 9) & 4)) // get bitmask for flags (eol escapes trim) + switch (((optmask >> 4) & 3) | ((optmask >> 9) & 4)) // get bitmask for flags (trim eol escapes); this simultaneously checks 3 options from assertion above { case 0: return strconv_pcdata_impl::parse; case 1: return strconv_pcdata_impl::parse; @@ -2697,7 +2719,7 @@ PUGI__NS_BEGIN case 5: return strconv_pcdata_impl::parse; case 6: return strconv_pcdata_impl::parse; case 7: return strconv_pcdata_impl::parse; - default: assert(false); return 0; // should not get here + default: assert(false); return 0; // unreachable } } @@ -2856,7 +2878,7 @@ PUGI__NS_BEGIN { PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_wconv_attribute == 0x40 && parse_wnorm_attribute == 0x80); - switch ((optmask >> 4) & 15) // get bitmask for flags (wconv wnorm eol escapes) + switch ((optmask >> 4) & 15) // get bitmask for flags (wnorm wconv eol escapes); this simultaneously checks 4 options from assertion above { case 0: return strconv_attribute_impl::parse_simple; case 1: return strconv_attribute_impl::parse_simple; @@ -2874,7 +2896,7 @@ PUGI__NS_BEGIN case 13: return strconv_attribute_impl::parse_wnorm; case 14: return strconv_attribute_impl::parse_wnorm; case 15: return strconv_attribute_impl::parse_wnorm; - default: assert(false); return 0; // should not get here + default: assert(false); return 0; // unreachable } } @@ -3623,7 +3645,7 @@ PUGI__NS_BEGIN if (encoding == encoding_latin1) return convert_buffer_output_generic(r_u8, data, length, wchar_decoder(), latin1_writer()); - assert(false && "Invalid encoding"); + assert(false && "Invalid encoding"); // unreachable return 0; } #else @@ -3662,7 +3684,7 @@ PUGI__NS_BEGIN if (encoding == encoding_latin1) return convert_buffer_output_generic(r_u8, data, length, utf8_decoder(), latin1_writer()); - assert(false && "Invalid encoding"); + assert(false && "Invalid encoding"); // unreachable return 0; } #endif @@ -3881,7 +3903,7 @@ PUGI__NS_BEGIN xml_encoding encoding; }; - PUGI__FN void text_output_escaped(xml_buffered_writer& writer, const char_t* s, chartypex_t type) + PUGI__FN void text_output_escaped(xml_buffered_writer& writer, const char_t* s, chartypex_t type, unsigned int flags) { while (*s) { @@ -3908,7 +3930,17 @@ PUGI__NS_BEGIN ++s; break; case '"': - writer.write('&', 'q', 'u', 'o', 't', ';'); + if (flags & format_attribute_single_quote) + writer.write('"'); + else + writer.write('&', 'q', 'u', 'o', 't', ';'); + ++s; + break; + case '\'': + if (flags & format_attribute_single_quote) + writer.write('&', 'a', 'p', 'o', 's', ';'); + else + writer.write('\''); ++s; break; default: // s is not a usual symbol @@ -3916,7 +3948,8 @@ PUGI__NS_BEGIN unsigned int ch = static_cast(*s++); assert(ch < 32); - writer.write('&', '#', static_cast((ch / 10) + '0'), static_cast((ch % 10) + '0'), ';'); + if (!(flags & format_skip_control_chars)) + writer.write('&', '#', static_cast((ch / 10) + '0'), static_cast((ch % 10) + '0'), ';'); } } } @@ -3927,7 +3960,7 @@ PUGI__NS_BEGIN if (flags & format_no_escapes) writer.write_string(s); else - text_output_escaped(writer, s, type); + text_output_escaped(writer, s, type, flags); } PUGI__FN void text_output_cdata(xml_buffered_writer& writer, const char_t* s) @@ -4041,6 +4074,7 @@ PUGI__NS_BEGIN PUGI__FN void node_output_attributes(xml_buffered_writer& writer, xml_node_struct* node, const char_t* indent, size_t indent_length, unsigned int flags, unsigned int depth) { const char_t* default_name = PUGIXML_TEXT(":anonymous"); + const char_t enquotation_char = (flags & format_attribute_single_quote) ? '\'' : '"'; for (xml_attribute_struct* a = node->first_attribute; a; a = a->next_attribute) { @@ -4056,12 +4090,12 @@ PUGI__NS_BEGIN } writer.write_string(a->name ? a->name + 0 : default_name); - writer.write('=', '"'); + writer.write('=', enquotation_char); if (a->value) text_output(writer, a->value, ctx_special_attr, flags); - writer.write('"'); + writer.write(enquotation_char); } } @@ -4189,7 +4223,7 @@ PUGI__NS_BEGIN break; default: - assert(false && "Invalid node type"); + assert(false && "Invalid node type"); // unreachable } } @@ -4401,6 +4435,10 @@ PUGI__NS_BEGIN while (sit && sit != sn) { + // loop invariant: dit is inside the subtree rooted at dn + assert(dit); + + // when a tree is copied into one of the descendants, we need to skip that subtree to avoid an infinite loop if (sit != dn) { xml_node_struct* copy = append_new_node(dit, alloc, PUGI__NODETYPE(sit)); @@ -4429,9 +4467,14 @@ PUGI__NS_BEGIN sit = sit->parent; dit = dit->parent; + + // loop invariant: dit is inside the subtree rooted at dn while sit is inside sn + assert(sit == sn || dit); } while (sit != sn); } + + assert(!sit || dit == dn->parent); } PUGI__FN void node_copy_attribute(xml_attribute_struct* da, xml_attribute_struct* sa) @@ -4451,7 +4494,7 @@ PUGI__NS_BEGIN } // get value with conversion functions - template U string_to_integer(const char_t* value, U minneg, U maxpos) + template PUGI__FN PUGI__UNSIGNED_OVERFLOW U string_to_integer(const char_t* value, U minv, U maxv) { U result = 0; const char_t* s = value; @@ -4521,14 +4564,21 @@ PUGI__NS_BEGIN } if (negative) - return (overflow || result > minneg) ? 0 - minneg : 0 - result; + { + // Workaround for crayc++ CC-3059: Expected no overflow in routine. + #ifdef _CRAYC + return (overflow || result > ~minv + 1) ? minv : ~result + 1; + #else + return (overflow || result > 0 - minv) ? minv : 0 - result; + #endif + } else - return (overflow || result > maxpos) ? maxpos : result; + return (overflow || result > maxv) ? maxv : result; } PUGI__FN int get_value_int(const char_t* value) { - return string_to_integer(value, 0 - static_cast(INT_MIN), INT_MAX); + return string_to_integer(value, static_cast(INT_MIN), INT_MAX); } PUGI__FN unsigned int get_value_uint(const char_t* value) @@ -4566,7 +4616,7 @@ PUGI__NS_BEGIN #ifdef PUGIXML_HAS_LONG_LONG PUGI__FN long long get_value_llong(const char_t* value) { - return string_to_integer(value, 0 - static_cast(LLONG_MIN), LLONG_MAX); + return string_to_integer(value, static_cast(LLONG_MIN), LLONG_MAX); } PUGI__FN unsigned long long get_value_ullong(const char_t* value) @@ -4575,7 +4625,7 @@ PUGI__NS_BEGIN } #endif - template PUGI__FN char_t* integer_to_string(char_t* begin, char_t* end, U value, bool negative) + template PUGI__FN PUGI__UNSIGNED_OVERFLOW char_t* integer_to_string(char_t* begin, char_t* end, U value, bool negative) { char_t* result = end - 1; U rest = negative ? 0 - value : value; @@ -4623,19 +4673,19 @@ PUGI__NS_BEGIN } template - PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, float value) + PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, float value, int precision) { char buf[128]; - sprintf(buf, "%.9g", value); + PUGI__SNPRINTF(buf, "%.*g", precision, double(value)); return set_value_ascii(dest, header, header_mask, buf); } template - PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, double value) + PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, double value, int precision) { char buf[128]; - sprintf(buf, "%.17g", value); + PUGI__SNPRINTF(buf, "%.*g", precision, value); return set_value_ascii(dest, header, header_mask, buf); } @@ -4658,6 +4708,7 @@ PUGI__NS_BEGIN char_t* buffer = 0; size_t length = 0; + // coverity[var_deref_model] if (!impl::convert_buffer(buffer, length, buffer_encoding, contents, size, is_mutable)) return impl::make_parse_result(status_out_of_memory); // delete original buffer if we performed a conversion @@ -4930,7 +4981,12 @@ PUGI__NS_BEGIN #if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) || (defined(__MINGW32__) && (!defined(__STRICT_ANSI__) || defined(__MINGW64_VERSION_MAJOR))) PUGI__FN FILE* open_file_wide(const wchar_t* path, const wchar_t* mode) { +#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 + FILE* file = 0; + return _wfopen_s(&file, path, mode) == 0 ? file : 0; +#else return _wfopen(path, mode); +#endif } #else PUGI__FN char* convert_path_heap(const wchar_t* str) @@ -4974,6 +5030,16 @@ PUGI__NS_BEGIN } #endif + PUGI__FN FILE* open_file(const char* path, const char* mode) + { +#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 + FILE* file = 0; + return fopen_s(&file, path, mode) == 0 ? file : 0; +#else + return fopen(path, mode); +#endif + } + PUGI__FN bool save_file_impl(const xml_document& doc, FILE* file, const char_t* indent, unsigned int flags, xml_encoding encoding) { if (!file) return false; @@ -5299,14 +5365,28 @@ namespace pugi { if (!_attr) return false; - return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); + return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, default_double_precision); + } + + PUGI__FN bool xml_attribute::set_value(double rhs, int precision) + { + if (!_attr) return false; + + return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, precision); } PUGI__FN bool xml_attribute::set_value(float rhs) { if (!_attr) return false; - return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); + return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, default_float_precision); + } + + PUGI__FN bool xml_attribute::set_value(float rhs, int precision) + { + if (!_attr) return false; + + return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, precision); } PUGI__FN bool xml_attribute::set_value(bool rhs) @@ -6016,6 +6096,27 @@ namespace pugi return true; } + PUGI__FN bool xml_node::remove_attributes() + { + if (!_root) return false; + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return false; + + for (xml_attribute_struct* attr = _root->first_attribute; attr; ) + { + xml_attribute_struct* next = attr->next_attribute; + + impl::destroy_attribute(attr, alloc); + + attr = next; + } + + _root->first_attribute = 0; + + return true; + } + PUGI__FN bool xml_node::remove_child(const char_t* name_) { return remove_child(child(name_)); @@ -6034,6 +6135,27 @@ namespace pugi return true; } + PUGI__FN bool xml_node::remove_children() + { + if (!_root) return false; + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return false; + + for (xml_node_struct* cur = _root->first_child; cur; ) + { + xml_node_struct* next = cur->next_sibling; + + impl::destroy_node(cur, alloc); + + cur = next; + } + + _root->first_child = 0; + + return true; + } + PUGI__FN xml_parse_result xml_node::append_buffer(const void* contents, size_t size, unsigned int options, xml_encoding encoding) { // append_buffer is only valid for elements/documents @@ -6047,11 +6169,17 @@ namespace pugi // get extra buffer element (we'll store the document fragment buffer there so that we can deallocate it later) impl::xml_memory_page* page = 0; - impl::xml_extra_buffer* extra = static_cast(doc->allocate_memory(sizeof(impl::xml_extra_buffer), page)); + impl::xml_extra_buffer* extra = static_cast(doc->allocate_memory(sizeof(impl::xml_extra_buffer) + sizeof(void*), page)); (void)page; if (!extra) return impl::make_parse_result(status_out_of_memory); + #ifdef PUGIXML_COMPACT + // align the memory block to a pointer boundary; this is required for compact mode where memory allocations are only 4b aligned + // note that this requires up to sizeof(void*)-1 additional memory, which the allocation above takes into account + extra = reinterpret_cast((reinterpret_cast(extra) + (sizeof(void*) - 1)) & ~(sizeof(void*) - 1)); + #endif + // add extra buffer to the list extra->buffer = 0; extra->next = doc->extra_buffers; @@ -6111,7 +6239,7 @@ namespace pugi if (j != _root) result[--offset] = delimiter; - if (j->name && *j->name) + if (j->name) { size_t length = impl::strlength(j->name); @@ -6128,16 +6256,9 @@ namespace pugi PUGI__FN xml_node xml_node::first_element_by_path(const char_t* path_, char_t delimiter) const { - xml_node found = *this; // Current search context. + xml_node context = path_[0] == delimiter ? root() : *this; - if (!_root || !path_ || !path_[0]) return found; - - if (path_[0] == delimiter) - { - // Absolute path; e.g. '/foo/bar' - found = found.root(); - ++path_; - } + if (!context._root) return xml_node(); const char_t* path_segment = path_; @@ -6147,19 +6268,19 @@ namespace pugi while (*path_segment_end && *path_segment_end != delimiter) ++path_segment_end; - if (path_segment == path_segment_end) return found; + if (path_segment == path_segment_end) return context; const char_t* next_segment = path_segment_end; while (*next_segment == delimiter) ++next_segment; if (*path_segment == '.' && path_segment + 1 == path_segment_end) - return found.first_element_by_path(next_segment, delimiter); + return context.first_element_by_path(next_segment, delimiter); else if (*path_segment == '.' && *(path_segment+1) == '.' && path_segment + 2 == path_segment_end) - return found.parent().first_element_by_path(next_segment, delimiter); + return context.parent().first_element_by_path(next_segment, delimiter); else { - for (xml_node_struct* j = found._root->first_child; j; j = j->next_sibling) + for (xml_node_struct* j = context._root->first_child; j; j = j->next_sibling) { if (j->name && impl::strequalrange(j->name, path_segment, static_cast(path_segment_end - path_segment))) { @@ -6177,10 +6298,10 @@ namespace pugi { walker._depth = -1; - xml_node arg_begin = *this; + xml_node arg_begin(_root); if (!walker.begin(arg_begin)) return false; - xml_node cur = first_child(); + xml_node_struct* cur = _root ? _root->first_child + 0 : 0; if (cur) { @@ -6188,36 +6309,35 @@ namespace pugi do { - xml_node arg_for_each = cur; + xml_node arg_for_each(cur); if (!walker.for_each(arg_for_each)) return false; - if (cur.first_child()) + if (cur->first_child) { ++walker._depth; - cur = cur.first_child(); + cur = cur->first_child; } - else if (cur.next_sibling()) - cur = cur.next_sibling(); + else if (cur->next_sibling) + cur = cur->next_sibling; else { - // Borland C++ workaround - while (!cur.next_sibling() && cur != *this && !cur.parent().empty()) + while (!cur->next_sibling && cur != _root && cur->parent) { --walker._depth; - cur = cur.parent(); + cur = cur->parent; } - if (cur != *this) - cur = cur.next_sibling(); + if (cur != _root) + cur = cur->next_sibling; } } - while (cur && cur != *this); + while (cur && cur != _root); } assert(walker._depth == -1); - xml_node arg_end = *this; + xml_node arg_end(_root); return walker.end(arg_end); } @@ -6284,6 +6404,7 @@ namespace pugi return _root->value && (_root->header & impl::xml_memory_page_value_allocated_or_shared_mask) == 0 ? _root->value - doc.buffer : -1; default: + assert(false && "Invalid node type"); // unreachable return -1; } } @@ -6454,14 +6575,28 @@ namespace pugi { xml_node_struct* dn = _data_new(); - return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; + return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, default_float_precision) : false; + } + + PUGI__FN bool xml_text::set(float rhs, int precision) + { + xml_node_struct* dn = _data_new(); + + return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, precision) : false; } PUGI__FN bool xml_text::set(double rhs) { xml_node_struct* dn = _data_new(); - return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; + return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, default_double_precision) : false; + } + + PUGI__FN bool xml_text::set(double rhs, int precision) + { + xml_node_struct* dn = _data_new(); + + return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, precision) : false; } PUGI__FN bool xml_text::set(bool rhs) @@ -6808,6 +6943,25 @@ namespace pugi _destroy(); } +#ifdef PUGIXML_HAS_MOVE + PUGI__FN xml_document::xml_document(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT: _buffer(0) + { + _create(); + _move(rhs); + } + + PUGI__FN xml_document& xml_document::operator=(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT + { + if (this == &rhs) return *this; + + _destroy(); + _create(); + _move(rhs); + + return *this; + } +#endif + PUGI__FN void xml_document::reset() { _destroy(); @@ -6818,8 +6972,7 @@ namespace pugi { reset(); - for (xml_node cur = proto.first_child(); cur; cur = cur.next_sibling()) - append_copy(cur); + impl::node_copy_tree(_root, proto._root); } PUGI__FN void xml_document::_create() @@ -6827,7 +6980,8 @@ namespace pugi assert(!_root); #ifdef PUGIXML_COMPACT - const size_t page_offset = sizeof(uint32_t); + // space for page marker for the first page (uint32_t), rounded up to pointer size; assumes pointers are at least 32-bit + const size_t page_offset = sizeof(void*); #else const size_t page_offset = 0; #endif @@ -6903,6 +7057,113 @@ namespace pugi _root = 0; } +#ifdef PUGIXML_HAS_MOVE + PUGI__FN void xml_document::_move(xml_document& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT + { + impl::xml_document_struct* doc = static_cast(_root); + impl::xml_document_struct* other = static_cast(rhs._root); + + // save first child pointer for later; this needs hash access + xml_node_struct* other_first_child = other->first_child; + + #ifdef PUGIXML_COMPACT + // reserve space for the hash table up front; this is the only operation that can fail + // if it does, we have no choice but to throw (if we have exceptions) + if (other_first_child) + { + size_t other_children = 0; + for (xml_node_struct* node = other_first_child; node; node = node->next_sibling) + other_children++; + + // in compact mode, each pointer assignment could result in a hash table request + // during move, we have to relocate document first_child and parents of all children + // normally there's just one child and its parent has a pointerless encoding but + // we assume the worst here + if (!other->_hash->reserve(other_children + 1)) + { + #ifdef PUGIXML_NO_EXCEPTIONS + return; + #else + throw std::bad_alloc(); + #endif + } + } + #endif + + // move allocation state + doc->_root = other->_root; + doc->_busy_size = other->_busy_size; + + // move buffer state + doc->buffer = other->buffer; + doc->extra_buffers = other->extra_buffers; + _buffer = rhs._buffer; + + #ifdef PUGIXML_COMPACT + // move compact hash; note that the hash table can have pointers to other but they will be "inactive", similarly to nodes removed with remove_child + doc->hash = other->hash; + doc->_hash = &doc->hash; + + // make sure we don't access other hash up until the end when we reinitialize other document + other->_hash = 0; + #endif + + // move page structure + impl::xml_memory_page* doc_page = PUGI__GETPAGE(doc); + assert(doc_page && !doc_page->prev && !doc_page->next); + + impl::xml_memory_page* other_page = PUGI__GETPAGE(other); + assert(other_page && !other_page->prev); + + // relink pages since root page is embedded into xml_document + if (impl::xml_memory_page* page = other_page->next) + { + assert(page->prev == other_page); + + page->prev = doc_page; + + doc_page->next = page; + other_page->next = 0; + } + + // make sure pages point to the correct document state + for (impl::xml_memory_page* page = doc_page->next; page; page = page->next) + { + assert(page->allocator == other); + + page->allocator = doc; + + #ifdef PUGIXML_COMPACT + // this automatically migrates most children between documents and prevents ->parent assignment from allocating + if (page->compact_shared_parent == other) + page->compact_shared_parent = doc; + #endif + } + + // move tree structure + assert(!doc->first_child); + + doc->first_child = other_first_child; + + for (xml_node_struct* node = other_first_child; node; node = node->next_sibling) + { + #ifdef PUGIXML_COMPACT + // most children will have migrated when we reassigned compact_shared_parent + assert(node->parent == other || node->parent == doc); + + node->parent = doc; + #else + assert(node->parent == other); + node->parent = doc; + #endif + } + + // reset other document + new (other) impl::xml_document_struct(PUGI__GETPAGE(other)); + rhs._buffer = 0; + } +#endif + #ifndef PUGIXML_NO_STL PUGI__FN xml_parse_result xml_document::load(std::basic_istream >& stream, unsigned int options, xml_encoding encoding) { @@ -6941,7 +7202,7 @@ namespace pugi reset(); using impl::auto_deleter; // MSVC7 workaround - auto_deleter file(fopen(path_, "rb"), impl::close_file); + auto_deleter file(impl::open_file(path_, "rb"), impl::close_file); return impl::load_file_impl(static_cast(_root), file.data, options, encoding, &_buffer); } @@ -7024,7 +7285,7 @@ namespace pugi PUGI__FN bool xml_document::save_file(const char* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const { using impl::auto_deleter; // MSVC7 workaround - auto_deleter file(fopen(path_, (flags & format_save_file_text) ? "w" : "wb"), impl::close_file); + auto_deleter file(impl::open_file(path_, (flags & format_save_file_text) ? "w" : "wb"), impl::close_file); return impl::save_file_impl(*this, file.data, indent, flags, encoding); } @@ -7168,14 +7429,14 @@ PUGI__NS_BEGIN } }; - template void swap(T& lhs, T& rhs) + template inline void swap(T& lhs, T& rhs) { T temp = lhs; lhs = rhs; rhs = temp; } - template I min_element(I begin, I end, const Pred& pred) + template PUGI__FN I min_element(I begin, I end, const Pred& pred) { I result = begin; @@ -7186,17 +7447,20 @@ PUGI__NS_BEGIN return result; } - template void reverse(I begin, I end) + template PUGI__FN void reverse(I begin, I end) { - while (end - begin > 1) swap(*begin++, *--end); + while (end - begin > 1) + swap(*begin++, *--end); } - template I unique(I begin, I end) + template PUGI__FN I unique(I begin, I end) { // fast skip head - while (end - begin > 1 && *begin != *(begin + 1)) begin++; + while (end - begin > 1 && *begin != *(begin + 1)) + begin++; - if (begin == end) return begin; + if (begin == end) + return begin; // last written element I write = begin++; @@ -7214,134 +7478,79 @@ PUGI__NS_BEGIN return write + 1; } - template void copy_backwards(I begin, I end, I target) - { - while (begin != end) *--target = *--end; - } - - template void insertion_sort(I begin, I end, const Pred& pred, T*) + template PUGI__FN void insertion_sort(T* begin, T* end, const Pred& pred) { - assert(begin != end); + if (begin == end) + return; - for (I it = begin + 1; it != end; ++it) + for (T* it = begin + 1; it != end; ++it) { T val = *it; + T* hole = it; - if (pred(val, *begin)) + // move hole backwards + while (hole > begin && pred(val, *(hole - 1))) { - // move to front - copy_backwards(begin, it, it + 1); - *begin = val; + *hole = *(hole - 1); + hole--; } - else - { - I hole = it; - - // move hole backwards - while (pred(val, *(hole - 1))) - { - *hole = *(hole - 1); - hole--; - } - // fill hole with element - *hole = val; - } + // fill hole with element + *hole = val; } } - // std variant for elements with == - template void partition(I begin, I middle, I end, const Pred& pred, I* out_eqbeg, I* out_eqend) + template inline I median3(I first, I middle, I last, const Pred& pred) { - I eqbeg = middle, eqend = middle + 1; - - // expand equal range - while (eqbeg != begin && *(eqbeg - 1) == *eqbeg) --eqbeg; - while (eqend != end && *eqend == *eqbeg) ++eqend; - - // process outer elements - I ltend = eqbeg, gtbeg = eqend; - - for (;;) - { - // find the element from the right side that belongs to the left one - for (; gtbeg != end; ++gtbeg) - if (!pred(*eqbeg, *gtbeg)) - { - if (*gtbeg == *eqbeg) swap(*gtbeg, *eqend++); - else break; - } - - // find the element from the left side that belongs to the right one - for (; ltend != begin; --ltend) - if (!pred(*(ltend - 1), *eqbeg)) - { - if (*eqbeg == *(ltend - 1)) swap(*(ltend - 1), *--eqbeg); - else break; - } + if (pred(*middle, *first)) + swap(middle, first); + if (pred(*last, *middle)) + swap(last, middle); + if (pred(*middle, *first)) + swap(middle, first); - // scanned all elements - if (gtbeg == end && ltend == begin) - { - *out_eqbeg = eqbeg; - *out_eqend = eqend; - return; - } - - // make room for elements by moving equal area - if (gtbeg == end) - { - if (--ltend != --eqbeg) swap(*ltend, *eqbeg); - swap(*eqbeg, *--eqend); - } - else if (ltend == begin) - { - if (eqend != gtbeg) swap(*eqbeg, *eqend); - ++eqend; - swap(*gtbeg++, *eqbeg++); - } - else swap(*gtbeg++, *--ltend); - } + return middle; } - template void median3(I first, I middle, I last, const Pred& pred) + template PUGI__FN void partition3(T* begin, T* end, T pivot, const Pred& pred, T** out_eqbeg, T** out_eqend) { - if (pred(*middle, *first)) swap(*middle, *first); - if (pred(*last, *middle)) swap(*last, *middle); - if (pred(*middle, *first)) swap(*middle, *first); - } + // invariant: array is split into 4 groups: = < ? > (each variable denotes the boundary between the groups) + T* eq = begin; + T* lt = begin; + T* gt = end; - template void median(I first, I middle, I last, const Pred& pred) - { - if (last - first <= 40) + while (lt < gt) { - // median of three for small chunks - median3(first, middle, last, pred); + if (pred(*lt, pivot)) + lt++; + else if (*lt == pivot) + swap(*eq++, *lt++); + else + swap(*lt, *--gt); } - else - { - // median of nine - size_t step = (last - first + 1) / 8; - median3(first, first + step, first + 2 * step, pred); - median3(middle - step, middle, middle + step, pred); - median3(last - 2 * step, last - step, last, pred); - median3(first + step, middle, last - step, pred); - } + // we now have just 4 groups: = < >; move equal elements to the middle + T* eqbeg = gt; + + for (T* it = begin; it != eq; ++it) + swap(*it, *--eqbeg); + + *out_eqbeg = eqbeg; + *out_eqend = gt; } - template void sort(I begin, I end, const Pred& pred) + template PUGI__FN void sort(I begin, I end, const Pred& pred) { // sort large chunks - while (end - begin > 32) + while (end - begin > 16) { // find median element I middle = begin + (end - begin) / 2; - median(begin, middle, end - 1, pred); + I median = median3(begin, middle, end - 1, pred); // partition in three chunks (< = >) I eqbeg, eqend; - partition(begin, middle, end, pred, &eqbeg, &eqend); + partition3(begin, end, *median, pred, &eqbeg, &eqend); // loop on larger half if (eqbeg - begin > end - eqend) @@ -7357,25 +7566,60 @@ PUGI__NS_BEGIN } // insertion sort small chunk - if (begin != end) insertion_sort(begin, end, pred, &*begin); + insertion_sort(begin, end, pred); } -PUGI__NS_END -// Allocator used for AST and evaluation stacks -PUGI__NS_BEGIN - static const size_t xpath_memory_page_size = - #ifdef PUGIXML_MEMORY_XPATH_PAGE_SIZE - PUGIXML_MEMORY_XPATH_PAGE_SIZE - #else - 4096 - #endif - ; + PUGI__FN bool hash_insert(const void** table, size_t size, const void* key) + { + assert(key); - static const uintptr_t xpath_memory_block_alignment = sizeof(double) > sizeof(void*) ? sizeof(double) : sizeof(void*); + unsigned int h = static_cast(reinterpret_cast(key)); - struct xpath_memory_block - { - xpath_memory_block* next; + // MurmurHash3 32-bit finalizer + h ^= h >> 16; + h *= 0x85ebca6bu; + h ^= h >> 13; + h *= 0xc2b2ae35u; + h ^= h >> 16; + + size_t hashmod = size - 1; + size_t bucket = h & hashmod; + + for (size_t probe = 0; probe <= hashmod; ++probe) + { + if (table[bucket] == 0) + { + table[bucket] = key; + return true; + } + + if (table[bucket] == key) + return false; + + // hash collision, quadratic probing + bucket = (bucket + probe + 1) & hashmod; + } + + assert(false && "Hash table is full"); // unreachable + return false; + } +PUGI__NS_END + +// Allocator used for AST and evaluation stacks +PUGI__NS_BEGIN + static const size_t xpath_memory_page_size = + #ifdef PUGIXML_MEMORY_XPATH_PAGE_SIZE + PUGIXML_MEMORY_XPATH_PAGE_SIZE + #else + 4096 + #endif + ; + + static const uintptr_t xpath_memory_block_alignment = sizeof(double) > sizeof(void*) ? sizeof(double) : sizeof(void*); + + struct xpath_memory_block + { + xpath_memory_block* next; size_t capacity; union @@ -7385,24 +7629,17 @@ PUGI__NS_BEGIN }; }; - class xpath_allocator + struct xpath_allocator { xpath_memory_block* _root; size_t _root_size; + bool* _error; - public: - #ifdef PUGIXML_NO_EXCEPTIONS - jmp_buf* error_handler; - #endif - - xpath_allocator(xpath_memory_block* root, size_t root_size = 0): _root(root), _root_size(root_size) + xpath_allocator(xpath_memory_block* root, bool* error = 0): _root(root), _root_size(0), _error(error) { - #ifdef PUGIXML_NO_EXCEPTIONS - error_handler = 0; - #endif } - void* allocate_nothrow(size_t size) + void* allocate(size_t size) { // round size up to block alignment boundary size = (size + xpath_memory_block_alignment - 1) & ~(xpath_memory_block_alignment - 1); @@ -7423,7 +7660,11 @@ PUGI__NS_BEGIN size_t block_size = block_capacity + offsetof(xpath_memory_block, data); xpath_memory_block* block = static_cast(xml_memory::allocate(block_size)); - if (!block) return 0; + if (!block) + { + if (_error) *_error = true; + return 0; + } block->next = _root; block->capacity = block_capacity; @@ -7435,23 +7676,6 @@ PUGI__NS_BEGIN } } - void* allocate(size_t size) - { - void* result = allocate_nothrow(size); - - if (!result) - { - #ifdef PUGIXML_NO_EXCEPTIONS - assert(error_handler); - longjmp(*error_handler, 1); - #else - throw std::bad_alloc(); - #endif - } - - return result; - } - void* reallocate(void* ptr, size_t old_size, size_t new_size) { // round size up to block alignment boundary @@ -7461,33 +7685,35 @@ PUGI__NS_BEGIN // we can only reallocate the last object assert(ptr == 0 || static_cast(ptr) + old_size == &_root->data[0] + _root_size); - // adjust root size so that we have not allocated the object at all - bool only_object = (_root_size == old_size); - - if (ptr) _root_size -= old_size; + // try to reallocate the object inplace + if (ptr && _root_size - old_size + new_size <= _root->capacity) + { + _root_size = _root_size - old_size + new_size; + return ptr; + } - // allocate a new version (this will obviously reuse the memory if possible) + // allocate a new block void* result = allocate(new_size); - assert(result); + if (!result) return 0; // we have a new block - if (result != ptr && ptr) + if (ptr) { - // copy old data + // copy old data (we only support growing) assert(new_size >= old_size); memcpy(result, ptr, old_size); // free the previous page if it had no other objects - if (only_object) - { - assert(_root->data == result); - assert(_root->next); + assert(_root->data == result); + assert(_root->next); + if (_root->next->data == ptr) + { + // deallocate the whole page, unless it was the first one xpath_memory_block* next = _root->next->next; if (next) { - // deallocate the whole page, unless it was the first one xml_memory::deallocate(_root->next); _root->next = next; } @@ -7559,22 +7785,15 @@ PUGI__NS_BEGIN xpath_allocator result; xpath_allocator temp; xpath_stack stack; + bool oom; - #ifdef PUGIXML_NO_EXCEPTIONS - jmp_buf error_handler; - #endif - - xpath_stack_data(): result(blocks + 0), temp(blocks + 1) + xpath_stack_data(): result(blocks + 0, &oom), temp(blocks + 1, &oom), oom(false) { blocks[0].next = blocks[1].next = 0; blocks[0].capacity = blocks[1].capacity = sizeof(blocks[0].data); stack.result = &result; stack.temp = &temp; - - #ifdef PUGIXML_NO_EXCEPTIONS - result.error_handler = temp.error_handler = &error_handler; - #endif } ~xpath_stack_data() @@ -7596,7 +7815,7 @@ PUGI__NS_BEGIN static char_t* duplicate_string(const char_t* string, size_t length, xpath_allocator* alloc) { char_t* result = static_cast(alloc->allocate((length + 1) * sizeof(char_t))); - assert(result); + if (!result) return 0; memcpy(result, string, length * sizeof(char_t)); result[length] = 0; @@ -7625,9 +7844,13 @@ PUGI__NS_BEGIN { assert(begin <= end); + if (begin == end) + return xpath_string(); + size_t length = static_cast(end - begin); + const char_t* data = duplicate_string(begin, length, alloc); - return length == 0 ? xpath_string() : xpath_string(duplicate_string(begin, length, alloc), true, length); + return data ? xpath_string(data, true, length) : xpath_string(); } xpath_string(): _buffer(PUGIXML_TEXT("")), _uses_heap(false), _length_heap(0) @@ -7653,7 +7876,7 @@ PUGI__NS_BEGIN // allocate new buffer char_t* result = static_cast(alloc->reallocate(_uses_heap ? const_cast(_buffer) : 0, (target_length + 1) * sizeof(char_t), (result_length + 1) * sizeof(char_t))); - assert(result); + if (!result) return; // append first string to the new buffer in case there was no reallocation if (!_uses_heap) memcpy(result, _buffer, target_length * sizeof(char_t)); @@ -7685,8 +7908,11 @@ PUGI__NS_BEGIN if (!_uses_heap) { size_t length_ = strlength(_buffer); + const char_t* data_ = duplicate_string(_buffer, length_, alloc); - _buffer = duplicate_string(_buffer, length_, alloc); + if (!data_) return 0; + + _buffer = data_; _uses_heap = true; _length_heap = length_; } @@ -7966,15 +8192,6 @@ PUGI__NS_BEGIN } }; - struct duplicate_comparator - { - bool operator()(const xpath_node& lhs, const xpath_node& rhs) const - { - if (lhs.attribute()) return rhs.attribute() ? lhs.attribute() < rhs.attribute() : true; - else return rhs.attribute() ? false : lhs.node() < rhs.node(); - } - }; - PUGI__FN double gen_nan() { #if defined(__STDC_IEC_559__) || ((FLT_RADIX - 0 == 2) && (FLT_MAX_EXP - 0 == 128) && (FLT_MANT_DIG - 0 == 24)) @@ -7982,7 +8199,7 @@ PUGI__NS_BEGIN typedef uint32_t UI; // BCC5 workaround union { float f; UI i; } u; u.i = 0x7fc00000; - return u.f; + return double(u.f); #else // fallback const volatile double zero = 0.0; @@ -8049,11 +8266,11 @@ PUGI__NS_BEGIN // gets mantissa digits in the form of 0.xxxxx with 0. implied and the exponent #if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 && !defined(_WIN32_WCE) - PUGI__FN void convert_number_to_mantissa_exponent(double value, char* buffer, size_t buffer_size, char** out_mantissa, int* out_exponent) + PUGI__FN void convert_number_to_mantissa_exponent(double value, char (&buffer)[32], char** out_mantissa, int* out_exponent) { // get base values int sign, exponent; - _ecvt_s(buffer, buffer_size, value, DBL_DIG + 1, &exponent, &sign); + _ecvt_s(buffer, sizeof(buffer), value, DBL_DIG + 1, &exponent, &sign); // truncate redundant zeros truncate_zeros(buffer, buffer + strlen(buffer)); @@ -8063,12 +8280,10 @@ PUGI__NS_BEGIN *out_exponent = exponent; } #else - PUGI__FN void convert_number_to_mantissa_exponent(double value, char* buffer, size_t buffer_size, char** out_mantissa, int* out_exponent) + PUGI__FN void convert_number_to_mantissa_exponent(double value, char (&buffer)[32], char** out_mantissa, int* out_exponent) { // get a scientific notation value with IEEE DBL_DIG decimals - sprintf(buffer, "%.*e", DBL_DIG, value); - assert(strlen(buffer) < buffer_size); - (void)!buffer_size; + PUGI__SNPRINTF(buffer, "%.*e", DBL_DIG, value); // get the exponent (possibly negative) char* exponent_string = strchr(buffer, 'e'); @@ -8105,12 +8320,12 @@ PUGI__NS_BEGIN char* mantissa; int exponent; - convert_number_to_mantissa_exponent(value, mantissa_buffer, sizeof(mantissa_buffer), &mantissa, &exponent); + convert_number_to_mantissa_exponent(value, mantissa_buffer, &mantissa, &exponent); // allocate a buffer of suitable length for the number size_t result_size = strlen(mantissa_buffer) + (exponent > 0 ? exponent : -exponent) + 4; char_t* result = static_cast(alloc->allocate(sizeof(char_t) * result_size)); - assert(result); + if (!result) return xpath_string(); // make the number! char_t* s = result; @@ -8127,7 +8342,7 @@ PUGI__NS_BEGIN { while (exponent > 0) { - assert(*mantissa == 0 || static_cast(static_cast(*mantissa) - '0') <= 9); + assert(*mantissa == 0 || static_cast(*mantissa - '0') <= 9); *s++ = *mantissa ? *mantissa++ : '0'; exponent--; } @@ -8394,12 +8609,10 @@ PUGI__NS_BEGIN if (!table[i]) table[i] = static_cast(i); - void* result = alloc->allocate_nothrow(sizeof(table)); + void* result = alloc->allocate(sizeof(table)); + if (!result) return 0; - if (result) - { - memcpy(result, table, sizeof(table)); - } + memcpy(result, table, sizeof(table)); return static_cast(result); } @@ -8486,7 +8699,7 @@ PUGI__NS_BEGIN static const xpath_node_set dummy_node_set; - PUGI__FN unsigned int hash_string(const char_t* str) + PUGI__FN PUGI__UNSIGNED_OVERFLOW unsigned int hash_string(const char_t* str) { // Jenkins one-at-a-time hash (http://en.wikipedia.org/wiki/Jenkins_hash_function#one-at-a-time) unsigned int result = 0; @@ -8569,7 +8782,7 @@ PUGI__NS_BEGIN break; default: - assert(false && "Invalid variable type"); + assert(false && "Invalid variable type"); // unreachable } } @@ -8590,7 +8803,7 @@ PUGI__NS_BEGIN return lhs->set(static_cast(rhs)->value); default: - assert(false && "Invalid variable type"); + assert(false && "Invalid variable type"); // unreachable return false; } } @@ -8677,7 +8890,7 @@ PUGI__NS_BEGIN return *min_element(begin, end, document_order_comparator()); default: - assert(false && "Invalid node set type"); + assert(false && "Invalid node set type"); // unreachable return xpath_node(); } } @@ -8742,7 +8955,7 @@ PUGI__NS_BEGIN { // reallocate the old array or allocate a new one xpath_node* data = static_cast(alloc->reallocate(_begin, capacity * sizeof(xpath_node), (size_ + count) * sizeof(xpath_node))); - assert(data); + if (!data) return; // finalize _begin = data; @@ -8766,12 +8979,42 @@ PUGI__NS_BEGIN _end = pos; } - void remove_duplicates() + void remove_duplicates(xpath_allocator* alloc) { - if (_type == xpath_node_set::type_unsorted) - sort(_begin, _end, duplicate_comparator()); + if (_type == xpath_node_set::type_unsorted && _end - _begin > 2) + { + xpath_allocator_capture cr(alloc); + + size_t size_ = static_cast(_end - _begin); + + size_t hash_size = 1; + while (hash_size < size_ + size_ / 2) hash_size *= 2; + + const void** hash_data = static_cast(alloc->allocate(hash_size * sizeof(void**))); + if (!hash_data) return; + + memset(hash_data, 0, hash_size * sizeof(const void**)); - _end = unique(_begin, _end); + xpath_node* write = _begin; + + for (xpath_node* it = _begin; it != _end; ++it) + { + const void* attr = it->attribute().internal_object(); + const void* node = it->node().internal_object(); + const void* key = attr ? attr : node; + + if (key && hash_insert(hash_data, hash_size, key)) + { + *write++ = *it; + } + } + + _end = write; + } + else + { + _end = unique(_begin, _end); + } } xpath_node_set::type_t type() const @@ -8794,7 +9037,7 @@ PUGI__NS_BEGIN // reallocate the old array or allocate a new one xpath_node* data = static_cast(alloc->reallocate(_begin, capacity * sizeof(xpath_node), new_capacity * sizeof(xpath_node))); - assert(data); + if (!data) return; // finalize _begin = data; @@ -9407,7 +9650,7 @@ PUGI__NS_BEGIN } } - assert(false && "Wrong types"); + assert(false && "Wrong types"); // unreachable return false; } @@ -9482,7 +9725,7 @@ PUGI__NS_BEGIN } else { - assert(false && "Wrong types"); + assert(false && "Wrong types"); // unreachable return false; } } @@ -9528,7 +9771,7 @@ PUGI__NS_BEGIN { xpath_context c(*it, i, size); - if (expr->eval_number(c, stack) == i) + if (expr->eval_number(c, stack) == static_cast(i)) { *last++ = *it; @@ -9552,11 +9795,11 @@ PUGI__NS_BEGIN double er = expr->eval_number(c, stack); - if (er >= 1.0 && er <= size) + if (er >= 1.0 && er <= static_cast(size)) { size_t eri = static_cast(er); - if (er == eri) + if (er == static_cast(eri)) { xpath_node r = last[eri - 1]; @@ -9700,7 +9943,7 @@ PUGI__NS_BEGIN break; default: - assert(false && "Unknown axis"); + assert(false && "Unknown axis"); // unreachable } return false; @@ -9895,7 +10138,7 @@ PUGI__NS_BEGIN } default: - assert(false && "Unimplemented axis"); + assert(false && "Unimplemented axis"); // unreachable } } @@ -9976,7 +10219,7 @@ PUGI__NS_BEGIN } default: - assert(false && "Unimplemented axis"); + assert(false && "Unimplemented axis"); // unreachable } } @@ -10000,6 +10243,7 @@ PUGI__NS_BEGIN bool once = (axis == axis_attribute && _test == nodetest_name) || (!_right && eval_once(axis_type, eval)) || + // coverity[mixed_enums] (_right && !_right->_next && _right->_test == predicate_constant_one); xpath_node_set_raw ns; @@ -10032,7 +10276,7 @@ PUGI__NS_BEGIN // child, attribute and self axes always generate unique set of nodes // for other axis, if the set stayed sorted, it stayed unique because the traversal algorithms do not visit the same node twice if (axis != axis_child && axis != axis_attribute && axis != axis_self && ns.type() == xpath_node_set::type_unsorted) - ns.remove_duplicates(); + ns.remove_duplicates(stack.temp); return ns; } @@ -10193,35 +10437,37 @@ PUGI__NS_BEGIN if (_rettype == xpath_type_boolean) return _data.variable->get_boolean(); - // fallthrough to type conversion + // variable needs to be converted to the correct type, this is handled by the fallthrough block below + break; } default: - { - switch (_rettype) - { - case xpath_type_number: - return convert_number_to_boolean(eval_number(c, stack)); + ; + } - case xpath_type_string: - { - xpath_allocator_capture cr(stack.result); + // none of the ast types that return the value directly matched, we need to perform type conversion + switch (_rettype) + { + case xpath_type_number: + return convert_number_to_boolean(eval_number(c, stack)); - return !eval_string(c, stack).empty(); - } + case xpath_type_string: + { + xpath_allocator_capture cr(stack.result); - case xpath_type_node_set: - { - xpath_allocator_capture cr(stack.result); + return !eval_string(c, stack).empty(); + } - return !eval_node_set(c, stack, nodeset_eval_any).empty(); - } + case xpath_type_node_set: + { + xpath_allocator_capture cr(stack.result); - default: - assert(false && "Wrong expression for return type boolean"); - return false; - } + return !eval_node_set(c, stack, nodeset_eval_any).empty(); } + + default: + assert(false && "Wrong expression for return type boolean"); // unreachable + return false; } } @@ -10329,36 +10575,37 @@ PUGI__NS_BEGIN if (_rettype == xpath_type_number) return _data.variable->get_number(); - // fallthrough to type conversion + // variable needs to be converted to the correct type, this is handled by the fallthrough block below + break; } default: - { - switch (_rettype) - { - case xpath_type_boolean: - return eval_boolean(c, stack) ? 1 : 0; - - case xpath_type_string: - { - xpath_allocator_capture cr(stack.result); + ; + } - return convert_string_to_number(eval_string(c, stack).c_str()); - } + // none of the ast types that return the value directly matched, we need to perform type conversion + switch (_rettype) + { + case xpath_type_boolean: + return eval_boolean(c, stack) ? 1 : 0; - case xpath_type_node_set: - { - xpath_allocator_capture cr(stack.result); + case xpath_type_string: + { + xpath_allocator_capture cr(stack.result); - return convert_string_to_number(eval_string(c, stack).c_str()); - } + return convert_string_to_number(eval_string(c, stack).c_str()); + } - default: - assert(false && "Wrong expression for return type number"); - return 0; - } + case xpath_type_node_set: + { + xpath_allocator_capture cr(stack.result); + return convert_string_to_number(eval_string(c, stack).c_str()); } + + default: + assert(false && "Wrong expression for return type number"); // unreachable + return 0; } } @@ -10372,16 +10619,9 @@ PUGI__NS_BEGIN size_t count = 1; for (xpath_ast_node* nc = _right; nc; nc = nc->_next) count++; - // gather all strings - xpath_string static_buffer[4]; - xpath_string* buffer = static_buffer; - - // allocate on-heap for large concats - if (count > sizeof(static_buffer) / sizeof(static_buffer[0])) - { - buffer = static_cast(stack.temp->allocate(count * sizeof(xpath_string))); - assert(buffer); - } + // allocate a buffer for temporary string objects + xpath_string* buffer = static_cast(stack.temp->allocate(count * sizeof(xpath_string))); + if (!buffer) return xpath_string(); // evaluate all strings to temporary stack xpath_stack swapped_stack = {stack.temp, stack.result}; @@ -10398,7 +10638,7 @@ PUGI__NS_BEGIN // create final string char_t* result = static_cast(stack.result->allocate((length + 1) * sizeof(char_t))); - assert(result); + if (!result) return xpath_string(); char_t* ri = result; @@ -10522,7 +10762,7 @@ PUGI__NS_BEGIN double first = round_nearest(_right->eval_number(c, stack)); if (is_nan(first)) return xpath_string(); // NaN - else if (first >= s_length + 1) return xpath_string(); + else if (first >= static_cast(s_length + 1)) return xpath_string(); size_t pos = first < 1 ? 1 : static_cast(first); assert(1 <= pos && pos <= s_length + 1); @@ -10546,12 +10786,12 @@ PUGI__NS_BEGIN double last = first + round_nearest(_right->_next->eval_number(c, stack)); if (is_nan(first) || is_nan(last)) return xpath_string(); - else if (first >= s_length + 1) return xpath_string(); + else if (first >= static_cast(s_length + 1)) return xpath_string(); else if (first >= last) return xpath_string(); else if (last < 1) return xpath_string(); size_t pos = first < 1 ? 1 : static_cast(first); - size_t end = last >= s_length + 1 ? s_length + 1 : static_cast(last); + size_t end = last >= static_cast(s_length + 1) ? s_length + 1 : static_cast(last); assert(1 <= pos && pos <= end && end <= s_length + 1); const char_t* rbegin = s.c_str() + (pos - 1); @@ -10565,6 +10805,8 @@ PUGI__NS_BEGIN xpath_string s = string_value(c.n, stack.result); char_t* begin = s.data(stack.result); + if (!begin) return xpath_string(); + char_t* end = normalize_space(begin); return xpath_string::from_heap_preallocated(begin, end); @@ -10575,6 +10817,8 @@ PUGI__NS_BEGIN xpath_string s = _left->eval_string(c, stack); char_t* begin = s.data(stack.result); + if (!begin) return xpath_string(); + char_t* end = normalize_space(begin); return xpath_string::from_heap_preallocated(begin, end); @@ -10591,6 +10835,8 @@ PUGI__NS_BEGIN xpath_string to = _right->_next->eval_string(c, swapped_stack); char_t* begin = s.data(stack.result); + if (!begin) return xpath_string(); + char_t* end = translate(begin, from.c_str(), to.c_str(), to.length()); return xpath_string::from_heap_preallocated(begin, end); @@ -10601,6 +10847,8 @@ PUGI__NS_BEGIN xpath_string s = _left->eval_string(c, stack); char_t* begin = s.data(stack.result); + if (!begin) return xpath_string(); + char_t* end = translate_table(begin, _data.table); return xpath_string::from_heap_preallocated(begin, end); @@ -10613,34 +10861,36 @@ PUGI__NS_BEGIN if (_rettype == xpath_type_string) return xpath_string::from_const(_data.variable->get_string()); - // fallthrough to type conversion + // variable needs to be converted to the correct type, this is handled by the fallthrough block below + break; } default: - { - switch (_rettype) - { - case xpath_type_boolean: - return xpath_string::from_const(eval_boolean(c, stack) ? PUGIXML_TEXT("true") : PUGIXML_TEXT("false")); + ; + } - case xpath_type_number: - return convert_number_to_string(eval_number(c, stack), stack.result); + // none of the ast types that return the value directly matched, we need to perform type conversion + switch (_rettype) + { + case xpath_type_boolean: + return xpath_string::from_const(eval_boolean(c, stack) ? PUGIXML_TEXT("true") : PUGIXML_TEXT("false")); - case xpath_type_node_set: - { - xpath_allocator_capture cr(stack.temp); + case xpath_type_number: + return convert_number_to_string(eval_number(c, stack), stack.result); - xpath_stack swapped_stack = {stack.temp, stack.result}; + case xpath_type_node_set: + { + xpath_allocator_capture cr(stack.temp); - xpath_node_set_raw ns = eval_node_set(c, swapped_stack, nodeset_eval_first); - return ns.empty() ? xpath_string() : string_value(ns.first(), stack.result); - } + xpath_stack swapped_stack = {stack.temp, stack.result}; - default: - assert(false && "Wrong expression for return type string"); - return xpath_string(); - } + xpath_node_set_raw ns = eval_node_set(c, swapped_stack, nodeset_eval_first); + return ns.empty() ? xpath_string() : string_value(ns.first(), stack.result); } + + default: + assert(false && "Wrong expression for return type string"); // unreachable + return xpath_string(); } } @@ -10654,16 +10904,16 @@ PUGI__NS_BEGIN xpath_stack swapped_stack = {stack.temp, stack.result}; - xpath_node_set_raw ls = _left->eval_node_set(c, swapped_stack, eval); - xpath_node_set_raw rs = _right->eval_node_set(c, stack, eval); + xpath_node_set_raw ls = _left->eval_node_set(c, stack, eval); + xpath_node_set_raw rs = _right->eval_node_set(c, swapped_stack, eval); // we can optimize merging two sorted sets, but this is a very rare operation, so don't bother - rs.set_type(xpath_node_set::type_unsorted); + ls.set_type(xpath_node_set::type_unsorted); - rs.append(ls.begin(), ls.end(), stack.result); - rs.remove_duplicates(); + ls.append(rs.begin(), rs.end(), stack.result); + ls.remove_duplicates(stack.temp); - return rs; + return ls; } case ast_filter: @@ -10728,7 +10978,7 @@ PUGI__NS_BEGIN return step_do(c, stack, eval, axis_to_type()); default: - assert(false && "Unknown axis"); + assert(false && "Unknown axis"); // unreachable return xpath_node_set_raw(); } } @@ -10763,13 +11013,17 @@ PUGI__NS_BEGIN return ns; } - // fallthrough to type conversion + // variable needs to be converted to the correct type, this is handled by the fallthrough block below + break; } default: - assert(false && "Wrong expression for return type node set"); - return xpath_node_set_raw(); + ; } + + // none of the ast types that return the value directly matched, but conversions to node set are invalid + assert(false && "Wrong expression for return type node set"); // unreachable + return xpath_node_set_raw(); } void optimize(xpath_allocator* alloc) @@ -10783,6 +11037,7 @@ PUGI__NS_BEGIN if (_next) _next->optimize(alloc); + // coverity[var_deref_model] optimize_self(alloc); } @@ -10791,13 +11046,14 @@ PUGI__NS_BEGIN // Rewrite [position()=expr] with [expr] // Note that this step has to go before classification to recognize [position()=1] if ((_type == ast_filter || _type == ast_predicate) && + _right && // workaround for clang static analyzer (_right is never null for ast_filter/ast_predicate) _right->_type == ast_op_equal && _right->_left->_type == ast_func_position && _right->_right->_rettype == xpath_type_number) { _right = _right->_right; } // Classify filter/predicate ops to perform various optimizations during evaluation - if (_type == ast_filter || _type == ast_predicate) + if ((_type == ast_filter || _type == ast_predicate) && _right) // workaround for clang static analyzer (_right is never null for ast_filter/ast_predicate) { assert(_test == predicate_default); @@ -10813,8 +11069,8 @@ PUGI__NS_BEGIN // The former is a full form of //foo, the latter is much faster since it executes the node test immediately // Do a similar kind of rewrite for self/descendant/descendant-or-self axes // Note that we only rewrite positionally invariant steps (//foo[1] != /descendant::foo[1]) - if (_type == ast_step && (_axis == axis_child || _axis == axis_self || _axis == axis_descendant || _axis == axis_descendant_or_self) && _left && - _left->_type == ast_step && _left->_axis == axis_descendant_or_self && _left->_test == nodetest_type_node && !_left->_right && + if (_type == ast_step && (_axis == axis_child || _axis == axis_self || _axis == axis_descendant || _axis == axis_descendant_or_self) && + _left && _left->_type == ast_step && _left->_axis == axis_descendant_or_self && _left->_test == nodetest_type_node && !_left->_right && is_posinv_step()) { if (_axis == axis_child || _axis == axis_descendant) @@ -10826,7 +11082,9 @@ PUGI__NS_BEGIN } // Use optimized lookup table implementation for translate() with constant arguments - if (_type == ast_func_translate && _right->_type == ast_string_constant && _right->_next->_type == ast_string_constant) + if (_type == ast_func_translate && + _right && // workaround for clang static analyzer (_right is never null for ast_func_translate) + _right->_type == ast_string_constant && _right->_next->_type == ast_string_constant) { unsigned char* table = translate_table_generate(alloc, _right->_data.string, _right->_next->_data.string); @@ -10839,6 +11097,8 @@ PUGI__NS_BEGIN // Use optimized path for @attr = 'value' or @attr = $value if (_type == ast_op_equal && + _left && _right && // workaround for clang static analyzer and Coverity (_left and _right are never null for ast_op_equal) + // coverity[mixed_enums] _left->_type == ast_step && _left->_axis == axis_attribute && _left->_test == nodetest_name && !_left->_left && !_left->_right && (_right->_type == ast_string_constant || (_right->_type == ast_variable && _right->_rettype == xpath_type_string))) { @@ -10898,6 +11158,14 @@ PUGI__NS_BEGIN } }; + static const size_t xpath_ast_depth_limit = + #ifdef PUGIXML_XPATH_DEPTH_LIMIT + PUGIXML_XPATH_DEPTH_LIMIT + #else + 1024 + #endif + ; + struct xpath_parser { xpath_allocator* _alloc; @@ -10910,66 +11178,84 @@ PUGI__NS_BEGIN char_t _scratch[32]; - #ifdef PUGIXML_NO_EXCEPTIONS - jmp_buf _error_handler; - #endif + size_t _depth; - void throw_error(const char* message) + xpath_ast_node* error(const char* message) { _result->error = message; _result->offset = _lexer.current_pos() - _query; - #ifdef PUGIXML_NO_EXCEPTIONS - longjmp(_error_handler, 1); - #else - throw xpath_exception(*_result); - #endif + return 0; } - void throw_error_oom() + xpath_ast_node* error_oom() { - #ifdef PUGIXML_NO_EXCEPTIONS - throw_error("Out of memory"); - #else - throw std::bad_alloc(); - #endif + assert(_alloc->_error); + *_alloc->_error = true; + + return 0; + } + + xpath_ast_node* error_rec() + { + return error("Exceeded maximum allowed query depth"); } void* alloc_node() { - void* result = _alloc->allocate_nothrow(sizeof(xpath_ast_node)); + return _alloc->allocate(sizeof(xpath_ast_node)); + } - if (!result) throw_error_oom(); + xpath_ast_node* alloc_node(ast_type_t type, xpath_value_type rettype, const char_t* value) + { + void* memory = alloc_node(); + return memory ? new (memory) xpath_ast_node(type, rettype, value) : 0; + } - return result; + xpath_ast_node* alloc_node(ast_type_t type, xpath_value_type rettype, double value) + { + void* memory = alloc_node(); + return memory ? new (memory) xpath_ast_node(type, rettype, value) : 0; } - const char_t* alloc_string(const xpath_lexer_string& value) + xpath_ast_node* alloc_node(ast_type_t type, xpath_value_type rettype, xpath_variable* value) { - if (value.begin) - { - size_t length = static_cast(value.end - value.begin); + void* memory = alloc_node(); + return memory ? new (memory) xpath_ast_node(type, rettype, value) : 0; + } - char_t* c = static_cast(_alloc->allocate_nothrow((length + 1) * sizeof(char_t))); - if (!c) throw_error_oom(); - assert(c); // workaround for clang static analysis + xpath_ast_node* alloc_node(ast_type_t type, xpath_value_type rettype, xpath_ast_node* left = 0, xpath_ast_node* right = 0) + { + void* memory = alloc_node(); + return memory ? new (memory) xpath_ast_node(type, rettype, left, right) : 0; + } - memcpy(c, value.begin, length * sizeof(char_t)); - c[length] = 0; + xpath_ast_node* alloc_node(ast_type_t type, xpath_ast_node* left, axis_t axis, nodetest_t test, const char_t* contents) + { + void* memory = alloc_node(); + return memory ? new (memory) xpath_ast_node(type, left, axis, test, contents) : 0; + } - return c; - } - else return 0; + xpath_ast_node* alloc_node(ast_type_t type, xpath_ast_node* left, xpath_ast_node* right, predicate_t test) + { + void* memory = alloc_node(); + return memory ? new (memory) xpath_ast_node(type, left, right, test) : 0; } - xpath_ast_node* parse_function_helper(ast_type_t type0, ast_type_t type1, size_t argc, xpath_ast_node* args[2]) + const char_t* alloc_string(const xpath_lexer_string& value) { - assert(argc <= 1); + if (!value.begin) + return PUGIXML_TEXT(""); + + size_t length = static_cast(value.end - value.begin); - if (argc == 1 && args[0]->rettype() != xpath_type_node_set) - throw_error("Function has to be applied to node set"); + char_t* c = static_cast(_alloc->allocate((length + 1) * sizeof(char_t))); + if (!c) return 0; - return new (alloc_node()) xpath_ast_node(argc == 0 ? type0 : type1, xpath_type_string, args[0]); + memcpy(c, value.begin, length * sizeof(char_t)); + c[length] = 0; + + return c; } xpath_ast_node* parse_function(const xpath_lexer_string& name, size_t argc, xpath_ast_node* args[2]) @@ -10978,103 +11264,110 @@ PUGI__NS_BEGIN { case 'b': if (name == PUGIXML_TEXT("boolean") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_boolean, xpath_type_boolean, args[0]); + return alloc_node(ast_func_boolean, xpath_type_boolean, args[0]); break; case 'c': if (name == PUGIXML_TEXT("count") && argc == 1) { - if (args[0]->rettype() != xpath_type_node_set) - throw_error("Function has to be applied to node set"); - - return new (alloc_node()) xpath_ast_node(ast_func_count, xpath_type_number, args[0]); + if (args[0]->rettype() != xpath_type_node_set) return error("Function has to be applied to node set"); + return alloc_node(ast_func_count, xpath_type_number, args[0]); } else if (name == PUGIXML_TEXT("contains") && argc == 2) - return new (alloc_node()) xpath_ast_node(ast_func_contains, xpath_type_boolean, args[0], args[1]); + return alloc_node(ast_func_contains, xpath_type_boolean, args[0], args[1]); else if (name == PUGIXML_TEXT("concat") && argc >= 2) - return new (alloc_node()) xpath_ast_node(ast_func_concat, xpath_type_string, args[0], args[1]); + return alloc_node(ast_func_concat, xpath_type_string, args[0], args[1]); else if (name == PUGIXML_TEXT("ceiling") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_ceiling, xpath_type_number, args[0]); + return alloc_node(ast_func_ceiling, xpath_type_number, args[0]); break; case 'f': if (name == PUGIXML_TEXT("false") && argc == 0) - return new (alloc_node()) xpath_ast_node(ast_func_false, xpath_type_boolean); + return alloc_node(ast_func_false, xpath_type_boolean); else if (name == PUGIXML_TEXT("floor") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_floor, xpath_type_number, args[0]); + return alloc_node(ast_func_floor, xpath_type_number, args[0]); break; case 'i': if (name == PUGIXML_TEXT("id") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_id, xpath_type_node_set, args[0]); + return alloc_node(ast_func_id, xpath_type_node_set, args[0]); break; case 'l': if (name == PUGIXML_TEXT("last") && argc == 0) - return new (alloc_node()) xpath_ast_node(ast_func_last, xpath_type_number); + return alloc_node(ast_func_last, xpath_type_number); else if (name == PUGIXML_TEXT("lang") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_lang, xpath_type_boolean, args[0]); + return alloc_node(ast_func_lang, xpath_type_boolean, args[0]); else if (name == PUGIXML_TEXT("local-name") && argc <= 1) - return parse_function_helper(ast_func_local_name_0, ast_func_local_name_1, argc, args); + { + if (argc == 1 && args[0]->rettype() != xpath_type_node_set) return error("Function has to be applied to node set"); + return alloc_node(argc == 0 ? ast_func_local_name_0 : ast_func_local_name_1, xpath_type_string, args[0]); + } break; case 'n': if (name == PUGIXML_TEXT("name") && argc <= 1) - return parse_function_helper(ast_func_name_0, ast_func_name_1, argc, args); + { + if (argc == 1 && args[0]->rettype() != xpath_type_node_set) return error("Function has to be applied to node set"); + return alloc_node(argc == 0 ? ast_func_name_0 : ast_func_name_1, xpath_type_string, args[0]); + } else if (name == PUGIXML_TEXT("namespace-uri") && argc <= 1) - return parse_function_helper(ast_func_namespace_uri_0, ast_func_namespace_uri_1, argc, args); + { + if (argc == 1 && args[0]->rettype() != xpath_type_node_set) return error("Function has to be applied to node set"); + return alloc_node(argc == 0 ? ast_func_namespace_uri_0 : ast_func_namespace_uri_1, xpath_type_string, args[0]); + } else if (name == PUGIXML_TEXT("normalize-space") && argc <= 1) - return new (alloc_node()) xpath_ast_node(argc == 0 ? ast_func_normalize_space_0 : ast_func_normalize_space_1, xpath_type_string, args[0], args[1]); + return alloc_node(argc == 0 ? ast_func_normalize_space_0 : ast_func_normalize_space_1, xpath_type_string, args[0], args[1]); else if (name == PUGIXML_TEXT("not") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_not, xpath_type_boolean, args[0]); + return alloc_node(ast_func_not, xpath_type_boolean, args[0]); else if (name == PUGIXML_TEXT("number") && argc <= 1) - return new (alloc_node()) xpath_ast_node(argc == 0 ? ast_func_number_0 : ast_func_number_1, xpath_type_number, args[0]); + return alloc_node(argc == 0 ? ast_func_number_0 : ast_func_number_1, xpath_type_number, args[0]); break; case 'p': if (name == PUGIXML_TEXT("position") && argc == 0) - return new (alloc_node()) xpath_ast_node(ast_func_position, xpath_type_number); + return alloc_node(ast_func_position, xpath_type_number); break; case 'r': if (name == PUGIXML_TEXT("round") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_round, xpath_type_number, args[0]); + return alloc_node(ast_func_round, xpath_type_number, args[0]); break; case 's': if (name == PUGIXML_TEXT("string") && argc <= 1) - return new (alloc_node()) xpath_ast_node(argc == 0 ? ast_func_string_0 : ast_func_string_1, xpath_type_string, args[0]); + return alloc_node(argc == 0 ? ast_func_string_0 : ast_func_string_1, xpath_type_string, args[0]); else if (name == PUGIXML_TEXT("string-length") && argc <= 1) - return new (alloc_node()) xpath_ast_node(argc == 0 ? ast_func_string_length_0 : ast_func_string_length_1, xpath_type_number, args[0]); + return alloc_node(argc == 0 ? ast_func_string_length_0 : ast_func_string_length_1, xpath_type_number, args[0]); else if (name == PUGIXML_TEXT("starts-with") && argc == 2) - return new (alloc_node()) xpath_ast_node(ast_func_starts_with, xpath_type_boolean, args[0], args[1]); + return alloc_node(ast_func_starts_with, xpath_type_boolean, args[0], args[1]); else if (name == PUGIXML_TEXT("substring-before") && argc == 2) - return new (alloc_node()) xpath_ast_node(ast_func_substring_before, xpath_type_string, args[0], args[1]); + return alloc_node(ast_func_substring_before, xpath_type_string, args[0], args[1]); else if (name == PUGIXML_TEXT("substring-after") && argc == 2) - return new (alloc_node()) xpath_ast_node(ast_func_substring_after, xpath_type_string, args[0], args[1]); + return alloc_node(ast_func_substring_after, xpath_type_string, args[0], args[1]); else if (name == PUGIXML_TEXT("substring") && (argc == 2 || argc == 3)) - return new (alloc_node()) xpath_ast_node(argc == 2 ? ast_func_substring_2 : ast_func_substring_3, xpath_type_string, args[0], args[1]); + return alloc_node(argc == 2 ? ast_func_substring_2 : ast_func_substring_3, xpath_type_string, args[0], args[1]); else if (name == PUGIXML_TEXT("sum") && argc == 1) { - if (args[0]->rettype() != xpath_type_node_set) throw_error("Function has to be applied to node set"); - return new (alloc_node()) xpath_ast_node(ast_func_sum, xpath_type_number, args[0]); + if (args[0]->rettype() != xpath_type_node_set) return error("Function has to be applied to node set"); + return alloc_node(ast_func_sum, xpath_type_number, args[0]); } break; case 't': if (name == PUGIXML_TEXT("translate") && argc == 3) - return new (alloc_node()) xpath_ast_node(ast_func_translate, xpath_type_string, args[0], args[1]); + return alloc_node(ast_func_translate, xpath_type_string, args[0], args[1]); else if (name == PUGIXML_TEXT("true") && argc == 0) - return new (alloc_node()) xpath_ast_node(ast_func_true, xpath_type_boolean); + return alloc_node(ast_func_true, xpath_type_boolean); break; @@ -11082,9 +11375,7 @@ PUGI__NS_BEGIN break; } - throw_error("Unrecognized function or wrong parameter count"); - - return 0; + return error("Unrecognized function or wrong parameter count"); } axis_t parse_axis_name(const xpath_lexer_string& name, bool& specified) @@ -11200,18 +11491,18 @@ PUGI__NS_BEGIN xpath_lexer_string name = _lexer.contents(); if (!_variables) - throw_error("Unknown variable: variable set is not provided"); + return error("Unknown variable: variable set is not provided"); xpath_variable* var = 0; if (!get_variable_scratch(_scratch, _variables, name.begin, name.end, &var)) - throw_error_oom(); + return error_oom(); if (!var) - throw_error("Unknown variable: variable set does not contain the given name"); + return error("Unknown variable: variable set does not contain the given name"); _lexer.next(); - return new (alloc_node()) xpath_ast_node(ast_variable, var->type(), var); + return alloc_node(ast_variable, var->type(), var); } case lex_open_brace: @@ -11219,9 +11510,10 @@ PUGI__NS_BEGIN _lexer.next(); xpath_ast_node* n = parse_expression(); + if (!n) return 0; if (_lexer.current() != lex_close_brace) - throw_error("Unmatched braces"); + return error("Expected ')' to match an opening '('"); _lexer.next(); @@ -11231,11 +11523,11 @@ PUGI__NS_BEGIN case lex_quoted_string: { const char_t* value = alloc_string(_lexer.contents()); + if (!value) return 0; - xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_string_constant, xpath_type_string, value); _lexer.next(); - return n; + return alloc_node(ast_string_constant, xpath_type_string, value); } case lex_number: @@ -11243,12 +11535,11 @@ PUGI__NS_BEGIN double value = 0; if (!convert_string_to_number_scratch(_scratch, _lexer.contents().begin, _lexer.contents().end, &value)) - throw_error_oom(); + return error_oom(); - xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_number_constant, xpath_type_number, value); _lexer.next(); - return n; + return alloc_node(ast_number_constant, xpath_type_number, value); } case lex_string: @@ -11262,19 +11553,25 @@ PUGI__NS_BEGIN xpath_ast_node* last_arg = 0; if (_lexer.current() != lex_open_brace) - throw_error("Unrecognized function call"); + return error("Unrecognized function call"); _lexer.next(); - if (_lexer.current() != lex_close_brace) - args[argc++] = parse_expression(); + size_t old_depth = _depth; while (_lexer.current() != lex_close_brace) { - if (_lexer.current() != lex_comma) - throw_error("No comma between function arguments"); - _lexer.next(); + if (argc > 0) + { + if (_lexer.current() != lex_comma) + return error("No comma between function arguments"); + _lexer.next(); + } + + if (++_depth > xpath_ast_depth_limit) + return error_rec(); xpath_ast_node* n = parse_expression(); + if (!n) return 0; if (argc < 2) args[argc] = n; else last_arg->set_next(n); @@ -11285,13 +11582,13 @@ PUGI__NS_BEGIN _lexer.next(); + _depth = old_depth; + return parse_function(function, argc, args); } default: - throw_error("Unrecognizable primary expression"); - - return 0; + return error("Unrecognizable primary expression"); } } @@ -11301,24 +11598,34 @@ PUGI__NS_BEGIN xpath_ast_node* parse_filter_expression() { xpath_ast_node* n = parse_primary_expression(); + if (!n) return 0; + + size_t old_depth = _depth; while (_lexer.current() == lex_open_square_brace) { _lexer.next(); - xpath_ast_node* expr = parse_expression(); + if (++_depth > xpath_ast_depth_limit) + return error_rec(); if (n->rettype() != xpath_type_node_set) - throw_error("Predicate has to be applied to node set"); + return error("Predicate has to be applied to node set"); - n = new (alloc_node()) xpath_ast_node(ast_filter, n, expr, predicate_default); + xpath_ast_node* expr = parse_expression(); + if (!expr) return 0; + + n = alloc_node(ast_filter, n, expr, predicate_default); + if (!n) return 0; if (_lexer.current() != lex_close_square_brace) - throw_error("Unmatched square brace"); + return error("Expected ']' to match an opening '['"); _lexer.next(); } + _depth = old_depth; + return n; } @@ -11330,7 +11637,7 @@ PUGI__NS_BEGIN xpath_ast_node* parse_step(xpath_ast_node* set) { if (set && set->rettype() != xpath_type_node_set) - throw_error("Step has to be applied to node set"); + return error("Step has to be applied to node set"); bool axis_specified = false; axis_t axis = axis_child; // implied child axis @@ -11346,13 +11653,19 @@ PUGI__NS_BEGIN { _lexer.next(); - return new (alloc_node()) xpath_ast_node(ast_step, set, axis_self, nodetest_type_node, 0); + if (_lexer.current() == lex_open_square_brace) + return error("Predicates are not allowed after an abbreviated step"); + + return alloc_node(ast_step, set, axis_self, nodetest_type_node, 0); } else if (_lexer.current() == lex_double_dot) { _lexer.next(); - return new (alloc_node()) xpath_ast_node(ast_step, set, axis_parent, nodetest_type_node, 0); + if (_lexer.current() == lex_open_square_brace) + return error("Predicates are not allowed after an abbreviated step"); + + return alloc_node(ast_step, set, axis_parent, nodetest_type_node, 0); } nodetest_t nt_type = nodetest_none; @@ -11369,12 +11682,12 @@ PUGI__NS_BEGIN { // parse axis name if (axis_specified) - throw_error("Two axis specifiers in one step"); + return error("Two axis specifiers in one step"); axis = parse_axis_name(nt_name, axis_specified); if (!axis_specified) - throw_error("Unknown axis"); + return error("Unknown axis"); // read actual node test _lexer.next(); @@ -11390,7 +11703,10 @@ PUGI__NS_BEGIN nt_name = _lexer.contents(); _lexer.next(); } - else throw_error("Unrecognized node test"); + else + { + return error("Unrecognized node test"); + } } if (nt_type == nodetest_none) @@ -11407,26 +11723,26 @@ PUGI__NS_BEGIN nt_type = parse_node_test_type(nt_name); if (nt_type == nodetest_none) - throw_error("Unrecognized node type"); + return error("Unrecognized node type"); nt_name = xpath_lexer_string(); } else if (nt_name == PUGIXML_TEXT("processing-instruction")) { if (_lexer.current() != lex_quoted_string) - throw_error("Only literals are allowed as arguments to processing-instruction()"); + return error("Only literals are allowed as arguments to processing-instruction()"); nt_type = nodetest_pi; nt_name = _lexer.contents(); _lexer.next(); if (_lexer.current() != lex_close_brace) - throw_error("Unmatched brace near processing-instruction()"); + return error("Unmatched brace near processing-instruction()"); _lexer.next(); } else { - throw_error("Unmatched brace near node type test"); + return error("Unmatched brace near node type test"); } } // QName or NCName:* @@ -11452,11 +11768,16 @@ PUGI__NS_BEGIN } else { - throw_error("Unrecognized node test"); + return error("Unrecognized node test"); } const char_t* nt_name_copy = alloc_string(nt_name); - xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_step, set, axis, nt_type, nt_name_copy); + if (!nt_name_copy) return 0; + + xpath_ast_node* n = alloc_node(ast_step, set, axis, nt_type, nt_name_copy); + if (!n) return 0; + + size_t old_depth = _depth; xpath_ast_node* last = 0; @@ -11464,12 +11785,17 @@ PUGI__NS_BEGIN { _lexer.next(); + if (++_depth > xpath_ast_depth_limit) + return error_rec(); + xpath_ast_node* expr = parse_expression(); + if (!expr) return 0; - xpath_ast_node* pred = new (alloc_node()) xpath_ast_node(ast_predicate, 0, expr, predicate_default); + xpath_ast_node* pred = alloc_node(ast_predicate, 0, expr, predicate_default); + if (!pred) return 0; if (_lexer.current() != lex_close_square_brace) - throw_error("Unmatched square brace"); + return error("Expected ']' to match an opening '['"); _lexer.next(); if (last) last->set_next(pred); @@ -11478,6 +11804,8 @@ PUGI__NS_BEGIN last = pred; } + _depth = old_depth; + return n; } @@ -11485,18 +11813,30 @@ PUGI__NS_BEGIN xpath_ast_node* parse_relative_location_path(xpath_ast_node* set) { xpath_ast_node* n = parse_step(set); + if (!n) return 0; + + size_t old_depth = _depth; while (_lexer.current() == lex_slash || _lexer.current() == lex_double_slash) { lexeme_t l = _lexer.current(); _lexer.next(); + if (++_depth > xpath_ast_depth_limit) + return error_rec(); + if (l == lex_double_slash) - n = new (alloc_node()) xpath_ast_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); + { + n = alloc_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); + if (!n) return 0; + } n = parse_step(n); + if (!n) return 0; } + _depth = old_depth; + return n; } @@ -11508,7 +11848,8 @@ PUGI__NS_BEGIN { _lexer.next(); - xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_step_root, xpath_type_node_set); + xpath_ast_node* n = alloc_node(ast_step_root, xpath_type_node_set); + if (!n) return 0; // relative location path can start from axis_attribute, dot, double_dot, multiply and string lexemes; any other lexeme means standalone root path lexeme_t l = _lexer.current(); @@ -11522,8 +11863,11 @@ PUGI__NS_BEGIN { _lexer.next(); - xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_step_root, xpath_type_node_set); - n = new (alloc_node()) xpath_ast_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); + xpath_ast_node* n = alloc_node(ast_step_root, xpath_type_node_set); + if (!n) return 0; + + n = alloc_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); + if (!n) return 0; return parse_relative_location_path(n); } @@ -11546,7 +11890,6 @@ PUGI__NS_BEGIN // PrimaryExpr begins with '$' in case of it being a variable reference, // '(' in case of it being an expression, string literal, number constant or // function call. - if (_lexer.current() == lex_var_ref || _lexer.current() == lex_open_brace || _lexer.current() == lex_quoted_string || _lexer.current() == lex_number || _lexer.current() == lex_string) @@ -11558,7 +11901,8 @@ PUGI__NS_BEGIN while (PUGI__IS_CHARTYPE(*state, ct_space)) ++state; - if (*state != '(') return parse_location_path(); + if (*state != '(') + return parse_location_path(); // This looks like a function call; however this still can be a node-test. Check it. if (parse_node_test_type(_lexer.contents()) != nodetest_none) @@ -11566,6 +11910,7 @@ PUGI__NS_BEGIN } xpath_ast_node* n = parse_filter_expression(); + if (!n) return 0; if (_lexer.current() == lex_slash || _lexer.current() == lex_double_slash) { @@ -11575,9 +11920,10 @@ PUGI__NS_BEGIN if (l == lex_double_slash) { if (n->rettype() != xpath_type_node_set) - throw_error("Step has to be applied to node set"); + return error("Step has to be applied to node set"); - n = new (alloc_node()) xpath_ast_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); + n = alloc_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); + if (!n) return 0; } // select from location path @@ -11591,9 +11937,10 @@ PUGI__NS_BEGIN _lexer.next(); // precedence 7+ - only parses union expressions - xpath_ast_node* expr = parse_expression_rec(parse_path_or_unary_expression(), 7); + xpath_ast_node* n = parse_expression(7); + if (!n) return 0; - return new (alloc_node()) xpath_ast_node(ast_op_negate, xpath_type_number, expr); + return alloc_node(ast_op_negate, xpath_type_number, n); } else { @@ -11675,21 +12022,27 @@ PUGI__NS_BEGIN { _lexer.next(); + if (++_depth > xpath_ast_depth_limit) + return error_rec(); + xpath_ast_node* rhs = parse_path_or_unary_expression(); + if (!rhs) return 0; binary_op_t nextop = binary_op_t::parse(_lexer); while (nextop.asttype != ast_unknown && nextop.precedence > op.precedence) { rhs = parse_expression_rec(rhs, nextop.precedence); + if (!rhs) return 0; nextop = binary_op_t::parse(_lexer); } if (op.asttype == ast_op_union && (lhs->rettype() != xpath_type_node_set || rhs->rettype() != xpath_type_node_set)) - throw_error("Union operator has to be applied to node sets"); + return error("Union operator has to be applied to node sets"); - lhs = new (alloc_node()) xpath_ast_node(op.asttype, op.rettype, lhs, rhs); + lhs = alloc_node(op.asttype, op.rettype, lhs, rhs); + if (!lhs) return 0; op = binary_op_t::parse(_lexer); } @@ -11715,37 +12068,46 @@ PUGI__NS_BEGIN // | MultiplicativeExpr '*' UnaryExpr // | MultiplicativeExpr 'div' UnaryExpr // | MultiplicativeExpr 'mod' UnaryExpr - xpath_ast_node* parse_expression() + xpath_ast_node* parse_expression(int limit = 0) { - return parse_expression_rec(parse_path_or_unary_expression(), 0); + size_t old_depth = _depth; + + if (++_depth > xpath_ast_depth_limit) + return error_rec(); + + xpath_ast_node* n = parse_path_or_unary_expression(); + if (!n) return 0; + + n = parse_expression_rec(n, limit); + + _depth = old_depth; + + return n; } - xpath_parser(const char_t* query, xpath_variable_set* variables, xpath_allocator* alloc, xpath_parse_result* result): _alloc(alloc), _lexer(query), _query(query), _variables(variables), _result(result) + xpath_parser(const char_t* query, xpath_variable_set* variables, xpath_allocator* alloc, xpath_parse_result* result): _alloc(alloc), _lexer(query), _query(query), _variables(variables), _result(result), _depth(0) { } xpath_ast_node* parse() { - xpath_ast_node* result = parse_expression(); + xpath_ast_node* n = parse_expression(); + if (!n) return 0; + + assert(_depth == 0); // check if there are unparsed tokens left if (_lexer.current() != lex_eof) - throw_error("Incorrect query"); + return error("Incorrect query"); - return result; + return n; } static xpath_ast_node* parse(const char_t* query, xpath_variable_set* variables, xpath_allocator* alloc, xpath_parse_result* result) { xpath_parser parser(query, variables, alloc, result); - #ifdef PUGIXML_NO_EXCEPTIONS - int error = setjmp(parser._error_handler); - - return (error == 0) ? parser.parse() : 0; - #else return parser.parse(); - #endif } }; @@ -11768,7 +12130,7 @@ PUGI__NS_BEGIN xml_memory::deallocate(impl); } - xpath_query_impl(): root(0), alloc(&block) + xpath_query_impl(): root(0), alloc(&block, &oom), oom(false) { block.next = 0; block.capacity = sizeof(block.data); @@ -11777,21 +12139,9 @@ PUGI__NS_BEGIN xpath_ast_node* root; xpath_allocator alloc; xpath_memory_block block; + bool oom; }; - PUGI__FN xpath_string evaluate_string_impl(xpath_query_impl* impl, const xpath_node& n, xpath_stack_data& sd) - { - if (!impl) return xpath_string(); - - #ifdef PUGIXML_NO_EXCEPTIONS - if (setjmp(sd.error_handler)) return xpath_string(); - #endif - - xpath_context c(n, 1, 1); - - return impl->root->eval_string(c, sd.stack); - } - PUGI__FN impl::xpath_ast_node* evaluate_node_set_prepare(xpath_query_impl* impl) { if (!impl) return 0; @@ -11900,74 +12250,61 @@ namespace pugi size_t size_ = static_cast(end_ - begin_); - if (size_ <= 1) - { - // deallocate old buffer - if (_begin != &_storage) impl::xml_memory::deallocate(_begin); - - // use internal buffer - if (begin_ != end_) _storage = *begin_; + // use internal buffer for 0 or 1 elements, heap buffer otherwise + xpath_node* storage = (size_ <= 1) ? _storage : static_cast(impl::xml_memory::allocate(size_ * sizeof(xpath_node))); - _begin = &_storage; - _end = &_storage + size_; - _type = type_; - } - else + if (!storage) { - // make heap copy - xpath_node* storage = static_cast(impl::xml_memory::allocate(size_ * sizeof(xpath_node))); + #ifdef PUGIXML_NO_EXCEPTIONS + return; + #else + throw std::bad_alloc(); + #endif + } - if (!storage) - { - #ifdef PUGIXML_NO_EXCEPTIONS - return; - #else - throw std::bad_alloc(); - #endif - } + // deallocate old buffer + if (_begin != _storage) + impl::xml_memory::deallocate(_begin); + // size check is necessary because for begin_ = end_ = nullptr, memcpy is UB + if (size_) memcpy(storage, begin_, size_ * sizeof(xpath_node)); - // deallocate old buffer - if (_begin != &_storage) impl::xml_memory::deallocate(_begin); - - // finalize - _begin = storage; - _end = storage + size_; - _type = type_; - } + _begin = storage; + _end = storage + size_; + _type = type_; } #ifdef PUGIXML_HAS_MOVE - PUGI__FN void xpath_node_set::_move(xpath_node_set& rhs) + PUGI__FN void xpath_node_set::_move(xpath_node_set& rhs) PUGIXML_NOEXCEPT { _type = rhs._type; - _storage = rhs._storage; - _begin = (rhs._begin == &rhs._storage) ? &_storage : rhs._begin; + _storage[0] = rhs._storage[0]; + _begin = (rhs._begin == rhs._storage) ? _storage : rhs._begin; _end = _begin + (rhs._end - rhs._begin); rhs._type = type_unsorted; - rhs._begin = &rhs._storage; - rhs._end = rhs._begin; + rhs._begin = rhs._storage; + rhs._end = rhs._storage; } #endif - PUGI__FN xpath_node_set::xpath_node_set(): _type(type_unsorted), _begin(&_storage), _end(&_storage) + PUGI__FN xpath_node_set::xpath_node_set(): _type(type_unsorted), _begin(_storage), _end(_storage) { } - PUGI__FN xpath_node_set::xpath_node_set(const_iterator begin_, const_iterator end_, type_t type_): _type(type_unsorted), _begin(&_storage), _end(&_storage) + PUGI__FN xpath_node_set::xpath_node_set(const_iterator begin_, const_iterator end_, type_t type_): _type(type_unsorted), _begin(_storage), _end(_storage) { _assign(begin_, end_, type_); } PUGI__FN xpath_node_set::~xpath_node_set() { - if (_begin != &_storage) + if (_begin != _storage) impl::xml_memory::deallocate(_begin); } - PUGI__FN xpath_node_set::xpath_node_set(const xpath_node_set& ns): _type(type_unsorted), _begin(&_storage), _end(&_storage) + PUGI__FN xpath_node_set::xpath_node_set(const xpath_node_set& ns): _type(type_unsorted), _begin(_storage), _end(_storage) { _assign(ns._begin, ns._end, ns._type); } @@ -11982,16 +12319,16 @@ namespace pugi } #ifdef PUGIXML_HAS_MOVE - PUGI__FN xpath_node_set::xpath_node_set(xpath_node_set&& rhs): _type(type_unsorted), _begin(&_storage), _end(&_storage) + PUGI__FN xpath_node_set::xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT: _type(type_unsorted), _begin(_storage), _end(_storage) { _move(rhs); } - PUGI__FN xpath_node_set& xpath_node_set::operator=(xpath_node_set&& rhs) + PUGI__FN xpath_node_set& xpath_node_set::operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT { if (this == &rhs) return *this; - if (_begin != &_storage) + if (_begin != _storage) impl::xml_memory::deallocate(_begin); _move(rhs); @@ -12076,7 +12413,7 @@ namespace pugi return static_cast(this)->name; default: - assert(false && "Invalid variable type"); + assert(false && "Invalid variable type"); // unreachable return 0; } } @@ -12182,7 +12519,7 @@ namespace pugi } #ifdef PUGIXML_HAS_MOVE - PUGI__FN xpath_variable_set::xpath_variable_set(xpath_variable_set&& rhs) + PUGI__FN xpath_variable_set::xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT { for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) { @@ -12191,7 +12528,7 @@ namespace pugi } } - PUGI__FN xpath_variable_set& xpath_variable_set::operator=(xpath_variable_set&& rhs) + PUGI__FN xpath_variable_set& xpath_variable_set::operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT { for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) { @@ -12362,6 +12699,15 @@ namespace pugi _impl = impl.release(); _result.error = 0; } + else + { + #ifdef PUGIXML_NO_EXCEPTIONS + if (qimpl->oom) _result.error = "Out of memory"; + #else + if (qimpl->oom) throw std::bad_alloc(); + throw xpath_exception(_result); + #endif + } } } @@ -12376,7 +12722,7 @@ namespace pugi } #ifdef PUGIXML_HAS_MOVE - PUGI__FN xpath_query::xpath_query(xpath_query&& rhs) + PUGI__FN xpath_query::xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT { _impl = rhs._impl; _result = rhs._result; @@ -12384,7 +12730,7 @@ namespace pugi rhs._result = xpath_parse_result(); } - PUGI__FN xpath_query& xpath_query::operator=(xpath_query&& rhs) + PUGI__FN xpath_query& xpath_query::operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT { if (this == &rhs) return *this; @@ -12414,11 +12760,18 @@ namespace pugi impl::xpath_context c(n, 1, 1); impl::xpath_stack_data sd; - #ifdef PUGIXML_NO_EXCEPTIONS - if (setjmp(sd.error_handler)) return false; - #endif + bool r = static_cast(_impl)->root->eval_boolean(c, sd.stack); - return static_cast(_impl)->root->eval_boolean(c, sd.stack); + if (sd.oom) + { + #ifdef PUGIXML_NO_EXCEPTIONS + return false; + #else + throw std::bad_alloc(); + #endif + } + + return r; } PUGI__FN double xpath_query::evaluate_number(const xpath_node& n) const @@ -12428,19 +12781,38 @@ namespace pugi impl::xpath_context c(n, 1, 1); impl::xpath_stack_data sd; - #ifdef PUGIXML_NO_EXCEPTIONS - if (setjmp(sd.error_handler)) return impl::gen_nan(); - #endif + double r = static_cast(_impl)->root->eval_number(c, sd.stack); + + if (sd.oom) + { + #ifdef PUGIXML_NO_EXCEPTIONS + return impl::gen_nan(); + #else + throw std::bad_alloc(); + #endif + } - return static_cast(_impl)->root->eval_number(c, sd.stack); + return r; } #ifndef PUGIXML_NO_STL PUGI__FN string_t xpath_query::evaluate_string(const xpath_node& n) const { + if (!_impl) return string_t(); + + impl::xpath_context c(n, 1, 1); impl::xpath_stack_data sd; - impl::xpath_string r = impl::evaluate_string_impl(static_cast(_impl), n, sd); + impl::xpath_string r = static_cast(_impl)->root->eval_string(c, sd.stack); + + if (sd.oom) + { + #ifdef PUGIXML_NO_EXCEPTIONS + return string_t(); + #else + throw std::bad_alloc(); + #endif + } return string_t(r.c_str(), r.length()); } @@ -12448,9 +12820,19 @@ namespace pugi PUGI__FN size_t xpath_query::evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const { + impl::xpath_context c(n, 1, 1); impl::xpath_stack_data sd; - impl::xpath_string r = impl::evaluate_string_impl(static_cast(_impl), n, sd); + impl::xpath_string r = _impl ? static_cast(_impl)->root->eval_string(c, sd.stack) : impl::xpath_string(); + + if (sd.oom) + { + #ifdef PUGIXML_NO_EXCEPTIONS + r = impl::xpath_string(); + #else + throw std::bad_alloc(); + #endif + } size_t full_size = r.length() + 1; @@ -12474,12 +12856,17 @@ namespace pugi impl::xpath_context c(n, 1, 1); impl::xpath_stack_data sd; - #ifdef PUGIXML_NO_EXCEPTIONS - if (setjmp(sd.error_handler)) return xpath_node_set(); - #endif - impl::xpath_node_set_raw r = root->eval_node_set(c, sd.stack, impl::nodeset_eval_all); + if (sd.oom) + { + #ifdef PUGIXML_NO_EXCEPTIONS + return xpath_node_set(); + #else + throw std::bad_alloc(); + #endif + } + return xpath_node_set(r.begin(), r.end(), r.type()); } @@ -12491,12 +12878,17 @@ namespace pugi impl::xpath_context c(n, 1, 1); impl::xpath_stack_data sd; - #ifdef PUGIXML_NO_EXCEPTIONS - if (setjmp(sd.error_handler)) return xpath_node(); - #endif - impl::xpath_node_set_raw r = root->eval_node_set(c, sd.stack, impl::nodeset_eval_first); + if (sd.oom) + { + #ifdef PUGIXML_NO_EXCEPTIONS + return xpath_node(); + #else + throw std::bad_alloc(); + #endif + } + return r.first(); } @@ -12522,7 +12914,7 @@ namespace pugi PUGI__FN xpath_node xml_node::select_node(const char_t* query, xpath_variable_set* variables) const { xpath_query q(query, variables); - return select_node(q); + return q.evaluate_node(*this); } PUGI__FN xpath_node xml_node::select_node(const xpath_query& query) const @@ -12533,7 +12925,7 @@ namespace pugi PUGI__FN xpath_node_set xml_node::select_nodes(const char_t* query, xpath_variable_set* variables) const { xpath_query q(query, variables); - return select_nodes(q); + return q.evaluate_node_set(*this); } PUGI__FN xpath_node_set xml_node::select_nodes(const xpath_query& query) const @@ -12544,7 +12936,7 @@ namespace pugi PUGI__FN xpath_node xml_node::select_single_node(const char_t* query, xpath_variable_set* variables) const { xpath_query q(query, variables); - return select_single_node(q); + return q.evaluate_node(*this); } PUGI__FN xpath_node xml_node::select_single_node(const xpath_query& query) const @@ -12565,12 +12957,18 @@ namespace pugi # pragma warning(pop) #endif +#if defined(_MSC_VER) && defined(__c2__) +# pragma clang diagnostic pop +#endif + // Undefine all local macros (makes sure we're not leaking macros in header-only mode) #undef PUGI__NO_INLINE #undef PUGI__UNLIKELY #undef PUGI__STATIC_ASSERT #undef PUGI__DMC_VOLATILE +#undef PUGI__UNSIGNED_OVERFLOW #undef PUGI__MSVC_CRT_VERSION +#undef PUGI__SNPRINTF #undef PUGI__NS_BEGIN #undef PUGI__NS_END #undef PUGI__FN @@ -12597,7 +12995,7 @@ namespace pugi #endif /** - * Copyright (c) 2006-2016 Arseny Kapoulkine + * Copyright (c) 2006-2020 Arseny Kapoulkine * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation From bb61afc3948bb3e3ca86253dffc570cd2f35d74d Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 09:25:01 -0500 Subject: [PATCH 02/48] #94: Updated PaassResources library build --- Resources/CMakeLists.txt | 18 ++++++++++++++++-- Resources/source/CMakeLists.txt | 23 ----------------------- 2 files changed, 16 insertions(+), 25 deletions(-) delete mode 100644 Resources/source/CMakeLists.txt diff --git a/Resources/CMakeLists.txt b/Resources/CMakeLists.txt index 0e564ed39..7b7b6508c 100644 --- a/Resources/CMakeLists.txt +++ b/Resources/CMakeLists.txt @@ -1,3 +1,17 @@ -# @authors S.V. Paulauskas and K. Smith +message(STATUS "Building PaassResource library") +add_library(PaassResources SHARED source/Messenger.cpp source/Notebook.cpp source/RandomInterface.cpp + source/XmlInterface.cpp source/XmlParser.cpp) + +target_include_directories(PaassResources PUBLIC ${PROJECT_SOURCE_DIR}/Resources/include + ${PROJECT_SOURCE_DIR}/ThirdParty/pugixml/include ${ROOT_INCLUDE_DIR}) + +if (ROOT_FOUND) + if(ROOT_HAS_MINUIT2) + add_definitions("-D ROOT_HAS_MINUIT2") + endif(ROOT_HAS_MINUIT2) + target_sources(PaassResources PUBLIC ${PROJECT_SOURCE_DIR}/Resources/source/RootInterface.cpp) +endif (ROOT_FOUND) + +target_link_libraries(PaassResources Pugixml-1.11.1) +install(TARGETS PaassResources DESTINATION lib) -add_subdirectory(source) diff --git a/Resources/source/CMakeLists.txt b/Resources/source/CMakeLists.txt deleted file mode 100644 index ecc4ba024..000000000 --- a/Resources/source/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# @authors S.V. Paulauskas and K. Smith - -#Set the utility sources that we will make a lib out of -set(PaassResourceSources Messenger.cpp Notebook.cpp RandomInterface.cpp XmlInterface.cpp XmlParser.cpp ) - -if (ROOT_FOUND) - if(ROOT_HAS_MINUIT2) - add_definitions("-D ROOT_HAS_MINUIT2") - endif(ROOT_HAS_MINUIT2) - list(APPEND PaassResourceSources RootInterface.cpp) -endif (ROOT_FOUND) - -#Add the sources to the library -add_library(PaassResourceObjects OBJECT ${PaassResourceSources}) -add_library(PaassResourceStatic STATIC $) -target_link_libraries(PaassResourceStatic PugixmlStatic) - -if (BUILD_SHARED_LIBS) - message(STATUS "Building Utility Shared Objects") - add_library(PaassResourceLibrary SHARED $) - target_link_libraries(PaassResourceLibrary Pugixml PaassResourceStatic) - install(TARGETS PaassResourceLibrary DESTINATION lib) -endif (BUILD_SHARED_LIBS) From 9a3c99c89364048a21c0bac8b58cff57008bae08 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 10:16:07 -0500 Subject: [PATCH 03/48] #94: Fixing the builds so that they install the includes Since we're only building SOs we need to make sure that all the headers get installed properly. We'll do this with the PUBLIC_HEADER property for the library. --- Core/CMakeLists.txt | 37 ++++++++++++++++++++++++------- Core/source/CMakeLists.txt | 21 ------------------ Resources/CMakeLists.txt | 10 +++++---- ThirdParty/CMakeLists.txt | 4 +--- ThirdParty/pugixml/CMakeLists.txt | 6 +++++ 5 files changed, 42 insertions(+), 36 deletions(-) create mode 100644 ThirdParty/pugixml/CMakeLists.txt diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index aa8b28198..292aaccb2 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -1,8 +1,29 @@ -#@authors K. Smith -install(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX}) - -add_subdirectory(source) - -if (PAASS_BUILD_TESTS) - add_subdirectory(tests) -endif (PAASS_BUILD_TESTS) +#install(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX}) +# +#set(PaassCoreSources Display.cpp hribf_buffers.cpp poll2_socket.cpp) +# +#if (${CURSES_FOUND}) +# list(APPEND PaassCoreSources CTerminal.cpp) +#endif () +# +#add_library(PaassCoreObjects OBJECT ${PaassCoreSources}) +# +#add_library(PaassCoreStatic STATIC $) +# +#if (${CURSES_FOUND}) +# target_link_libraries(PaassCoreStatic ${CURSES_LIBRARIES}) +#endif () +# +#if (PAASS_BUILD_SHARED_LIBS) +# add_library(PaassCore SHARED $) +# if (${CURSES_FOUND}) +# target_link_libraries(PaassCore ${CURSES_LIBRARIES}) +# endif (${CURSES_FOUND}) +# install(TARGETS PaassCore DESTINATION lib) +#endif (PAASS_BUILD_SHARED_LIBS) +# +#add_subdirectory(source) +# +#if (PAASS_BUILD_TESTS) +# add_subdirectory(tests) +#endif (PAASS_BUILD_TESTS) diff --git a/Core/source/CMakeLists.txt b/Core/source/CMakeLists.txt index c27e31a0a..8c1bababb 100644 --- a/Core/source/CMakeLists.txt +++ b/Core/source/CMakeLists.txt @@ -1,22 +1 @@ #@authors K. Smith -set(PaassCoreSources Display.cpp hribf_buffers.cpp poll2_socket.cpp) - -if (${CURSES_FOUND}) - list(APPEND PaassCoreSources CTerminal.cpp) -endif () - -add_library(PaassCoreObjects OBJECT ${PaassCoreSources}) - -add_library(PaassCoreStatic STATIC $) - -if (${CURSES_FOUND}) - target_link_libraries(PaassCoreStatic ${CURSES_LIBRARIES}) -endif () - -if (PAASS_BUILD_SHARED_LIBS) - add_library(PaassCore SHARED $) - if (${CURSES_FOUND}) - target_link_libraries(PaassCore ${CURSES_LIBRARIES}) - endif (${CURSES_FOUND}) - install(TARGETS PaassCore DESTINATION lib) -endif (PAASS_BUILD_SHARED_LIBS) \ No newline at end of file diff --git a/Resources/CMakeLists.txt b/Resources/CMakeLists.txt index 7b7b6508c..0a5cdc935 100644 --- a/Resources/CMakeLists.txt +++ b/Resources/CMakeLists.txt @@ -2,9 +2,6 @@ message(STATUS "Building PaassResource library") add_library(PaassResources SHARED source/Messenger.cpp source/Notebook.cpp source/RandomInterface.cpp source/XmlInterface.cpp source/XmlParser.cpp) -target_include_directories(PaassResources PUBLIC ${PROJECT_SOURCE_DIR}/Resources/include - ${PROJECT_SOURCE_DIR}/ThirdParty/pugixml/include ${ROOT_INCLUDE_DIR}) - if (ROOT_FOUND) if(ROOT_HAS_MINUIT2) add_definitions("-D ROOT_HAS_MINUIT2") @@ -12,6 +9,11 @@ if (ROOT_FOUND) target_sources(PaassResources PUBLIC ${PROJECT_SOURCE_DIR}/Resources/source/RootInterface.cpp) endif (ROOT_FOUND) +target_include_directories(PaassResources PUBLIC ${PROJECT_SOURCE_DIR}/Resources/include + ${PROJECT_SOURCE_DIR}/ThirdParty/pugixml/include ${ROOT_INCLUDE_DIR}) + target_link_libraries(PaassResources Pugixml-1.11.1) -install(TARGETS PaassResources DESTINATION lib) +file(GLOB PAASS_RESOURCES_PUBLIC_HEADERS include/*.hpp) +set_target_properties(PaassResources PROPERTIES PUBLIC_HEADER "${PAASS_RESOURCES_PUBLIC_HEADERS}") +install(TARGETS PaassResources LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index 0eb591cb0..8929878ff 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -1,3 +1 @@ -add_library(Pugixml-1.11.1 SHARED pugixml/source/pugixml.cpp) -target_include_directories(Pugixml-1.11.1 PUBLIC ${PROJECT_SOURCE_DIR}/ThirdParty/pugixml/include) -install(TARGETS Pugixml-1.11.1 DESTINATION lib) +add_subdirectory(pugixml) \ No newline at end of file diff --git a/ThirdParty/pugixml/CMakeLists.txt b/ThirdParty/pugixml/CMakeLists.txt new file mode 100644 index 000000000..f7fa4765c --- /dev/null +++ b/ThirdParty/pugixml/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(Pugixml-1.11.1 SHARED source/pugixml.cpp) +target_include_directories(Pugixml-1.11.1 PUBLIC ${PROJECT_SOURCE_DIR}/ThirdParty/pugixml/include) + +file(GLOB PUGIXML_PUBLIC_HEADERS include/*.hpp) +set_target_properties(Pugixml-1.11.1 PROPERTIES PUBLIC_HEADER "${PUGIXML_PUBLIC_HEADERS}") +install(TARGETS Pugixml-1.11.1 LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include) From fdad5ff53729f1e415415b34b903ddfdb48d6660 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 11:42:22 -0500 Subject: [PATCH 04/48] #94: Updating Core files so that they build properly --- Core/CMakeLists.txt | 36 ++++--------------- Core/source/CMakeLists.txt | 1 - Core/tests/CMakeLists.txt | 4 --- Tests/functional/CMakeLists.txt | 3 ++ .../functional}/CTerminalTest.cpp | 0 5 files changed, 10 insertions(+), 34 deletions(-) delete mode 100644 Core/source/CMakeLists.txt delete mode 100644 Core/tests/CMakeLists.txt create mode 100644 Tests/functional/CMakeLists.txt rename {Core/tests => Tests/functional}/CTerminalTest.cpp (100%) diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index 292aaccb2..757e2954f 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -1,29 +1,7 @@ -#install(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX}) -# -#set(PaassCoreSources Display.cpp hribf_buffers.cpp poll2_socket.cpp) -# -#if (${CURSES_FOUND}) -# list(APPEND PaassCoreSources CTerminal.cpp) -#endif () -# -#add_library(PaassCoreObjects OBJECT ${PaassCoreSources}) -# -#add_library(PaassCoreStatic STATIC $) -# -#if (${CURSES_FOUND}) -# target_link_libraries(PaassCoreStatic ${CURSES_LIBRARIES}) -#endif () -# -#if (PAASS_BUILD_SHARED_LIBS) -# add_library(PaassCore SHARED $) -# if (${CURSES_FOUND}) -# target_link_libraries(PaassCore ${CURSES_LIBRARIES}) -# endif (${CURSES_FOUND}) -# install(TARGETS PaassCore DESTINATION lib) -#endif (PAASS_BUILD_SHARED_LIBS) -# -#add_subdirectory(source) -# -#if (PAASS_BUILD_TESTS) -# add_subdirectory(tests) -#endif (PAASS_BUILD_TESTS) +add_library(PaassCore SHARED source/CTerminal.cpp source/Display.cpp source/hribf_buffers.cpp source/poll2_socket.cpp) +target_link_libraries(PaassCore ${CURSES_LIBRARIES}) +target_include_directories(PaassCore PUBLIC include) + +file(GLOB PAASS_CORE_PUBLIC_HEADERS include/*.h) +set_target_properties(PaassCore PROPERTIES PUBLIC_HEADER "${PAASS_CORE_PUBLIC_HEADERS}") +install(TARGETS PaassCore LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include) diff --git a/Core/source/CMakeLists.txt b/Core/source/CMakeLists.txt deleted file mode 100644 index 8c1bababb..000000000 --- a/Core/source/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -#@authors K. Smith diff --git a/Core/tests/CMakeLists.txt b/Core/tests/CMakeLists.txt deleted file mode 100644 index 88ccb3312..000000000 --- a/Core/tests/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -#@authors K. Smith -add_executable(CTerminalTest CTerminalTest.cpp) -target_link_libraries(CTerminalTest PaassCoreStatic) -install(TARGETS CTerminalTest DESTINATION bin) diff --git a/Tests/functional/CMakeLists.txt b/Tests/functional/CMakeLists.txt new file mode 100644 index 000000000..12e2782e9 --- /dev/null +++ b/Tests/functional/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(CTerminalTest tests/CTerminalTest.cpp) +target_link_libraries(CTerminalTest PaassCoreStatic) +install(TARGETS CTerminalTest DESTINATION bin) \ No newline at end of file diff --git a/Core/tests/CTerminalTest.cpp b/Tests/functional/CTerminalTest.cpp similarity index 100% rename from Core/tests/CTerminalTest.cpp rename to Tests/functional/CTerminalTest.cpp From 51fb3e1f793cbb8db886f76a181d6c3d4c750462 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 15:21:58 -0500 Subject: [PATCH 05/48] #94: Updating FindPLX.cmake to look for the stock lib names The stock makefile generates PlxApi.a and PlxApi.so without lib on the front. I wanted to move this back to a more stock install, so we modified the variables to support the stock library names. --- Cmake/modules/FindPLX.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cmake/modules/FindPLX.cmake b/Cmake/modules/FindPLX.cmake index 9176a0628..87006c2ae 100644 --- a/Cmake/modules/FindPLX.cmake +++ b/Cmake/modules/FindPLX.cmake @@ -8,17 +8,17 @@ # find_path(PLX_LIBRARY_DIR - NAMES libPlxApi.a - HINTS ENV PLX_SDK_DIR - PATHS /opt/plx/current/PlxSdk + NAMES PlxApi.a PlxApi.so + HINTS $ENV{PLX_SDK_DIR} + PATHS /usr/local/broadcom/current PATH_SUFFIXES PlxApi/Library Linux/PlxApi/Library) -# Support the REQUIRED and QUIET arguments, and set PLX_FOUND if found. include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(PLX DEFAULT_MSG PLX_LIBRARY_DIR) if (PLX_FOUND) - set(PLX_LIBRARIES -lPlxApi -ldl) # CACHE STRING "List of PLX libraries") -endif () + set(PLX_SHARED_LIB -l:PlxApi.so -ldl) + set(PLX_STATIC_LIB -l:PlxApi.a -ldl) +endif (PLX_FOUND) -mark_as_advanced(PLX_LIBRARIES PLX_LIBRARY_DIR) +mark_as_advanced(PLX_SHARED_LIB PLX_STATIC_LIB PLX_LIBRARY_DIR) From 54189d166caacb424613a0688d24be6ab6087c92 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 15:31:20 -0500 Subject: [PATCH 06/48] #94: Updating FindXIA.cmake to take into account latest XIA updates --- Cmake/modules/FindXIA.cmake | 38 +++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/Cmake/modules/FindXIA.cmake b/Cmake/modules/FindXIA.cmake index 91d1b20d1..02891b67a 100644 --- a/Cmake/modules/FindXIA.cmake +++ b/Cmake/modules/FindXIA.cmake @@ -9,27 +9,29 @@ # XIA_FIRMWARE_DIR - Directory to be searched for firmwares for pixie.cfg. # # Expected Structure: -# - **/opt** -# - **xia** -# - **api** - files provided by the XIA API -# - **lib** - API libraries -# - **include** - API includes -# - **share** -# - **pxisys** - contains the pxisys*.ini files provided in the API -# - **slotdef** - probably just a single slot def, can be added to the API install -# - **firmware** -# - **2016-02-02-12b250m-vandle** (and other specific firmware) -# - **config** - not something that XIA distributes on their website, **DO NOT** add to repos -# - **dsp** -# - **fpga** +# - **/usr** +# - **local/** +# - **xia** +# - **pixie** - files provided by the XIA API +# - **sdk** +# - **lib** - API libraries +# - **include** - API includes +# - **share** +# - **pxisys** - contains the pxisys*.ini files provided in the API +# - **slotdef** - probably just a single slot def, can be added to the API install +# - **firmware** +# - **2016-02-02-12b250m-vandle** (and other specific firmware) +# - **config** - not something that XIA distributes on their website, **DO NOT** add to repos +# - **dsp** +# - **fpga** # @authors K. Smith, C. R. Thornsberry, S. V. Paulauskas #Find the library path by looking for the library. find_path(XIA_LIBRARY_DIR - NAMES libPixie16App.a libPixie16Sys.a - HINTS $ENV{XIA_ROOT_DIR} - PATHS /opt/xia - PATH_SUFFIXES api/lib current/software + NAMES libPixie16App.so libPixie16Sys.so + HINTS $ENV{XIA_PIXIE_SDK} + PATHS /usr/local/xia/pixie/sdk + PATH_SUFFIXES lib DOC "Path to pixie library.") get_filename_component(XIA_LIBRARY_DIR "${XIA_LIBRARY_DIR}" REALPATH) @@ -39,7 +41,7 @@ get_filename_component(XIA_LIBRARY_DIR "${XIA_LIBRARY_DIR}" REALPATH) unset(XIA_FIRMWARE_DIR CACHE) if (NOT XIA_FIRMWARE_DIR) - get_filename_component(XIA_FIRMWARE_DIR "${XIA_LIBRARY_DIR}/../firmwares" REALPATH) + get_filename_component(XIA_FIRMWARE_DIR "${XIA_LIBRARY_DIR}/../firmware" REALPATH) if (NOT EXISTS ${XIA_FIRMWARE_DIR}) get_filename_component(XIA_FIRMWARE_DIR "${XIA_LIBRARY_DIR}/../../" REALPATH) endif (NOT EXISTS ${XIA_FIRMWARE_DIR}) From be427999edb861e9f36a735752066d7f68c3eedd Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 15:40:10 -0500 Subject: [PATCH 07/48] #94: Fixing CI build script due to changes in the APIs --- .travis.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 64b25199b..2e7e6bb74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,6 @@ jobs: - MATRIX_EVAL="" - BUILD_OPTIONS="-DPAASS_BUILD_TESTS=ON -DPAASS_BUILD_UTKSCAN=ON -DPAASS_BUILD_ROOT_SCANNER=OFF -DPAASS_BUILD_SETUP=ON" - before_install: - sudo apt-get -qq update --install-suggests - eval "${MATRIX_EVAL}" @@ -63,5 +62,8 @@ before_install: - source root/bin/thisroot.sh script: - - mkdir paass-build && cd paass-build - - cmake ../ ${BUILD_OPTIONS} && make -j8 && ./Tests/tests + - mkdir build + - cd paass-build + - cmake ../ ${BUILD_OPTIONS} + - make -j12 + - ./Tests/tests \ No newline at end of file From 1e415bc4c7c7dfc1960a63aae34343b0b680e7ad Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 15:42:59 -0500 Subject: [PATCH 08/48] #94: Interface builds and installs as expected --- Acquisition/CMakeLists.txt | 35 ++++++--------------- Acquisition/Interface/CMakeLists.txt | 9 ++++++ Acquisition/Interface/source/CMakeLists.txt | 13 -------- 3 files changed, 18 insertions(+), 39 deletions(-) create mode 100644 Acquisition/Interface/CMakeLists.txt delete mode 100644 Acquisition/Interface/source/CMakeLists.txt diff --git a/Acquisition/CMakeLists.txt b/Acquisition/CMakeLists.txt index 5ea5d4abf..832f88028 100644 --- a/Acquisition/CMakeLists.txt +++ b/Acquisition/CMakeLists.txt @@ -1,27 +1,10 @@ -# @authors S. V. Paulauskas, K. Smith, and C. R. Thornsberry - -#Adds the install prefix for referencing in the source code add_definitions(-D INSTALL_PREFIX="\\"${CMAKE_INSTALL_PREFIX}\\"") - -#Build the pixie interface -include_directories(Interface/include) -add_subdirectory(Interface/source) - -#Build the MCA objects -include_directories(MCA/include) -add_subdirectory(MCA) - -#Build PxiDump -add_subdirectory(set2root) - -#Build poll -add_subdirectory(Poll) - -if(PAASS_BUILD_ANALYSIS) - add_subdirectory(Utilities/DataGenerator) -endif(PAASS_BUILD_ANALYSIS) - -#Build the setup tools -if (PAASS_BUILD_SETUP) - add_subdirectory(Setup) -endif (PAASS_BUILD_SETUP) \ No newline at end of file +if (PAASS_BUILD_ACQ) + add_subdirectory(Interface) +# add_subdirectory(Poll) +# add_subdirectory(Utilities/MCA) +endif (PAASS_BUILD_ACQ) + +#add_subdirectory(Utilities/set2root) +#add_subdirectory(Utilities/DataGenerator) +#add_subdirectory(Setup) diff --git a/Acquisition/Interface/CMakeLists.txt b/Acquisition/Interface/CMakeLists.txt new file mode 100644 index 000000000..d355b93d0 --- /dev/null +++ b/Acquisition/Interface/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(PixieInterface SHARED source/PixieInterface.cpp source/Lock.cpp source/PixieSupport.cpp source/Utility.cpp) +target_include_directories(PixieInterface PUBLIC include ${PROJECT_SOURCE_DIR}/Core/include ${XIA_INCLUDE_DIR}) +target_link_directories(PixieInterface PUBLIC ${XIA_LIBRARY_DIR} ${PLX_LIBRARY_DIR}) +target_link_libraries(PixieInterface PaassCore ${XIA_LIBRARIES} ${PLX_LIBRARIES}) +target_compile_options(PixieInterface PRIVATE "-fPIC") + +file(GLOB PIXIE_INTERFACE_PUBLIC_HEADERS include/*.h) +set_target_properties(PixieInterface PROPERTIES PUBLIC_HEADER "${PIXIE_INTERFACE_PUBLIC_HEADERS}") +install(TARGETS PixieInterface LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include) \ No newline at end of file diff --git a/Acquisition/Interface/source/CMakeLists.txt b/Acquisition/Interface/source/CMakeLists.txt deleted file mode 100644 index 66dbcc40c..000000000 --- a/Acquisition/Interface/source/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# @authors C. R. Thornsberry, K. Smith -set(Interface_SOURCES PixieInterface.cpp Lock.cpp) - -add_library(PixieInterface STATIC ${Interface_SOURCES}) - -#Order is important, XIA before PLX -target_link_libraries(PixieInterface PaassCoreStatic ${XIA_LIBRARIES} - ${PLX_LIBRARIES}) - -set(Support_SOURCES PixieSupport.cpp) -add_library(PixieSupport STATIC ${Support_SOURCES}) - -add_library(Utility STATIC Utility.cpp) From 8880f45c8e6dc7a3ec8c2af817cbc3f7fe9be9d1 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 16:12:23 -0500 Subject: [PATCH 09/48] #94: Removing a confusing message from CMakeLists.txt --- Resources/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/Resources/CMakeLists.txt b/Resources/CMakeLists.txt index 0a5cdc935..bb4851beb 100644 --- a/Resources/CMakeLists.txt +++ b/Resources/CMakeLists.txt @@ -1,4 +1,3 @@ -message(STATUS "Building PaassResource library") add_library(PaassResources SHARED source/Messenger.cpp source/Notebook.cpp source/RandomInterface.cpp source/XmlInterface.cpp source/XmlParser.cpp) From 1a7e093e4b17370b8e3626ef0f1b0f4bd34ed36a Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 16:37:11 -0500 Subject: [PATCH 10/48] #94: MCA binary and library build and install --- Acquisition/CMakeLists.txt | 4 ++-- Acquisition/MCA/CMakeLists.txt | 19 ++++++++++++------- Acquisition/MCA/source/CMakeLists.txt | 9 --------- 3 files changed, 14 insertions(+), 18 deletions(-) delete mode 100644 Acquisition/MCA/source/CMakeLists.txt diff --git a/Acquisition/CMakeLists.txt b/Acquisition/CMakeLists.txt index 832f88028..3210d4e9a 100644 --- a/Acquisition/CMakeLists.txt +++ b/Acquisition/CMakeLists.txt @@ -1,8 +1,8 @@ add_definitions(-D INSTALL_PREFIX="\\"${CMAKE_INSTALL_PREFIX}\\"") if (PAASS_BUILD_ACQ) add_subdirectory(Interface) -# add_subdirectory(Poll) -# add_subdirectory(Utilities/MCA) + add_subdirectory(MCA) + # add_subdirectory(Poll) endif (PAASS_BUILD_ACQ) #add_subdirectory(Utilities/set2root) diff --git a/Acquisition/MCA/CMakeLists.txt b/Acquisition/MCA/CMakeLists.txt index 5b14afc2b..588e583f7 100644 --- a/Acquisition/MCA/CMakeLists.txt +++ b/Acquisition/MCA/CMakeLists.txt @@ -1,7 +1,12 @@ -# @authors C. R. Thornsberry, K. Smith -include_directories(include) -if(ROOT_FOUND) - add_subdirectory(source) -else () - message(STATUS "MCA not built as no compatible histogramming routines selected.") -endif () \ No newline at end of file +add_library(MCALibrary SHARED source/MCA.cpp source/MCA_ROOT.cpp) +target_include_directories(MCALibrary PUBLIC include ${PROJECT_SOURCE_DIR}/Acquisition/Interface/include ${ROOT_INCLUDE_DIR}) +target_link_libraries(MCALibrary PixieInterface ${ROOT_LIBRARIES}) + +file(GLOB MCA_PUBLIC_HEADERS include/*.h) +set_target_properties(MCALibrary PROPERTIES PUBLIC_HEADER "${MCA_PUBLIC_HEADERS}") +install(TARGETS MCALibrary LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include) + +add_executable(mca source/MCA_exec.cpp) +target_include_directories(mca PUBLIC include ${PROJECT_SOURCE_DIR}/Acquisition/Interface/include ${ROOT_INCLUDE_DIR}) +target_link_libraries(mca PixieInterface MCALibrary ${ROOT_LIBRARIES}) +install(TARGETS mca DESTINATION bin) diff --git a/Acquisition/MCA/source/CMakeLists.txt b/Acquisition/MCA/source/CMakeLists.txt deleted file mode 100644 index 3c9dd5823..000000000 --- a/Acquisition/MCA/source/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# @authors K. Smith - -add_executable(MCA MCA_exec.cpp MCA.cpp MCA_ROOT.cpp) -target_link_libraries(MCA PixieInterface Utility ${ROOT_LIBRARIES}) -install(TARGETS MCA DESTINATION bin) - -set(MCA_LIB_SOURCES MCA.cpp MCA_ROOT.cpp) -add_library(MCA_LIBRARY STATIC ${MCA_LIB_SOURCES}) -target_link_libraries(MCA_LIBRARY PixieInterface Utility ${ROOT_LIBRARIES}) \ No newline at end of file From 705641d9e01f466bf9d60571127c18e935f88f7b Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 16:43:52 -0500 Subject: [PATCH 11/48] #94: poll2 binary builds and installs --- Acquisition/CMakeLists.txt | 2 +- Acquisition/Poll/CMakeLists.txt | 12 ++++-------- Acquisition/Poll/source/CMakeLists.txt | 16 ---------------- 3 files changed, 5 insertions(+), 25 deletions(-) delete mode 100644 Acquisition/Poll/source/CMakeLists.txt diff --git a/Acquisition/CMakeLists.txt b/Acquisition/CMakeLists.txt index 3210d4e9a..a515043b5 100644 --- a/Acquisition/CMakeLists.txt +++ b/Acquisition/CMakeLists.txt @@ -2,7 +2,7 @@ add_definitions(-D INSTALL_PREFIX="\\"${CMAKE_INSTALL_PREFIX}\\"") if (PAASS_BUILD_ACQ) add_subdirectory(Interface) add_subdirectory(MCA) - # add_subdirectory(Poll) + add_subdirectory(Poll) endif (PAASS_BUILD_ACQ) #add_subdirectory(Utilities/set2root) diff --git a/Acquisition/Poll/CMakeLists.txt b/Acquisition/Poll/CMakeLists.txt index db62abfd3..e13b4d7b0 100644 --- a/Acquisition/Poll/CMakeLists.txt +++ b/Acquisition/Poll/CMakeLists.txt @@ -1,8 +1,4 @@ -#@authors K. Smith -include_directories(include) -add_subdirectory(source) - -install( - FILES ${CMAKE_CURRENT_SOURCE_DIR}/send_alarm - PERMISSIONS OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ - DESTINATION bin) \ No newline at end of file +add_executable(poll2 source/poll2.cpp source/poll2_core.cpp source/poll2_stats.cpp) +target_include_directories(poll2 PUBLIC include ${PROJECT_SOURCE_DIR}/Resources/include) +target_link_libraries(poll2 PixieInterface MCALibrary) +install(TARGETS poll2 DESTINATION bin) diff --git a/Acquisition/Poll/source/CMakeLists.txt b/Acquisition/Poll/source/CMakeLists.txt deleted file mode 100644 index f9537e49f..000000000 --- a/Acquisition/Poll/source/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# @authors C. R. Thornsberry, K. Smith, S. V. Paulauskas - -set(POLL2_SOURCES poll2.cpp poll2_core.cpp poll2_stats.cpp) -add_executable(poll2 ${POLL2_SOURCES}) -target_link_libraries(poll2 PixieInterface PixieSupport Utility MCA_LIBRARY ${CMAKE_THREAD_LIBS_INIT}) -install(TARGETS poll2 DESTINATION bin) - -set(LISTENER_SOURCES listener.cpp) -add_executable(listener ${LISTENER_SOURCES}) -target_link_libraries(listener PaassCoreStatic) - -set(MONITOR_SOURCES monitor.cpp) -add_executable(monitor ${MONITOR_SOURCES}) -target_link_libraries(monitor PaassCoreStatic) - -install(TARGETS listener monitor DESTINATION bin) From ef7a5c5c9ba1ab13fb7695cb519e804a4568864b Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 16:47:22 -0500 Subject: [PATCH 12/48] #94: Moved listener to the Acquisition/Utilities folder --- Acquisition/CMakeLists.txt | 1 + Acquisition/Utilities/listener/CMakeLists.txt | 4 ++++ Acquisition/{Poll => Utilities/listener}/source/listener.cpp | 0 3 files changed, 5 insertions(+) create mode 100644 Acquisition/Utilities/listener/CMakeLists.txt rename Acquisition/{Poll => Utilities/listener}/source/listener.cpp (100%) diff --git a/Acquisition/CMakeLists.txt b/Acquisition/CMakeLists.txt index a515043b5..8ee78a76a 100644 --- a/Acquisition/CMakeLists.txt +++ b/Acquisition/CMakeLists.txt @@ -3,6 +3,7 @@ if (PAASS_BUILD_ACQ) add_subdirectory(Interface) add_subdirectory(MCA) add_subdirectory(Poll) + add_subdirectory(Utilities/listener) endif (PAASS_BUILD_ACQ) #add_subdirectory(Utilities/set2root) diff --git a/Acquisition/Utilities/listener/CMakeLists.txt b/Acquisition/Utilities/listener/CMakeLists.txt new file mode 100644 index 000000000..3c6f81c25 --- /dev/null +++ b/Acquisition/Utilities/listener/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(listener source/listener.cpp) +target_include_directories(listener PUBLIC ${PROJECT_SOURCE_DIR}/Core/include) +target_link_libraries(listener PaassCore) +install(TARGETS listener DESTINATION bin) \ No newline at end of file diff --git a/Acquisition/Poll/source/listener.cpp b/Acquisition/Utilities/listener/source/listener.cpp similarity index 100% rename from Acquisition/Poll/source/listener.cpp rename to Acquisition/Utilities/listener/source/listener.cpp From 40f21c96517baa641d52b95503d546332c000331 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 16:49:02 -0500 Subject: [PATCH 13/48] #94: Moved monitor to the Acquisition/Utilities folder --- Acquisition/CMakeLists.txt | 1 + Acquisition/Utilities/monitor/CMakeLists.txt | 4 ++++ Acquisition/{Poll => Utilities/monitor}/source/monitor.cpp | 0 3 files changed, 5 insertions(+) create mode 100644 Acquisition/Utilities/monitor/CMakeLists.txt rename Acquisition/{Poll => Utilities/monitor}/source/monitor.cpp (100%) diff --git a/Acquisition/CMakeLists.txt b/Acquisition/CMakeLists.txt index 8ee78a76a..e373813e7 100644 --- a/Acquisition/CMakeLists.txt +++ b/Acquisition/CMakeLists.txt @@ -4,6 +4,7 @@ if (PAASS_BUILD_ACQ) add_subdirectory(MCA) add_subdirectory(Poll) add_subdirectory(Utilities/listener) + add_subdirectory(Utilities/monitor) endif (PAASS_BUILD_ACQ) #add_subdirectory(Utilities/set2root) diff --git a/Acquisition/Utilities/monitor/CMakeLists.txt b/Acquisition/Utilities/monitor/CMakeLists.txt new file mode 100644 index 000000000..20dc19b89 --- /dev/null +++ b/Acquisition/Utilities/monitor/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(monitor source/monitor.cpp) +target_include_directories(monitor PUBLIC ${PROJECT_SOURCE_DIR}/Core/include) +target_link_libraries(monitor PaassCore) +install(TARGETS monitor DESTINATION bin) \ No newline at end of file diff --git a/Acquisition/Poll/source/monitor.cpp b/Acquisition/Utilities/monitor/source/monitor.cpp similarity index 100% rename from Acquisition/Poll/source/monitor.cpp rename to Acquisition/Utilities/monitor/source/monitor.cpp From b227b31e06da524c6a030d2fb5fe272cac01df47 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 16:49:47 -0500 Subject: [PATCH 14/48] #94: Moved monitor.bash to keep it organized --- Acquisition/{Poll => Utilities/monitor/bin}/monitor.bash | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Acquisition/{Poll => Utilities/monitor/bin}/monitor.bash (100%) mode change 100755 => 100644 diff --git a/Acquisition/Poll/monitor.bash b/Acquisition/Utilities/monitor/bin/monitor.bash old mode 100755 new mode 100644 similarity index 100% rename from Acquisition/Poll/monitor.bash rename to Acquisition/Utilities/monitor/bin/monitor.bash From 29450a06d6d6429d14cb8a9f2c5b7133ab8c114a Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 16:51:11 -0500 Subject: [PATCH 15/48] #94: Updated so that we install monitor.bash --- Acquisition/Utilities/monitor/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Acquisition/Utilities/monitor/CMakeLists.txt b/Acquisition/Utilities/monitor/CMakeLists.txt index 20dc19b89..9e8dcd39b 100644 --- a/Acquisition/Utilities/monitor/CMakeLists.txt +++ b/Acquisition/Utilities/monitor/CMakeLists.txt @@ -1,4 +1,5 @@ add_executable(monitor source/monitor.cpp) target_include_directories(monitor PUBLIC ${PROJECT_SOURCE_DIR}/Core/include) target_link_libraries(monitor PaassCore) -install(TARGETS monitor DESTINATION bin) \ No newline at end of file +install(TARGETS monitor DESTINATION bin) +install(FILES bin/monitor.bash DESTINATION bin) \ No newline at end of file From 069c336b9c01785d40378e04fb7b746b1403c8dd Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 16:53:49 -0500 Subject: [PATCH 16/48] #94: Organizing send_alarm to be in Utilities --- Acquisition/CMakeLists.txt | 1 + Acquisition/Utilities/send_alarm/CMakeLists.txt | 1 + Acquisition/{Poll => Utilities/send_alarm/bin}/send_alarm | 0 3 files changed, 2 insertions(+) create mode 100644 Acquisition/Utilities/send_alarm/CMakeLists.txt rename Acquisition/{Poll => Utilities/send_alarm/bin}/send_alarm (100%) mode change 100755 => 100644 diff --git a/Acquisition/CMakeLists.txt b/Acquisition/CMakeLists.txt index e373813e7..2142cf4ea 100644 --- a/Acquisition/CMakeLists.txt +++ b/Acquisition/CMakeLists.txt @@ -5,6 +5,7 @@ if (PAASS_BUILD_ACQ) add_subdirectory(Poll) add_subdirectory(Utilities/listener) add_subdirectory(Utilities/monitor) + add_subdirectory(Utilities/send_alarm) endif (PAASS_BUILD_ACQ) #add_subdirectory(Utilities/set2root) diff --git a/Acquisition/Utilities/send_alarm/CMakeLists.txt b/Acquisition/Utilities/send_alarm/CMakeLists.txt new file mode 100644 index 000000000..70fe98a00 --- /dev/null +++ b/Acquisition/Utilities/send_alarm/CMakeLists.txt @@ -0,0 +1 @@ +install(FILES bin/send_alarm DESTINATION bin) \ No newline at end of file diff --git a/Acquisition/Poll/send_alarm b/Acquisition/Utilities/send_alarm/bin/send_alarm old mode 100755 new mode 100644 similarity index 100% rename from Acquisition/Poll/send_alarm rename to Acquisition/Utilities/send_alarm/bin/send_alarm From c082dc9affa93ffde240a5f625faa656f72ba02e Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 17:07:55 -0500 Subject: [PATCH 17/48] #94: Updating set2root build and install --- Acquisition/CMakeLists.txt | 3 ++- Acquisition/set2root/CMakeLists.txt | 12 +++++++++--- Acquisition/set2root/source/CMakeLists.txt | 11 ----------- 3 files changed, 11 insertions(+), 15 deletions(-) delete mode 100644 Acquisition/set2root/source/CMakeLists.txt diff --git a/Acquisition/CMakeLists.txt b/Acquisition/CMakeLists.txt index 2142cf4ea..ab2cdae6c 100644 --- a/Acquisition/CMakeLists.txt +++ b/Acquisition/CMakeLists.txt @@ -8,6 +8,7 @@ if (PAASS_BUILD_ACQ) add_subdirectory(Utilities/send_alarm) endif (PAASS_BUILD_ACQ) -#add_subdirectory(Utilities/set2root) +add_subdirectory(set2root) + #add_subdirectory(Utilities/DataGenerator) #add_subdirectory(Setup) diff --git a/Acquisition/set2root/CMakeLists.txt b/Acquisition/set2root/CMakeLists.txt index 64d07953b..b15079d59 100644 --- a/Acquisition/set2root/CMakeLists.txt +++ b/Acquisition/set2root/CMakeLists.txt @@ -1,3 +1,9 @@ -# @authors K. Smith -include_directories(include) -add_subdirectory(source) +add_executable(set2ascii source/set2root.cpp) +target_include_directories(set2ascii PUBLIC include ${PROJECT_SOURCE_DIR}/Resources/include) +install(TARGETS set2ascii DESTINATION bin) + +add_executable(set2root source/set2root.cpp) +set_target_properties(set2root PROPERTIES COMPILE_FLAGS "-DUSE_ROOT_OUTPUT") +target_include_directories(set2root PUBLIC include ${PROJECT_SOURCE_DIR}/Resources/include ${ROOT_INCLUDE_DIR}) +target_link_libraries(set2root ${ROOT_LIBRARIES}) +install(TARGETS set2root DESTINATION bin) diff --git a/Acquisition/set2root/source/CMakeLists.txt b/Acquisition/set2root/source/CMakeLists.txt deleted file mode 100644 index 197fd4ad2..000000000 --- a/Acquisition/set2root/source/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -#@authors K. Smith -set(SET2ROOT_SOURCES set2root.cpp) - -add_executable(set2ascii ${SET2ROOT_SOURCES}) -target_link_libraries(set2ascii) -install(TARGETS set2ascii DESTINATION bin) - -add_executable(set2root ${SET2ROOT_SOURCES}) -set_target_properties(set2root PROPERTIES COMPILE_FLAGS "-DUSE_ROOT_OUTPUT") -target_link_libraries(set2root ${ROOT_LIBRARIES}) -install(TARGETS set2root DESTINATION bin) From 3df5c10968388bd4c481d5af7244c613eb5a31b5 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 17:09:21 -0500 Subject: [PATCH 18/48] #94: Moving set2root to live with the other Utilities --- Acquisition/CMakeLists.txt | 2 +- Acquisition/{ => Utilities}/set2root/CMakeLists.txt | 0 Acquisition/{ => Utilities}/set2root/include/set2root.hpp | 0 Acquisition/{ => Utilities}/set2root/source/set2root.cpp | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename Acquisition/{ => Utilities}/set2root/CMakeLists.txt (100%) rename Acquisition/{ => Utilities}/set2root/include/set2root.hpp (100%) rename Acquisition/{ => Utilities}/set2root/source/set2root.cpp (100%) diff --git a/Acquisition/CMakeLists.txt b/Acquisition/CMakeLists.txt index ab2cdae6c..04285d4a7 100644 --- a/Acquisition/CMakeLists.txt +++ b/Acquisition/CMakeLists.txt @@ -8,7 +8,7 @@ if (PAASS_BUILD_ACQ) add_subdirectory(Utilities/send_alarm) endif (PAASS_BUILD_ACQ) -add_subdirectory(set2root) +add_subdirectory(Utilities/set2root) #add_subdirectory(Utilities/DataGenerator) #add_subdirectory(Setup) diff --git a/Acquisition/set2root/CMakeLists.txt b/Acquisition/Utilities/set2root/CMakeLists.txt similarity index 100% rename from Acquisition/set2root/CMakeLists.txt rename to Acquisition/Utilities/set2root/CMakeLists.txt diff --git a/Acquisition/set2root/include/set2root.hpp b/Acquisition/Utilities/set2root/include/set2root.hpp similarity index 100% rename from Acquisition/set2root/include/set2root.hpp rename to Acquisition/Utilities/set2root/include/set2root.hpp diff --git a/Acquisition/set2root/source/set2root.cpp b/Acquisition/Utilities/set2root/source/set2root.cpp similarity index 100% rename from Acquisition/set2root/source/set2root.cpp rename to Acquisition/Utilities/set2root/source/set2root.cpp From 05d5cb31b3b76f32c1f2a3df787d4922e6ea7891 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 17:17:18 -0500 Subject: [PATCH 19/48] #94: Building and installing individual setup programs --- Acquisition/CMakeLists.txt | 9 +++++---- Acquisition/Setup/CMakeLists.txt | 21 +++++++++++++++++---- Acquisition/Setup/source/CMakeLists.txt | 19 ------------------- 3 files changed, 22 insertions(+), 27 deletions(-) delete mode 100644 Acquisition/Setup/source/CMakeLists.txt diff --git a/Acquisition/CMakeLists.txt b/Acquisition/CMakeLists.txt index 04285d4a7..fb917de20 100644 --- a/Acquisition/CMakeLists.txt +++ b/Acquisition/CMakeLists.txt @@ -1,4 +1,9 @@ add_definitions(-D INSTALL_PREFIX="\\"${CMAKE_INSTALL_PREFIX}\\"") + +add_subdirectory(Utilities/set2root) +add_subdirectory(Setup) +#add_subdirectory(Utilities/DataGenerator) + if (PAASS_BUILD_ACQ) add_subdirectory(Interface) add_subdirectory(MCA) @@ -8,7 +13,3 @@ if (PAASS_BUILD_ACQ) add_subdirectory(Utilities/send_alarm) endif (PAASS_BUILD_ACQ) -add_subdirectory(Utilities/set2root) - -#add_subdirectory(Utilities/DataGenerator) -#add_subdirectory(Setup) diff --git a/Acquisition/Setup/CMakeLists.txt b/Acquisition/Setup/CMakeLists.txt index 9f0762322..f85a5c0c9 100644 --- a/Acquisition/Setup/CMakeLists.txt +++ b/Acquisition/Setup/CMakeLists.txt @@ -1,4 +1,17 @@ -#@author K. Smith -include_directories(include) -add_subdirectory(source) -add_subdirectory(Traces) +set(SETUP_UTILS adjust_offsets find_tau copy_params pread pwrite pmread pmwrite + rate boot trace get_traces csr_test toggle set_standard set_pileups_only + set_pileups_reject set_hybrid) + +foreach (UTIL ${SETUP_UTILS}) + add_executable(${UTIL} source/${UTIL}.cpp) + target_link_libraries(${UTIL} PixieInterface) + target_include_directories(${UTIL} PUBLIC include ${PROJECT_SOURCE_DIR}/Acquisition/Interface/include) +endforeach (UTIL) + +install(TARGETS ${SETUP_UTILS} DESTINATION bin) + +add_executable(paramScan source/paramScan.cpp) +target_include_directories(paramScan PUBLIC include ${PROJECT_SOURCE_DIR}/Acquisition/Interface/include + ${ROOT_INCLUDE_DIR}) +target_link_libraries(paramScan PixieInterface MCALibrary ${ROOT_LIBRARIES} "-lSpectrum") +install(TARGETS paramScan DESTINATION bin) diff --git a/Acquisition/Setup/source/CMakeLists.txt b/Acquisition/Setup/source/CMakeLists.txt deleted file mode 100644 index f611849c6..000000000 --- a/Acquisition/Setup/source/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -#authors K. Smith, C. R. Thornsberry -#Build and install setup utilities, and configuration file -set(SETUP_UTILS adjust_offsets find_tau copy_params pread pwrite pmread pmwrite - rate boot trace get_traces csr_test toggle set_standard set_pileups_only - set_pileups_reject set_hybrid) - -foreach (UTIL ${SETUP_UTILS}) - add_executable(${UTIL} ${UTIL}.cpp) - target_link_libraries(${UTIL} PixieSupport PixieInterface) # The order matters here! CRT -endforeach (UTIL) - -install(TARGETS ${SETUP_UTILS} DESTINATION bin) - -if (ROOT_FOUND) - add_executable(paramScan paramScan.cpp) - target_link_libraries(paramScan PixieInterface MCA_LIBRARY ${ROOT_LIBRARIES} - "-lSpectrum") - install(TARGETS paramScan DESTINATION bin) -endif (ROOT_FOUND) From f1084e46ec38a3de3594041535b0af5cb531600f Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 17:19:54 -0500 Subject: [PATCH 20/48] #94: Adding note about the DataGenerator --- Acquisition/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Acquisition/CMakeLists.txt b/Acquisition/CMakeLists.txt index fb917de20..711b15fcf 100644 --- a/Acquisition/CMakeLists.txt +++ b/Acquisition/CMakeLists.txt @@ -2,6 +2,7 @@ add_definitions(-D INSTALL_PREFIX="\\"${CMAKE_INSTALL_PREFIX}\\"") add_subdirectory(Utilities/set2root) add_subdirectory(Setup) +#TODO: We need to revist where this guy lives as he's dependent on the scan libraries. Maybe should live there?? #add_subdirectory(Utilities/DataGenerator) if (PAASS_BUILD_ACQ) From 887f2bffbd83a36f7ce128a2deb012fd81d9cd21 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 17:25:10 -0500 Subject: [PATCH 21/48] #94: Moving PLX and XIA SDK finds to the Acquisition CMakeLists.txt --- Acquisition/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Acquisition/CMakeLists.txt b/Acquisition/CMakeLists.txt index 711b15fcf..3383ceed3 100644 --- a/Acquisition/CMakeLists.txt +++ b/Acquisition/CMakeLists.txt @@ -6,6 +6,10 @@ add_subdirectory(Setup) #add_subdirectory(Utilities/DataGenerator) if (PAASS_BUILD_ACQ) + find_package(PLX REQUIRED) + find_package(XIA REQUIRED) + XIA_CONFIG() + add_subdirectory(Interface) add_subdirectory(MCA) add_subdirectory(Poll) From 5c2f0acf50fe4d72f597f89135cf8d5925dd518f Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 17:39:53 -0500 Subject: [PATCH 22/48] #94: Adding missing library to poll2 build --- Acquisition/Poll/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Acquisition/Poll/CMakeLists.txt b/Acquisition/Poll/CMakeLists.txt index e13b4d7b0..628705bab 100644 --- a/Acquisition/Poll/CMakeLists.txt +++ b/Acquisition/Poll/CMakeLists.txt @@ -1,4 +1,4 @@ add_executable(poll2 source/poll2.cpp source/poll2_core.cpp source/poll2_stats.cpp) target_include_directories(poll2 PUBLIC include ${PROJECT_SOURCE_DIR}/Resources/include) -target_link_libraries(poll2 PixieInterface MCALibrary) +target_link_libraries(poll2 PixieInterface MCALibrary ${CMAKE_THREAD_LIBS_INIT}) install(TARGETS poll2 DESTINATION bin) From 56b3c6c69d9c1cee42b79a68eab36b8dacd86099 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 18:03:13 -0500 Subject: [PATCH 23/48] #94: Analysis/Resources builds and installs as expected. --- Analysis/CMakeLists.txt | 58 ++++++----------- Analysis/Resources/CMakeLists.txt | 13 +++- Analysis/Resources/source/CMakeLists.txt | 18 ------ Analysis/ScanLibraries/CMakeLists.txt | 18 ++++-- Analysis/ScanLibraries/source/CMakeLists.txt | 24 ------- CMakeLists.txt | 68 +++++--------------- 6 files changed, 60 insertions(+), 139 deletions(-) delete mode 100644 Analysis/Resources/source/CMakeLists.txt delete mode 100644 Analysis/ScanLibraries/source/CMakeLists.txt diff --git a/Analysis/CMakeLists.txt b/Analysis/CMakeLists.txt index ac1e81229..3a8ca3a00 100644 --- a/Analysis/CMakeLists.txt +++ b/Analysis/CMakeLists.txt @@ -1,38 +1,22 @@ -#@authors K. Smith, S. V. Paulauskas, C. R. Thornsberry -option(PAASS_USE_HRIBF "Use HRIBF library for scan base." OFF) - -#Check if GSL is installed -find_package(GSL REQUIRED) -include_directories(${GSL_INCLUDE_DIRS}) -link_directories(${GSL_LIBRARY_DIRS}) -if (${GSL_VERSION} LESS 2.0) - add_definitions("-D GSL_VERSION_ONE") -endif (${GSL_VERSION} LESS 2.0) - -#Everything below is dependent on these two sets of libaries so we include the headers. -include_directories(Resources/include) -include_directories(ScanLibraries/include) - -if (PAASS_USE_HRIBF) - #Find HRIBF Libraries - find_package(HRIBF REQUIRED) - add_definitions("-D USE_HRIBF") - - enable_language(Fortran) - - #If we are using HRIBF interface we need to include the ScanorInterface header for the following code. - include_directories(Scanor/include) - add_subdirectory(Scanor) -endif (PAASS_USE_HRIBF) - -#We will always build these two since they include static lib for the rest add_subdirectory(ScanLibraries) -add_subdirectory(Resources) - -#Build utilities. -add_subdirectory(Utilities) - -option(PAASS_BUILD_UTKSCAN "Build utkscan" OFF) -if (PAASS_BUILD_UTKSCAN) - add_subdirectory(Utkscan) -endif (PAASS_BUILD_UTKSCAN) +#add_subdirectory(Resources) +#add_subdirectory(Utilities) + +#option(PAASS_USE_HRIBF "Use HRIBF library for scan base." OFF) +#if (PAASS_USE_HRIBF) +# #Find HRIBF Libraries +# find_package(HRIBF REQUIRED) +# add_definitions("-D USE_HRIBF") +# +# enable_language(Fortran) +# +# #If we are using HRIBF interface we need to include the ScanorInterface header for the following code. +# include_directories(Scanor/include) +# add_subdirectory(Scanor) +#endif (PAASS_USE_HRIBF) +# +# +#option(PAASS_BUILD_UTKSCAN "Build utkscan" OFF) +#if (PAASS_BUILD_UTKSCAN) +# add_subdirectory(Utkscan) +#endif (PAASS_BUILD_UTKSCAN) diff --git a/Analysis/Resources/CMakeLists.txt b/Analysis/Resources/CMakeLists.txt index 6dce72622..62dde4da8 100644 --- a/Analysis/Resources/CMakeLists.txt +++ b/Analysis/Resources/CMakeLists.txt @@ -1,2 +1,11 @@ -#author S. V. Paulauskas -add_subdirectory(source) \ No newline at end of file +add_library(AnalysisResources SHARED source/ChannelConfiguration.cpp source/CrystalBallFunction.cpp + source/CsiFunction.cpp source/EmCalTimingFunction.cpp source/GslFitter.cpp source/PolynomialCfd.cpp + source/RootFitter.cpp source/SiPmtFastTimingFunction.cpp source/TimingConfiguration.cpp source/TraceFilter.cpp + source/TraditionalCfd.cpp source/VandleTimingFunction.cpp source/XiaCfd.cpp) +target_include_directories(AnalysisResources PUBLIC include ${PROJECT_SOURCE_DIR}/Resources/include + ${PROJECT_SOURCE_DIR}/Analysis/ScanLibraries/include) +target_link_libraries(AnalysisResources PaassResources ${ROOT_LIBRARIES}) + +file(GLOB ANALYSIS_RESOURCES_PUBLIC_HEADERS include/*.hpp) +set_target_properties(AnalysisResources PROPERTIES PUBLIC_HEADER "${ANALYSIS_RESOURCES_PUBLIC_HEADERS}") +install(TARGETS AnalysisResources LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include) \ No newline at end of file diff --git a/Analysis/Resources/source/CMakeLists.txt b/Analysis/Resources/source/CMakeLists.txt deleted file mode 100644 index fa9f6f3a1..000000000 --- a/Analysis/Resources/source/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -#@author S. V. Paulauskas -set(ResourceSources GslFitter.cpp PolynomialCfd.cpp TraditionalCfd.cpp TraceFilter.cpp TimingConfiguration.cpp - ChannelConfiguration.cpp CrystalBallFunction.cpp CsiFunction.cpp EmCalTimingFunction.cpp - SiPmtFastTimingFunction.cpp RootFitter.cpp VandleTimingFunction.cpp) - -#Add the sources to the library -add_library(ResourceObjects OBJECT ${ResourceSources}) - -if (BUILD_SHARED_LIBS) - message(STATUS "Building Utility Shared Objects") - add_library(UtilityLibrary SHARED $) - target_link_libraries(UtilityLibrary PaassCoreStatic ${ROOT_LIBRARIES}) - install(TARGETS UtilityLibrary DESTINATION lib) -endif (BUILD_SHARED_LIBS) - -#Create Utility static library and add ncurses if we have it -add_library(ResourceStatic STATIC $) -target_link_libraries(ResourceStatic ${ROOT_LIBRARIES}) diff --git a/Analysis/ScanLibraries/CMakeLists.txt b/Analysis/ScanLibraries/CMakeLists.txt index cc5590563..18eef24d4 100644 --- a/Analysis/ScanLibraries/CMakeLists.txt +++ b/Analysis/ScanLibraries/CMakeLists.txt @@ -1,6 +1,14 @@ -# @author S. V. Paulauskas, K. Smith -if (PAASS_BUILD_SHARED_LIBS) - install(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX}) -endif (PAASS_BUILD_SHARED_LIBS) +add_library(PaassScan SHARED source/ScanInterface.cpp source/Unpacker.cpp source/XiaData.cpp + source/XiaListModeDataDecoder.cpp source/XiaListModeDataEncoder.cpp source/XiaListModeDataMask.cpp) -add_subdirectory(source) +if (XIA_FOUND) + target_sources(PaassScan source/StatsData.cpp) +endif(XIA_FOUND) + +target_include_directories(PaassScan PUBLIC include ${PROJECT_SOURCE_DIR}/Resources/include ${XIA_INCLUDE_DIR} + ${PROJECT_SOURCE_DIR}/ThirdParty/pugixml/include) +target_link_libraries(PaassScan PaassResources PaassCore Pugixml-1.11.1 ${CMAKE_THREAD_LIBS_INIT} ${CURSES_LIBRARIES}) + +file(GLOB PAASS_SCAN_PUBLIC_HEADERS include/*.hpp) +set_target_properties(PaassScan PROPERTIES PUBLIC_HEADER "${PAASS_SCAN_PUBLIC_HEADERS}") +install(TARGETS PaassScan LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include) diff --git a/Analysis/ScanLibraries/source/CMakeLists.txt b/Analysis/ScanLibraries/source/CMakeLists.txt deleted file mode 100644 index 8806f4923..000000000 --- a/Analysis/ScanLibraries/source/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# @author S. V. Paulauskas, K. Smith -#Set the scan sources that we will make a lib out of -set(PaassScanSources ScanInterface.cpp Unpacker.cpp XiaData.cpp XiaListModeDataMask.cpp XiaListModeDataDecoder.cpp - XiaListModeDataEncoder.cpp) - -#Add the sources to the library -add_library(PaassScanObjects OBJECT ${PaassScanSources}) - -if (PAASS_BUILD_SHARED_LIBS) - message(STATUS "Building Scan Shared Objects") - add_library(PaassScan SHARED $) - target_link_libraries(PaassScan PaassResourceStatic PaassCoreStatic ${CMAKE_THREAD_LIBS_INIT}) - if (${CURSES_FOUND}) - target_link_libraries(PaassScan ${CURSES_LIBRARIES}) - endif (${CURSES_FOUND}) - install(TARGETS PaassScan DESTINATION lib) -endif (PAASS_BUILD_SHARED_LIBS) - -#Create PixieScan static library and add ncurses if we have it -add_library(PaassScanStatic STATIC $) -target_link_libraries(PaassScanStatic PaassCoreStatic PaassResourceStatic ${CMAKE_THREAD_LIBS_INIT}) -if (${CURSES_FOUND}) - target_link_libraries(PaassScanStatic ${CURSES_LIBRARIES}) -endif (${CURSES_FOUND}) diff --git a/CMakeLists.txt b/CMakeLists.txt index dfca8c4ec..e67333a25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,4 @@ -# @authors S.V. Paulauskas, K. Smith, and C. Thronsberry - -cmake_minimum_required(VERSION 3.11) +cmake_minimum_required(VERSION 3.13) project(PAASS) @@ -48,17 +46,7 @@ include(CMakeDependentOption) #Install options option(PAASS_BUILD_ACQ "Build and install Acquisition software" ON) option(PAASS_BUILD_ANALYSIS "Build analysis related programs" ON) -option(PAASS_BUILD_SETUP "Include the older setup programs in installation" OFF) -option(PAASS_BUILD_SHARED_LIBS "Install only scan libraries" ON) option(PAASS_BUILD_TESTS "Builds programs designed to test the package." OFF) -option(PAASS_BUILD_UTKSCAN "Build utkscan" OFF) -option(PAASS_USE_DAMM "Use DAMM for MCA" ON) -option(PAASS_USE_NCURSES "Use ncurses for terminal" ON) -option(PAASS_USE_ROOT "Use ROOT (Currently REQUIRED!!)" ON) - -mark_as_advanced(PAASS_USE_NCURSES) -mark_as_advanced(PAASS_USE_DAMM) -mark_as_advanced(PAASS_USE_ROOT) option(PAASS_EXPORT_COMPILE_COMMANDS "CMAKE_EXPORT_COMPILE_COMMANDS WRAPPER" ON) mark_as_advanced(PAASS_EXPORT_COMPILE_COMMANDS) @@ -73,62 +61,36 @@ else () endif (PAASS_EXPORT_COMPILE_COMMANDS) #------------------------------------------------------------------------------ - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/Cmake/modules/") find_package(Threads REQUIRED) -if (PAASS_BUILD_ACQ) - #Find the PLX Library - find_package(PLX REQUIRED) - link_directories(${PLX_LIBRARY_DIR}) - - #Find the Pixie Firmware - find_package(XIA REQUIRED) - include_directories(${XIA_INCLUDE_DIR}) - link_directories(${XIA_LIBRARY_DIR}) - - # Create pixie.cfg and copy slot_def.set as well as copy default.set to current.set - XIA_CONFIG() -endif () - find_package(Curses REQUIRED) add_definitions("-D USE_NCURSES") mark_as_advanced(FORCE CURSES_HAVE_CURSES_H CURSES_CURSES_H_PATH CURSES_FORM_LIBRARY) find_package(ROOT REQUIRED COMPONENTS TreePlayer) mark_as_advanced(FORCE GENREFLEX_EXECUTABLE ROOTCINT_EXECUTABLE ROOT_CONFIG_EXECUTABLE) -include_directories(${ROOT_INCLUDE_DIR}) -link_directories(${ROOT_LIBRARY_DIR}) add_definitions("-D USE_ROOT") -if (PAASS_BUILD_TESTS) - add_subdirectory(Tests) - enable_testing() -endif (PAASS_BUILD_TESTS) +find_package(GSL REQUIRED) +if (${GSL_VERSION} LESS 2.0) + add_definitions("-D GSL_VERSION_ONE") +endif (${GSL_VERSION} LESS 2.0) -#------------------------------------------------------------------------------ -#Put all the include directories that we might need at this point. Third party includes must come before the Resources. -# TODO : We will need to update all these to be target_include calls paired with the right executable. -include_directories(ThirdParty/pugixml/include Resources/include Core/include) +#if (PAASS_BUILD_TESTS) +# add_subdirectory(Tests) +# enable_testing() +#endif (PAASS_BUILD_TESTS) +#------------------------------------------------------------------------------ add_subdirectory(ThirdParty) add_subdirectory(Resources) add_subdirectory(Core) - -#Build Acquisition software, we don't have this broken into as fine of a -#granularity as the Analysis software, so we just wrap the whole thing in an if. -if (PAASS_BUILD_ACQ) - add_subdirectory(Acquisition) -else () - #Ensure that we can still build set2* even when BUILD_ACQ is off - add_subdirectory(Acquisition/set2root) -endif (PAASS_BUILD_ACQ) - -#Build any of the analysis related things that we need to build. -if (PAASS_BUILD_ANALYSIS) - add_subdirectory(Analysis) -endif (PAASS_BUILD_ANALYSIS) +add_subdirectory(Acquisition) +#if (PAASS_BUILD_ANALYSIS) +add_subdirectory(Analysis) +#endif (PAASS_BUILD_ANALYSIS) #Build/install the miscellaneous stuff -add_subdirectory(Share) +#add_subdirectory(Share) From f72089ee79fd2b8cf4da2525bea1e09f56524b8e Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 18:17:44 -0500 Subject: [PATCH 24/48] #94: Adding Acquisition/Setup/Traces to install --- Acquisition/Setup/CMakeLists.txt | 3 +++ Acquisition/Setup/Traces/CMakeLists.txt | 5 ----- Acquisition/Setup/{Traces/source => bin}/viewBaseline.sh | 0 Acquisition/Setup/{Traces => }/share/traces/plotTraces_ch | 0 Acquisition/Setup/{Traces => }/share/traces/plotTraces_mod | 0 Acquisition/Setup/{Traces => }/share/traces/tra | 0 6 files changed, 3 insertions(+), 5 deletions(-) delete mode 100644 Acquisition/Setup/Traces/CMakeLists.txt rename Acquisition/Setup/{Traces/source => bin}/viewBaseline.sh (100%) rename Acquisition/Setup/{Traces => }/share/traces/plotTraces_ch (100%) rename Acquisition/Setup/{Traces => }/share/traces/plotTraces_mod (100%) rename Acquisition/Setup/{Traces => }/share/traces/tra (100%) diff --git a/Acquisition/Setup/CMakeLists.txt b/Acquisition/Setup/CMakeLists.txt index f85a5c0c9..d00f299e2 100644 --- a/Acquisition/Setup/CMakeLists.txt +++ b/Acquisition/Setup/CMakeLists.txt @@ -15,3 +15,6 @@ target_include_directories(paramScan PUBLIC include ${PROJECT_SOURCE_DIR}/Acquis ${ROOT_INCLUDE_DIR}) target_link_libraries(paramScan PixieInterface MCALibrary ${ROOT_LIBRARIES} "-lSpectrum") install(TARGETS paramScan DESTINATION bin) + +install(DIRECTORY share/traces DESTINATION share) +install(PROGRAMS bin/viewBaseline.sh DESTINATION bin RENAME viewBaseline) diff --git a/Acquisition/Setup/Traces/CMakeLists.txt b/Acquisition/Setup/Traces/CMakeLists.txt deleted file mode 100644 index 6dd8b8cb5..000000000 --- a/Acquisition/Setup/Traces/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -#@authors K. Smith -#install the traces scripts to share. -install(DIRECTORY share/traces DESTINATION share) - -install(PROGRAMS source/viewBaseline.sh DESTINATION bin RENAME viewBaseline) diff --git a/Acquisition/Setup/Traces/source/viewBaseline.sh b/Acquisition/Setup/bin/viewBaseline.sh similarity index 100% rename from Acquisition/Setup/Traces/source/viewBaseline.sh rename to Acquisition/Setup/bin/viewBaseline.sh diff --git a/Acquisition/Setup/Traces/share/traces/plotTraces_ch b/Acquisition/Setup/share/traces/plotTraces_ch similarity index 100% rename from Acquisition/Setup/Traces/share/traces/plotTraces_ch rename to Acquisition/Setup/share/traces/plotTraces_ch diff --git a/Acquisition/Setup/Traces/share/traces/plotTraces_mod b/Acquisition/Setup/share/traces/plotTraces_mod similarity index 100% rename from Acquisition/Setup/Traces/share/traces/plotTraces_mod rename to Acquisition/Setup/share/traces/plotTraces_mod diff --git a/Acquisition/Setup/Traces/share/traces/tra b/Acquisition/Setup/share/traces/tra similarity index 100% rename from Acquisition/Setup/Traces/share/traces/tra rename to Acquisition/Setup/share/traces/tra From 38cf0bb52fa064db1851765dafb6425ee673b734 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sat, 5 Dec 2020 18:22:53 -0500 Subject: [PATCH 25/48] #94: EventReader builds and installs --- Analysis/CMakeLists.txt | 4 +- Analysis/Utilities/CMakeLists.txt | 38 +++++++++---------- Analysis/Utilities/EventReader/CMakeLists.txt | 13 +++++-- .../EventReader/source/CMakeLists.txt | 12 ------ 4 files changed, 31 insertions(+), 36 deletions(-) delete mode 100644 Analysis/Utilities/EventReader/source/CMakeLists.txt diff --git a/Analysis/CMakeLists.txt b/Analysis/CMakeLists.txt index 3a8ca3a00..9e102a525 100644 --- a/Analysis/CMakeLists.txt +++ b/Analysis/CMakeLists.txt @@ -1,6 +1,6 @@ +add_subdirectory(Resources) add_subdirectory(ScanLibraries) -#add_subdirectory(Resources) -#add_subdirectory(Utilities) +add_subdirectory(Utilities) #option(PAASS_USE_HRIBF "Use HRIBF library for scan base." OFF) #if (PAASS_USE_HRIBF) diff --git a/Analysis/Utilities/CMakeLists.txt b/Analysis/Utilities/CMakeLists.txt index 657f08d57..e08cd25ff 100644 --- a/Analysis/Utilities/CMakeLists.txt +++ b/Analysis/Utilities/CMakeLists.txt @@ -10,22 +10,22 @@ if(PAASS_BUILD_EVENT_READER) add_subdirectory(EventReader) endif(PAASS_BUILD_EVENT_READER) -if(PAASS_BUILD_HEAD_READER) - add_subdirectory(HeadReader) -endif(PAASS_BUILD_HEAD_READER) - -if(PAASS_BUILD_HEX_READER) - add_subdirectory(HexReader) -endif(PAASS_BUILD_HEX_READER) - -if(PAASS_BUILD_SKELETON) - add_subdirectory(Skeleton) -endif(PAASS_BUILD_SKELETON) - -if(PAASS_BUILD_ROOT_SCANNER) - add_subdirectory(RootScanner) -endif(PAASS_BUILD_ROOT_SCANNER) - -if(PAASS_BUILD_SCOPE) - add_subdirectory(Scope) -endif(PAASS_BUILD_SCOPE) +#if(PAASS_BUILD_HEAD_READER) +# add_subdirectory(HeadReader) +#endif(PAASS_BUILD_HEAD_READER) +# +#if(PAASS_BUILD_HEX_READER) +# add_subdirectory(HexReader) +#endif(PAASS_BUILD_HEX_READER) +# +#if(PAASS_BUILD_SKELETON) +# add_subdirectory(Skeleton) +#endif(PAASS_BUILD_SKELETON) +# +#if(PAASS_BUILD_ROOT_SCANNER) +# add_subdirectory(RootScanner) +#endif(PAASS_BUILD_ROOT_SCANNER) +# +#if(PAASS_BUILD_SCOPE) +# add_subdirectory(Scope) +#endif(PAASS_BUILD_SCOPE) diff --git a/Analysis/Utilities/EventReader/CMakeLists.txt b/Analysis/Utilities/EventReader/CMakeLists.txt index feb733dea..ebf54b5d1 100644 --- a/Analysis/Utilities/EventReader/CMakeLists.txt +++ b/Analysis/Utilities/EventReader/CMakeLists.txt @@ -1,4 +1,11 @@ -# @author S. V. Paulauskas +add_executable(eventReader source/eventReader.cpp source/EventReaderInterface.cpp source/EventReaderUnpacker.cpp) -include_directories(include) -add_subdirectory(source) \ No newline at end of file +if (PAASS_USE_HRIBF) + target_sources(eventReader $) + target_link_libraries(eventReader ${HRIBF_LIBRARIES}) +endif (PAASS_USE_HRIBF) + +target_link_libraries(eventReader PaassScan ${ROOT_LIBRARIES}) +target_include_directories(eventReader PUBLIC include ${PROJECT_SOURCE_DIR}/Analysis/ScanLibraries/include + ${ROOT_INCLUDE_DIR}) +install(TARGETS eventReader DESTINATION bin) diff --git a/Analysis/Utilities/EventReader/source/CMakeLists.txt b/Analysis/Utilities/EventReader/source/CMakeLists.txt deleted file mode 100644 index eac21314a..000000000 --- a/Analysis/Utilities/EventReader/source/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# @authors C. R. Thornsberry and S. V. Paulauskas - -if (PAASS_USE_HRIBF) - add_executable(eventReader eventReader.cpp EventReaderInterface.cpp EventReaderUnpacker.cpp - $) - target_link_libraries(eventReader ${HRIBF_LIBRARIES}) -else () - add_executable(eventReader eventReader.cpp EventReaderInterface.cpp EventReaderUnpacker.cpp) -endif (PAASS_USE_HRIBF) - -target_link_libraries(eventReader PaassScanStatic ${ROOT_LIBRARIES}) -install(TARGETS eventReader DESTINATION bin) From 489da2cdf5c07402b48da42b07b7a79673f72e7f Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 08:50:32 -0500 Subject: [PATCH 26/48] #94: HeadReader builds and installs --- Analysis/Utilities/CMakeLists.txt | 8 ++++---- Analysis/Utilities/HeadReader/CMakeLists.txt | 8 +++++--- Analysis/Utilities/HeadReader/source/CMakeLists.txt | 5 ----- 3 files changed, 9 insertions(+), 12 deletions(-) delete mode 100644 Analysis/Utilities/HeadReader/source/CMakeLists.txt diff --git a/Analysis/Utilities/CMakeLists.txt b/Analysis/Utilities/CMakeLists.txt index e08cd25ff..e5f15c29a 100644 --- a/Analysis/Utilities/CMakeLists.txt +++ b/Analysis/Utilities/CMakeLists.txt @@ -10,10 +10,10 @@ if(PAASS_BUILD_EVENT_READER) add_subdirectory(EventReader) endif(PAASS_BUILD_EVENT_READER) -#if(PAASS_BUILD_HEAD_READER) -# add_subdirectory(HeadReader) -#endif(PAASS_BUILD_HEAD_READER) -# +if(PAASS_BUILD_HEAD_READER) + add_subdirectory(HeadReader) +endif(PAASS_BUILD_HEAD_READER) + #if(PAASS_BUILD_HEX_READER) # add_subdirectory(HexReader) #endif(PAASS_BUILD_HEX_READER) diff --git a/Analysis/Utilities/HeadReader/CMakeLists.txt b/Analysis/Utilities/HeadReader/CMakeLists.txt index 6d3bc8484..0219bb7ba 100644 --- a/Analysis/Utilities/HeadReader/CMakeLists.txt +++ b/Analysis/Utilities/HeadReader/CMakeLists.txt @@ -1,3 +1,5 @@ -# @author C. R. Thornsberry -include_directories(include) -add_subdirectory(source) \ No newline at end of file +add_executable(headReader source/headReader.cpp) +target_include_directories(headReader PUBLIC ${PROJECT_SOURCE_DIR}/ThirdParty/pugixml/include + ${PROJECT_SOURCE_DIR}/Analysis/ScanLibraries/include ${PROJECT_SOURCE_DIR}/Resources/include) +target_link_libraries(headReader PaassScan Pugixml-1.11.1 PaassResources ${ROOT_LIBRARIES}) +install(TARGETS headReader DESTINATION bin) \ No newline at end of file diff --git a/Analysis/Utilities/HeadReader/source/CMakeLists.txt b/Analysis/Utilities/HeadReader/source/CMakeLists.txt deleted file mode 100644 index 39eb769dd..000000000 --- a/Analysis/Utilities/HeadReader/source/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# @author C. R. Thornsberry -# Install headReader executable. -add_executable(headReader headReader.cpp) -target_link_libraries(headReader PaassScanStatic PugixmlStatic PaassResourceStatic) -install(TARGETS headReader DESTINATION bin) \ No newline at end of file From ed9e9c5cdc68e93f83a76a9c731cc82d6863a114 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 08:51:49 -0500 Subject: [PATCH 27/48] #94: HexReader builds and installs --- Analysis/Utilities/CMakeLists.txt | 8 ++++---- Analysis/Utilities/HexReader/CMakeLists.txt | 5 ++--- Analysis/Utilities/HexReader/source/CMakeLists.txt | 4 ---- 3 files changed, 6 insertions(+), 11 deletions(-) delete mode 100644 Analysis/Utilities/HexReader/source/CMakeLists.txt diff --git a/Analysis/Utilities/CMakeLists.txt b/Analysis/Utilities/CMakeLists.txt index e5f15c29a..d6a00849a 100644 --- a/Analysis/Utilities/CMakeLists.txt +++ b/Analysis/Utilities/CMakeLists.txt @@ -14,10 +14,10 @@ if(PAASS_BUILD_HEAD_READER) add_subdirectory(HeadReader) endif(PAASS_BUILD_HEAD_READER) -#if(PAASS_BUILD_HEX_READER) -# add_subdirectory(HexReader) -#endif(PAASS_BUILD_HEX_READER) -# +if(PAASS_BUILD_HEX_READER) + add_subdirectory(HexReader) +endif(PAASS_BUILD_HEX_READER) + #if(PAASS_BUILD_SKELETON) # add_subdirectory(Skeleton) #endif(PAASS_BUILD_SKELETON) diff --git a/Analysis/Utilities/HexReader/CMakeLists.txt b/Analysis/Utilities/HexReader/CMakeLists.txt index 58e89bda0..5bdc20aa0 100644 --- a/Analysis/Utilities/HexReader/CMakeLists.txt +++ b/Analysis/Utilities/HexReader/CMakeLists.txt @@ -1,3 +1,2 @@ -# @author S. V. Paulauskas - -add_subdirectory(source) \ No newline at end of file +add_executable(hexReader source/hexReader.cpp) +install(TARGETS hexReader DESTINATION bin) diff --git a/Analysis/Utilities/HexReader/source/CMakeLists.txt b/Analysis/Utilities/HexReader/source/CMakeLists.txt deleted file mode 100644 index e5ad81911..000000000 --- a/Analysis/Utilities/HexReader/source/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -# @authors S. V. Paulauskas - -add_executable(hexReader hexReader.cpp) -install(TARGETS hexReader DESTINATION bin) From 0bac09635839131de573d6945fa239c83d206a1a Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 09:00:56 -0500 Subject: [PATCH 28/48] #94: Fixing CI build script --- .travis.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2e7e6bb74..4bcff1cdb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,12 +51,20 @@ before_install: - sudo apt-get -qq update --install-suggests - eval "${MATRIX_EVAL}" - export ORIG_DIR=$PWD - - mkdir -p /opt/plx/ && cd /opt/plx - - git clone https://github.com/spaulaus/plx-api.git && ln -s plx-api current && cd plx-api - - export PLX_SDK_DIR=$PWD && make all && cd ${ORIG_DIR} - - git clone https://github.com/spaulaus/xia-api.git && cd xia-api - - python3 waf configure build install --prefix=${ORIG_DIR} && cd $ORIG_DIR - - export XIA_ROOT_DIR=${ORIG_DIR}/xia + - mkdir -p /opt/plx/ + - cd /opt/plx + - git clone https://github.com/spaulaus/plx-api.git + - cd plx-api + - export PLX_SDK_DIR=$PWD + - make all + - cd ${ORIG_DIR} + - git clone https://github.com/spaulaus/xia-api.git + - cd xia-api + - mkdir build + - cd build + - cmake ../ + - make -j12 -DCMAKE_INSTALL_PREFIX=${ORIG_DIR} + - export XIA_PIXIE_SDK=${ORIG_DIR}/xia/pixie - wget https://root.cern/download/root_v6.22.02.Linux-ubuntu20-x86_64-gcc9.3.tar.gz - tar xzf root_v6.22.02.Linux-ubuntu20-x86_64-gcc9.3.tar.gz - source root/bin/thisroot.sh From 2367075db6b6695df4b15518319653f504dbeda6 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 09:39:27 -0500 Subject: [PATCH 29/48] #94: RootScanner builds and installs --- Analysis/Utilities/CMakeLists.txt | 8 ++++---- Analysis/Utilities/RootScanner/CMakeLists.txt | 12 ++++++++---- Analysis/Utilities/RootScanner/source/CMakeLists.txt | 6 ------ 3 files changed, 12 insertions(+), 14 deletions(-) delete mode 100644 Analysis/Utilities/RootScanner/source/CMakeLists.txt diff --git a/Analysis/Utilities/CMakeLists.txt b/Analysis/Utilities/CMakeLists.txt index d6a00849a..0f5e93166 100644 --- a/Analysis/Utilities/CMakeLists.txt +++ b/Analysis/Utilities/CMakeLists.txt @@ -18,14 +18,14 @@ if(PAASS_BUILD_HEX_READER) add_subdirectory(HexReader) endif(PAASS_BUILD_HEX_READER) +if(PAASS_BUILD_ROOT_SCANNER) + add_subdirectory(RootScanner) +endif(PAASS_BUILD_ROOT_SCANNER) + #if(PAASS_BUILD_SKELETON) # add_subdirectory(Skeleton) #endif(PAASS_BUILD_SKELETON) # -#if(PAASS_BUILD_ROOT_SCANNER) -# add_subdirectory(RootScanner) -#endif(PAASS_BUILD_ROOT_SCANNER) -# #if(PAASS_BUILD_SCOPE) # add_subdirectory(Scope) #endif(PAASS_BUILD_SCOPE) diff --git a/Analysis/Utilities/RootScanner/CMakeLists.txt b/Analysis/Utilities/RootScanner/CMakeLists.txt index bf83a0a61..5da92710f 100644 --- a/Analysis/Utilities/RootScanner/CMakeLists.txt +++ b/Analysis/Utilities/RootScanner/CMakeLists.txt @@ -1,4 +1,8 @@ -# @authors K. Smith - -include_directories(include) -add_subdirectory(source) \ No newline at end of file +root_generate_dictionary(HistScannerDictionary include/HistScannerChanData.hpp LINKDEF include/HistScannerLinkDef.h) +add_executable(rootscan source/HistUnpacker.cpp source/HistScanner.cpp source/HistScannerChanData.cpp + ${CMAKE_CURRENT_BINARY_DIR}/HistScannerDictionary.cxx source/hist.cpp) +target_include_directories(rootscan PUBLIC include ${PROJECT_SOURCE_DIR}/Resources/include + ${PROJECT_SOURCE_DIR}/Analysis/ScanLibraries/include ${PROJECT_SOURCE_DIR}/Analysis/Resources/include + ${ROOT_INCLUDE_DIR}) +target_link_libraries(rootscan PaassScan AnalysisResources Pugixml-1.11.1 PaassResources ${ROOT_LIBRARIES} -lTreePlayer) +install(TARGETS rootscan DESTINATION bin) \ No newline at end of file diff --git a/Analysis/Utilities/RootScanner/source/CMakeLists.txt b/Analysis/Utilities/RootScanner/source/CMakeLists.txt deleted file mode 100644 index 1c72214b2..000000000 --- a/Analysis/Utilities/RootScanner/source/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# @authors K. Smith, S. V. Paulauskas - -root_generate_dictionary(HistScannerDictionary HistScannerChanData.hpp LINKDEF HistScannerLinkDef.h) -add_executable(rootscan HistUnpacker.cpp HistScanner.cpp HistScannerChanData.cpp HistScannerDictionary.cxx hist.cpp) -target_link_libraries(rootscan PaassScanStatic ResourceStatic PugixmlStatic PaassResourceStatic ${ROOT_LIBRARIES} -lTreePlayer) -install(TARGETS rootscan DESTINATION bin) \ No newline at end of file From 0dee74f4dffb9a5cf55b69a9168c357c087e5221 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 10:17:15 -0500 Subject: [PATCH 30/48] #94: Adding GSL library to the linker for AnalysisResources --- .travis.yml | 4 ++-- Analysis/Resources/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4bcff1cdb..36e8a3db0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,8 +62,8 @@ before_install: - cd xia-api - mkdir build - cd build - - cmake ../ - - make -j12 -DCMAKE_INSTALL_PREFIX=${ORIG_DIR} + - cmake ../ -DCMAKE_INSTALL_PREFIX=${ORIG_DIR} + - make -j12 - export XIA_PIXIE_SDK=${ORIG_DIR}/xia/pixie - wget https://root.cern/download/root_v6.22.02.Linux-ubuntu20-x86_64-gcc9.3.tar.gz - tar xzf root_v6.22.02.Linux-ubuntu20-x86_64-gcc9.3.tar.gz diff --git a/Analysis/Resources/CMakeLists.txt b/Analysis/Resources/CMakeLists.txt index 62dde4da8..0b0c95126 100644 --- a/Analysis/Resources/CMakeLists.txt +++ b/Analysis/Resources/CMakeLists.txt @@ -3,8 +3,8 @@ add_library(AnalysisResources SHARED source/ChannelConfiguration.cpp source/Crys source/RootFitter.cpp source/SiPmtFastTimingFunction.cpp source/TimingConfiguration.cpp source/TraceFilter.cpp source/TraditionalCfd.cpp source/VandleTimingFunction.cpp source/XiaCfd.cpp) target_include_directories(AnalysisResources PUBLIC include ${PROJECT_SOURCE_DIR}/Resources/include - ${PROJECT_SOURCE_DIR}/Analysis/ScanLibraries/include) -target_link_libraries(AnalysisResources PaassResources ${ROOT_LIBRARIES}) + ${PROJECT_SOURCE_DIR}/Analysis/ScanLibraries/include ${GSL_INCLUDE_DIRS}) +target_link_libraries(AnalysisResources PaassResources ${ROOT_LIBRARIES} ${GSL_LIBRARIES}) file(GLOB ANALYSIS_RESOURCES_PUBLIC_HEADERS include/*.hpp) set_target_properties(AnalysisResources PROPERTIES PUBLIC_HEADER "${ANALYSIS_RESOURCES_PUBLIC_HEADERS}") From 865733f297a0f15f23ad67a448baafa92b0c75c9 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 10:17:25 -0500 Subject: [PATCH 31/48] #94: Scope builds and installs --- Analysis/Utilities/Scope/CMakeLists.txt | 14 +++++++++++--- Analysis/Utilities/Scope/source/CMakeLists.txt | 10 ---------- 2 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 Analysis/Utilities/Scope/source/CMakeLists.txt diff --git a/Analysis/Utilities/Scope/CMakeLists.txt b/Analysis/Utilities/Scope/CMakeLists.txt index 3cc523f92..1cc0c5be3 100644 --- a/Analysis/Utilities/Scope/CMakeLists.txt +++ b/Analysis/Utilities/Scope/CMakeLists.txt @@ -1,3 +1,11 @@ -# @authors K. Smith -include_directories(include) -add_subdirectory(source) \ No newline at end of file +add_executable(scope source/scope.cpp source/ScopeUnpacker.cpp source/ScopeScanner.cpp) +target_link_libraries(scope PaassResources PaassScan Pugixml-1.11.1 AnalysisResources ${ROOT_LIBRARIES} ${GSL_LIBRARIES}) +target_include_directories(scope PUBLIC include ${PROJECT_SOURCE_DIR}/Resources/include + ${PROJECT_SOURCE_DIR}/ThirdParty/pugixml/include ${PROJECT_SOURCE_DIR}/Analysis/Resources/include + ${ROOT_INCLUDE_DIR} ${GSL_INCLUDE_DIRS}) + +if (PAASS_USE_HRIBF) + target_link_libraries(scope PaassScanor ${HRIBF_LIBRARIES}) +endif (PAASS_USE_HRIBF) + +install(TARGETS scope DESTINATION bin) \ No newline at end of file diff --git a/Analysis/Utilities/Scope/source/CMakeLists.txt b/Analysis/Utilities/Scope/source/CMakeLists.txt deleted file mode 100644 index 0994d9ce4..000000000 --- a/Analysis/Utilities/Scope/source/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# @authors C. R. Thornsberry, K. Smith, S. V. Paulauskas -if (PAASS_USE_HRIBF) - add_executable(scope scope.cpp ScopeUnpacker.cpp ScopeScanner.cpp $) - target_link_libraries(scope ${HRIBF_LIBRARIES}) -else () - add_executable(scope scope.cpp ScopeUnpacker.cpp ScopeScanner.cpp) -endif (PAASS_USE_HRIBF) - -target_link_libraries(scope PaassResourceStatic PaassScanStatic PugixmlStatic ResourceStatic ${ROOT_LIBRARIES}) -install(TARGETS scope DESTINATION bin) \ No newline at end of file From 7a1769a97a010013c753f6ae8b840d7bba5ecc28 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 10:22:17 -0500 Subject: [PATCH 32/48] #94: Skeleton builds and installs --- Analysis/Utilities/CMakeLists.txt | 14 +++++++------- Analysis/Utilities/Skeleton/CMakeLists.txt | 14 +++++++++++--- Analysis/Utilities/Skeleton/source/CMakeLists.txt | 10 ---------- 3 files changed, 18 insertions(+), 20 deletions(-) delete mode 100644 Analysis/Utilities/Skeleton/source/CMakeLists.txt diff --git a/Analysis/Utilities/CMakeLists.txt b/Analysis/Utilities/CMakeLists.txt index 0f5e93166..4680cb3c1 100644 --- a/Analysis/Utilities/CMakeLists.txt +++ b/Analysis/Utilities/CMakeLists.txt @@ -22,10 +22,10 @@ if(PAASS_BUILD_ROOT_SCANNER) add_subdirectory(RootScanner) endif(PAASS_BUILD_ROOT_SCANNER) -#if(PAASS_BUILD_SKELETON) -# add_subdirectory(Skeleton) -#endif(PAASS_BUILD_SKELETON) -# -#if(PAASS_BUILD_SCOPE) -# add_subdirectory(Scope) -#endif(PAASS_BUILD_SCOPE) +if(PAASS_BUILD_SCOPE) + add_subdirectory(Scope) +endif(PAASS_BUILD_SCOPE) + +if(PAASS_BUILD_SKELETON) + add_subdirectory(Skeleton) +endif(PAASS_BUILD_SKELETON) diff --git a/Analysis/Utilities/Skeleton/CMakeLists.txt b/Analysis/Utilities/Skeleton/CMakeLists.txt index 6d3bc8484..27f3cc119 100644 --- a/Analysis/Utilities/Skeleton/CMakeLists.txt +++ b/Analysis/Utilities/Skeleton/CMakeLists.txt @@ -1,3 +1,11 @@ -# @author C. R. Thornsberry -include_directories(include) -add_subdirectory(source) \ No newline at end of file +add_executable(skeleton source/Skeleton.cpp source/SkeletonUnpacker.cpp source/SkeletonInterface.cpp) +target_include_directories(skeleton PUBLIC include ${PROJECT_SOURCE_DIR}/Analysis/ScanLibraries/include + ${PROJECT_SOURCE_DIR}/ThirdParty/pugixml/include ${PROJECT_SOURCE_DIR}/Resources/include + ${ROOT_INCLUDE_DIR}) +target_link_libraries(skeleton PaassScan Pugixml-1.11.1 PaassResources ${ROOT_LIBRARIES}) + +if (PAASS_USE_HRIBF) + target_link_libraries(skeleton PaassScanor ${HRIBF_LIBRARIES}) +endif (PAASS_USE_HRIBF) + +install(TARGETS skeleton DESTINATION bin) diff --git a/Analysis/Utilities/Skeleton/source/CMakeLists.txt b/Analysis/Utilities/Skeleton/source/CMakeLists.txt deleted file mode 100644 index 7e91ea4b3..000000000 --- a/Analysis/Utilities/Skeleton/source/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# @authors C. R. Thornsberry, S. V. Paulauskas -if (PAASS_USE_HRIBF) - add_executable(skeleton Skeleton.cpp SkeletonUnpacker.cpp SkeletonInterface.cpp $) - target_link_libraries(skeleton ${HRIBF_LIBRARIES}) -else () - add_executable(skeleton Skeleton.cpp SkeletonUnpacker.cpp SkeletonInterface.cpp) -endif (PAASS_USE_HRIBF) - -target_link_libraries(skeleton PaassScanStatic PugixmlStatic PaassResourceStatic) -install(TARGETS skeleton DESTINATION bin) From 145c54e184725bb831febd26cad989da7f207f4a Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 11:11:45 -0500 Subject: [PATCH 33/48] #94: utkscan builds and installs --- Analysis/CMakeLists.txt | 8 +- Analysis/Utkscan/CMakeLists.txt | 183 ++++++++---------- Analysis/Utkscan/analyzers/CMakeLists.txt | 12 +- .../Utkscan/analyzers/source/CMakeLists.txt | 7 - Analysis/Utkscan/core/CMakeLists.txt | 27 ++- Analysis/Utkscan/core/source/CMakeLists.txt | 18 -- Analysis/Utkscan/experiment/CMakeLists.txt | 18 +- .../Utkscan/experiment/source/CMakeLists.txt | 18 -- Analysis/Utkscan/processors/CMakeLists.txt | 31 ++- .../Utkscan/processors/source/CMakeLists.txt | 31 --- 10 files changed, 164 insertions(+), 189 deletions(-) delete mode 100644 Analysis/Utkscan/analyzers/source/CMakeLists.txt delete mode 100644 Analysis/Utkscan/core/source/CMakeLists.txt delete mode 100644 Analysis/Utkscan/experiment/source/CMakeLists.txt delete mode 100644 Analysis/Utkscan/processors/source/CMakeLists.txt diff --git a/Analysis/CMakeLists.txt b/Analysis/CMakeLists.txt index 9e102a525..d809ffb1a 100644 --- a/Analysis/CMakeLists.txt +++ b/Analysis/CMakeLists.txt @@ -1,6 +1,7 @@ add_subdirectory(Resources) add_subdirectory(ScanLibraries) add_subdirectory(Utilities) +add_subdirectory(Utkscan) #option(PAASS_USE_HRIBF "Use HRIBF library for scan base." OFF) #if (PAASS_USE_HRIBF) @@ -14,9 +15,4 @@ add_subdirectory(Utilities) # include_directories(Scanor/include) # add_subdirectory(Scanor) #endif (PAASS_USE_HRIBF) -# -# -#option(PAASS_BUILD_UTKSCAN "Build utkscan" OFF) -#if (PAASS_BUILD_UTKSCAN) -# add_subdirectory(Utkscan) -#endif (PAASS_BUILD_UTKSCAN) + diff --git a/Analysis/Utkscan/CMakeLists.txt b/Analysis/Utkscan/CMakeLists.txt index fe47876e2..206571257 100644 --- a/Analysis/Utkscan/CMakeLists.txt +++ b/Analysis/Utkscan/CMakeLists.txt @@ -1,101 +1,82 @@ -# @author S. V. Paulauskas -option(PAASS_UTKSCAN_GAMMA_GATES "Gamma-Gamma gates in GeProcessor" OFF) -option(PAASS_UTKSCAN_ONLINE "Options for online scans" OFF) -option(PAASS_UTKSCAN_TREE_DEBUG "Debugging info for TreeCorrelator" OFF) -option(PAASS_UTKSCAN_VERBOSE "Make Scan More Verbose" OFF) - -mark_as_advanced(PAASS_UTKSCAN_GAMMA_GATES PAASS_UTKSCAN_ONLINE PAASS_UTKSCAN_TREE_DEBUG PAASS_UTKSCAN_VERBOSE) - -# newreadout is needed to account for a change to pixie16 readout -# structure change on 03/20/08. Is is REQUIRED!! -# @TODO : Need to determine if this is still required by the scan code. -add_definitions(-D newreadout) - -#utkscan will have Gamma-Gamma gating in the CloverProcessor and GammaScintProcessor -if (PAASS_UTKSCAN_GAMMA_GATES) - add_definitions(-DGGATES) -endif (PAASS_UTKSCAN_GAMMA_GATES) - -#utkscan will be streamlined for online processing -if (PAASS_UTKSCAN_ONLINE) - add_definitions(-DONLINE) -endif (PAASS_UTKSCAN_ONLINE) - -#utkscan will have debugging for the TreeCorrelator -if (PAASS_UTKSCAN_TREE_DEBUG) - add_definitions(-DTREE_DEBUG) -endif (PAASS_UTKSCAN_TREE_DEBUG) - -#utkscan will be more verbose in its output -if (PAASS_UTKSCAN_VERBOSE) - add_definitions(-DVERBOSE) -endif (PAASS_UTKSCAN_VERBOSE) - -#------------------------------------------------------------------------------ - -#added by T.T. King for Vector Root Libs -SET(CMAKE_SKIP_BUILD_RPATH FALSE) -SET(CMAKE_SKIP_INSTALL_RPATH FALSE) -SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - -SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - -ROOT_GENERATE_DICTIONARY(PaassRootStruct core/include/PaassRootStruct.hpp LINKDEF core/include/PaassRootLinkDef.hpp ) -add_library(PaassRootStruct SHARED PaassRootStruct.cxx PaassRootStruct) -install(TARGETS PaassRootStruct DESTINATION lib) - -install(FILES ${CMAKE_SOURCE_DIR}/Analysis/Utkscan/core/include/PaassRootStruct.hpp DESTINATION include/) -#Install the ROOT 6 PCM. -if (${ROOT_VERSION} VERSION_GREATER "6.0") - install( FILES ${CMAKE_CURRENT_BINARY_DIR}/PaassRootStruct_rdict.pcm DESTINATION lib/) -endif (${ROOT_VERSION} VERSION_GREATER "6.0") -#End T.T. King Additions - -#------------------------------------------------------------------------------ - -include_directories(analyzers/include core/include experiment/include processors/include) -add_subdirectory(analyzers) -add_subdirectory(core) -add_subdirectory(experiment) -add_subdirectory(processors) - -#------------------------------------------------------------------------------ - -if (NOT PAASS_USE_HRIBF) - set(SCAN_NAME utkscan) - add_executable(${SCAN_NAME} - $ - $ - $ - $ - $ - PaassRootStruct.cxx) -else (PAASS_USE_HRIBF) - set(SCAN_NAME utkscanor) - add_executable(${SCAN_NAME} - $ - $ - $ - $ - $ - $ - PaassRootStruct.cxx) - target_link_libraries(utkscanor ${HRIBF_LIBRARIES}) -endif (NOT PAASS_USE_HRIBF) - -target_link_libraries(${SCAN_NAME} ${LIBS} PaassScanStatic ResourceStatic PaassCoreStatic PugixmlStatic - PaassResourceStatic ${GSL_LIBRARIES} ${ROOT_LIBRARIES}) - -#------------------------------------------------------------------------------ - -install(TARGETS ${SCAN_NAME} DESTINATION bin) -install(DIRECTORY share/utkscan DESTINATION share) -install(TARGETS PaassRootStruct DESTINATION lib) - -install(FILES ${CMAKE_SOURCE_DIR}/Analysis/Utkscan/core/include/PaassRootStruct.hpp DESTINATION include/) -install(FILES ${CMAKE_SOURCE_DIR}/Analysis/Utkscan/processors/include/GSaddback.hpp DESTINATION include/) -#Install the ROOT 6 PCM. -if (${ROOT_VERSION} VERSION_GREATER "6.0") - install( FILES ${CMAKE_CURRENT_BINARY_DIR}/PaassRootStruct_rdict.pcm DESTINATION lib/) -endif (${ROOT_VERSION} VERSION_GREATER "6.0") +option(PAASS_BUILD_UTKSCAN "Build utkscan" ON) +if (PAASS_BUILD_UTKSCAN) + #------------------------------------------------------------------------------ + if (NOT PAASS_USE_HRIBF) + set(UTKSCAN_NAME utkscan) + add_executable(${UTKSCAN_NAME} core/source/utkscan.cpp) + else (PAASS_USE_HRIBF) + set(UTKSCAN_NAME utkscanor) + add_executable(${UTKSCAN_NAME} core/source/utkscanor.cpp) + endif (NOT PAASS_USE_HRIBF) + + #------------------------------------------------------------------------------ + + option(PAASS_UTKSCAN_GAMMA_GATES "Gamma-Gamma gates in GeProcessor" OFF) + option(PAASS_UTKSCAN_ONLINE "Options for online scans" OFF) + option(PAASS_UTKSCAN_TREE_DEBUG "Debugging info for TreeCorrelator" OFF) + option(PAASS_UTKSCAN_VERBOSE "Make Scan More Verbose" OFF) + + mark_as_advanced(PAASS_UTKSCAN_GAMMA_GATES PAASS_UTKSCAN_ONLINE PAASS_UTKSCAN_TREE_DEBUG PAASS_UTKSCAN_VERBOSE) + + # newreadout is needed to account for a change to pixie16 readout + # structure change on 03/20/08. Is is REQUIRED!! + # @TODO : Need to determine if this is still required by the scan code. + target_compile_definitions(${UTKSCAN_NAME} PUBLIC -Dnewreadout) + + if (PAASS_UTKSCAN_GAMMA_GATES) + target_compile_definitions(${UTKSCAN_NAME} PUBLIC -DGGATES) + endif (PAASS_UTKSCAN_GAMMA_GATES) + + if (PAASS_UTKSCAN_ONLINE) + target_compile_definitions(${UTKSCAN_NAME} PUBLIC -DONLINE) + endif (PAASS_UTKSCAN_ONLINE) + + if (PAASS_UTKSCAN_TREE_DEBUG) + target_compile_definitions(${UTKSCAN_NAME} PUBLIC -DTREE_DEBUG) + endif (PAASS_UTKSCAN_TREE_DEBUG) + + if (PAASS_UTKSCAN_VERBOSE) + target_compile_definitions(${UTKSCAN_NAME} PUBLIC -DVERBOSE) + endif (PAASS_UTKSCAN_VERBOSE) + + #------------------------------------------------------------------------------ + + add_subdirectory(analyzers) + add_subdirectory(core) + add_subdirectory(experiment) + add_subdirectory(processors) + + #------------------------------------------------------------------------------ + + ROOT_GENERATE_DICTIONARY(PaassRootStruct core/include/PaassRootStruct.hpp LINKDEF core/include/PaassRootLinkDef.hpp) + add_library(PaassRootStruct SHARED ${CMAKE_CURRENT_BINARY_DIR}/PaassRootStruct.cxx PaassRootStruct) + target_link_libraries(PaassRootStruct ${ROOT_LIBRARIES}) + target_include_directories(PaassRootStruct PUBLIC ${ROOT_INCLUDE_DIR}) + + #------------------------------------------------------------------------------ + + target_link_libraries(${UTKSCAN_NAME} PaassScan AnalysisResources PaassCore Pugixml-1.11.1 + PaassResources ${GSL_LIBRARIES} ${ROOT_LIBRARIES} PaassRootStruct) + + target_include_directories(${UTKSCAN_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/Analysis/Resources/include + ${PROJECT_SOURCE_DIR}/Analysis/ScanLibraries/include ${PROJECT_SOURCE_DIR}/ThirdParty/pugixml/include + ${PROJECT_SOURCE_DIR}/Resources/include ${PROJECT_SOURCE_DIR}/Core/include ${ROOT_INCLUDE_DIR} + ${GSL_INCLUDE_DIR}) + + if (PAASS_USE_HRIBF) + target_link_libraries(${UTKSCAN_NAME} ${HRIBF_LIBRARIES}) + target_include_directories(${UTKSCAN_NAME} ${PROJECT_SOURCE_DIR}/Analysis/Scanor/include) + endif (PAASS_USE_HRIBF) + + #------------------------------------------------------------------------------ + + install(TARGETS ${UTKSCAN_NAME} DESTINATION bin) + install(TARGETS PaassRootStruct DESTINATION lib) + install(DIRECTORY share/utkscan DESTINATION share) + + install(FILES core/include/PaassRootStruct.hpp DESTINATION include/) + install(FILES processors/include/GSaddback.hpp DESTINATION include/) + if (${ROOT_VERSION} VERSION_GREATER "6.0") + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PaassRootStruct_rdict.pcm DESTINATION lib/) + endif (${ROOT_VERSION} VERSION_GREATER "6.0") +endif (PAASS_BUILD_UTKSCAN) diff --git a/Analysis/Utkscan/analyzers/CMakeLists.txt b/Analysis/Utkscan/analyzers/CMakeLists.txt index b1a7b7181..2c7fd60a6 100644 --- a/Analysis/Utkscan/analyzers/CMakeLists.txt +++ b/Analysis/Utkscan/analyzers/CMakeLists.txt @@ -1,2 +1,10 @@ -# @author S. V. Paulauskas -add_subdirectory(source) \ No newline at end of file +target_sources(${UTKSCAN_NAME} PUBLIC + source/CfdAnalyzer.cpp + source/FittingAnalyzer.cpp + source/TauAnalyzer.cpp + source/TraceExtractor.cpp + source/TraceFilterAnalyzer.cpp + source/TraceAnalyzer.cpp + source/WaaAnalyzer.cpp + source/WaveformAnalyzer.cpp) +target_include_directories(${UTKSCAN_NAME} PUBLIC include) \ No newline at end of file diff --git a/Analysis/Utkscan/analyzers/source/CMakeLists.txt b/Analysis/Utkscan/analyzers/source/CMakeLists.txt deleted file mode 100644 index 8d7707bf7..000000000 --- a/Analysis/Utkscan/analyzers/source/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# @author S. V. Paulauskas, K. Smith -set(UTKSCAN_ANALYZER_SOURCES CfdAnalyzer.cpp FittingAnalyzer.cpp TauAnalyzer.cpp TraceExtractor.cpp - TraceFilterAnalyzer.cpp TraceAnalyzer.cpp WaaAnalyzer.cpp WaveformAnalyzer.cpp) -add_library(UtkscanAnalyzerObjects OBJECT ${UTKSCAN_ANALYZER_SOURCES}) - - - diff --git a/Analysis/Utkscan/core/CMakeLists.txt b/Analysis/Utkscan/core/CMakeLists.txt index 05c382896..f316db84d 100644 --- a/Analysis/Utkscan/core/CMakeLists.txt +++ b/Analysis/Utkscan/core/CMakeLists.txt @@ -1,2 +1,25 @@ -add_subdirectory(source) - +target_sources(${UTKSCAN_NAME} PUBLIC + source/BarBuilder.cpp + source/Calibrator.cpp + source/Correlator.cpp + source/DetectorDriver.cpp + source/DetectorDriverXmlParser.cpp + source/DetectorLibrary.cpp + source/DetectorSummary.cpp + source/Globals.cpp + source/GlobalsXmlParser.cpp + source/MapNodeXmlParser.cpp + source/Places.cpp + source/PlaceBuilder.cpp + source/Plots.cpp + source/PlotsRegister.cpp + source/RawEvent.cpp + source/RootHandler.cpp + source/TimingCalibrator.cpp + source/TimingMapBuilder.cpp + source/TreeCorrelator.cpp + source/TreeCorrelatorXmlParser.cpp + source/UtkScanInterface.cpp + source/UtkUnpacker.cpp + source/WalkCorrector.cpp) +target_include_directories(${UTKSCAN_NAME} PUBLIC include) \ No newline at end of file diff --git a/Analysis/Utkscan/core/source/CMakeLists.txt b/Analysis/Utkscan/core/source/CMakeLists.txt deleted file mode 100644 index ecfe13395..000000000 --- a/Analysis/Utkscan/core/source/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# @author S. V. Paulauskas -set(CORE_SOURCES BarBuilder.cpp Calibrator.cpp DetectorDriver.cpp DetectorDriverXmlParser.cpp DetectorLibrary.cpp - DetectorSummary.cpp Globals.cpp GlobalsXmlParser.cpp MapNodeXmlParser.cpp RawEvent.cpp TimingCalibrator.cpp - TimingMapBuilder.cpp UtkScanInterface.cpp UtkUnpacker.cpp WalkCorrector.cpp) - -set(CORRELATION_SOURCES Correlator.cpp PlaceBuilder.cpp Places.cpp TreeCorrelator.cpp TreeCorrelatorXmlParser.cpp) - -set(PLOTTING_SOURCES Plots.cpp PlotsRegister.cpp RootHandler.cpp) - -if (NOT PAASS_USE_HRIBF) - set(MAIN_SOURCES utkscan.cpp) -else (PAASS_USE_HRIBF) - set(MAIN_SOURCES utkscanor.cpp) -endif (NOT PAASS_USE_HRIBF) - -add_library(UtkscanMainObjects OBJECT ${MAIN_SOURCES}) - -add_library(UtkscanCoreObjects OBJECT ${CORE_SOURCES} ${CORRELATION_SOURCES} ${PLOTTING_SOURCES}) diff --git a/Analysis/Utkscan/experiment/CMakeLists.txt b/Analysis/Utkscan/experiment/CMakeLists.txt index 4a363afda..9aa98821c 100644 --- a/Analysis/Utkscan/experiment/CMakeLists.txt +++ b/Analysis/Utkscan/experiment/CMakeLists.txt @@ -1,2 +1,16 @@ -#@author S. V. Paulauskas -add_subdirectory(source) +target_sources(${UTKSCAN_NAME} PUBLIC + source/Anl1471Processor.cpp + #source/Beta4Hen3Processor.cpp + #source/CrosstalkProcessor.cpp + #source/Dssd4SHEProcessor.cpp + source/E11027Processor.cpp + #source/Ge4Hen3Processor.cpp + source/IS600Processor.cpp + #source/LaBr3TestProcessor.cpp + source/SheCorrelator.cpp + source/TemplateExpProcessor.cpp + source/TwoChanTimingProcessor.cpp + source/VandleOrnl2012Processor.cpp + #source/WalkVandleBetaProcessor.cpp + ) +target_include_directories(${UTKSCAN_NAME} PUBLIC include) \ No newline at end of file diff --git a/Analysis/Utkscan/experiment/source/CMakeLists.txt b/Analysis/Utkscan/experiment/source/CMakeLists.txt deleted file mode 100644 index fb53cd102..000000000 --- a/Analysis/Utkscan/experiment/source/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -#@authors S. V. Paulauskas -set(EXPERIMENT_SOURCES - Anl1471Processor.cpp - #Beta4Hen3Processor.cpp - #CrosstalkProcessor.cpp - #Dssd4SHEProcessor.cpp - E11027Processor.cpp - #Ge4Hen3Processor.cpp - IS600Processor.cpp - #LaBr3TestProcessor.cpp - SheCorrelator.cpp - TemplateExpProcessor.cpp - TwoChanTimingProcessor.cpp - VandleOrnl2012Processor.cpp - #WalkVandleBetaProcessor.cpp - ) - -add_library(UtkscanExperimentObjects OBJECT ${EXPERIMENT_SOURCES}) diff --git a/Analysis/Utkscan/processors/CMakeLists.txt b/Analysis/Utkscan/processors/CMakeLists.txt index 5f0c34f08..a408b4ab8 100644 --- a/Analysis/Utkscan/processors/CMakeLists.txt +++ b/Analysis/Utkscan/processors/CMakeLists.txt @@ -1,2 +1,29 @@ -#@authors S. V. Paulauskas -add_subdirectory(source) \ No newline at end of file +target_sources(${UTKSCAN_NAME} PUBLIC + source/BetaScintProcessor.cpp + source/DoubleBetaProcessor.cpp + source/CloverCalibProcessor.cpp + source/CloverFragProcessor.cpp + source/CloverProcessor.cpp + source/DssdProcessor.cpp + source/EventProcessor.cpp + source/ExtTSSenderProcessor.cpp + source/GammaScintProcessor.cpp + source/GammaScintFragProcessor.cpp + source/GeProcessor.cpp + source/Hen3Processor.cpp + source/ImplantSsdProcessor.cpp + source/IonChamberProcessor.cpp + source/LiquidScintProcessor.cpp + source/LitePositionProcessor.cpp + source/LogicProcessor.cpp + source/McpProcessor.cpp + source/NeutronScintProcessor.cpp + source/PositionProcessor.cpp + source/PspmtProcessor.cpp + source/RootDevProcessor.cpp + source/SingleBetaProcessor.cpp + source/TeenyVandleProcessor.cpp + source/TemplateProcessor.cpp + source/VandleProcessor.cpp + ) +target_include_directories(${UTKSCAN_NAME} PUBLIC include) diff --git a/Analysis/Utkscan/processors/source/CMakeLists.txt b/Analysis/Utkscan/processors/source/CMakeLists.txt deleted file mode 100644 index 2f2a2a5cd..000000000 --- a/Analysis/Utkscan/processors/source/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# @authors S. V. Paulauskas -set(PROCESSOR_SOURCES - BetaScintProcessor.cpp - DoubleBetaProcessor.cpp - CloverCalibProcessor.cpp - CloverFragProcessor.cpp - CloverProcessor.cpp - DssdProcessor.cpp - EventProcessor.cpp - ExtTSSenderProcessor.cpp - GammaScintProcessor.cpp - GammaScintFragProcessor.cpp - GeProcessor.cpp - Hen3Processor.cpp - ImplantSsdProcessor.cpp - IonChamberProcessor.cpp - LiquidScintProcessor.cpp - LitePositionProcessor.cpp - LogicProcessor.cpp - McpProcessor.cpp - NeutronScintProcessor.cpp - PositionProcessor.cpp - PspmtProcessor.cpp - RootDevProcessor.cpp - SingleBetaProcessor.cpp - TeenyVandleProcessor.cpp - TemplateProcessor.cpp - VandleProcessor.cpp - ) - -add_library(UtkscanProcessorObjects OBJECT ${PROCESSOR_SOURCES}) From 025f1115848a153d30c169b5da575b51ef72c119 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 12:09:56 -0500 Subject: [PATCH 34/48] #94: Adding GSL Option to AnalysisResources to allow GSL 1.X or 2.X usage. --- Analysis/Resources/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Analysis/Resources/CMakeLists.txt b/Analysis/Resources/CMakeLists.txt index 0b0c95126..6d0595a05 100644 --- a/Analysis/Resources/CMakeLists.txt +++ b/Analysis/Resources/CMakeLists.txt @@ -2,6 +2,11 @@ add_library(AnalysisResources SHARED source/ChannelConfiguration.cpp source/Crys source/CsiFunction.cpp source/EmCalTimingFunction.cpp source/GslFitter.cpp source/PolynomialCfd.cpp source/RootFitter.cpp source/SiPmtFastTimingFunction.cpp source/TimingConfiguration.cpp source/TraceFilter.cpp source/TraditionalCfd.cpp source/VandleTimingFunction.cpp source/XiaCfd.cpp) + +if (${GSL_VERSION} LESS 2.0) + target_compile_definitions(AnalysisResource "-DGSL_VERSION_ONE") +endif (${GSL_VERSION} LESS 2.0) + target_include_directories(AnalysisResources PUBLIC include ${PROJECT_SOURCE_DIR}/Resources/include ${PROJECT_SOURCE_DIR}/Analysis/ScanLibraries/include ${GSL_INCLUDE_DIRS}) target_link_libraries(AnalysisResources PaassResources ${ROOT_LIBRARIES} ${GSL_LIBRARIES}) From a92082c8a4262601bf8b570e5f2bd719ffb2cde0 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 12:12:41 -0500 Subject: [PATCH 35/48] #94: Adding compilation flag to PixieInterface to ensure we get the Linux version of Pixie SDK --- Acquisition/Interface/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Acquisition/Interface/CMakeLists.txt b/Acquisition/Interface/CMakeLists.txt index d355b93d0..c77a7fd82 100644 --- a/Acquisition/Interface/CMakeLists.txt +++ b/Acquisition/Interface/CMakeLists.txt @@ -2,7 +2,7 @@ add_library(PixieInterface SHARED source/PixieInterface.cpp source/Lock.cpp sour target_include_directories(PixieInterface PUBLIC include ${PROJECT_SOURCE_DIR}/Core/include ${XIA_INCLUDE_DIR}) target_link_directories(PixieInterface PUBLIC ${XIA_LIBRARY_DIR} ${PLX_LIBRARY_DIR}) target_link_libraries(PixieInterface PaassCore ${XIA_LIBRARIES} ${PLX_LIBRARIES}) -target_compile_options(PixieInterface PRIVATE "-fPIC") +target_compile_options(PixieInterface PRIVATE "-DPLX_LINUX") file(GLOB PIXIE_INTERFACE_PUBLIC_HEADERS include/*.h) set_target_properties(PixieInterface PROPERTIES PUBLIC_HEADER "${PIXIE_INTERFACE_PUBLIC_HEADERS}") From 13ebfcb44b26a0939b6a8dc002154138bd58531b Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 12:17:22 -0500 Subject: [PATCH 36/48] #94: Cleaning up the root directory's CMakeLists.txt --- CMakeLists.txt | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e67333a25..dcba7d43a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,28 +39,28 @@ if (CMAKE_BUILD_TYPE MATCHES "Debug") endif (CMAKE_BUILD_TYPE MATCHES "Debug") #------------------------------------------------------------------------------ -#We are going to include this additional module here since it could be useful -#when setting all of the following options. include(CMakeDependentOption) -#Install options option(PAASS_BUILD_ACQ "Build and install Acquisition software" ON) option(PAASS_BUILD_ANALYSIS "Build analysis related programs" ON) option(PAASS_BUILD_TESTS "Builds programs designed to test the package." OFF) +#------------------------------------------------------------------------------ + option(PAASS_EXPORT_COMPILE_COMMANDS "CMAKE_EXPORT_COMPILE_COMMANDS WRAPPER" ON) mark_as_advanced(PAASS_EXPORT_COMPILE_COMMANDS) #Generate the compile_commands.json file which is used by VSCode (among others) to generate the clang autocomplete #Needs the PAASS_EXPORT_COMPILE_COMMANDS wrapper because of the "FORCE" which is required to even set the var from CMakeList.txt, #while maintaining the ability to toggle it on/off without wiping the build dir -if(PAASS_EXPORT_COMPILE_COMMANDS) +if (PAASS_EXPORT_COMPILE_COMMANDS) set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Generates compile_commands.json, needed for some IDEs among other things" FORCE) else () - set(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL "Generates compile_commands.json, needed for some IDEs among other things" FORCE) + set(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL "Generates compile_commands.json, needed for some IDEs among other things" FORCE) endif (PAASS_EXPORT_COMPILE_COMMANDS) #------------------------------------------------------------------------------ + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/Cmake/modules/") find_package(Threads REQUIRED) @@ -74,23 +74,15 @@ mark_as_advanced(FORCE GENREFLEX_EXECUTABLE ROOTCINT_EXECUTABLE ROOT_CONFIG_EXEC add_definitions("-D USE_ROOT") find_package(GSL REQUIRED) -if (${GSL_VERSION} LESS 2.0) - add_definitions("-D GSL_VERSION_ONE") -endif (${GSL_VERSION} LESS 2.0) +#------------------------------------------------------------------------------ +add_subdirectory(Acquisition) +add_subdirectory(Analysis) +add_subdirectory(Core) +add_subdirectory(Resources) +add_subdirectory(Share) #if (PAASS_BUILD_TESTS) # add_subdirectory(Tests) # enable_testing() #endif (PAASS_BUILD_TESTS) - -#------------------------------------------------------------------------------ add_subdirectory(ThirdParty) -add_subdirectory(Resources) -add_subdirectory(Core) -add_subdirectory(Acquisition) -#if (PAASS_BUILD_ANALYSIS) -add_subdirectory(Analysis) -#endif (PAASS_BUILD_ANALYSIS) - -#Build/install the miscellaneous stuff -#add_subdirectory(Share) From c9058230c288feaf9bfb8966109ce67026f5e57f Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 12:31:00 -0500 Subject: [PATCH 37/48] #94: Ensuring tests pass and CTerminalTest builds. We're not installing this binary as it's meant for test purposes. --- CMakeLists.txt | 10 +++++----- Tests/CMakeLists.txt | 12 +++--------- Tests/functional/CMakeLists.txt | 5 ++--- Tests/functional/{ => source}/CTerminalTest.cpp | 0 4 files changed, 10 insertions(+), 17 deletions(-) rename Tests/functional/{ => source}/CTerminalTest.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index dcba7d43a..94008fdc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ include(CMakeDependentOption) option(PAASS_BUILD_ACQ "Build and install Acquisition software" ON) option(PAASS_BUILD_ANALYSIS "Build analysis related programs" ON) -option(PAASS_BUILD_TESTS "Builds programs designed to test the package." OFF) +option(PAASS_BUILD_TESTS "Builds programs designed to test the package." ON) #------------------------------------------------------------------------------ @@ -81,8 +81,8 @@ add_subdirectory(Analysis) add_subdirectory(Core) add_subdirectory(Resources) add_subdirectory(Share) -#if (PAASS_BUILD_TESTS) -# add_subdirectory(Tests) -# enable_testing() -#endif (PAASS_BUILD_TESTS) +if (PAASS_BUILD_TESTS) + add_subdirectory(Tests) + enable_testing() +endif (PAASS_BUILD_TESTS) add_subdirectory(ThirdParty) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 1d7b88736..9a7bacdfe 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1,18 +1,12 @@ -#Check if GSL is installed -find_package(GSL REQUIRED) -include_directories(${GSL_INCLUDE_DIRS}) -link_directories(${GSL_LIBRARY_DIRS}) -if (${GSL_VERSION} LESS 2.0) - add_definitions("-D GSL_VERSION_ONE") -endif (${GSL_VERSION} LESS 2.0) - add_executable(tests tests.cpp) -target_include_directories(tests PUBLIC ${PROJECT_SOURCE_DIR}/ThirdParty/doctest include) +target_include_directories(tests PUBLIC ${PROJECT_SOURCE_DIR}/ThirdParty/doctest include ${ROOT_INCLUDE_DIR} + ${GSL_INCLUDE_DIR}) target_link_libraries(tests PUBLIC ${ROOT_LIBRARIES} ${GSL_LIBRARIES}) add_subdirectory(unit/analysis/resources) add_subdirectory(unit/analysis/scan_libraries) add_subdirectory(unit/analysis/utkscan/core) add_subdirectory(unit/resources) +add_subdirectory(functional) add_test(Tests tests) \ No newline at end of file diff --git a/Tests/functional/CMakeLists.txt b/Tests/functional/CMakeLists.txt index 12e2782e9..b99173a0d 100644 --- a/Tests/functional/CMakeLists.txt +++ b/Tests/functional/CMakeLists.txt @@ -1,3 +1,2 @@ -add_executable(CTerminalTest tests/CTerminalTest.cpp) -target_link_libraries(CTerminalTest PaassCoreStatic) -install(TARGETS CTerminalTest DESTINATION bin) \ No newline at end of file +add_executable(CTerminalTest source/CTerminalTest.cpp) +target_link_libraries(CTerminalTest PaassCore) \ No newline at end of file diff --git a/Tests/functional/CTerminalTest.cpp b/Tests/functional/source/CTerminalTest.cpp similarity index 100% rename from Tests/functional/CTerminalTest.cpp rename to Tests/functional/source/CTerminalTest.cpp From 4b37a3f718c6ba8469aac93d5830e076343b25ec Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 12:40:40 -0500 Subject: [PATCH 38/48] #94: Adding missing compiler flag to Setup utilities --- Acquisition/Setup/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Acquisition/Setup/CMakeLists.txt b/Acquisition/Setup/CMakeLists.txt index d00f299e2..d05e21a67 100644 --- a/Acquisition/Setup/CMakeLists.txt +++ b/Acquisition/Setup/CMakeLists.txt @@ -4,6 +4,7 @@ set(SETUP_UTILS adjust_offsets find_tau copy_params pread pwrite pmread pmwrite foreach (UTIL ${SETUP_UTILS}) add_executable(${UTIL} source/${UTIL}.cpp) + target_compile_definitions(${UTIL} PUBLIC "-DPLX_LINUX") target_link_libraries(${UTIL} PixieInterface) target_include_directories(${UTIL} PUBLIC include ${PROJECT_SOURCE_DIR}/Acquisition/Interface/include) endforeach (UTIL) From 74da5cd565be42c7627028517a346686d9860b62 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 12:51:49 -0500 Subject: [PATCH 39/48] #94: Updating CI build script --- .travis.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36e8a3db0..0b8a29386 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,11 +48,8 @@ jobs: - BUILD_OPTIONS="-DPAASS_BUILD_TESTS=ON -DPAASS_BUILD_UTKSCAN=ON -DPAASS_BUILD_ROOT_SCANNER=OFF -DPAASS_BUILD_SETUP=ON" before_install: - - sudo apt-get -qq update --install-suggests - eval "${MATRIX_EVAL}" - - export ORIG_DIR=$PWD - - mkdir -p /opt/plx/ - - cd /opt/plx + - export ORIG_DIR=${PWD} - git clone https://github.com/spaulaus/plx-api.git - cd plx-api - export PLX_SDK_DIR=$PWD @@ -63,15 +60,16 @@ before_install: - mkdir build - cd build - cmake ../ -DCMAKE_INSTALL_PREFIX=${ORIG_DIR} - - make -j12 - - export XIA_PIXIE_SDK=${ORIG_DIR}/xia/pixie + - make -j12 install + - export XIA_PIXIE_SDK=${ORIG_DIR}/xia/pixie/sdk + - cd ${ORIG_DIR} - wget https://root.cern/download/root_v6.22.02.Linux-ubuntu20-x86_64-gcc9.3.tar.gz - tar xzf root_v6.22.02.Linux-ubuntu20-x86_64-gcc9.3.tar.gz - source root/bin/thisroot.sh script: - mkdir build - - cd paass-build + - cd build - cmake ../ ${BUILD_OPTIONS} - make -j12 - ./Tests/tests \ No newline at end of file From 5c20234877ddd047c1044c4a5c1821edd858bc97 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Sun, 6 Dec 2020 13:57:31 -0500 Subject: [PATCH 40/48] #94: Removing build options as we don't need them in the CI now. --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0b8a29386..14a0800f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,6 @@ jobs: - python3 env: - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" - - BUILD_OPTIONS="-DPAASS_BUILD_TESTS=ON -DPAASS_BUILD_UTKSCAN=ON -DPAASS_BUILD_ROOT_SCANNER=OFF -DPAASS_BUILD_SETUP=ON" - name: GCC 8 Test addons: apt: @@ -33,7 +32,6 @@ jobs: - python3 env: - MATRIX_EVAL="CC=gcc-8 && CXX=g++-8" - - BUILD_OPTIONS="-DPAASS_BUILD_TESTS=ON -DPAASS_BUILD_UTKSCAN=ON -DPAASS_BUILD_ROOT_SCANNER=OFF -DPAASS_BUILD_SETUP=ON" - name: GCC 9 Test addons: apt: @@ -45,7 +43,6 @@ jobs: - python3 env: - MATRIX_EVAL="" - - BUILD_OPTIONS="-DPAASS_BUILD_TESTS=ON -DPAASS_BUILD_UTKSCAN=ON -DPAASS_BUILD_ROOT_SCANNER=OFF -DPAASS_BUILD_SETUP=ON" before_install: - eval "${MATRIX_EVAL}" @@ -70,6 +67,6 @@ before_install: script: - mkdir build - cd build - - cmake ../ ${BUILD_OPTIONS} + - cmake ../ - make -j12 - ./Tests/tests \ No newline at end of file From a7ba7b32b6482ef08ce89482a3589a5932a3634e Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Mon, 7 Dec 2020 16:41:32 -0500 Subject: [PATCH 41/48] #94: Don't need to carry around our own FindGSL anymore. It was added to Cmake in version 3.2. --- Cmake/modules/FindGSL.cmake | 113 ------------------------------------ 1 file changed, 113 deletions(-) delete mode 100644 Cmake/modules/FindGSL.cmake diff --git a/Cmake/modules/FindGSL.cmake b/Cmake/modules/FindGSL.cmake deleted file mode 100644 index fce4a49ac..000000000 --- a/Cmake/modules/FindGSL.cmake +++ /dev/null @@ -1,113 +0,0 @@ -# Try to find gnu scientific library GSL -# See -# http://www.gnu.org/software/gsl/ and -# http://gnuwin32.sourceforge.net/packages/gsl.htm -# -# Based on a script of Felix Woelk and Jan Woetzel modified by S. V. Paulauskas -# (www.mip.informatik.uni-kiel.de) -# -# -# It defines the following variables: -# GSL_FOUND - system has GSL lib -# GSL_INCLUDE_DIRS - where to find headers -# GSL_LIBRARIES - full path to the libraries -# GSL_LIBRARY_DIRS, the directory where the PLplot library is found. - -# CMAKE_GSL_CXX_FLAGS = Unix compiler flags for GSL, essentially "`gsl-config --cxxflags`" -# GSL_LINK_DIRECTORIES = link directories, useful for rpath on Unix -# GSL_EXE_LINKER_FLAGS = rpath on Unix - -# Support the REQUIRED and QUIET arguments. -include(FindPackageHandleStandardArgs) - -set(GSL_FOUND OFF) -set(GSL_CBLAS_FOUND OFF) - -mark_as_advanced(GSL_INCLUDE_DIR GSL_LIBRARY GSL_CBLAS_LIBRARY) - -find_program(GSL_CONFIG_EXECUTABLE gsl-config /usr/bin/ /usr/local/bin) - -if (GSL_CONFIG_EXECUTABLE) - set(GSL_FOUND ON) - - #run the gsl-config to get the GSL Version - execute_process( - COMMAND sh "${GSL_CONFIG_EXECUTABLE}" --version - OUTPUT_VARIABLE GSL_VERSION - RESULT_VARIABLE RET - ERROR_QUIET) - - # run the gsl-config program to get cxxflags - execute_process( - COMMAND sh "${GSL_CONFIG_EXECUTABLE}" --cflags - OUTPUT_VARIABLE GSL_CFLAGS - RESULT_VARIABLE RET - ERROR_QUIET) - if (RET EQUAL 0) - string(STRIP "${GSL_CFLAGS}" GSL_CFLAGS) - separate_arguments(GSL_CFLAGS) - - # parse definitions from cflags; drop -D* from CFLAGS - string(REGEX MATCHALL "-D[^;]+" - GSL_DEFINITIONS "${GSL_CFLAGS}") - string(REGEX REPLACE "-D[^;]+;" "" - GSL_CFLAGS "${GSL_CFLAGS}") - - # parse include dirs from cflags; drop -I prefix - string(REGEX MATCHALL "-I[^;]+" - GSL_INCLUDE_DIRS "${GSL_CFLAGS}") - string(REPLACE "-I" "" - GSL_INCLUDE_DIRS "${GSL_INCLUDE_DIRS}") - string(REGEX REPLACE "-I[^;]+;" "" - GSL_CFLAGS "${GSL_CFLAGS}") - - # message("GSL_DEFINITIONS=${GSL_DEFINITIONS}") - # message("GSL_INCLUDE_DIRS=${GSL_INCLUDE_DIRS}") - # message("GSL_CFLAGS=${GSL_CFLAGS}") - else (RET EQUAL 0) - set(GSL_FOUND OFF) - endif (RET EQUAL 0) - - # run the gsl-config program to get the libs - execute_process( - COMMAND sh "${GSL_CONFIG_EXECUTABLE}" --libs - OUTPUT_VARIABLE GSL_LIBRARIES - RESULT_VARIABLE RET - ERROR_QUIET) - if (RET EQUAL 0) - string(STRIP "${GSL_LIBRARIES}" GSL_LIBRARIES) - separate_arguments(GSL_LIBRARIES) - - # extract linkdirs (-L) for rpath (i.e., LINK_DIRECTORIES) - string(REGEX MATCHALL "-L[^;]+" - GSL_LIBRARY_DIRS "${GSL_LIBRARIES}") - string(REPLACE "-L" "" - GSL_LIBRARY_DIRS "${GSL_LIBRARY_DIRS}") - else (RET EQUAL 0) - set(GSL_FOUND OFF) - endif (RET EQUAL 0) - - #run the gsl-config program to get the GSL installation prefix - execute_process( - COMMAND sh "${GSL_CONFIG_EXECUTABLE}" --prefix - OUTPUT_VARIABLE GSL_PREFIX - RESULT_VARIABLE RET - ERROR_QUIET) - if (NOT RET EQUAL 0) - set(GSL_FOUND OFF) - endif (NOT RET EQUAL 0) - - MARK_AS_ADVANCED(GSL_CFLAGS) -else (GSL_CONFIG_EXECUTABLE) - message(STATUS "FindGSL: gsl-config not found.") -endif (GSL_CONFIG_EXECUTABLE) - -if (GSL_FOUND) - if (NOT GSL_FIND_QUIETLY) - message(STATUS "FindGSL: Found GSL version ${GSL_VERSION}") - endif (NOT GSL_FIND_QUIETLY) -else (GSL_FOUND) - if (GSL_FIND_REQUIRED) - message(FATAL_ERROR "FindGSL: Could not find GSL headers or library") - endif (GSL_FIND_REQUIRED) -endif (GSL_FOUND) \ No newline at end of file From e283d010a3f1ffdb0a6fe71b25b927c9f9da1ffc Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Mon, 7 Dec 2020 17:48:24 -0500 Subject: [PATCH 42/48] #94: Fixing install prefix settings and adjusting install paths I hated that the install directory would be created no matter what. We now use the default install prefix and append the project name to it. This should help make us more portable. Added a library configuration file since we're building only SOs now. This will make it easier for users to update ld's search paths. Adjsuted the install paths for files to match where you should find them on *nix systems. Not perfect but makes things clearer. --- CMakeLists.txt | 25 ++++++++++--------------- Share/CMakeLists.txt | 8 ++++---- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94008fdc4..8f112cb06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.13) -project(PAASS) +project(paass) -#Use rpath on Mac OS set(CMAKE_MACOSX_RPATH TRUE) if (CMAKE_COMPILER_IS_GNUCXX) @@ -12,20 +11,10 @@ if (CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -fPIC -fdiagnostics-color=auto") endif () -#if user does not specify prefix we assign it to the install directory -#@TODO I do not like the fact that it makes the install directory before I'm -#ready for it. There are cases where I do not want to actually install just -#build. This configuration adds additional junk to my directory that I may -#not actually want or need. if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - message(STATUS "Install Prefix not specified.") - file(MAKE_DIRECTORY install) - get_filename_component(INSTALL_DIR ${CMAKE_BINARY_DIR}/../install REALPATH) - set(CMAKE_INSTALL_PREFIX ${INSTALL_DIR} CACHE PATH "Install Prefix" FORCE) -endif () -message(STATUS "Installing to ${CMAKE_INSTALL_PREFIX}") + set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME} CACHE PATH "..." FORCE) +endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) -#Define the default build type to be Release if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) @@ -33,7 +22,6 @@ if (NOT CMAKE_BUILD_TYPE) endif (NOT CMAKE_BUILD_TYPE) message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") -#Add additional CXX flags if we use the Debug option if (CMAKE_BUILD_TYPE MATCHES "Debug") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") endif (CMAKE_BUILD_TYPE MATCHES "Debug") @@ -76,6 +64,7 @@ add_definitions("-D USE_ROOT") find_package(GSL REQUIRED) #------------------------------------------------------------------------------ + add_subdirectory(Acquisition) add_subdirectory(Analysis) add_subdirectory(Core) @@ -86,3 +75,9 @@ if (PAASS_BUILD_TESTS) enable_testing() endif (PAASS_BUILD_TESTS) add_subdirectory(ThirdParty) + +#------------------------------------------------------------------------------ + +set(SO_LIBRARY_CONF_FILE ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.conf) +file(WRITE ${SO_LIBRARY_CONF_FILE} ${CMAKE_INSTALL_PREFIX}/lib) +install(FILES ${SO_LIBRARY_CONF_FILE} DESTINATION etc/ld.so.conf.d/) diff --git a/Share/CMakeLists.txt b/Share/CMakeLists.txt index 305ab261e..f64bedf5b 100644 --- a/Share/CMakeLists.txt +++ b/Share/CMakeLists.txt @@ -2,16 +2,16 @@ #Configure and install the module file configure_file("modulefiles/pixieSuite" pixieSuite @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pixieSuite DESTINATION share/modulefiles/) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pixieSuite DESTINATION usr/share/modules/modulefiles/) #Configure and install the systemd service file configure_file("plx/systemd/plx.service" plx.service @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plx.service DESTINATION share/systemd/) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plx.service DESTINATION etc/systemd/system/) #Configure and install the init.d script to load the plx drivers configure_file("plx/init.d/plxload" plxload @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plxload DESTINATION share/init.d/) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plxload DESTINATION etc/init.d/) #Configure and install the init.d script to unload the plx drivers configure_file("plx/systemd/plx.service" plxunload @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plxunload DESTINATION share/init.d/) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plxunload DESTINATION etc/init.d/) From aaab4cbf142570f60116a9549a406cbb988e7237 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Mon, 7 Dec 2020 17:51:37 -0500 Subject: [PATCH 43/48] #94: Taking the opportunity to update modulefile --- Share/CMakeLists.txt | 6 ++---- Share/modulefiles/{pixieSuite => paass} | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) rename Share/modulefiles/{pixieSuite => paass} (52%) diff --git a/Share/CMakeLists.txt b/Share/CMakeLists.txt index f64bedf5b..2c48af48f 100644 --- a/Share/CMakeLists.txt +++ b/Share/CMakeLists.txt @@ -1,8 +1,6 @@ -# @author S.V. Paulauskas - #Configure and install the module file -configure_file("modulefiles/pixieSuite" pixieSuite @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pixieSuite DESTINATION usr/share/modules/modulefiles/) +configure_file("modulefiles/paass" pixieSuite @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/paass DESTINATION usr/share/modules/modulefiles/) #Configure and install the systemd service file configure_file("plx/systemd/plx.service" plx.service @ONLY) diff --git a/Share/modulefiles/pixieSuite b/Share/modulefiles/paass similarity index 52% rename from Share/modulefiles/pixieSuite rename to Share/modulefiles/paass index 39d2a1bcb..eb7745d22 100644 --- a/Share/modulefiles/pixieSuite +++ b/Share/modulefiles/paass @@ -1,15 +1,15 @@ #%Module1.0 ## -## modulefiles/pixieSuite +## modulefiles/paass ## -## @author K. Smith +## @author K. Smith / S. V. Paulauskas proc ModulesHelp {} { global version modroot - puts stderr "pixieSuite - Pixie Suite provides utilities for XIA Pixie 16 Data Acquisition" + puts stderr "PAASS - Pixie Acquisition and Analysis Software Suite for use with XIAs Pixie hardware." } -module-whatis "Pixie Suite provides utilities for XIA Pixie 16 Data Acquisition" +module-whatis "PAASS - Pixie Acquisition and Analysis Software Suite for use with XIAs Pixie hardware." set topdir @CMAKE_INSTALL_PREFIX@ From 50c9af9f67e72e233579158c320d0efc0e88b11e Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Mon, 7 Dec 2020 18:03:19 -0500 Subject: [PATCH 44/48] #94: Removing all the jazz around generating compile_commands.json --- CMakeLists.txt | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f112cb06..957f3006e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ if (CMAKE_BUILD_TYPE MATCHES "Debug") endif (CMAKE_BUILD_TYPE MATCHES "Debug") #------------------------------------------------------------------------------ + include(CMakeDependentOption) option(PAASS_BUILD_ACQ "Build and install Acquisition software" ON) @@ -35,17 +36,7 @@ option(PAASS_BUILD_TESTS "Builds programs designed to test the package." ON) #------------------------------------------------------------------------------ -option(PAASS_EXPORT_COMPILE_COMMANDS "CMAKE_EXPORT_COMPILE_COMMANDS WRAPPER" ON) -mark_as_advanced(PAASS_EXPORT_COMPILE_COMMANDS) - -#Generate the compile_commands.json file which is used by VSCode (among others) to generate the clang autocomplete -#Needs the PAASS_EXPORT_COMPILE_COMMANDS wrapper because of the "FORCE" which is required to even set the var from CMakeList.txt, -#while maintaining the ability to toggle it on/off without wiping the build dir -if (PAASS_EXPORT_COMPILE_COMMANDS) - set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Generates compile_commands.json, needed for some IDEs among other things" FORCE) -else () - set(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL "Generates compile_commands.json, needed for some IDEs among other things" FORCE) -endif (PAASS_EXPORT_COMPILE_COMMANDS) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Generates compile_commands.json." FORCE) #------------------------------------------------------------------------------ From f855e64899e1d8460cbce203e0ae6c73a32afebd Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Mon, 7 Dec 2020 18:08:10 -0500 Subject: [PATCH 45/48] #94: Turning off tests by default. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 957f3006e..ea36feeea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ include(CMakeDependentOption) option(PAASS_BUILD_ACQ "Build and install Acquisition software" ON) option(PAASS_BUILD_ANALYSIS "Build analysis related programs" ON) -option(PAASS_BUILD_TESTS "Builds programs designed to test the package." ON) +option(PAASS_BUILD_TESTS "Builds programs designed to test the package." OFF) #------------------------------------------------------------------------------ From 3bfbb8cc04a02c3c11e4d512d1f5607c33242258 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Mon, 7 Dec 2020 18:47:30 -0500 Subject: [PATCH 46/48] #94: Fixing install name for modulefile --- Share/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Share/CMakeLists.txt b/Share/CMakeLists.txt index 2c48af48f..295e5b9de 100644 --- a/Share/CMakeLists.txt +++ b/Share/CMakeLists.txt @@ -1,5 +1,5 @@ #Configure and install the module file -configure_file("modulefiles/paass" pixieSuite @ONLY) +configure_file("modulefiles/paass" paass @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/paass DESTINATION usr/share/modules/modulefiles/) #Configure and install the systemd service file From 60c14efa4b27241f044ec7f932d35c9e15936f70 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Mon, 7 Dec 2020 18:49:45 -0500 Subject: [PATCH 47/48] #94: Now that we don't have the tests built by default we need to adjust CI scripts to build them. --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 14a0800f5..e2262ed73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ jobs: - python3 env: - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" + - BUILD_OPTIONS="-DPAASS_BUILD_TESTS=ON" - name: GCC 8 Test addons: apt: @@ -32,6 +33,7 @@ jobs: - python3 env: - MATRIX_EVAL="CC=gcc-8 && CXX=g++-8" + - BUILD_OPTIONS="-DPAASS_BUILD_TESTS=ON" - name: GCC 9 Test addons: apt: @@ -43,6 +45,7 @@ jobs: - python3 env: - MATRIX_EVAL="" + - BUILD_OPTIONS="-DPAASS_BUILD_TESTS=ON" before_install: - eval "${MATRIX_EVAL}" @@ -67,6 +70,6 @@ before_install: script: - mkdir build - cd build - - cmake ../ + - cmake ../ ${BUILD_OPTIONS} - make -j12 - ./Tests/tests \ No newline at end of file From d29292aa47651e9752c565a7a4ecc2c5a8868411 Mon Sep 17 00:00:00 2001 From: "S. V. Paulauskas" Date: Mon, 7 Dec 2020 20:04:08 -0500 Subject: [PATCH 48/48] #94: Fixing documentation in FindXIA.cmake --- Cmake/modules/FindXIA.cmake | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cmake/modules/FindXIA.cmake b/Cmake/modules/FindXIA.cmake index 02891b67a..d9bd62e54 100644 --- a/Cmake/modules/FindXIA.cmake +++ b/Cmake/modules/FindXIA.cmake @@ -16,14 +16,14 @@ # - **sdk** # - **lib** - API libraries # - **include** - API includes -# - **share** -# - **pxisys** - contains the pxisys*.ini files provided in the API -# - **slotdef** - probably just a single slot def, can be added to the API install -# - **firmware** -# - **2016-02-02-12b250m-vandle** (and other specific firmware) -# - **config** - not something that XIA distributes on their website, **DO NOT** add to repos -# - **dsp** -# - **fpga** +# - **share** +# - **pxisys** - contains the pxisys*.ini files provided in the API +# - **slotdef** - probably just a single slot def, can be added to the API install +# - **firmware** +# - **2016-02-02-12b250m-vandle** (and other specific firmware) +# - **config** - not something that XIA distributes on their website, **DO NOT** add to repos +# - **dsp** +# - **fpga** # @authors K. Smith, C. R. Thornsberry, S. V. Paulauskas #Find the library path by looking for the library.