From c109ffe3156f759723e0609b46182201c65a64e4 Mon Sep 17 00:00:00 2001 From: Colden Cullen Date: Thu, 14 Mar 2019 10:26:59 -0700 Subject: [PATCH] Add support for overriding uv.h location (#110) --- .clang-tidy | 2 +- CMakeLists.txt | 13 +++++++++++++ include/aws/io/uv/uv_include.h | 33 +++++++++++++++++++++++++++++++++ source/host_resolver.c | 2 +- source/libuv/uv_event_loop.c | 3 ++- 5 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 include/aws/io/uv/uv_include.h diff --git a/.clang-tidy b/.clang-tidy index 38a5748d6..cf0886961 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -10,6 +10,6 @@ CheckOptions: - key: google-runtime-int.TypeSufix value: '_t' - key: fuchsia-restrict-system-includes.Includes - value: '*,-stdint.h,-stdbool.h' + value: '*,-stdint.h,-stdbool.h,-uv.h' ... diff --git a/CMakeLists.txt b/CMakeLists.txt index ad6a678af..b3dd680c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,10 @@ file(GLOB AWS_IO_HEADERS "include/aws/io/*.h" ) +file(GLOB AWS_IO_UV_HEADERS + "include/aws/io/uv/*.h" + ) + file(GLOB AWS_IO_TESTING_HEADERS "include/aws/testing/*.h" ) @@ -192,6 +196,12 @@ if (USE_LIBUV) if (UV_LINK_LIBRARY) target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC ${LIBUV_LIBRARY}) endif () + + # Allow specific overriding of uv.h location + if (UV_HEADER_PATH) + message(STATUS "Using uv.h location: ${UV_HEADER_PATH}") + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC "UV_HEADER_PATH=${UV_HEADER_PATH}") + endif () endif () if (BUILD_JNI_BINDINGS) @@ -217,6 +227,9 @@ aws_prepare_shared_lib_exports(${CMAKE_PROJECT_NAME}) install(FILES ${AWS_IO_HEADERS} DESTINATION "include/aws/io" COMPONENT Development) install(FILES ${AWS_IO_TESTING_HEADERS} DESTINATION "include/aws/testing" COMPONENT Development) +if (USE_LIBUV) + install(FILES ${AWS_IO_UV_HEADERS} DESTINATION "include/aws/io/uv" COMPONENT Development) +endif () install(EXPORT "${CMAKE_PROJECT_NAME}-targets" DESTINATION "${LIBRARY_DIRECTORY}/${CMAKE_PROJECT_NAME}/cmake/" diff --git a/include/aws/io/uv/uv_include.h b/include/aws/io/uv/uv_include.h new file mode 100644 index 000000000..5d474562d --- /dev/null +++ b/include/aws/io/uv/uv_include.h @@ -0,0 +1,33 @@ +#ifndef AWS_IO_UV_UV_INCLUDE +#define AWS_IO_UV_UV_INCLUDE + +/* + * Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +/** + * This file exists to support the UV_HEADER_PATH macro, which + * may be defined by CMake when building against things that bundle libuv (ie. nodejs). + */ + +/* Default, just search the include paths */ +#ifndef UV_HEADER_PATH +# define UV_HEADER_PATH uv.h +#endif + +#define UV_HEADER_PATH_2 +/* NOLINTNEXTLINE(fuchsia-restrict-system-includes) */ +#include UV_HEADER_PATH_2 + +#endif /* AWS_IO_UV_UV_INCLUDE */ diff --git a/source/host_resolver.c b/source/host_resolver.c index 59504b32e..6fe772523 100644 --- a/source/host_resolver.c +++ b/source/host_resolver.c @@ -832,7 +832,7 @@ int aws_host_resolver_init_default( #ifdef AWS_USE_LIBUV -# include +# include struct uv_host_resolver { /* This needs to be the first element in the struct so the pointers are safely castable. diff --git a/source/libuv/uv_event_loop.c b/source/libuv/uv_event_loop.c index adf71a9e5..78b4f57d6 100644 --- a/source/libuv/uv_event_loop.c +++ b/source/libuv/uv_event_loop.c @@ -20,8 +20,9 @@ #include #include +#include + #include -#include #if defined(AWS_USE_EPOLL) # include