diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4499d16aa..aea7c2d92 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,5 +1,17 @@ +# Team Review * @robambalu @AdamGlustein @svatasoiu @alexddobkin -.github @robambalu @timkpaine @ngoldbaum @alexddobkin @AdamGlustein @svatasoiu -.github/CODEOWNERS @robambalu +# Packaging code +CMakeLists.txt @robambalu @AdamGlustein @svatasoiu @alexddobkin @timkpaine @czgdp1807 +setup.py @robambalu @AdamGlustein @svatasoiu @alexddobkin @timkpaine @czgdp1807 +pyproject.toml @robambalu @AdamGlustein @svatasoiu @alexddobkin @timkpaine @czgdp1807 +Makefile @robambalu @AdamGlustein @svatasoiu @alexddobkin @timkpaine @czgdp1807 +MANIFEST.in @robambalu @AdamGlustein @svatasoiu @alexddobkin @timkpaine @czgdp1807 +.bumpversion.cfg @robambalu @AdamGlustein @svatasoiu @alexddobkin @timkpaine @czgdp1807 + +# CI/CD +.github @robambalu @AdamGlustein @svatasoiu @alexddobkin @timkpaine @czgdp1807 +ci @robambalu @AdamGlustein @svatasoiu @alexddobkin @timkpaine @czgdp1807 +# Administrative +.github/CODEOWNERS @robambalu diff --git a/CMakeLists.txt b/CMakeLists.txt index fb3aae993..2ca7725af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,35 +115,9 @@ if(MACOS) set(CMAKE_USE_PTHREADS_INIT 1) set(THREADS_PREFER_PTHREAD_FLAG ON) - # for exception unwinding on macOS - # TODO this does not work, which would be the - # proper cmake way of doing it, so instead we - # use a vanilla option - # check_linker_flag(CXX "-Wl,-ld_classic" CSP_USE_LD_CLASSIC_MAC) - if(CSP_USE_LD_CLASSIC_MAC) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-ld_classic") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-ld_classic") - endif() - - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X deployment version") - # don't link against build python # https://blog.tim-smith.us/2015/09/python-extension-modules-os-x/ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup") - - # Support cross build - check_c_compiler_flag("-arch x86_64" x86_64Supported) - check_c_compiler_flag("-arch arm64" arm64Supported) - - if(x86_64Supported AND arm64Supported) - set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build universal architecture for OSX" FORCE) - elseif(x86_64Supported) - set(CMAKE_REQUIRED_LINK_OPTIONS "-arch;x86_64") - set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build universal architecture for OSX" FORCE) - elseif(arm64Supported) - set(CMAKE_REQUIRED_LINK_OPTIONS "-arch;arm64") - set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Build universal architecture for OSX" FORCE) - endif() endif() diff --git a/cpp/cmake/modules/FindCSP.cmake b/cpp/cmake/modules/FindCSP.cmake index f0ff3daa3..b72cec45a 100644 --- a/cpp/cmake/modules/FindCSP.cmake +++ b/cpp/cmake/modules/FindCSP.cmake @@ -13,6 +13,8 @@ # CSP_BASELIB_STATIC_LIBRARY # CSP_BASKETLIB_LIBRARY # CSP_BASKETLIB_STATIC_LIBRARY +# CSP_MATH_LIBRARY +# CSP_MATH_STATIC_LIBRARY # CSP_STATS_LIBRARY # CSP_STATS_STATIC_LIBRARY # CSP_NPSTATS_LIBRARY @@ -72,6 +74,9 @@ find_library(CSP_BASELIB_STATIC_LIBRARY NAMES libbaselibimpl_static.a PATHS "${_ find_library(CSP_BASKETLIB_LIBRARY NAMES _cspbasketlibimpl.so PATHS "${__csp_lib_path}" NO_DEFAULT_PATH) find_library(CSP_BASKETLIB_STATIC_LIBRARY NAMES libbasketlibimpl_static.a PATHS "${__csp_lib_path}" NO_DEFAULT_PATH) +find_library(CSP_MATH_LIBRARY NAMES _cspmathimpl.so PATHS "${__csp_lib_path}" NO_DEFAULT_PATH) +find_library(CSP_MATH_STATIC_LIBRARY NAMES libmathimpl_static.a PATHS "${__csp_lib_path}" NO_DEFAULT_PATH) + find_library(CSP_STATS_LIBRARY NAMES _cspstatsimpl.so PATHS "${__csp_lib_path}" NO_DEFAULT_PATH) find_library(CSP_STATS_STATIC_LIBRARY NAMES libstatsimpl_static.a PATHS "${__csp_lib_path}" NO_DEFAULT_PATH) diff --git a/cpp/cmake/modules/Findcsp_autogen.cmake b/cpp/cmake/modules/Findcsp_autogen.cmake index 2e0b1c85a..98b3604d3 100644 --- a/cpp/cmake/modules/Findcsp_autogen.cmake +++ b/cpp/cmake/modules/Findcsp_autogen.cmake @@ -14,7 +14,7 @@ function(csp_autogen MODULE_NAME DEST_FILENAME HEADER_NAME_OUTVAR SOURCE_NAME_OU endif() add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/csp_autogen/${DEST_FILENAME}.cpp" "${CMAKE_CURRENT_BINARY_DIR}/csp_autogen/${DEST_FILENAME}.h" - COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${PROJECT_BINARY_DIR}/lib:${CMAKE_SOURCE_DIR}:ext:$$PYTHONPATH" "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib:$$LD_LIBRARY_PATH}" ${Python_EXECUTABLE} ${CSP_AUTOGEN} -m ${MODULE_NAME} -d ${CMAKE_CURRENT_BINARY_DIR}/csp_autogen -o ${DEST_FILENAME} ${CSP_AUTOGEN_EXTRA_ARGS} + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${PROJECT_BINARY_DIR}/lib:${CMAKE_SOURCE_DIR}:$$PYTHONPATH" "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib:$$LD_LIBRARY_PATH}" ${Python_EXECUTABLE} ${CSP_AUTOGEN} -m ${MODULE_NAME} -d ${CMAKE_CURRENT_BINARY_DIR}/csp_autogen -o ${DEST_FILENAME} ${CSP_AUTOGEN_EXTRA_ARGS} COMMENT "generating csp c++ types from module ${MODULE_NAME} ${PROJECT_BINARY_DIR} ${CSP_AUTOGEN}" DEPENDS mkdir_autogen_${MODULE_NAME} ${CMAKE_SOURCE_DIR}/${MODULE_FILENAME}) diff --git a/cpp/csp/engine/Scheduler.h b/cpp/csp/engine/Scheduler.h index 9c1d6606f..96efc2c58 100644 --- a/cpp/csp/engine/Scheduler.h +++ b/cpp/csp/engine/Scheduler.h @@ -6,6 +6,7 @@ #include #include #include +#include #include namespace csp @@ -18,9 +19,9 @@ class Scheduler struct Event; public: - //For non-collapsing inputs, the callback should return a pointer to the input adapter that is + //For non-collapsing inputs, the callback should return a pointer to the input adapter that is //unrolling / not collapsing. This will ensure pending events for a given input adapter will get deferred - //to the next cycle until its completely unrolled. This avoids a O(n^2) loop of reprocessing multiple pending events on + //to the next cycle until its completely unrolled. This avoids a O(n^2) loop of reprocessing multiple pending events on //a given input adapter. If the callback isnt for an input adapter or if it is able to consume / process the tick, return nullptr using Callback = std::function; @@ -31,13 +32,13 @@ class Scheduler Handle( const Handle & rhs ) = default; bool expired() const; bool active() const { return !expired(); } - + operator bool() const { return active(); } //Only valid if handle is active, otherwise returns NONE DateTime time() const; - void reset() + void reset() { event = nullptr; id = 0; @@ -70,9 +71,9 @@ class Scheduler }; Scheduler(); - ~Scheduler(); + ~Scheduler(); - //Callback can return false which means it should stick around + //Callback can return false which means it should stick around //and re-execute next engine cycle Handle scheduleCallback( Handle reserved, DateTime time, Callback &&cb ); Handle scheduleCallback( DateTime time, Callback &&cb ); @@ -80,7 +81,7 @@ class Scheduler bool cancelCallback( Handle handle ); //useful to break circular dep of a callback needing its own handle - Handle reserveHandle(); + Handle reserveHandle(); bool hasEvents() { return !m_map.empty() || m_pendingEvents.hasEvents(); } DateTime nextTime() const { return m_pendingEvents.hasEvents() ? m_pendingEvents.time() : m_map.begin() -> first; } @@ -104,7 +105,7 @@ class Scheduler return m_allocator.allocate(); } - void deallocate( T* p, std::size_t n ) noexcept + void deallocate( T* p, std::size_t n ) noexcept { assert( n == 1 ); m_allocator.free( p ); @@ -160,7 +161,7 @@ class Scheduler private: //NOTE the reason that this isnt simply kept as an unordered_map list is to ensure - //simulated runs have complete reproducibility and are deterministic. If we key by InputAdapter * pointer, ordering of + //simulated runs have complete reproducibility and are deterministic. If we key by InputAdapter * pointer, ordering of //invocations will vary across runs ( this generally wouldnt matter if all code was side-effect free, but even so basket input //tickeditems() order depends on order of basket elemnt ticks in a given cycle ) //Instead we maintain an unordered_map to ensure we keep an adapter once in the m_pendingEvents list @@ -177,7 +178,7 @@ class Scheduler }; //time of all pending events - DateTime m_time; + DateTime m_time; //Every list entry is *PER ADAPTER*, each entry will have a linked list of Event objects std::list m_pendingEvents; diff --git a/cpp/tests/core/CMakeLists.txt b/cpp/tests/core/CMakeLists.txt index 4934b9278..bbc8231e2 100644 --- a/cpp/tests/core/CMakeLists.txt +++ b/cpp/tests/core/CMakeLists.txt @@ -22,8 +22,8 @@ target_link_libraries(test_time csp_core GTest::gtest GTest::gtest_main rt) install(TARGETS test_basic_allocator test_dynamicbitset test_enum - test_srmwlockfreequeue - test_tagged_pointer_union + test_srmwlockfreequeue + test_tagged_pointer_union test_time RUNTIME DESTINATION tests/bin/ LIBRARY DESTINATION tests/lib/ diff --git a/setup.py b/setup.py index 86b9d4315..ea14be2a6 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,19 @@ from shutil import which from skbuild import setup -CSP_USE_VCPKG = os.environ.get("CSP_USE_VCPKG", "1") == "1" +# CMake Options +CSP_USE_VCPKG = os.environ.get("CSP_USE_VCPKG", "1").lower() in ("1", "on") +CMAKE_OPTIONS = ( + ("CSP_BUILD_NO_CXX_ABI", "0"), + ("CSP_BUILD_TESTS", "0"), + ("CSP_MANYLINUX", "0"), + ("CSP_BUILD_KAFKA_ADAPTER", "1"), + ("CSP_BUILD_PARQUET_ADAPTER", "1"), + # NOTE: + # - omit vcpkg, need to test for presence + # - omit ccache, need to test for presence + # - omit coverage/gprof, not implemented +) # This will be used for e.g. the sdist if CSP_USE_VCPKG: @@ -18,8 +30,8 @@ if not os.path.exists("vcpkg/buildtrees"): subprocess.call(["git", "pull"], cwd="vcpkg") if os.name == "nt": - subprocess.call(["bootstrap-vcpkg.bat"], cwd="vcpkg") - subprocess.call(["vcpkg", "install"], cwd="vcpkg") + subprocess.call(["bootstrap-vcpkg.bat"], cwd="vcpkg", shell=True) + subprocess.call(["vcpkg.bat", "install"], cwd="vcpkg", shell=True) else: subprocess.call(["./bootstrap-vcpkg.sh"], cwd="vcpkg") subprocess.call(["./vcpkg", "install"], cwd="vcpkg") @@ -50,20 +62,39 @@ if "DEBUG" in os.environ: cmake_args.append("-DCMAKE_BUILD_TYPE=Debug") -if "CSP_MANYLINUX" in os.environ: - cmake_args.append("-DCSP_MANYLINUX=ON") +if platform.system() == "Windows": + import distutils.msvccompiler as dm + + # https://wiki.python.org/moin/WindowsCompilers#Microsoft_Visual_C.2B-.2B-_14.0_with_Visual_Studio_2015_.28x86.2C_x64.2C_ARM.29 + msvc = { + "12": "Visual Studio 12 2013", + "14": "Visual Studio 14 2015", + "14.0": "Visual Studio 14 2015", + "14.1": "Visual Studio 15 2017", + "14.2": "Visual Studio 16 2019", + "14.3": "Visual Studio 17 2022", + }.get(str(dm.get_build_version()), "Visual Studio 15 2017") + cmake_args.extend( + [ + "-G", + os.environ.get("CSP_GENERATOR", msvc), + ] + ) + +for cmake_option, default in CMAKE_OPTIONS: + if os.environ.get(cmake_option, default).lower() in ("1", "on"): + cmake_args.append(f"-D{cmake_option}=ON") + else: + cmake_args.append(f"-D{cmake_option}=OFF") if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ: os.environ["CMAKE_BUILD_PARALLEL_LEVEL"] = str(multiprocessing.cpu_count()) if platform.system() == "Darwin": - os.environ["OSX_DEPLOYMENT_TARGET"] = os.environ.get("OSX_DEPLOYMENT_TARGET", "10.13") - os.environ["MACOSX_DEPLOYMENT_TARGET"] = os.environ.get("OSX_DEPLOYMENT_TARGET", "10.13") - -if hasattr(platform, "mac_ver") and platform.mac_ver()[0].startswith("14"): - cmake_args.append("-DCSP_USE_LD_CLASSIC_MAC=ON") + os.environ["MACOSX_DEPLOYMENT_TARGET"] = os.environ.get("OSX_DEPLOYMENT_TARGET", "10.15") + cmake_args.append(f'-DCMAKE_OSX_DEPLOYMENT_TARGET={os.environ.get("OSX_DEPLOYMENT_TARGET", "10.15")}') -if which("ccache"): +if which("ccache") and os.environ.get("CSP_USE_CCACHE", "") != "0": cmake_args.append("-DCSP_USE_CCACHE=On") print(f"CMake Args: {cmake_args}")