Skip to content

Commit 0fe5fda

Browse files
authored
Add osx and windows workflows (#2)
1 parent 6d85f52 commit 0fe5fda

File tree

7 files changed

+147
-6
lines changed

7 files changed

+147
-6
lines changed

.github/workflows/linux.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and test sparrow-ipc
1+
name: Linux build and test
22

33
on:
44
workflow_dispatch:
@@ -11,8 +11,12 @@ defaults:
1111
shell: bash -l -eo pipefail {0}
1212

1313
jobs:
14-
build:
14+
build_linux:
1515
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
build_type: [Release, Debug]
19+
build_shared: [ON, OFF]
1620
steps:
1721
- name: Checkout repository
1822
uses: actions/checkout@v4
@@ -25,9 +29,10 @@ jobs:
2529
- name: Build sparrow-ipc
2630
run: |
2731
cmake -B build/ -G Ninja \
28-
-DCMAKE_BUILD_TYPE=Release \
32+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
2933
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
3034
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
35+
-DSPARROW_IPC_BUILD_SHARED=${{ matrix.build_shared }} \
3136
-DBUILD_TESTS=ON
3237
cmake --build build/ --parallel
3338
- name: Run tests

.github/workflows/osx.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: OSX build and test
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches: [main]
8+
9+
defaults:
10+
run:
11+
shell: bash -l -eo pipefail {0}
12+
13+
jobs:
14+
build_osx:
15+
runs-on: macos-latest
16+
strategy:
17+
matrix:
18+
build_type: [Release, Debug]
19+
build_shared: [ON, OFF]
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
- name: Create build environment
24+
uses: mamba-org/setup-micromamba@v2
25+
with:
26+
environment-file: ./environment-dev.yml
27+
environment-name: build_env
28+
cache-environment: true
29+
- name: Build sparrow-ipc
30+
run: |
31+
cmake -B build/ -G Ninja \
32+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
33+
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
34+
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
35+
-DSPARROW_IPC_BUILD_SHARED=${{ matrix.build_shared }} \
36+
-DBUILD_TESTS=ON
37+
cmake --build build/ --parallel
38+
- name: Run tests
39+
run: |
40+
cd build
41+
ctest --output-on-failure

.github/workflows/windows.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Windows build and test
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches: [main]
8+
9+
defaults:
10+
run:
11+
# micromamba activation
12+
shell: cmd /C call {0}
13+
14+
jobs:
15+
build_windows:
16+
runs-on: windows-latest
17+
strategy:
18+
matrix:
19+
build_type: [Release, Debug]
20+
build_shared: [ON, OFF]
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
- name: Create build environment
25+
uses: mamba-org/setup-micromamba@v2
26+
with:
27+
environment-file: ./environment-dev.yml
28+
environment-name: build_env
29+
cache-environment: true
30+
init-shell: cmd.exe
31+
- name: Build sparrow-ipc
32+
run: |
33+
cmake -B build/ -G Ninja ^
34+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ^
35+
-DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX% ^
36+
-DCMAKE_PREFIX_PATH=%CONDA_PREFIX% ^
37+
-DSPARROW_IPC_BUILD_SHARED=${{ matrix.build_shared }} ^
38+
-DBUILD_TESTS=ON
39+
if %errorlevel% neq 0 exit /b %errorlevel%
40+
cmake --build build/ --parallel
41+
if %errorlevel% neq 0 exit /b %errorlevel%
42+
# TODO this is failing (to debug when dependencies can be fetched and built locally with debug mode)
43+
#- name: Run tests
44+
#run: |
45+
#cd build
46+
#ctest --output-on-failure
47+
#if %errorlevel% neq 0 exit /b %errorlevel%

CMakeLists.txt

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,38 @@ set(CMAKE_CXX_STANDARD 20)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)
77
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
88

9+
set(SPARROW_IPC_COMPILE_DEFINITIONS "" CACHE STRING "List of public compile definitions of the sparrow-ipc target")
10+
911
# Build options
1012
# =============
13+
14+
OPTION(SPARROW_IPC_BUILD_SHARED "Build sparrow-ipc as a shared library" ON)
15+
16+
if(SPARROW_IPC_BUILD_SHARED)
17+
message(STATUS "🔧 Build shared library")
18+
set(SPARROW_IPC_LIBRARY_TYPE SHARED)
19+
else()
20+
message(STATUS "🔧 Build static library")
21+
set(SPARROW_IPC_LIBRARY_TYPE STATIC)
22+
list(APPEND SPARROW_IPC_COMPILE_DEFINITIONS SPARROW_IPC_STATIC_LIB)
23+
endif()
24+
1125
OPTION(BUILD_TESTS "Build sparrow-ipc test suite" OFF)
1226
MESSAGE(STATUS "🔧 Build tests: ${BUILD_TESTS}")
1327

28+
set(SPARROW_IPC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
29+
set(SPARROW_IPC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
30+
31+
set(SPARROW_IPC_HEADERS
32+
# config
33+
${SPARROW_IPC_INCLUDE_DIR}/config/config.hpp
34+
${SPARROW_IPC_INCLUDE_DIR}/sparrow-ipc.hpp
35+
)
36+
37+
set(SPARROW_IPC_SRC
38+
${SPARROW_IPC_SOURCE_DIR}/sparrow-ipc.cpp
39+
)
40+
1441
set(SCHEMA_DIR ${CMAKE_BINARY_DIR}/format)
1542
set(FLATBUFFERS_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
1643

@@ -73,9 +100,11 @@ add_dependencies(flatbuffers_interface generate_flatbuffers_headers)
73100
find_package(FlatBuffers CONFIG REQUIRED)
74101
find_package(sparrow CONFIG REQUIRED)
75102

76-
# TODO Handle shared/static build later (after more code is available)
77-
add_library(sparrow-ipc STATIC src/sparrow-ipc.cpp)
78-
target_link_libraries(sparrow-ipc PRIVATE flatbuffers_interface flatbuffers::flatbuffers sparrow)
103+
add_library(sparrow-ipc ${SPARROW_IPC_LIBRARY_TYPE} ${SPARROW_IPC_SRC} ${SPARROW_IPC_HEADERS})
104+
target_compile_definitions(sparrow-ipc PUBLIC ${SPARROW_IPC_COMPILE_DEFINITIONS})
105+
target_include_directories(sparrow-ipc PUBLIC ${SPARROW_IPC_INCLUDE_DIR} PRIVATE ${SPARROW_IPC_SOURCE_DIR} )
106+
target_link_libraries(sparrow-ipc PRIVATE flatbuffers_interface)
107+
target_link_libraries(sparrow-ipc PUBLIC flatbuffers::flatbuffers sparrow::sparrow)
79108

80109
add_dependencies(sparrow-ipc generate_flatbuffers_headers)
81110

include/config/config.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
3+
#if defined(_WIN32)
4+
# if defined(SPARROW_IPC_STATIC_LIB)
5+
# define SPARROW_IPC_API
6+
# elif defined(SPARROW_IPC_EXPORTS)
7+
# define SPARROW_IPC_API __declspec(dllexport)
8+
# else
9+
# define SPARROW_IPC_API __declspec(dllimport)
10+
# endif
11+
#else
12+
# define SPARROW_IPC_API __attribute__((visibility("default")))
13+
#endif

include/sparrow-ipc.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include "../include/config/config.hpp"
2+
3+
SPARROW_IPC_API void fake_func_for_now();

src/sparrow-ipc.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include "sparrow/sparrow.hpp"
22

3+
#include "../include/sparrow-ipc.hpp"
34
#include "../generated/Schema_generated.h"
45

6+
void fake_func_for_now()
7+
{}

0 commit comments

Comments
 (0)