Skip to content

Commit e65dc9f

Browse files
committed
Stash all commits
0 parents  commit e65dc9f

24 files changed

+4039
-0
lines changed

.github/workflows/cmake.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CMake + SonarCloud Analysis
2+
3+
on: [push]
4+
5+
env:
6+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
7+
BUILD_TYPE: Release
8+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
10+
11+
jobs:
12+
build:
13+
# The CMake configure and build commands are platform agnostic and should work equally
14+
# well on Windows or Mac. You can convert this to a matrix build if you need
15+
# cross-platform coverage.
16+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Checkout submodules
25+
run: git submodule update --init --recursive
26+
27+
- name: Configure CMake
28+
shell: bash
29+
# Use a bash shell so we can use the same syntax for environment variable
30+
# access regardless of the host operating system
31+
# Note the current convention is to use the -S and -B options here to specify source
32+
# and build directories, but this is only available with CMake 3.13 and higher.
33+
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
34+
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_COTE_EXAMPLES=ON
35+
36+
- name: Build
37+
shell: bash
38+
run: |
39+
curl -L -O https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
40+
unzip -o build-wrapper-linux-x86.zip
41+
build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir cfamily-output make -j$(nproc)
42+
43+
- name: Test
44+
shell: bash
45+
# Execute tests defined by the CMake configuration.
46+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
47+
run: ctest -C $BUILD_TYPE
48+
49+
- name: SonarCloud
50+
shell: bash
51+
run: |
52+
curl -L -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.4.0.2170-linux.zip
53+
unzip sonar-scanner-cli-4.4.0.2170-linux.zip
54+
sonar-scanner-4.4.0.2170-linux/bin/sonar-scanner -Dsonar.host.url=https://sonarcloud.io -Dsonar.cfamily.threads=$(nproc) -Dsonar.cfamily.cache.enabled=false -Dsonar.branch.name=${GITHUB_REF##*/} -Dsonar.organization=joelguittet -Dsonar.projectKey=joelguittet_c-cote -Dsonar.cfamily.build-wrapper-output=cfamily-output -X

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CMakeCache.txt
2+
CMakeFiles/
3+
Makefile
4+
build/
5+
cmake_install.cmake
6+
install_manifest.txt

.gitmodules

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[submodule "lib/amp"]
2+
path = lib/amp
3+
url = https://github.com/joelguittet/c-amp.git
4+
[submodule "lib/discover"]
5+
path = lib/discover
6+
url = https://github.com/joelguittet/c-discover.git
7+
[submodule "lib/axon"]
8+
path = lib/axon
9+
url = https://github.com/joelguittet/c-axon.git
10+
[submodule "lib/cJSON"]
11+
path = lib/cJSON
12+
url = https://github.com/DaveGamble/cJSON.git

CMakeLists.txt

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# CMake minimum version
2+
cmake_minimum_required(VERSION 3.14)
3+
4+
# Project name
5+
project(c-cote)
6+
7+
# Project version
8+
set(COTE_VERSION_MAJOR 1)
9+
set(COTE_VERSION_MINOR 0)
10+
set(COTE_VERSION_PATCH 0)
11+
12+
# Additional flags
13+
set(c_flags "${c_flags} -Os -ffunction-sections -Wall -fPIC")
14+
set(linker_flags "${linker_flags} -Wl,-gc-sections")
15+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
16+
17+
# Definitions
18+
add_definitions(-DCOTE_EXPORT_SYMBOLS -DCOTE_API_VISIBILITY)
19+
20+
# Output directories
21+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/lib)
22+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/bin)
23+
24+
# CMake subdirectories
25+
if (NOT TARGET amp)
26+
if(EXISTS lib/amp)
27+
add_subdirectory(lib/amp)
28+
endif()
29+
endif()
30+
if (NOT TARGET axon)
31+
if(EXISTS lib/axon)
32+
add_subdirectory(lib/axon)
33+
endif()
34+
endif()
35+
if (NOT TARGET discover)
36+
if(EXISTS lib/discover)
37+
add_subdirectory(lib/discover)
38+
endif()
39+
endif()
40+
if(NOT TARGET cjson)
41+
if(EXISTS lib/cJSON)
42+
add_subdirectory(lib/cJSON)
43+
endif()
44+
endif()
45+
46+
# List of sources
47+
file(GLOB_RECURSE src "src/*.c")
48+
49+
# Add include directories
50+
include_directories(inc)
51+
if(EXISTS lib/amp)
52+
include_directories(lib/amp/inc)
53+
endif()
54+
if(EXISTS lib/axon)
55+
include_directories(lib/axon/inc)
56+
endif()
57+
if(EXISTS lib/discover)
58+
include_directories(lib/discover/inc)
59+
endif()
60+
if(EXISTS lib/cJSON)
61+
include_directories(lib/cJSON)
62+
endif()
63+
64+
# Creation of the library
65+
add_library(cote SHARED ${src})
66+
67+
# Link the library with the wanted libraries
68+
target_link_libraries(cote discover axon amp cjson pthread rt)
69+
70+
# Properties of the library
71+
set_target_properties(cote
72+
PROPERTIES
73+
SOVERSION "${COTE_VERSION_MAJOR}"
74+
VERSION "${COTE_VERSION_MAJOR}.${COTE_VERSION_MINOR}.${COTE_VERSION_PATCH}"
75+
)
76+
77+
# Creation of the examples binaries
78+
option(ENABLE_COTE_EXAMPLES "Enable building cote examples" OFF)
79+
if(ENABLE_COTE_EXAMPLES)
80+
add_executable(monitor "examples/monitor/monitor.c")
81+
target_link_libraries(monitor cote)
82+
add_executable(publisher "examples/pubsub/publisher.c")
83+
target_link_libraries(publisher cote)
84+
add_executable(subscriber "examples/pubsub/subscriber.c")
85+
target_link_libraries(subscriber cote)
86+
add_executable(publisher_namespace1 "examples/pubsub_namespace/publisher_namespace1.c")
87+
target_link_libraries(publisher_namespace1 cote)
88+
add_executable(subscriber_namespace1 "examples/pubsub_namespace/subscriber_namespace1.c")
89+
target_link_libraries(subscriber_namespace1 cote)
90+
add_executable(publisher_topic1_topic2 "examples/pubsub_topics/publisher_topic1_topic2.c")
91+
target_link_libraries(publisher_topic1_topic2 cote)
92+
add_executable(subscriber_topic1_topic2 "examples/pubsub_topics/subscriber_topic1_topic2.c")
93+
target_link_libraries(subscriber_topic1_topic2 cote)
94+
add_executable(subscriber_topic1 "examples/pubsub_topics/subscriber_topic1.c")
95+
target_link_libraries(subscriber_topic1 cote)
96+
add_executable(subscriber_topic2 "examples/pubsub_topics/subscriber_topic2.c")
97+
target_link_libraries(subscriber_topic2 cote)
98+
add_executable(subscriber_topics "examples/pubsub_topics/subscriber_topics.c")
99+
target_link_libraries(subscriber_topics cote)
100+
add_executable(requester "examples/reqrep/requester.c")
101+
target_link_libraries(requester cote)
102+
add_executable(responder "examples/reqrep/responder.c")
103+
target_link_libraries(responder cote)
104+
endif()
105+
106+
# Installation
107+
set(CMAKE_INSTALL_FULL_LIBDIR lib)
108+
set(CMAKE_INSTALL_FULL_BINDIR bin)
109+
set(CMAKE_INSTALL_FULL_INCLUDEDIR include)
110+
if(EXISTS lib/cJSON)
111+
install(FILES lib/cJSON/cJSON.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
112+
install(TARGETS cjson
113+
ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
114+
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
115+
RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}"
116+
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}"
117+
)
118+
endif()
119+
if(EXISTS lib/amp)
120+
install(FILES lib/amp/inc/amp.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
121+
install(TARGETS amp
122+
ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
123+
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
124+
RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}"
125+
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}"
126+
)
127+
endif()
128+
if(EXISTS lib/axon)
129+
install(FILES lib/axon/inc/axon.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
130+
install(TARGETS axon
131+
ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
132+
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
133+
RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}"
134+
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}"
135+
)
136+
endif()
137+
if(EXISTS lib/discover)
138+
install(FILES lib/discover/inc/discover.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
139+
install(TARGETS discover
140+
ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
141+
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
142+
RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}"
143+
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}"
144+
)
145+
endif()
146+
install(FILES inc/cote.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
147+
install(TARGETS cote
148+
ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
149+
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
150+
RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}"
151+
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}"
152+
)
153+
if(ENABLE_COTE_EXAMPLES)
154+
install(TARGETS monitor publisher subscriber publisher_namespace1 subscriber_namespace1 publisher_topic1_topic2 subscriber_topic1_topic2 subscriber_topic1 subscriber_topic2 subscriber_topics requester responder
155+
ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
156+
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
157+
RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}"
158+
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}"
159+
)
160+
endif()

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 joelguittet
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)