-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e65dc9f
Showing
24 changed files
with
4,039 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: CMake + SonarCloud Analysis | ||
|
||
on: [push] | ||
|
||
env: | ||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | ||
BUILD_TYPE: Release | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
|
||
jobs: | ||
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 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Checkout submodules | ||
run: git submodule update --init --recursive | ||
|
||
- name: Configure CMake | ||
shell: bash | ||
# Use a bash shell so we can use the same syntax for environment variable | ||
# access regardless of the host operating system | ||
# Note the current convention is to use the -S and -B options here to specify source | ||
# and build directories, but this is only available with CMake 3.13 and higher. | ||
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12 | ||
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_COTE_EXAMPLES=ON | ||
|
||
- name: Build | ||
shell: bash | ||
run: | | ||
curl -L -O https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip | ||
unzip -o build-wrapper-linux-x86.zip | ||
build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir cfamily-output make -j$(nproc) | ||
- name: Test | ||
shell: bash | ||
# Execute tests defined by the CMake configuration. | ||
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | ||
run: ctest -C $BUILD_TYPE | ||
|
||
- name: SonarCloud | ||
shell: bash | ||
run: | | ||
curl -L -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.4.0.2170-linux.zip | ||
unzip sonar-scanner-cli-4.4.0.2170-linux.zip | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CMakeCache.txt | ||
CMakeFiles/ | ||
Makefile | ||
build/ | ||
cmake_install.cmake | ||
install_manifest.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[submodule "lib/amp"] | ||
path = lib/amp | ||
url = https://github.com/joelguittet/c-amp.git | ||
[submodule "lib/discover"] | ||
path = lib/discover | ||
url = https://github.com/joelguittet/c-discover.git | ||
[submodule "lib/axon"] | ||
path = lib/axon | ||
url = https://github.com/joelguittet/c-axon.git | ||
[submodule "lib/cJSON"] | ||
path = lib/cJSON | ||
url = https://github.com/DaveGamble/cJSON.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
# CMake minimum version | ||
cmake_minimum_required(VERSION 3.14) | ||
|
||
# Project name | ||
project(c-cote) | ||
|
||
# Project version | ||
set(COTE_VERSION_MAJOR 1) | ||
set(COTE_VERSION_MINOR 0) | ||
set(COTE_VERSION_PATCH 0) | ||
|
||
# Additional flags | ||
set(c_flags "${c_flags} -Os -ffunction-sections -Wall -fPIC") | ||
set(linker_flags "${linker_flags} -Wl,-gc-sections") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") | ||
|
||
# Definitions | ||
add_definitions(-DCOTE_EXPORT_SYMBOLS -DCOTE_API_VISIBILITY) | ||
|
||
# Output directories | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/lib) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/bin) | ||
|
||
# CMake subdirectories | ||
if (NOT TARGET amp) | ||
if(EXISTS lib/amp) | ||
add_subdirectory(lib/amp) | ||
endif() | ||
endif() | ||
if (NOT TARGET axon) | ||
if(EXISTS lib/axon) | ||
add_subdirectory(lib/axon) | ||
endif() | ||
endif() | ||
if (NOT TARGET discover) | ||
if(EXISTS lib/discover) | ||
add_subdirectory(lib/discover) | ||
endif() | ||
endif() | ||
if(NOT TARGET cjson) | ||
if(EXISTS lib/cJSON) | ||
add_subdirectory(lib/cJSON) | ||
endif() | ||
endif() | ||
|
||
# List of sources | ||
file(GLOB_RECURSE src "src/*.c") | ||
|
||
# Add include directories | ||
include_directories(inc) | ||
if(EXISTS lib/amp) | ||
include_directories(lib/amp/inc) | ||
endif() | ||
if(EXISTS lib/axon) | ||
include_directories(lib/axon/inc) | ||
endif() | ||
if(EXISTS lib/discover) | ||
include_directories(lib/discover/inc) | ||
endif() | ||
if(EXISTS lib/cJSON) | ||
include_directories(lib/cJSON) | ||
endif() | ||
|
||
# Creation of the library | ||
add_library(cote SHARED ${src}) | ||
|
||
# Link the library with the wanted libraries | ||
target_link_libraries(cote discover axon amp cjson pthread rt) | ||
|
||
# Properties of the library | ||
set_target_properties(cote | ||
PROPERTIES | ||
SOVERSION "${COTE_VERSION_MAJOR}" | ||
VERSION "${COTE_VERSION_MAJOR}.${COTE_VERSION_MINOR}.${COTE_VERSION_PATCH}" | ||
) | ||
|
||
# Creation of the examples binaries | ||
option(ENABLE_COTE_EXAMPLES "Enable building cote examples" OFF) | ||
if(ENABLE_COTE_EXAMPLES) | ||
add_executable(monitor "examples/monitor/monitor.c") | ||
target_link_libraries(monitor cote) | ||
add_executable(publisher "examples/pubsub/publisher.c") | ||
target_link_libraries(publisher cote) | ||
add_executable(subscriber "examples/pubsub/subscriber.c") | ||
target_link_libraries(subscriber cote) | ||
add_executable(publisher_namespace1 "examples/pubsub_namespace/publisher_namespace1.c") | ||
target_link_libraries(publisher_namespace1 cote) | ||
add_executable(subscriber_namespace1 "examples/pubsub_namespace/subscriber_namespace1.c") | ||
target_link_libraries(subscriber_namespace1 cote) | ||
add_executable(publisher_topic1_topic2 "examples/pubsub_topics/publisher_topic1_topic2.c") | ||
target_link_libraries(publisher_topic1_topic2 cote) | ||
add_executable(subscriber_topic1_topic2 "examples/pubsub_topics/subscriber_topic1_topic2.c") | ||
target_link_libraries(subscriber_topic1_topic2 cote) | ||
add_executable(subscriber_topic1 "examples/pubsub_topics/subscriber_topic1.c") | ||
target_link_libraries(subscriber_topic1 cote) | ||
add_executable(subscriber_topic2 "examples/pubsub_topics/subscriber_topic2.c") | ||
target_link_libraries(subscriber_topic2 cote) | ||
add_executable(subscriber_topics "examples/pubsub_topics/subscriber_topics.c") | ||
target_link_libraries(subscriber_topics cote) | ||
add_executable(requester "examples/reqrep/requester.c") | ||
target_link_libraries(requester cote) | ||
add_executable(responder "examples/reqrep/responder.c") | ||
target_link_libraries(responder cote) | ||
endif() | ||
|
||
# Installation | ||
set(CMAKE_INSTALL_FULL_LIBDIR lib) | ||
set(CMAKE_INSTALL_FULL_BINDIR bin) | ||
set(CMAKE_INSTALL_FULL_INCLUDEDIR include) | ||
if(EXISTS lib/cJSON) | ||
install(FILES lib/cJSON/cJSON.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") | ||
install(TARGETS cjson | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" | ||
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}" | ||
) | ||
endif() | ||
if(EXISTS lib/amp) | ||
install(FILES lib/amp/inc/amp.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") | ||
install(TARGETS amp | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" | ||
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}" | ||
) | ||
endif() | ||
if(EXISTS lib/axon) | ||
install(FILES lib/axon/inc/axon.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") | ||
install(TARGETS axon | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" | ||
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}" | ||
) | ||
endif() | ||
if(EXISTS lib/discover) | ||
install(FILES lib/discover/inc/discover.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") | ||
install(TARGETS discover | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" | ||
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}" | ||
) | ||
endif() | ||
install(FILES inc/cote.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") | ||
install(TARGETS cote | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" | ||
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}" | ||
) | ||
if(ENABLE_COTE_EXAMPLES) | ||
install(TARGETS monitor publisher subscriber publisher_namespace1 subscriber_namespace1 publisher_topic1_topic2 subscriber_topic1_topic2 subscriber_topic1 subscriber_topic2 subscriber_topics requester responder | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" | ||
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}" | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 joelguittet | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.