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
40 changes: 40 additions & 0 deletions .github/workflows/macos-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Celix MacOS Nightly

on:
schedule:
- cron: '0 0 * * *'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macOS-latest]
compiler: [clang]
timeout-minutes: 120
steps:
- name: Checkout source code
uses: actions/checkout@master
- name: Install dependencies
run: |
brew update
brew install lcov zeromq czmq openssl cpputest
brew unlink openssl && brew link openssl --force
- name: Build
env:
CC: ${{ matrix.compiler }}
BUILD_OPTIONS: |
-DENABLE_TESTING=ON
-DENABLE_ADDRESS_SANITIZER=ON
run: |
mkdir build install
cd build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ${BUILD_OPTIONS} -DCMAKE_INSTALL_PREFIX=../install ..
make -j && make install
- name: Test
run: |
cd $GITHUB_WORKSPACE/build
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH:$(pwd)/utils:$(pwd)/framework:$(pwd)/dfi
make test ARGS="-V"

78 changes: 78 additions & 0 deletions .github/workflows/ubuntu-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Celix Ubuntu Nightly

on:
schedule:
- cron: '0 0 * * *'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
#os: [ubuntu-18.04, ubuntu-16.04]
#compiler: [gcc, clang]
include:
- os: ubuntu-18.04
name: clang
sanitizer: false #note sanitizer on clang with cpputest does not work
compiler: clang
cxx_compiler: clang++
- os: ubuntu-18.04
name: gcc
sanitizer: true
compiler: gcc
cxx_compiler: g++
- os: ubuntu-18.04
name: only v3 api
sanitizer: true
compiler: gcc
cxx_compiler: g++
v3_api: true
timeout-minutes: 120
steps:
- name: Checkout source code
uses: actions/checkout@master
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -yq --no-install-recommends \
build-essential \
curl \
uuid-dev \
libjansson-dev \
libcurl4-openssl-dev \
default-jdk \
cmake \
libffi-dev \
libxml2-dev \
libczmq-dev \
libcpputest-dev
- name: Build
env:
CC: ${{ matrix.compiler }}
CXX: ${{ matrix.cxx_compiler }}
BUILD_OPTIONS: |
-DENABLE_TESTING=ON
BUILD_OPTIONS_SANITIZER: |
-DENABLE_ADDRESS_SANITIZER=ON
BUILD_OPTIONS_V3_API: |
-DCELIX_USE_ZIP_INSTEAD_OF_JAR=ON
-DCELIX_INSTALL_DEPRECATED_API=OFF
run: |
mkdir build install
cd build
if [[ "${{ matrix.v3_api }}" == "true" ]]; then
export BUILD_OPTIONS="${BUILD_OPTIONS} ${BUILD_OPTIONS_V3_API}"
fi
if [[ "${{ matrix.sanitizer }}" == "true" ]]; then
export BUILD_OPTIONS="${BUILD_OPTIONS} ${BUILD_OPTIONS_SANITIZER}"
fi
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ${BUILD_OPTIONS} -DCMAKE_INSTALL_PREFIX=../install ..
make -j && make install
- name: Test
run: |
cd $GITHUB_WORKSPACE/build
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH:$(pwd)/utils:$(pwd)/framework:$(pwd)/dfi
make test ARGS="-V"

62 changes: 40 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

cmake_minimum_required (VERSION 3.2)
cmake_minimum_required (VERSION 3.14)
cmake_policy(SET CMP0012 NEW)
cmake_policy(SET CMP0042 NEW)
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.9.0")
Expand All @@ -39,27 +39,35 @@ if (ENABLE_TESTING)
endif()
endif ()

set(ENABLE_W_ERROR ON)
set(ENABLE_MORE_WARNINGS OFF)

IF (ANDROID)
set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -Wall ${CMAKE_C_FLAGS}")
ELSE ()
set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -fPIC ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-std=c++11 -fno-rtti ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-Wall -Werror ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Weffc++ ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG ${CMAKE_CXX_FLAGS}")
ENDIF()
# Set C specific flags
set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -fPIC ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "-Wall -Werror ${CMAKE_C_FLAGS}")

# Set C++ specific flags
set(CMAKE_CXX_FLAGS "-std=c++11 -fno-rtti ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wall -Werror -Wextra -Weffc++ ${CMAKE_CXX_FLAGS}")

IF(APPLE)
if(APPLE)
set(CMAKE_MACOSX_RPATH 1)
ELSE ()
endif()

if(NOT APPLE)
set(CMAKE_C_FLAGS "-pthread ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-pthread ${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-pthread ${CMAKE_EXE_LINKER_FLAGS}")
ENDIF()
endif()

# Set compiler specific options
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "-Wno-nullability-completeness -Wno-expansion-to-defined ${CMAKE_C_FLAGS}")
endif()

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_C_FLAGS "-Wno-unused-result -Wno-format-truncation -Wno-stringop-truncation -Wno-stringop-overflow ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wno-unused-result -Wno-format-truncation -Wno-stringop-truncation -Wno-stringop-overflow ${CMAKE_CXX_FLAGS}")
endif()

if (ENABLE_MORE_WARNINGS)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
Expand All @@ -82,15 +90,25 @@ if (ENABLE_MORE_WARNINGS)
set(CMAKE_CXX_EXTRA_FLAGS "-Wold-style-cast -Wuseless-cast ${CMAKE_CXX_EXTRA_FLAGS}")
endif()
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_EXTRA_FLAGS} ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_EXTRA_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
endif()

if(ENABLE_W_ERROR)
set(CMAKE_CXX_FLAGS "-Werror ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}")
endif()
# Set build type specific flags
# Debug
set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG ${CMAKE_CXX_FLAGS}")
set(CMAKE_DEBUG_POSTFIX "d")

# Release with debug info
# Optimization is disabled, enabled it will result in segfaults due to the ffi_call function
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O0 -g -DNDEBUG ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O0 -g -DNDEBUG ${CMAKE_CXX_FLAGS}")

# Release
# Optimization is disabled, enabled it will result in segfaults due to the ffi_call function
set(CMAKE_C_FLAGS_RELEASE "-O0 -DNDEBUG ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "-O0 -DNDEBUG ${CMAKE_CXX_FLAGS}")

# Set version for the framework package/release
set(CELIX_MAJOR "2")
Expand Down Expand Up @@ -137,7 +155,7 @@ add_subdirectory(examples/celix-examples examples)

#export targets
install(EXPORT celix NAMESPACE Celix:: DESTINATION share/celix/cmake FILE Targets.cmake COMPONENT cmake)
install_celix_targets(celix NAMESPACE Celix:: DESTINATION share/celix/cmake FILE CelixTargets.cmake COMPONENT cmake)
install_celix_targets(celix NAMESPACE Celix:: DESTINATION share/celix/cmake FILE CelixTargets COMPONENT cmake)

#install celix cmake modules
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/ DESTINATION share/celix/cmake/Modules)
Expand Down
2 changes: 1 addition & 1 deletion cmake/CelixConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ get_filename_component(REL_INSTALL_DIR "${REL_INSTALL_DIR}" PATH)

include("${REL_INSTALL_DIR}/share/celix/cmake/cmake_celix/UseCelix.cmake") #adds celix commands (e.g. add_celix_bundle)
include("${REL_INSTALL_DIR}/share/celix/cmake/Targets.cmake") #imports lib and exe targets (e.g. Celix::framework)
include("${REL_INSTALL_DIR}/share/celix/cmake/CelixTargets.cmake") #imports bundle targets (e.g. Celix::shell)
include("${REL_INSTALL_DIR}/share/celix/cmake/CelixTargets-${CMAKE_BUILD_TYPE}.cmake") #imports bundle targets (e.g. Celix::shell)

# The rest is added to ensure backwards compatiblity with project using the cmake lib/include var instead of targets.
set(CELIX_CMAKE_MODULES_DIR ${REL_INSTALL_DIR}/share/celix/cmake/Modules)
Expand Down
5 changes: 5 additions & 0 deletions cmake/celix_project/CelixProject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ option(ENABLE_ADDRESS_SANITIZER "Enabled building with address sanitizer. Note f
option(ENABLE_UNDEFINED_SANITIZER "Enabled building with undefined behavior sanitizer." OFF)
option(ENABLE_THREAD_SANITIZER "Enabled building with thread sanitizer." OFF)

# Clear "Advanced" flag for sanitizer options
mark_as_advanced(CLEAR ENABLE_ADDRESS_SANITIZER)
mark_as_advanced(CLEAR ENABLE_UNDEFINED_SANITIZER)
mark_as_advanced(CLEAR ENABLE_THREAD_SANITIZER)

if (ENABLE_ADDRESS_SANITIZER)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(CMAKE_C_FLAGS "-fsanitize=address -fno-omit-frame-pointer ${CMAKE_C_FLAGS}")
Expand Down
33 changes: 24 additions & 9 deletions cmake/cmake_celix/BundlePackaging.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
Expand All @@ -15,6 +16,9 @@
# specific language governing permissions and limitations
# under the License.


set(CELIX_NO_POSTFIX_BUILD_TYPE "RelWithDebInfo" CACHE STRING "The build type used for creating bundle without a build type postfix.")

find_program(JAR_COMMAND jar NO_CMAKE_FIND_ROOT_PATH)

if(JAR_COMMAND AND NOT CELIX_USE_ZIP_INSTEAD_OF_JAR)
Expand Down Expand Up @@ -107,7 +111,7 @@ Optional arguments are:
- GROUP: The group the bundle is part of. This will be used as Bundle-Group manifest entry. Default this is empty (no group).
- VERSION: The bundle version. This will be used for the Bundle-Version manifest entry. In combination with SOURCES the version will also be used to set the activator library target property VERSION and SOVERSION.
For SOVERSION only the major part is used. Expected scheme is "<major>.<minor>.<path>". Default version is "0.0.0"
- FILENAME: The filename of the bundle file. Default is <bundle_target_name>.zip.
- FILENAME: The filename of the bundle file, without extension. Default is <bundle_target_name>. Together with the BUILD_TYPE, this will result in a filename like "bundle_target_name_Debug.zip
- PRIVATE_LIBRARIES: private libraries to be included in the bundle. Specified libraries are added to the "Private-Library" manifest statement and added in the root of the bundle. libraries can be cmake library targets or absolute paths to existing libraries.
- HEADERS: Additional headers values that are appended to the bundle manifest.

Expand Down Expand Up @@ -189,8 +193,15 @@ function(add_celix_bundle)
if (NOT DEFINED BUNDLE_SYMBOLIC_NAME)
set(BUNDLE_SYMBOLIC_NAME ${BUNDLE_TARGET_NAME})
endif ()

if (NOT DEFINED BUNDLE_FILENAME)
set(BUNDLE_FILENAME ${BUNDLE_TARGET_NAME}.zip)
set(BUNDLE_FILENAME ${BUNDLE_TARGET_NAME})
endif ()

if ("${CMAKE_BUILD_TYPE}" STREQUAL "${CELIX_NO_POSTFIX_BUILD_TYPE}")
set(BUNDLE_FILENAME ${BUNDLE_FILENAME}.zip)
else ()
set(BUNDLE_FILENAME ${BUNDLE_FILENAME}-${CMAKE_BUILD_TYPE}.zip)
endif ()

set(BUNDLE_FILE "${CMAKE_CURRENT_BINARY_DIR}/${BUNDLE_FILENAME}")
Expand Down Expand Up @@ -762,7 +773,7 @@ function(install_celix_bundle)
if (INSTALL_EXPORT)
get_target_property(CURRENT_EXPORT_BUNDLES celix-bundles EXPORT_${INSTALL_EXPORT}_BUNDLES)

if (NOT CURRENT_EXPORT_BUNDLES)
if (NOT CURRENT_EXPORT_BUNDLES)
set(CURRENT_EXPORT_BUNDLES ${BUNDLE})
else ()
list(APPEND CURRENT_EXPORT_BUNDLES ${BUNDLE})
Expand Down Expand Up @@ -791,7 +802,7 @@ install using the provided <export_name>. These imported CMake targets can be us
bundles.

Optional Arguments:
- FILE: The Celix Targets cmake filename to used. Default is <export_name>BundleTargets.cmake
- FILE: The Celix Targets cmake filename to used, without the cmake extension. Default is <export_name>BundleTargets
- PROJECT_NAME: The project name to used for the share location. Default is the cmake project name.
- DESTINATION: The (relative) location to install the Celix Targets cmake file to. Default is share/<PROJECT_NAME>/cmake.

Expand All @@ -803,7 +814,7 @@ install_celix_targets(<export_name>
)

Example:
install_celix_targets(celix NAMESPACE Celix:: DESTINATION share/celix/cmake FILE CelixTargets.cmake)
install_celix_targets(celix NAMESPACE Celix:: DESTINATION share/celix/cmake FILE CelixTargets)
]]

function(install_celix_bundle_targets)
Expand All @@ -825,10 +836,14 @@ function(install_celix_bundle_targets)
message(FATAL_ERROR "Please provide a namespace used for the generated cmake targets.")
endif ()


if (NOT DEFINED EXPORT_FILE)
set(EXPORT_FILE ${EXPORT_NAME}BundleTargets.cmake)
set(EXPORT_FILE ${EXPORT_NAME}BundleTargets)
endif ()

# if (NOT CMAKE_BUILD_TYPE STREQUAL "Release")
set(EXPORT_FILE ${EXPORT_FILE}-${CMAKE_BUILD_TYPE})
# endif ()

if (NOT DEFINED EXPORT_PROJECT_NAME)
string(TOLOWER ${PROJECT_NAME} EXPORT_PROJECT_NAME)
endif()
Expand Down Expand Up @@ -875,8 +890,8 @@ endif ()
file(GENERATE OUTPUT "${CONF_FILE}" INPUT "${CONF_IN_FILE}")

if (EXPORT_COMPONENT)
install(FILES "${CONF_FILE}" DESTINATION ${EXPORT_DESTINATION} RENAME ${EXPORT_FILE} COMPONENT ${EXPORT_COMPONENT})
install(FILES "${CONF_FILE}" DESTINATION ${EXPORT_DESTINATION} RENAME ${EXPORT_FILE}.cmake COMPONENT ${EXPORT_COMPONENT})
else ()
install(FILES "${CONF_FILE}" DESTINATION ${EXPORT_DESTINATION} RENAME ${EXPORT_FILE})
install(FILES "${CONF_FILE}" DESTINATION ${EXPORT_DESTINATION} RENAME ${EXPORT_FILE}.cmake)
endif ()
endfunction()
6 changes: 3 additions & 3 deletions documents/cmake_commands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Optional arguments are:
- GROUP: The group the bundle is part of. This will be used as Bundle-Group manifest entry. Default this is empty (no group).
- VERSION: The bundle version. This will be used for the Bundle-Version manifest entry. In combination with SOURCES the version will also be used to set the activator library target property VERSION and SOVERSION.
For SOVERSION only the major part is used. Expected scheme is "<major>.<minor>.<path>". Default version is "0.0.0"
- FILENAME: The filename of the bundle file. Default is <bundle_target_name>.zip.
- FILENAME: The filename of the bundle file, without extension. Default is <bundle_target_name>. Together with the BUILD_TYPE, this will result in a filename like "bundle_target_name_Debug.zip
- PRIVATE_LIBRARIES: private libraries to be included in the bundle. Specified libraries are added to the "Private-Library" manifest statement and added in the root of the bundle. libraries can be cmake library targets or absolute paths to existing libraries.
- HEADERS: Additional headers values that are appended to the bundle manifest.

Expand Down Expand Up @@ -189,7 +189,7 @@ install using the provided <export_name>. These imported CMake targets can be us
bundles.

Optional Arguments:
- FILE: The Celix Targets cmake filename to used. Default is <export_name>BundleTargets.cmake
- FILE: The Celix Targets cmake filename to used, without the cmake extension. Default is <export_name>BundleTargets.
- PROJECT_NAME: The project name to used for the share location. Default is the cmake project name.
- DESTINATION: The (relative) location to install the Celix Targets cmake file to. Default is share/<PROJECT_NAME>/cmake.

Expand All @@ -204,7 +204,7 @@ install_celix_targets(<export_name>

Example:
```CMake
install_celix_targets(celix NAMESPACE Celix:: DESTINATION share/celix/cmake FILE CelixTargets.cmake)
install_celix_targets(celix NAMESPACE Celix:: DESTINATION share/celix/cmake FILE CelixTargets)
```


Expand Down
15 changes: 14 additions & 1 deletion libs/framework/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ add_celix_bundle(bundle_with_exception SOURCES src/nop_activator.c VERSION 1.0.0
add_subdirectory(subdir) #simple_test_bundle4, simple_test_bundle5 and sublib

add_celix_bundle(unresolveable_bundle SOURCES src/nop_activator.c VERSION 1.0.0)
target_link_libraries(unresolveable_bundle PRIVATE "-L${CMAKE_CURRENT_BINARY_DIR}/subdir -lsublib")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(POSTFIX ${CMAKE_DEBUG_POSTFIX})
endif()
target_link_libraries(unresolveable_bundle PRIVATE "-L${CMAKE_CURRENT_BINARY_DIR}/subdir -lsublib${POSTFIX}")
if(NOT APPLE)
set_target_properties(unresolveable_bundle PROPERTIES LINK_FLAGS -Wl,--no-as-needed)
endif()
Expand All @@ -41,6 +44,16 @@ target_link_libraries(test_framework Celix::framework CURL::libcurl GTest::gtest
add_dependencies(test_framework simple_test_bundle1_bundle simple_test_bundle2_bundle simple_test_bundle3_bundle simple_test_bundle4_bundle simple_test_bundle5_bundle bundle_with_exception_bundle unresolveable_bundle_bundle)
target_include_directories(test_framework PRIVATE ../src)

target_compile_definitions(test_framework PRIVATE
-DSIMPLE_TEST_BUNDLE1_LOCATION="$<TARGET_PROPERTY:simple_test_bundle1,BUNDLE_FILE>"
-DSIMPLE_TEST_BUNDLE2_LOCATION="$<TARGET_PROPERTY:simple_test_bundle2,BUNDLE_FILE>"
-DSIMPLE_TEST_BUNDLE3_LOCATION="$<TARGET_PROPERTY:simple_test_bundle3,BUNDLE_FILE>"
-DSIMPLE_TEST_BUNDLE4_LOCATION="$<TARGET_PROPERTY:simple_test_bundle4,BUNDLE_FILENAME>"
-DSIMPLE_TEST_BUNDLE5_LOCATION="$<TARGET_PROPERTY:simple_test_bundle5,BUNDLE_FILENAME>"
-DTEST_BUNDLE_WITH_EXCEPTION_LOCATION="$<TARGET_PROPERTY:bundle_with_exception,BUNDLE_FILE>"
-DTEST_BUNDLE_UNRESOLVEABLE_LOCATION="$<TARGET_PROPERTY:unresolveable_bundle,BUNDLE_FILE>"
)

configure_file(config.properties.in config.properties @ONLY)
configure_file(framework1.properties.in framework1.properties @ONLY)
configure_file(framework2.properties.in framework2.properties @ONLY)
Expand Down
Loading