Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add aws-cdi-sdk 2.2.0 #7407

Merged
merged 12 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from 10 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
10 changes: 10 additions & 0 deletions recipes/aws-cdi-sdk/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.5)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(AWSSDK REQUIRED)
add_library(aws-cpp-sdk-core ALIAS AWS::aws-sdk-cpp-core)

add_subdirectory(source_subfolder/aws-cpp-sdk-cdi)
8 changes: 8 additions & 0 deletions recipes/aws-cdi-sdk/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sources:
"2.2.0":
url: https://github.com/aws/aws-cdi-sdk/archive/refs/tags/v2.2.0.tar.gz
sha256: 4ee109b7fa2f683b4b0cd03028d0946857f09f34da4e89fe69a5c297cdaeb689
patches:
"2.2.0":
- base_path: source_subfolder
patch_file: patches/001-Makefile.patch
141 changes: 141 additions & 0 deletions recipes/aws-cdi-sdk/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import os
import re

from conans import AutoToolsBuildEnvironment, CMake, ConanFile, tools
from conans.errors import ConanInvalidConfiguration

required_conan_version = ">=1.35.0"

class AwsCdiSdkConan(ConanFile):
name = "aws-cdi-sdk"
SSE4 marked this conversation as resolved.
Show resolved Hide resolved
description = "AWS Cloud Digital Interface (CDI) SDK"
topics = ("aws", "communication", "framework", "service")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/aws/aws-cdi-sdk"
license = "BSD-2-Clause"
settings = "os", "arch", "compiler", "build_type"
exports_sources = ["CMakeLists.txt", "patches/**"]
generators = "cmake", "cmake_find_package"

@property
def _source_subfolder(self):
return "source_subfolder"

_autotools = None
_cmake = None

def requirements(self):
self.requires("aws-libfabric/1.9.1amzncdi1.0")
self.requires("aws-sdk-cpp/1.8.130")

def configure(self):
self.options["aws-libfabric"].shared = True
self.options["aws-sdk-cpp"].shared = True

def validate(self):
if self.settings.os != "Linux":
raise ConanInvalidConfiguration("This recipe currently only supports Linux. Feel free to contribute other platforms!")
if not self.options["aws-libfabric"].shared or not self.options["aws-sdk-cpp"].shared:
raise ConanInvalidConfiguration("Cannot build with static dependencies")
if not getattr(self.options["aws-sdk-cpp"], "monitoring"):
raise ConanInvalidConfiguration("This package requires the monitoring AWS SDK")
tools.check_min_cppstd(self, 11)
dvirtz marked this conversation as resolved.
Show resolved Hide resolved

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self)
return self._autotools

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.configure()
return self._cmake

def _detect_compilers(self):
cmake_cache = tools.load(os.path.join(self.build_folder, "CMakeCache.txt"))
cc = re.search("CMAKE_C_COMPILER:FILEPATH=(.*)", cmake_cache)[1]
cxx = re.search("CMAKE_CXX_COMPILER:FILEPATH=(.*)", cmake_cache)[1]
return cc, cxx

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)

# build aws-cpp-sdk-cdi
cmake = self._configure_cmake()
cmake.build()

autotools = self._configure_autotools()
with tools.chdir(self._source_subfolder):
# configure autotools to find aws-cpp-sdk-cdi
autotools.include_paths.append(os.path.join(self.build_folder, self._source_subfolder, "aws-cpp-sdk-cdi", "include"))
autotools.library_paths.append(os.path.join(self.build_folder, "lib"))
autotools.libs.append("aws-cpp-sdk-cdi")

vars = autotools.vars
cc, cxx = self._detect_compilers()
dvirtz marked this conversation as resolved.
Show resolved Hide resolved
vars["CC"] = cc
vars["CXX"] = cxx
if self.settings.build_type == "Debug":
vars["DEBUG"] = "y"

args = ["require_aws_sdk=no"]

autotools.make(target="libsdk", vars=vars, args=args)

def package(self):
cmake = self._configure_cmake()
cmake.install()

self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include"))
config = "debug" if self.settings.build_type == "Debug" else "release"
self.copy(pattern="*", dst="lib", src=os.path.join(self._source_subfolder, "build", config, "lib"))

tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "AWS"
self.cpp_info.names["cmake_find_package_multi"] = "AWS"
self.cpp_info.filenames["cmake_find_package"] = "aws-cdi-sdk"
self.cpp_info.filenames["cmake_find_package_multi"] = "aws-cdi-sdk"

cppSdk = self.cpp_info.components["aws-cpp-sdk-cdi"]
cppSdk.libs = ["aws-cpp-sdk-cdi"]

cppSdk.requires = ["aws-sdk-cpp::monitoring", "aws-libfabric::aws-libfabric"]

cppSdk.set_property("cmake_file_name", "aws-cpp-sdk-cdi")
cppSdk.set_property("cmake_target_name", "AWS::aws-cpp-sdk-cdi")
cppSdk.set_property("pkg_config_name", "aws-cpp-sdk-cdi")

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
# TODO: Remove the namespace on CMake targets
cppSdk.names["cmake_find_package"] = "aws-cpp-sdk-cdi"
cppSdk.names["cmake_find_package_multi"] = "aws-cpp-sdk-cdi"
cppSdk.names["pkg_config"] = "aws-cpp-sdk-cdi"

cSdk = self.cpp_info.components["cdisdk"]
cSdk.libs = ["cdisdk"]
cSdk.requires = ["aws-cpp-sdk-cdi"]
if self.settings.os == "Linux":
SSE4 marked this conversation as resolved.
Show resolved Hide resolved
cSdk.defines = ["_LINUX"]

cSdk.set_property("cmake_file_name", "aws-cdi-sdk")
cSdk.set_property("cmake_target_name", "AWS::aws-cdi-sdk")
cSdk.set_property("pkg_config_name", "aws-cdi-sdk")

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
# TODO: Remove the namespace on CMake targets
cSdk.names["cmake_find_package"] = "aws-cdi-sdk"
cSdk.names["cmake_find_package_multi"] = "aws-cdi-sdk"
cSdk.names["pkg_config"] = "aws-cdi-sdk"

Copy link
Contributor

@SpaceIm SpaceIm Mar 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still wrong and inconsistent. See #7407 (comment)

100 changes: 100 additions & 0 deletions recipes/aws-cdi-sdk/all/patches/001-Makefile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
commit dfff3ca2bd52df35be52ec104d1f31f1e4aeef0e
Author: dvirtz <dvirtz@gmail.com>
Date: Tue Aug 3 16:48:41 2021 +0300

build with external sdk

diff --git a/Makefile b/Makefile
index 6929dee..74194b5 100644
--- a/Makefile
+++ b/Makefile
@@ -98,9 +98,6 @@ endif
# makefile.[name].vars.mk.
-include makefile.*.vars.mk

-ifeq ($(top.libfabric),)
- $(error libfabric source tree not found)
-endif
# Build artifacts for libfabric go into a debug or release directory under top.libfabric
build_dir.libfabric := $(top.libfabric)/build/$(config_libfabric)

@@ -127,7 +124,7 @@ srcs.cdi := $(foreach ext,c cpp,$(wildcard $(src_dir.cdi)/*.$(ext)))
srcs.cdi += queue.c fifo.c list.c logger.c os_linux.c pool.c
objs.cdi := $(addprefix $(build_dir.obj)/,$(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(notdir $(srcs.cdi)))))
headers.cdi := $(foreach dir,$(include_dirs.cdi),$(wildcard $(dir)/*.h))
-include_opts.cdi := $(foreach proj,cdi libfabric,$(addprefix -I,$(include_dirs.$(proj))))
+include_opts.cdi := $(foreach proj,cdi,$(addprefix -I,$(include_dirs.$(proj))))
depends.cdi := $(patsubst %.o,%.d,$(objs.cdi))

# the end goal of building the SDK library
@@ -186,24 +183,24 @@ headers.all := $(foreach dir,cdi test test_common test_min_tx test_min_rx test_u
# augment compiler flags
COMMON_COMPILER_FLAG_ADDITIONS := \
$(include_opts.cdi) $(include_opts.test) \
- $(EXTRA_COMPILER_FLAG_ADDITIONS) \
- -Wall -Wextra -Werror -pthread -fPIC \
+ -Wall -Wextra -pthread -fPIC \
-D_LINUX -D_POSIX_C_SOURCE=200112L \
- $(sanitize_opts)
+ $(sanitize_opts) \
+ $(EXTRA_COMPILER_FLAG_ADDITIONS)
ifeq ($(config), debug)
COMMON_COMPILER_FLAG_ADDITIONS += -O0 -g -DDEBUG
else
COMMON_COMPILER_FLAG_ADDITIONS += -O3 -DNDEBUG
endif

-CFLAGS += $(COMMON_COMPILER_FLAG_ADDITIONS) --std=c99
-CXXFLAGS += $(COMMON_COMPILER_FLAG_ADDITIONS) --std=c++11
+CFLAGS += $(CPPFLAGS) $(COMMON_COMPILER_FLAG_ADDITIONS) --std=c99
+CXXFLAGS += $(CPPFLAGS) $(COMMON_COMPILER_FLAG_ADDITIONS) --std=c++11

# additional flags to pass to the linker to create cdi_test* programs
# The only libraries needed here are those that present new dependencies beyond what libcdisdk.so already requires.
# An rpath is specified so cdi_test can find libcdisdk.so.2 in the same directory as cdi_test or in a sibling directory
# named lib.
-CDI_LDFLAGS = $(LDFLAGS) -L$(build_dir.lib) -lcdisdk -lfabric $(EXTRA_LD_LIBS) -lncurses -lm $(aws_sdk_library_flags) \
+CDI_LDFLAGS = $(LDFLAGS) -L$(build_dir.lib) -lcdisdk -lfabric $(EXTRA_LD_LIBS) -lncurses -lm \
-Wl,-rpath,\$$ORIGIN:\$$ORIGIN/../lib64:\$$ORIGIN/../lib

# docs go into the build directory but are not specific to release/debug
@@ -284,7 +281,7 @@ vpath %.c $(foreach proj,cdi common test test_common test_minimal test_unit,$(sr
vpath %.cpp $(src_dir.cdi)

# rule to create the various build output directories
-$(foreach d,obj lib bin doc packages libfabric results image libaws,$(build_dir.$(d))) :
+$(foreach d,obj lib bin doc packages results image libaws,$(build_dir.$(d))) :
$(Q)mkdir -p $@

# Setup flags for libfabric depending on debug/release build target.
@@ -321,12 +318,10 @@ $(libfabric) : $(libfabric_config_h) | $(build_dir.lib)
# rule to create the SDK library file
.PHONY : libsdk
libsdk : $(libsdk)
-$(libsdk) : $(libfabric_config_h) $(objs.cdi) $(libfabric) $(libaws) | $(build_dir.lib)
+$(libsdk) : $(objs.cdi) | $(build_dir.lib)
@echo "GCC version is" $(GCCVERSION)
$(Q)$(CC) -shared -o $@ -Wl,-z,defs,-soname=$(basename $(notdir $@)),--version-script,libcdisdk.vers \
- $(objs.cdi) -L$(build_dir.lib) $(aws_sdk_library_flags) \
- -lfabric -ldl -lrt $(EXTRA_CC_LIBS) -lnl-3 -lm $(EXTRA_LD_LIBS) -lpthread -lc \
- $(ASAN_LIBS) -Wl,-rpath,\$$ORIGIN:\$$ORIGIN/../lib
+ $(objs.cdi) $(LDFLAGS) $(LIBS)
$(Q)ln -fs $@ $(basename $@)
$(Q)ln -fs $@ $(basename $(basename $@))

@@ -432,13 +427,12 @@ clean ::
$(Q)$(RM) -r $(top.build)

cleanall :: clean
- $(Q)$(RM) -r $(top.libfabric)/build $(libfabric_config_h)

-$(depends.cdi) : $(libfabric_config_h) $(aws_h)
+$(depends.cdi) : $(aws_h)

# include dependency rules from generated files; this is conditional so .d files are only created if needed.
ifneq ($(real_build_goals),)
--include $(foreach proj,cdi test test_min_tx test_min_rx test_unit,$(depends.$(proj)))
+-include $(foreach proj,$(real_build_goals),$(depends.$(proj)))
endif

# Users can add their own rules to this makefile by creating a makefile in this directory called
10 changes: 10 additions & 0 deletions recipes/aws-cdi-sdk/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup(TARGETS)

find_package(aws-cdi-sdk REQUIRED)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} AWS::aws-cdi-sdk)
17 changes: 17 additions & 0 deletions recipes/aws-cdi-sdk/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
16 changes: 16 additions & 0 deletions recipes/aws-cdi-sdk/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* example was taken from https://www.gnu.org/ghm/2011/paris/slides/andreas-enge-mpc.pdf */

#include <cdi_core_api.h>
#include <cdi_logger_api.h>
#include <stdlib.h>

int main () {
CdiLoggerInitialize(); // Intialize logger so we can use the CDI_LOG_THREAD() macro to generate console messages.

CDI_LOG_THREAD(kLogInfo, "CDI SDK Version: %d.%d.%d\n", CDI_SDK_VERSION, CDI_SDK_MAJOR_VERSION,
CDI_SDK_MINOR_VERSION);

CdiLoggerShutdown(false);

return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/aws-cdi-sdk/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.2.0":
folder: all