Skip to content

Commit

Permalink
Add support for overriding uv.h location (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdenCullen authored Mar 14, 2019
1 parent fe48ccc commit c109ffe
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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'

...
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
Expand All @@ -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/"
Expand Down
33 changes: 33 additions & 0 deletions include/aws/io/uv/uv_include.h
Original file line number Diff line number Diff line change
@@ -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 <UV_HEADER_PATH>
/* NOLINTNEXTLINE(fuchsia-restrict-system-includes) */
#include UV_HEADER_PATH_2

#endif /* AWS_IO_UV_UV_INCLUDE */
2 changes: 1 addition & 1 deletion source/host_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ int aws_host_resolver_init_default(

#ifdef AWS_USE_LIBUV

# include <uv.h>
# include <aws/io/uv/uv_include.h>

struct uv_host_resolver {
/* This needs to be the first element in the struct so the pointers are safely castable.
Expand Down
3 changes: 2 additions & 1 deletion source/libuv/uv_event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
#include <aws/common/task_scheduler.h>
#include <aws/common/thread.h>

#include <aws/io/uv/uv_include.h>

#include <poll.h>
#include <uv.h>

#if defined(AWS_USE_EPOLL)
# include <sys/epoll.h>
Expand Down

0 comments on commit c109ffe

Please sign in to comment.