Skip to content

Commit effe33a

Browse files
authored
Merge pull request #815 from apache/feature/769-libuv-package-and-thread-header
Feature/769 libuv package and thread header
2 parents 6eca661 + 8571cbc commit effe33a

File tree

13 files changed

+424
-68
lines changed

13 files changed

+424
-68
lines changed

.devcontainer/Containerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ RUN DEBIAN_FRONTEND="noninteractive" sudo apt-get update && \
6868
libjansson-dev \
6969
libxml2-dev \
7070
libzip-dev \
71+
libuv1-dev \
7172
rapidjson-dev \
7273
uuid-dev && \
7374
sudo apt-get clean

.github/workflows/coverage.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@ jobs:
1919
- name: Install conan and lcov
2020
run: |
2121
sudo apt-get install -yq --no-install-recommends lcov
22-
sudo pip install conan==1.62.0 coverage
22+
sudo pip install -U conan coverage
2323
- name: Setup Conan Profile
2424
run: |
25-
conan profile new default --detect
26-
conan profile update settings.build_type=Debug default
27-
#Note no backwards compatiblity for gcc5 needed, setting libcxx to c++11.
28-
conan profile update settings.compiler.libcxx=libstdc++11 default
29-
echo "[tool_requires]" >> `conan config home`/profiles/default
30-
echo "cmake/3.26.4" >> `conan config home`/profiles/default
25+
# build profile
26+
conan profile detect -f --name release
27+
sed -i 's/compiler.cppstd=gnu14/compiler.cppstd=gnu17/g' `conan profile path release`
28+
echo "[tool_requires]" >> `conan profile path release`
29+
echo "cmake/3.26.4" >> `conan profile path release`
30+
31+
# host profile
32+
conan profile detect -f
33+
sed -i 's/build_type=Release/build_type=Debug/g' `conan profile path default`
34+
sed -i 's/compiler.cppstd=gnu14/compiler.cppstd=gnu17/g' `conan profile path default`
35+
echo "[tool_requires]" >> `conan profile path default`
36+
echo "cmake/3.26.4" >> `conan profile path default`
3137
- name: Conan Cache
3238
id: cache-conan
3339
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf #v4.2.2
@@ -48,19 +54,16 @@ jobs:
4854
key: ${{ runner.os }}-gcov-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
4955
restore-keys: |
5056
${{ runner.os }}-gcov-ccache-
51-
- name: Install Dependencies
57+
- name: Install Dependencies and Build
5258
env:
5359
CONAN_BUILD_OPTIONS: |
54-
-o celix:enable_testing=True
55-
-o celix:build_all=True
56-
-o celix:enable_code_coverage=True
57-
-o celix:enable_testing_on_ci=True
58-
-o celix:enable_ccache=True
60+
-o celix/*:enable_testing=True
61+
-o celix/*:build_all=True
62+
-o celix/*:enable_code_coverage=True
63+
-o celix/*:enable_testing_on_ci=True
64+
-o celix/*:enable_ccache=True
5965
run: |
60-
conan install . celix/ci -pr:b default -pr:h default -if build ${CONAN_BUILD_OPTIONS} -b missing --require-override=openssl/1.1.1s
61-
- name: Build
62-
run: |
63-
conan build . -bf build
66+
conan build . -pr:b release -pr:h default -of build ${CONAN_BUILD_OPTIONS} -b missing
6467
- name: Test with coverage
6568
run: |
6669
cd build

.github/workflows/macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0
8181
- name: Install dependencies
8282
run: |
83-
brew install lcov jansson rapidjson libzip ccache ninja openssl@1.1 google-benchmark
83+
brew install lcov jansson rapidjson libzip ccache ninja openssl@1.1 google-benchmark libuv
8484
- name: Prepare ccache timestamp
8585
id: ccache_cache_timestamp
8686
run: |

.github/workflows/ubuntu.yml

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,25 @@ jobs:
2828
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0
2929
- name: Install build dependencies
3030
run: |
31-
sudo pip install -U conan==1.62.0
31+
sudo pip install -U conan
3232
sudo apt-get install -yq --no-install-recommends ninja-build
3333
- name: Setup Conan Profile
3434
env:
3535
CC: ${{ matrix.compiler[0] }}
3636
CXX: ${{ matrix.compiler[1] }}
3737
run: |
3838
# build profile
39-
conan profile new release --detect
40-
conan profile update settings.build_type=Release release
41-
#Note no backwards compatibility for gcc5 needed, setting libcxx to c++11.
42-
conan profile update settings.compiler.libcxx=libstdc++11 release
43-
conan profile show release
44-
echo "[tool_requires]" >> `conan config home`/profiles/release
45-
echo "cmake/3.26.4" >> `conan config home`/profiles/release
39+
conan profile detect -f --name release
40+
sed -i 's/compiler.cppstd=gnu14/compiler.cppstd=gnu17/g' `conan profile path release`
41+
echo "[tool_requires]" >> `conan profile path release`
42+
echo "cmake/3.26.4" >> `conan profile path release`
43+
4644
# host profile
47-
conan profile new default --detect
48-
conan profile update settings.build_type=${{ matrix.type }} default
49-
#Note no backwards compatibility for gcc5 needed, setting libcxx to c++11.
50-
conan profile update settings.compiler.libcxx=libstdc++11 default
51-
conan profile show default
52-
echo "[tool_requires]" >> `conan config home`/profiles/default
53-
echo "cmake/3.26.4" >> `conan config home`/profiles/default
45+
conan profile detect -f
46+
sed -i 's/build_type=Release/build_type=${{ matrix.type }}/g' `conan profile path default`
47+
sed -i 's/compiler.cppstd=gnu14/compiler.cppstd=gnu17/g' `conan profile path default`
48+
echo "[tool_requires]" >> `conan profile path default`
49+
echo "cmake/3.26.4" >> `conan profile path default`
5450
- name: Conan Cache
5551
id: cache-conan
5652
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf #v4.2.2
@@ -71,29 +67,22 @@ jobs:
7167
key: ${{ runner.os }}-test-ccache-${{ matrix.compiler[0] }}-${{ matrix.type }}-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
7268
restore-keys: |
7369
${{ runner.os }}-test-ccache-${{ matrix.compiler[0] }}-${{ matrix.type }}-
74-
- name: Configure and install dependencies
70+
- name: Install Dependencies and Build
7571
env:
7672
CC: ${{ matrix.compiler[0] }}
7773
CXX: ${{ matrix.compiler[1] }}
7874
CONAN_BUILD_OPTIONS: |
79-
-o celix:enable_testing=True
80-
-o celix:enable_benchmarking=True
81-
-o celix:enable_address_sanitizer=True
82-
-o celix:enable_undefined_sanitizer=True
83-
-o celix:build_all=True
84-
-o celix:enable_cmake_warning_tests=True
85-
-o celix:enable_testing_on_ci=True
86-
-o celix:framework_curlinit=False
87-
-o celix:enable_ccache=True
75+
-o celix/*:enable_testing=True
76+
-o celix/*:enable_benchmarking=True
77+
-o celix/*:enable_address_sanitizer=True
78+
-o celix/*:enable_undefined_sanitizer=True
79+
-o celix/*:build_all=True
80+
-o celix/*:enable_cmake_warning_tests=True
81+
-o celix/*:enable_testing_on_ci=True
82+
-o celix/*:framework_curlinit=False
83+
-o celix/*:enable_ccache=True
8884
run: |
89-
conan install . celix/ci -c tools.cmake.cmaketoolchain:generator=Ninja -pr:b release -pr:h default -if build ${CONAN_BUILD_OPTIONS} -b missing
90-
- name: Build
91-
env:
92-
CC: ${{ matrix.compiler[0] }}
93-
CXX: ${{ matrix.compiler[1] }}
94-
CONAN_CMAKE_GENERATOR: Ninja
95-
run: |
96-
conan build . -bf build
85+
conan build . -c tools.cmake.cmaketoolchain:generator=Ninja -pr:b release -pr:h default -of build ${CONAN_BUILD_OPTIONS} -b missing
9786
- name: Test
9887
run: |
9988
cd build
@@ -123,6 +112,7 @@ jobs:
123112
libjansson-dev \
124113
libcurl4-openssl-dev \
125114
libbenchmark-dev \
115+
libuv1-dev \
126116
default-jdk \
127117
cmake \
128118
libffi-dev \

cmake/CelixConfig.cmake

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ include(CMakeFindDependencyMacro)
3535
set(THREADS_PREFER_PTHREAD_FLAG ON)
3636
find_dependency(Threads)
3737

38+
# The rest is added to ensure backwards compatibility with project using the cmake lib/include var instead of targets.
39+
set(CELIX_CMAKE_MODULES_DIR ${CELIX_REL_INSTALL_DIR}/share/celix/cmake/Modules)
40+
3841
#adds celix optional dependencies
3942
include("${CELIX_REL_INSTALL_DIR}/share/celix/cmake/CelixDeps.cmake")
4043

4144
#imports lib and exe targets (e.g. Celix::framework)
4245
include("${CELIX_REL_INSTALL_DIR}/share/celix/cmake/Targets.cmake")
4346
include("${CELIX_REL_INSTALL_DIR}/share/celix/cmake/CelixTargets.cmake")
4447

45-
# The rest is added to ensure backwards compatiblity with project using the cmake lib/include var instead of targets.
46-
set(CELIX_CMAKE_MODULES_DIR ${CELIX_REL_INSTALL_DIR}/share/celix/cmake/Modules)
47-
4848
set(CELIX_FRAMEWORK_INCLUDE_DIR "${CELIX_REL_INSTALL_DIR}/include/celix")
4949
set(CELIX_UTILS_INCLUDE_DIR "${CELIX_REL_INSTALL_DIR}/include/utils")
5050
set(CELIX_DFI_INCLUDE_DIR "${CELIX_REL_INSTALL_DIR}/include/dfi")
@@ -69,16 +69,6 @@ if (TARGET Celix::etcdlib)
6969
set(CELIX_ETCD_LIB Celix::etcdlib)
7070
endif ()
7171

72-
if (TARGET Celix::dependency_manager_so)
73-
set(CELIX_DM_LIB Celix::dependency_manager_so)
74-
set(CELIX_DM_INCLUDE_DIR $<TARGET_PROPERTY:Celix::dependency_manager_so,INTERFACE_INCLUDE_DIRECTORIES>)
75-
set(CELIX_DM_STATIC_LIB Celix::dependency_manager_static)
76-
endif ()
77-
if (TARGET Celix::dependency_manager_cxx)
78-
set(CELIX_DM_STATIC_CXX_LIB Celix::dependency_manager_cxx)
79-
set(CELIX_DM_CXX_STATIC_LIB $<TARGET_PROPERTY:Celix::dependency_manager_cxx,INTERFACE_INCLUDE_DIRECTORIES>)
80-
endif ()
81-
8272
set(CELIX_BUNDLES_DIR ${CELIX_REL_INSTALL_DIR}/share/celix/bundles)
8373
set(CELIX_SHELL_BUNDLE ${CELIX_BUNDLES_DIR}/shell.zip)
8474
set(CELIX_SHELL_TUI_BUNDLE ${CELIX_BUNDLES_DIR}/shell_tui.zip)

cmake/CelixDeps.cmake.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ $<$<BOOL:$<TARGET_NAME_IF_EXISTS:Celix::framework>>:find_dependency(libuuid)>
22
$<$<BOOL:$<TARGET_NAME_IF_EXISTS:Celix::deployment_admin>>:find_dependency(libuuid)>
33
$<$<BOOL:$<TARGET_NAME_IF_EXISTS:Celix::pubsub_spi>>:find_dependency(libuuid)>
44
$<$<BOOL:$<TARGET_NAME_IF_EXISTS:Celix::utils>>:find_dependency(libzip)>
5+
$<$<BOOL:$<TARGET_NAME_IF_EXISTS:Celix::utils>>:find_dependency(jansson)>
6+
$<$<BOOL:$<TARGET_NAME_IF_EXISTS:Celix::utils>>:find_dependency(libuv)>
57
$<$<BOOL:$<TARGET_NAME_IF_EXISTS:Celix::deployment_admin>>:find_dependency(ZLIB)>
68
$<$<BOOL:$<TARGET_NAME_IF_EXISTS:Celix::dfi>>:find_dependency(libffi)>
79
$<$<BOOL:$<TARGET_NAME_IF_EXISTS:Celix::dfi>>:find_dependency(jansson)>

cmake/Modules/Findlibuv.cmake

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# - Try to find libuv
19+
# Once done this will define
20+
# libuv_FOUND - System has libuv
21+
# LIBUV_INCLUDE_DIR - The libuv include directory
22+
# LIBUV_LIBRARY - The libuv library
23+
# uv - Imported target for libuv
24+
25+
find_package(libuv CONFIG QUIET)
26+
27+
if (NOT libuv_FOUND)
28+
find_package(PkgConfig QUIET)
29+
if (PkgConfig_FOUND)
30+
pkg_check_modules(LIBUV QUIET libuv)
31+
endif ()
32+
endif ()
33+
34+
if (NOT libuv_FOUND)
35+
find_path(LIBUV_INCLUDE_DIR
36+
NAMES uv.h
37+
HINTS ${LIBUV_INCLUDEDIR} ${LIBUV_INCLUDE_DIRS}
38+
)
39+
40+
find_library(LIBUV_LIBRARY
41+
NAMES uv libuv
42+
HINTS ${LIBUV_LIBDIR} ${LIBUV_LIBRARY_DIRS}
43+
)
44+
45+
include(FindPackageHandleStandardArgs)
46+
find_package_handle_standard_args(libuv DEFAULT_MSG LIBUV_LIBRARY LIBUV_INCLUDE_DIR)
47+
mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
48+
endif ()
49+
50+
if (libuv_FOUND AND NOT TARGET libuv::uv AND TARGET libuv::libuv)
51+
#Note: libuv cmake config possible defines libuv::libuv target
52+
# and conan libuv package defines uv target
53+
# so create an alias target uv for consistency
54+
add_library(libuv::uv ALIAS libuv::libuv)
55+
elseif (libuv_FOUND AND NOT TARGET libuv::uv AND LIBUV_LIBRARY AND LIBUV_INCLUDE_DIR)
56+
add_library(libuv::uv SHARED IMPORTED)
57+
set_target_properties(libuv::uv PROPERTIES
58+
IMPORTED_LOCATION "${LIBUV_LIBRARY}"
59+
INTERFACE_INCLUDE_DIRECTORIES "${LIBUV_INCLUDE_DIR}"
60+
)
61+
endif ()

conanfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ def configure(self):
309309
# https://github.com/conan-io/conan/issues/14528#issuecomment-1685344080
310310
if self.options.build_utils:
311311
self.options['libzip'].shared = True
312+
self.options['libuv'].shared = True
312313
if self.options.build_framework:
313314
self.options['util-linux-libuuid'].shared = True
314315
if ((self.options.build_framework and self.options.framework_curlinit)
@@ -340,6 +341,7 @@ def configure(self):
340341
def requirements(self):
341342
if self.options.build_utils:
342343
self.requires("libzip/[>=1.7.3 <2.0.0]")
344+
self.requires("libuv/[>=1.49.2 <2.0.0]")
343345
if self.options.build_framework:
344346
self.requires("util-linux-libuuid/[>=2.39 <3.0.0]")
345347
if self.settings.os == "Macos":

libs/utils/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
celix_subproject(UTILS "Option to enable building the Utilities library" ON)
1919
if (UTILS)
2020
find_package(libzip REQUIRED)
21-
find_package(jansson REQUIRED) #TODO add jansson dep info to build (conan) and documentation info
21+
find_package(jansson REQUIRED)
22+
find_package(libuv REQUIRED)
2223

2324
set(MEMSTREAM_SOURCES )
2425
set(MEMSTREAM_INCLUDES )
@@ -46,7 +47,7 @@ if (UTILS)
4647
${MEMSTREAM_SOURCES}
4748
)
4849
set(UTILS_PRIVATE_DEPS libzip::zip jansson::jansson)
49-
set(UTILS_PUBLIC_DEPS)
50+
set(UTILS_PUBLIC_DEPS libuv::uv)
5051

5152
add_library(utils SHARED ${UTILS_SRC})
5253

libs/utils/gtest/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ add_executable(test_utils
3535
src/VersionTestSuite.cc
3636
src/ErrTestSuite.cc
3737
src/ThreadsTestSuite.cc
38+
src/UvThreadsTestSuite.cc
3839
src/CelixErrnoTestSuite.cc
3940
src/CelixUtilsAutoCleanupTestSuite.cc
4041
src/ArrayListTestSuite.cc
4142
src/DeprecatedHashmapTestSuite.cc
4243
src/CxxExceptionsTestSuite.cc
4344
)
4445

45-
target_link_libraries(test_utils PRIVATE utils_cut Celix::utils GTest::gtest GTest::gtest_main libzip::zip)
46+
target_link_libraries(test_utils PRIVATE utils_cut Celix::utils GTest::gtest GTest::gtest_main libzip::zip libuv::uv)
4647
target_include_directories(test_utils PRIVATE ../src) #for version_private (needs refactoring of test)
4748
celix_deprecated_utils_headers(test_utils)
4849

0 commit comments

Comments
 (0)