Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 29 additions & 32 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ name: CMake

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
Expand All @@ -18,41 +17,39 @@ jobs:
- uses: actions/checkout@v4
- uses: jidicula/clang-format-action@v4.13.0
with:
clang-format-version: '17'
exclude-regex: '(third_party)'
clang-format-version: "17"
exclude-regex: "(third_party)"

build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}
continue-on-error: true

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Packages (Ubuntu)
run: |
sudo apt-get install -y uuid-dev
if: matrix.os == 'ubuntu-latest'

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -Dflow-core_BUILD_TESTS=ON

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel 18

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Packages (Ubuntu)
run: |
sudo apt-get install -y uuid-dev
if: matrix.os == 'ubuntu-latest'

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -Dflow-core_BUILD_TESTS=ON

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel 18

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Test Module (${{matrix.os}})
path: ${{github.workspace}}/build/tests/test_module.fmod

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure
48 changes: 36 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2024, Cisco Systems, Inc.
# All rights reserved.

cmake_minimum_required(VERSION 3.10)

project(flow-core VERSION 1.1.1 LANGUAGES CXX)
Expand All @@ -15,8 +18,9 @@ endif()
# Options
# -----------------------------------------------------------------------------

option(flow-core_BUILD_TESTS "Build tests - requires gtest" OFF)
option(flow-core_INSTALL "Add installation targets" OFF)
option(${PROJECT_NAME}_BUILD_TESTS "Build tests (gtest)" OFF)
option(${PROJECT_NAME}_BUILD_TOOLS "Build tools" OFF)
option(${PROJECT_NAME}_INSTALL "Add installation targets" OFF)

# -----------------------------------------------------------------------------
# Dependencies
Expand All @@ -26,15 +30,21 @@ include(cmake/CPM.cmake)

CPMAddPackage("gh:nlohmann/json@3.11.3")
CPMAddPackage("gh:bshoshany/thread-pool@5.0.0")
CPMAddPackage("gh:Lecrapouille/zipper@3.0.0")
set_target_properties(zipper PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)

# -----------------------------------------------------------------------------
# Library
# -----------------------------------------------------------------------------

set(flow-core_HEADERS_DIR "${CMAKE_CURRENT_LIST_DIR}/include")
file(GLOB flow-core_HEADERS "${flow-core_HEADERS_DIR}/flow/core/*.hpp")
set(${PROJECT_NAME}_HEADERS_DIR "${CMAKE_CURRENT_LIST_DIR}/include")
file(GLOB ${PROJECT_NAME}_HEADERS "${${PROJECT_NAME}_HEADERS_DIR}/flow/core/*.hpp")
file(GLOB thread-pool_HEADERS "${thread-pool_SOURCE_DIR}/include/*.hpp")
list(APPEND ${flow-core_HEADERS} ${thread-pool_HEADERS})
list(APPEND ${${PROJECT_NAME}_HEADERS} ${thread-pool_HEADERS})

add_library(${PROJECT_NAME} SHARED
src/Connection.cpp
Expand All @@ -48,10 +58,11 @@ add_library(${PROJECT_NAME} SHARED
src/TypeConversion.cpp
src/UUID.cpp

${flow-core_HEADERS}
${${PROJECT_NAME}_HEADERS}
)

add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_compile_definitions(${PROJECT_NAME} PRIVATE FLOW_CORE_EXPORT)

target_include_directories(${PROJECT_NAME}
PUBLIC
Expand All @@ -68,31 +79,36 @@ if(APPLE)
target_link_libraries(${PROJECT_NAME} PUBLIC
"-framework CoreFoundation"
pthread
nlohmann_json::nlohmann_json
)
elseif(MSVC)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /MP)
target_link_libraries(${PROJECT_NAME} PUBLIC nlohmann_json::nlohmann_json)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror)
target_link_libraries(${PROJECT_NAME} PUBLIC
dl
pthread
uuid
nlohmann_json::nlohmann_json
)
endif()

target_link_libraries(${PROJECT_NAME} PUBLIC
nlohmann_json::nlohmann_json
)

target_link_libraries(${PROJECT_NAME} PRIVATE
zipper
)

# -----------------------------------------------------------------------------
# Install
# -----------------------------------------------------------------------------

if(flow-core_INSTALL)
if(${PROJECT_NAME}_INSTALL)
set(export_destination "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(export_targets ${PROJECT_NAME})

if (NOT flow-core_USE_EXTERNAL_JSON)
if (NOT ${PROJECT_NAME}_USE_EXTERNAL_JSON)
list(APPEND export_targets nlohmann_json)
endif()

Expand Down Expand Up @@ -131,7 +147,15 @@ endif()
# Tests
# -----------------------------------------------------------------------------

if (flow-core_BUILD_TESTS)
if (${PROJECT_NAME}_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()

# -----------------------------------------------------------------------------
# Tools
# -----------------------------------------------------------------------------

if (${PROJECT_NAME}_BUILD_TOOLS)
add_subdirectory(tools)
endif()
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
[![License: MIT](https://img.shields.io/github/license/InFlowStructure/flow-core)](https://github.com/InFlowStructure/flow-core/blob/main/LICENSE)
[![Language: C++20](https://img.shields.io/badge/Language-C%2B%2B20%20-blue)](https://en.cppreference.com/w/cpp/20)

![Linux](https://img.shields.io/badge/OS-Linux-blue)
![Windows](https://img.shields.io/badge/OS-Windows-blue)
![macOS](https://img.shields.io/badge/OS-macOS-blue)

## Overview

Flow Core is a cross-platform C++20 graph-based code engine designed for building dynamically modifiable code flows. It serves as a foundation for Low-Code/No-Code solutions by providing a flexible and extensible graph computation system.
Expand All @@ -26,18 +30,21 @@ Flow Core is a cross-platform C++20 graph-based code engine designed for buildin
## Dependencies

Flow Core relies on these open-source libraries:

- [nlohmann_json](https://github.com/nlohmann/json) - Modern JSON handling
- [thread-pool](https://github.com/bshoshany/thread-pool) - Efficient thread management

## Building

### Basic Build

```bash
cmake -B build
cmake --build build --parallel
```

### Build with Tests

```bash
cmake -B build -Dflow-core_BUILD_TESTS=ON
cmake --build build --parallel
Expand All @@ -46,6 +53,7 @@ cmake --build build --parallel
## Installation

Configure and install:

```bash
cmake -B build -Dflow-core_INSTALL=ON
cmake --build build --parallel
Expand All @@ -55,6 +63,7 @@ cmake --install build
## Getting Started

Check out our [documentation](docs/getting-started.md) for:

- Basic concepts and architecture
- Creating your first flow
- Building custom nodes
Expand Down
50 changes: 50 additions & 0 deletions cmake/FlowModule.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
function(CreateFlowModule module_name)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(MODULE_BINARY_DIR "linux")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(MODULE_BINARY_DIR "macos")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(MODULE_BINARY_DIR "windows")
else()
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
endif()

if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(x86_64|amd64|AMD64)$")
set(MODULE_BINARY_DIR "${MODULE_BINARY_DIR}/x86_64")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(arm64|aarch64)$")
set(MODULE_BINARY_DIR "${MODULE_BINARY_DIR}/arm64")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i386|i686)$")
set(MODULE_BINARY_DIR "${MODULE_BINARY_DIR}/x86")
else()
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif()

add_custom_command(TARGET ${module_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:${module_name}>
$<TARGET_FILE_DIR:${module_name}>/${module_name}/${MODULE_BINARY_DIR}/${module_name}${CMAKE_SHARED_LIBRARY_SUFFIX}
)

add_custom_command(TARGET ${module_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/module.json
$<TARGET_FILE_DIR:${module_name}>/${module_name}/module.json
)

add_custom_command(TARGET ${module_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/README.md
$<TARGET_FILE_DIR:${module_name}>/${module_name}/README.md
)

add_custom_command(TARGET ${module_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/LICENSE
$<TARGET_FILE_DIR:${module_name}>/${module_name}/LICENSE
)

add_custom_command(TARGET ${module_name} POST_BUILD
WORKING_DIRECTORY $<TARGET_FILE_DIR:${module_name}>
COMMAND ${CMAKE_COMMAND} -E tar -cfv ${CMAKE_CURRENT_BINARY_DIR}/${module_name}.fmod --format=zip ${module_name}/
)
endfunction()
4 changes: 2 additions & 2 deletions include/flow/core/Concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FLOW_NAMESPACE_END
/**
* @brief Type traits for compile-time type information and validation
*/
FLOW_SUBNAMESPACE_START(type_traits)
FLOW_SUBNAMESPACE_BEGIN(type_traits)

/**
* @brief Check if type is specialization of template
Expand All @@ -44,7 +44,7 @@ FLOW_SUBNAMESPACE_END
/**
* @brief Concepts for constraining template parameters
*/
FLOW_SUBNAMESPACE_START(concepts)
FLOW_SUBNAMESPACE_BEGIN(concepts)

/**
* @brief Requires type to be arithmetic (integral or floating point)
Expand Down
12 changes: 11 additions & 1 deletion include/flow/core/Core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
#error "Platform unsupported"
#endif

#if defined(__x86_64__) || defined(_M_X64) || defined(__amd64__)
#define FLOW_X86_64
#elif defined(__i386__) || defined(_M_IX86)
#define FLOW_X86
#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64)
#define FLOW_ARM
#else
#error "Architecture unsupported"
#endif

#ifdef FLOW_WINDOWS
#define FLOW_CORE_CALL __stdcall
#else
Expand All @@ -21,7 +31,7 @@

// clang-format off
#define FLOW_NAMESPACE_BEGIN namespace flow {
#define FLOW_SUBNAMESPACE_START(nested) namespace flow { namespace nested {
#define FLOW_SUBNAMESPACE_BEGIN(nested) namespace flow { namespace nested {
#define FLOW_NAMESPACE_END }
#define FLOW_SUBNAMESPACE_END } }
//clang-format on
Loading
Loading