Skip to content

Commit

Permalink
feat build: build easy library in conan
Browse files Browse the repository at this point in the history
Tests: протестировано CI

Pull Request resolved: #804
commit_hash:4e55eb9309aaa8f70cecc61959d7be3dbcfcf784
  • Loading branch information
apolukhin committed Dec 24, 2024
1 parent d029f4c commit 5a3043c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 3 deletions.
1 change: 1 addition & 0 deletions .mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@
"conan/test_package/proto/greeter.proto":"taxi/uservices/userver/conan/test_package/proto/greeter.proto",
"conan/test_package/test_clickhouse.cpp":"taxi/uservices/userver/conan/test_package/test_clickhouse.cpp",
"conan/test_package/test_core.cpp":"taxi/uservices/userver/conan/test_package/test_core.cpp",
"conan/test_package/test_easy.cpp":"taxi/uservices/userver/conan/test_package/test_easy.cpp",
"conan/test_package/test_grpc.cpp":"taxi/uservices/userver/conan/test_package/test_grpc.cpp",
"conan/test_package/test_kafka.cpp":"taxi/uservices/userver/conan/test_package/test_kafka.cpp",
"conan/test_package/test_mongo.cpp":"taxi/uservices/userver/conan/test_package/test_mongo.cpp",
Expand Down
5 changes: 5 additions & 0 deletions conan/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,9 @@ if (TARGET userver::kafka)
target_link_libraries(${PROJECT_NAME}_kafka ${PROJECT_NAME}_objs userver::kafka)
endif()

if (TARGET userver::easy)
add_executable(${PROJECT_NAME}_easy test_easy.cpp)
target_link_libraries(${PROJECT_NAME}_easy userver::easy)
endif()

add_subdirectory(hello_service)
3 changes: 3 additions & 0 deletions conan/test_package/test_easy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <userver/easy.hpp>

int main() {}
63 changes: 60 additions & 3 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class UserverConan(ConanFile):
'with_utest': [True, False],
'with_kafka': [True, False],
'with_otlp': [True, False],
'with_easy': [True, False],
'with_s3api': [True, False],
'with_grpc_reflection': [True, False],
'namespace': ['ANY'],
'namespace_begin': ['ANY'],
'namespace_end': ['ANY'],
Expand All @@ -60,6 +63,9 @@ class UserverConan(ConanFile):
'with_utest': True,
'with_kafka': True,
'with_otlp': True,
'with_easy': True,
'with_s3api': False,
'with_grpc_reflection': False,
'namespace': 'userver',
'namespace_begin': 'namespace userver {',
'namespace_end': '}',
Expand Down Expand Up @@ -227,6 +233,11 @@ def generate(self):
)
tool_ch.variables['USERVER_FEATURE_KAFKA'] = self.options.with_kafka
tool_ch.variables['USERVER_FEATURE_OTLP'] = self.options.with_otlp
tool_ch.variables['USERVER_FEATURE_EASY'] = self.options.with_easy
tool_ch.variables['USERVER_FEATURE_S3API'] = self.options.with_s3api
tool_ch.variables['USERVER_FEATURE_GRPC_REFLECTION'] = (
self.options.with_grpc_reflection
)
tool_ch.generate()

CMakeDeps(self).generate()
Expand Down Expand Up @@ -266,19 +277,26 @@ def package(self):
keep_path=True,
)

def copy_component(component):
def copy_component(component, is_library: bool = False):
component_path = (
os.path.join('libraries', component)
if is_library
else component
)
copy(
self,
pattern='*',
dst=os.path.join(self.package_folder, 'include', component),
src=os.path.join(self.source_folder, component, 'include'),
src=os.path.join(
self.source_folder, component_path, 'include',
),
keep_path=True,
)
copy(
self,
pattern='*.a',
dst=os.path.join(self.package_folder, 'lib'),
src=os.path.join(self._build_subfolder, component),
src=os.path.join(self._build_subfolder, component_path),
keep_path=False,
)

Expand Down Expand Up @@ -399,6 +417,15 @@ def copy_component(component):
if self.options.with_otlp:
copy_component('otlp')

if self.options.with_easy:
copy_component('easy', is_library=True)

if self.options.with_s3api:
copy_component('s3api', is_library=True)

if self.options.with_grpc_reflection:
copy_component('grpc-reflection', is_library=True)

@property
def _userver_components(self):
def abseil():
Expand Down Expand Up @@ -489,6 +516,9 @@ def hiredis():
def amqpcpp():
return ['amqp-cpp::amqp-cpp'] if self.options.with_rabbitmq else []

def pugixml():
return ['pugixml::pugixml'] if self.options.with_s3api else []

def clickhouse():
return (
['clickhouse-cpp::clickhouse-cpp']
Expand Down Expand Up @@ -638,6 +668,33 @@ def librdkafka():
userver_components.extend([
{'target': 'otlp', 'lib': 'otlp', 'requires': ['core']},
])

if self.options.with_easy:
userver_components.extend([
{
'target': 'easy',
'lib': 'easy',
'requires': ['core', 'postgresql'],
},
])

if self.options.with_s3api:
userver_components.extend([
{
'target': 's3api',
'lib': 's3api',
'requires': ['core'] + pugixml(),
},
])

if self.options.with_grpc_reflection:
userver_components.extend([
{
'target': 'grpc-reflection',
'lib': 'grpc-reflection',
'requires': ['grpc'],
},
])
return userver_components

def package_info(self):
Expand Down

0 comments on commit 5a3043c

Please sign in to comment.