Skip to content

Commit

Permalink
Build csp core and csp engine as DLLs
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Glustein <[email protected]>
  • Loading branch information
AdamGlustein committed Nov 8, 2024
1 parent 512a6fd commit a284577
Show file tree
Hide file tree
Showing 46 changed files with 100 additions and 79 deletions.
2 changes: 1 addition & 1 deletion cpp/csp/core/BasicAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace csp
{

// Extremely basic non-thread safe fixed-size allocator
class CSPIMPL_EXPORT BasicAllocator
class CSPCORE_EXPORT BasicAllocator
{
public:
//elemsize is size of a single alloc, blockSize is number of elements to
Expand Down
11 changes: 9 additions & 2 deletions cpp/csp/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include(GenerateExportHeader)

set(CORE_PUBLIC_HEADERS
BasicAllocator.h
Config.h.in
Expand Down Expand Up @@ -25,12 +27,17 @@ set(CORE_SOURCE_FILES

configure_file(Config.h.in ${CMAKE_CURRENT_BINARY_DIR}/cpp/csp/core/Config.h)

add_library(csp_core STATIC ${CORE_SOURCE_FILES})
add_library(csp_core SHARED ${CORE_SOURCE_FILES})
generate_export_header(csp_core
BASE_NAME cspcore
EXPORT_MACRO_NAME CSPCORE_EXPORT
)
set_target_properties(csp_core PROPERTIES PUBLIC_HEADER "${CORE_PUBLIC_HEADERS}")

install(TARGETS csp_core
PUBLIC_HEADER DESTINATION include/csp/core
RUNTIME DESTINATION ${CSP_RUNTIME_INSTALL_SUBDIR}
LIBRARY DESTINATION lib/
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cpp/csp/core/Config.h DESTINATION include/csp/core)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cpp/csp/core/Config.h DESTINATION include/csp/core)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cspcore_export.h DESTINATION include/csp/core)
2 changes: 1 addition & 1 deletion cpp/csp/core/DynamicBitSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace csp
{

template<typename NodeT = uint64_t, typename IndexT = int32_t>
class CSPIMPL_EXPORT DynamicBitSet
class CSPCORE_EXPORT DynamicBitSet
{

public:
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/core/Enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bool UnknownOnInvalidValue(long) { return false; }

START_PACKED
template<typename EnumTraits>
struct CSPTYPESIMPL_EXPORT Enum : public EnumTraits
struct CSPCORE_EXPORT Enum : public EnumTraits
{
using EnumV = typename EnumTraits::_enum;
using Mapping = std::vector<std::string>;
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/core/EnumBitSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace csp
//Utility class to hold enums as a bitmask ( where enum values are incremental from 0 )
//enum must have a NUM_TYPES entry for number of entries
template< typename EnumT >
class CSPTYPESIMPL_EXPORT EnumBitSet
class CSPCORE_EXPORT EnumBitSet
{
using value_type = uint64_t;

Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/core/Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace csp
{
template< typename V, typename ...Args >
class CSPIMPL_EXPORT Generator
class CSPCORE_EXPORT Generator
{
public:
using Ptr = std::shared_ptr<Generator<V, Args...>>;
Expand Down
4 changes: 4 additions & 0 deletions cpp/csp/core/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include <time.h>

// cmake autogenerated export files
#include <csp/core/cspcore_export.h>
#include <csp/engine/cspengine_export.h>
#include <csp/engine/csptypes_export.h>

#include <csp/python/cspimpl_export.h>
#include <csp/python/csptypesimpl_export.h>

Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/core/QueueWaiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace csp

class TimeDelta;

class CSPIMPL_EXPORT QueueWaiter
class CSPCORE_EXPORT QueueWaiter
{
public:
QueueWaiter() : m_eventsPending( false )
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/core/TaggedPointerUnion.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct IndexOf<T, TypeList<TOther, Ts...> >


template<typename... Ts>
class CSPIMPL_EXPORT TaggedPointerUnion
class CSPCORE_EXPORT TaggedPointerUnion
{
public:
static inline constexpr size_t NUM_TAGS = sizeof...(Ts);
Expand Down
10 changes: 5 additions & 5 deletions cpp/csp/core/Time.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const int64_t NANOS_PER_SECOND = 1000000000;
const int64_t SECONDS_PER_DAY = 86400;
const int64_t NANOS_PER_DAY = NANOS_PER_SECOND * SECONDS_PER_DAY;

class CSPTYPESIMPL_EXPORT TimeDelta
class CSPCORE_EXPORT TimeDelta
{
public:
constexpr TimeDelta() : TimeDelta( TimeDelta::NONE() ) {}
Expand Down Expand Up @@ -165,7 +165,7 @@ inline std::ostream & operator <<( std::ostream &os, const TimeDelta & d )
return os;
}

class CSPTYPESIMPL_EXPORT Date
class CSPCORE_EXPORT Date
{
public:
Date() : Date( NONE() ) {}
Expand Down Expand Up @@ -316,7 +316,7 @@ inline std::ostream & operator <<( std::ostream &os, const Date & d )
return os;
}

class CSPTYPESIMPL_EXPORT Time
class CSPCORE_EXPORT Time
{
public:
Time() : Time( -1 ) {} //NONE
Expand Down Expand Up @@ -446,7 +446,7 @@ inline std::ostream & operator <<( std::ostream &os, const Time & t )

// Time is internally stored as an int64_t nanoseconds since 1970.
// All DateTime objects are stored as UTC and should be treated as such
class CSPTYPESIMPL_EXPORT DateTime
class CSPCORE_EXPORT DateTime
{
public:
DateTime() : DateTime( DateTime::NONE() ) {}
Expand Down Expand Up @@ -597,7 +597,7 @@ inline std::ostream & operator <<( std::ostream &os, const DateTime & dt )
//Helper class to extract day/month/year/etc info from raw timestamp
//ie DateTimeEx dte( existingDt )
//dte.day, etc etc
class CSPTYPESIMPL_EXPORT DateTimeEx : public DateTime
class CSPCORE_EXPORT DateTimeEx : public DateTime
{
public:
DateTimeEx( const DateTime & dt );
Expand Down
4 changes: 2 additions & 2 deletions cpp/csp/engine/AdapterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AdapterManager;

class Engine;

class CSPIMPL_EXPORT ManagedSimInputAdapter : public InputAdapter
class CSPENGINE_EXPORT ManagedSimInputAdapter : public InputAdapter
{
public:
ManagedSimInputAdapter( csp::Engine *engine, const CspTypePtr &type, AdapterManager *manager, PushMode pushMode );
Expand Down Expand Up @@ -94,7 +94,7 @@ bool ManagedSimInputAdapter::pushNullTick()
return true;
}

class CSPIMPL_EXPORT AdapterManager : public EngineOwned
class CSPENGINE_EXPORT AdapterManager : public EngineOwned
{
public:
AdapterManager( csp::Engine * );
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/engine/AlarmInputAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace csp
{

template<typename T>
class CSPIMPL_EXPORT AlarmInputAdapter final : public InputAdapter
class CSPENGINE_EXPORT AlarmInputAdapter final : public InputAdapter
{
public:
AlarmInputAdapter( Engine * engine, CspTypePtr & type ) : InputAdapter( engine, type, PushMode::NON_COLLAPSING )
Expand Down
8 changes: 4 additions & 4 deletions cpp/csp/engine/BasketInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace csp

class Node;

class CSPIMPL_EXPORT InputBasketInfo
class CSPENGINE_EXPORT InputBasketInfo
{
using TickedInputs = std::vector<INOUT_ELEMID_TYPE>;

Expand Down Expand Up @@ -189,7 +189,7 @@ class CSPIMPL_EXPORT InputBasketInfo
bool m_isDynamic;
};

class CSPIMPL_EXPORT DynamicInputBasketInfo : public InputBasketInfo
class CSPENGINE_EXPORT DynamicInputBasketInfo : public InputBasketInfo
{
public:
using ChangeCallback = std::function<void(const DialectGenericType & key,bool added, int64_t elemId, int64_t replaceId )>;
Expand Down Expand Up @@ -228,7 +228,7 @@ class CSPIMPL_EXPORT DynamicInputBasketInfo : public InputBasketInfo
TimeDelta m_timeWindowPolicy;
};

class CSPIMPL_EXPORT OutputBasketInfo
class CSPENGINE_EXPORT OutputBasketInfo
{
public:
OutputBasketInfo( CspTypePtr & type, Node * node, size_t size, bool isDynamic = false );
Expand All @@ -255,7 +255,7 @@ class CSPIMPL_EXPORT OutputBasketInfo
bool m_isDynamic;
};

class CSPIMPL_EXPORT DynamicOutputBasketInfo : public OutputBasketInfo
class CSPENGINE_EXPORT DynamicOutputBasketInfo : public OutputBasketInfo
{
public:
DynamicOutputBasketInfo( CspTypePtr & type, Node * node );
Expand Down
18 changes: 14 additions & 4 deletions cpp/csp/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include(GenerateExportHeader)
csp_autogen( csp.impl.types.autogen_types autogen_types ENGINE_AUTOGEN_HEADER ENGINE_AUTOGEN_SOURCE )

set(CSP_TYPES_PUBLIC_HEADERS
Expand All @@ -12,10 +13,7 @@ set(CSP_TYPES_PUBLIC_HEADERS
set(CSP_TYPES_SOURCE_FILES
CspEnum.cpp
CspType.cpp
DialectGenericType.h
PartialSwitchCspType.h
Struct.cpp
TypeCast.h
)

set(ENGINE_PUBLIC_HEADERS
Expand Down Expand Up @@ -83,10 +81,18 @@ set(ENGINE_SOURCE_FILES
${ENGINE_PUBLIC_HEADERS}
)

add_library(csp_types STATIC ${CSP_TYPES_SOURCE_FILES})
add_library(csp_types SHARED ${CSP_TYPES_SOURCE_FILES})
generate_export_header(csp_types
BASE_NAME csptypes
EXPORT_MACRO_NAME CSPTYPES_EXPORT
)
set_target_properties(csp_types PROPERTIES PUBLIC_HEADER "${CSP_TYPES_PUBLIC_HEADERS}")

add_library(csp_engine STATIC ${ENGINE_SOURCE_FILES})
generate_export_header(csp_engine
BASE_NAME cspengine
EXPORT_MACRO_NAME CSPENGINE_EXPORT
)
set_target_properties(csp_engine PROPERTIES PUBLIC_HEADER "${ENGINE_PUBLIC_HEADERS}")
target_link_libraries(csp_engine csp_core csp_types)

Expand All @@ -97,3 +103,7 @@ install(TARGETS csp_types csp_engine
RUNTIME DESTINATION ${CSP_RUNTIME_INSTALL_SUBDIR}
LIBRARY DESTINATION lib/
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cspengine_export.h
${CMAKE_CURRENT_BINARY_DIR}/csptypes_export.h
DESTINATION include/csp/engine)
2 changes: 1 addition & 1 deletion cpp/csp/engine/Consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace csp
class InputAdapter;

//Base of either regular Nodes or output adapters
class CSPIMPL_EXPORT Consumer
class CSPENGINE_EXPORT Consumer
{
public:
Consumer( Engine * );
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/engine/CppNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace csp

//CppNode is used specifically for C++ defined Nodes, and should only be used
//for definig c++ nodes using the macros defined at the end
class CSPIMPL_EXPORT CppNode : public csp::Node
class CSPENGINE_EXPORT CppNode : public csp::Node
{
public:
using Shape = std::variant<std::uint64_t,std::vector<std::string>>;
Expand Down
6 changes: 3 additions & 3 deletions cpp/csp/engine/CspEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace csp

class CspEnumMeta;

class CSPTYPESIMPL_EXPORT CspEnumInstance
class CSPTYPES_EXPORT CspEnumInstance
{
public:
CspEnumInstance( std::string name, int64_t value, csp::CspEnumMeta * meta ) : m_name( name ), m_value( value ), m_meta( meta ) {}
Expand All @@ -35,7 +35,7 @@ class CSPTYPESIMPL_EXPORT CspEnumInstance

//As an optimization we do NOT attach meta or value to every instance of an enum. Instead, the enum
//holds only a pointer to a singleton CspEnumInstance, which holds the value, name, and meta pointer.
class CSPTYPESIMPL_EXPORT CspEnum
class CSPTYPES_EXPORT CspEnum
{
public:
CspEnum();
Expand All @@ -59,7 +59,7 @@ class CSPTYPESIMPL_EXPORT CspEnum

std::ostream &operator<<( std::ostream &os, const CspEnum & rhs );

class CSPTYPESIMPL_EXPORT CspEnumMeta
class CSPTYPES_EXPORT CspEnumMeta
{
public:
using ValueDef = std::unordered_map<std::string,int64_t>;
Expand Down
10 changes: 5 additions & 5 deletions cpp/csp/engine/CspType.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace csp

class CspStringType;

class CSPTYPESIMPL_EXPORT CspType
class CSPTYPES_EXPORT CspType
{
public:

Expand Down Expand Up @@ -116,7 +116,7 @@ class CSPTYPESIMPL_EXPORT CspType
Type m_type;
};

class CSPTYPESIMPL_EXPORT CspStringType : public CspType
class CSPTYPES_EXPORT CspStringType : public CspType
{
public:
CspStringType(bool isBytes)
Expand All @@ -135,7 +135,7 @@ class CspEnum;

class CspEnumMeta;

class CSPTYPESIMPL_EXPORT CspEnumType : public CspType
class CSPTYPES_EXPORT CspEnumType : public CspType
{
public:
CspEnumType( std::shared_ptr<CspEnumMeta> & meta ) : CspType( CspType::Type::ENUM ),
Expand All @@ -155,7 +155,7 @@ using StructPtr = TypedStructPtr<Struct>;

class StructMeta;

class CSPTYPESIMPL_EXPORT CspStructType : public CspType
class CSPTYPES_EXPORT CspStructType : public CspType
{
public:
CspStructType( const std::shared_ptr<StructMeta> & meta ) : CspType( CspType::Type::STRUCT ),
Expand All @@ -168,7 +168,7 @@ class CSPTYPESIMPL_EXPORT CspStructType : public CspType
std::shared_ptr<StructMeta> m_meta;
};

class CSPTYPESIMPL_EXPORT CspArrayType : public CspType
class CSPTYPES_EXPORT CspArrayType : public CspType
{
public:
CspArrayType( CspTypePtr elemType, bool isPyStructFastList = false ) :
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/engine/CycleStepTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace csp
class Consumer;
class Profiler;

class CSPIMPL_EXPORT CycleStepTable
class CSPENGINE_EXPORT CycleStepTable
{
public:
CycleStepTable();
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/engine/Dictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using DictionaryPtr = std::shared_ptr<Dictionary>;
class StructMeta;
using StructMetaPtr = std::shared_ptr<StructMeta>;

class CSPTYPESIMPL_EXPORT Dictionary
class CSPENGINE_EXPORT Dictionary
{
public:
struct Data;
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/engine/DynamicEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace csp
{

class CSPIMPL_EXPORT DynamicEngine final : public Engine
class CSPENGINE_EXPORT DynamicEngine final : public Engine
{
public:
using ShutdownFn = std::function<void()>;
Expand Down
2 changes: 1 addition & 1 deletion cpp/csp/engine/DynamicNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DynamicEngine;
//external inputs and triggering a cycle step.
//All dynamic engine input adapters as well as all external timeseries wired into dynamic are registered as inputs
//into the DynanicNode instance so that it can invoke cycle step at the appropriate times.
class CSPIMPL_EXPORT DynamicNode final : public Node
class CSPENGINE_EXPORT DynamicNode final : public Node
{
public:
using Outputs = std::vector<const TimeSeriesProvider *>;
Expand Down
4 changes: 2 additions & 2 deletions cpp/csp/engine/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TimeSeriesProvider;
class Engine;
class RootEngine;

struct CSPIMPL_EXPORT EngineOwned
struct CSPENGINE_EXPORT EngineOwned
{
//force objects derived from EngineOwned to go through engine createOwnedObject methods
//little trick here to force all derivations to fail
Expand All @@ -35,7 +35,7 @@ struct CSPIMPL_EXPORT EngineOwned
void operator delete( void* ptr ) { ::operator delete(ptr); }
};

class CSPIMPL_EXPORT Engine
class CSPENGINE_EXPORT Engine
{
using AdapterManagers = std::vector<std::shared_ptr<AdapterManager>>;
using InputAdapters = std::vector<std::unique_ptr<InputAdapter>>;
Expand Down
Loading

0 comments on commit a284577

Please sign in to comment.