-
Notifications
You must be signed in to change notification settings - Fork 558
CURL support for Bazel #402
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
005d74c
Get CURL working for BAZEL build.
jsuereth 766ed6a
Fix up formatting.
jsuereth ca667d2
fix mem leak in test case
lalitb 33f77d2
fix race condition reported by ThreadSanitizer
lalitb 5f064f1
fix ThreadSanitizer error for curl test case ( using mutex )
lalitb 03e7562
Delete BUILD
jsuereth 98100de
Fix windows curl test build.
jsuereth eb5d1da
Fix unsubmitted build change
jsuereth c611b6b
fix http timeout test for Darwin
lalitb f410313
fix format
lalitb bebc4f5
Merge branch 'master' into wip-curl-support
reyang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| # Copyright 2020, OpenTelemetry Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License 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. | ||
|
|
||
| # Compiler options for building libcurl. | ||
|
|
||
| BASE_CURL_COPTS = [ | ||
| # Disable everything else except HTTP protocol. | ||
| "-DHTTP_ONLY=1", | ||
| "-DENABLE_IPV6=1", | ||
| "-DGETHOSTNAME_TYPE_ARG2=size_t", | ||
| "-DGETSERVBYPORT_R_ARGS=6", | ||
| "-DGETSERVBYPORT_R_BUFSIZE=4096", | ||
| "-DHAVE_ALARM=1", | ||
| "-DHAVE_ALLOCA_H=1", | ||
| "-DHAVE_ARPA_INET_H=1", | ||
| "-DHAVE_ARPA_TFTP_H=1", | ||
| "-DHAVE_ASSERT_H=1", | ||
| "-DHAVE_BASENAME=1", | ||
| "-DHAVE_BOOL_T=1", | ||
| "-DHAVE_CLOCK_GETTIME_MONOTONIC=1", | ||
| "-DHAVE_CONNECT=1", | ||
| "-DHAVE_DLFCN_H=1", | ||
| "-DHAVE_ENGINE_LOAD_BUILTIN_ENGINES=1", | ||
| "-DHAVE_ERRNO_H=1", | ||
| "-DHAVE_FCNTL=1", | ||
| "-DHAVE_FCNTL_H=1", | ||
| "-DHAVE_FCNTL_O_NONBLOCK=1", | ||
| "-DHAVE_FDOPEN=1", | ||
| "-DHAVE_FREEADDRINFO=1", | ||
| "-DHAVE_FREEIFADDRS=1", | ||
| "-DHAVE_FSETXATTR=1", | ||
| "-DHAVE_FSETXATTR_5=1", | ||
| "-DHAVE_FTRUNCATE=1", | ||
| "-DHAVE_GAI_STRERROR=1", | ||
| "-DHAVE_GETADDRINFO=1", | ||
| "-DHAVE_GETADDRINFO_THREADSAFE=1", | ||
| "-DHAVE_GETEUID=1", | ||
| "-DHAVE_GETHOSTBYADDR=1", | ||
| "-DHAVE_GETHOSTBYADDR_R=1", | ||
| "-DHAVE_GETHOSTBYADDR_R_8=1", | ||
| "-DHAVE_GETHOSTBYNAME=1", | ||
| "-DHAVE_GETHOSTBYNAME_R=1", | ||
| "-DHAVE_GETHOSTBYNAME_R_6=1", | ||
| "-DHAVE_GETHOSTNAME=1", | ||
| "-DHAVE_GETIFADDRS=1", | ||
| "-DHAVE_GETNAMEINFO=1", | ||
| "-DHAVE_GETPPID=1", | ||
| "-DHAVE_GETPWUID=1", | ||
| "-DHAVE_GETPWUID_R=1", | ||
| "-DHAVE_GETRLIMIT=1", | ||
| "-DHAVE_GETSERVBYPORT_R=1", | ||
| "-DHAVE_GETTIMEOFDAY=1", | ||
| "-DHAVE_GMTIME_R=1", | ||
| "-DHAVE_IFADDRS_H=1", | ||
| "-DHAVE_IF_NAMETOINDEX=1", | ||
| "-DHAVE_INET_NTOP=1", | ||
| "-DHAVE_INET_PTON=1", | ||
| "-DHAVE_INTTYPES_H=1", | ||
| "-DHAVE_IOCTL=1", | ||
| "-DHAVE_IOCTL_FIONBIO=1", | ||
| "-DHAVE_IOCTL_SIOCGIFADDR=1", | ||
| "-DHAVE_LIBGEN_H=1", | ||
| "-DHAVE_LL=1", | ||
| "-DHAVE_LOCALE_H=1", | ||
| "-DHAVE_LOCALTIME_R=1", | ||
| "-DHAVE_LONGLONG=1", | ||
| "-DHAVE_MALLOC_H=1", | ||
| "-DHAVE_MEMORY_H=1", | ||
| "-DHAVE_NETDB_H=1", | ||
| "-DHAVE_NETINET_IN_H=1", | ||
| "-DHAVE_NETINET_TCP_H=1", | ||
| "-DHAVE_NET_IF_H=1", | ||
| "-DHAVE_PIPE=1", | ||
| "-DHAVE_POLL=1", | ||
| "-DHAVE_POLL_FINE=1", | ||
| "-DHAVE_POLL_H=1", | ||
| "-DHAVE_POSIX_STRERROR_R=1", | ||
| "-DHAVE_PTHREAD_H=1", | ||
| "-DHAVE_PWD_H=1", | ||
| "-DHAVE_RECV=1", | ||
| "-DHAVE_SELECT=1", | ||
| "-DHAVE_SEND=1", | ||
| "-DHAVE_SETJMP_H=1", | ||
| "-DHAVE_SETLOCALE=1", | ||
| "-DHAVE_SETRLIMIT=1", | ||
| "-DHAVE_SETSOCKOPT=1", | ||
| "-DHAVE_SGTTY_H=1", | ||
| "-DHAVE_SIGACTION=1", | ||
| "-DHAVE_SIGINTERRUPT=1", | ||
| "-DHAVE_SIGNAL=1", | ||
| "-DHAVE_SIGNAL_H=1", | ||
| "-DHAVE_SIGSETJMP=1", | ||
| "-DHAVE_SIG_ATOMIC_T=1", | ||
| "-DHAVE_SOCKADDR_IN6_SIN6_SCOPE_ID=1", | ||
| "-DHAVE_SOCKET=1", | ||
| "-DHAVE_SOCKETPAIR=1", | ||
| "-DHAVE_STDBOOL_H=1", | ||
| "-DHAVE_STDINT_H=1", | ||
| "-DHAVE_STDIO_H=1", | ||
| "-DHAVE_STDLIB_H=1", | ||
| "-DHAVE_STRCASECMP=1", | ||
| "-DHAVE_STRDUP=1", | ||
| "-DHAVE_STRERROR_R=1", | ||
| "-DHAVE_STRINGS_H=1", | ||
| "-DHAVE_STRING_H=1", | ||
| "-DHAVE_STRNCASECMP=1", | ||
| "-DHAVE_STRSTR=1", | ||
| "-DHAVE_STRTOK_R=1", | ||
| "-DHAVE_STRTOLL=1", | ||
| "-DHAVE_STRUCT_SOCKADDR_STORAGE=1", | ||
| "-DHAVE_STRUCT_TIMEVAL=1", | ||
| "-DHAVE_SYS_IOCTL_H=1", | ||
| "-DHAVE_SYS_PARAM_H=1", | ||
| "-DHAVE_SYS_POLL_H=1", | ||
| "-DHAVE_SYS_RESOURCE_H=1", | ||
| "-DHAVE_SYS_SELECT_H=1", | ||
| "-DHAVE_SYS_SOCKET_H=1", | ||
| "-DHAVE_SYS_STAT_H=1", | ||
| "-DHAVE_SYS_TIME_H=1", | ||
| "-DHAVE_SYS_TYPES_H=1", | ||
| "-DHAVE_SYS_UIO_H=1", | ||
| "-DHAVE_SYS_UN_H=1", | ||
| "-DHAVE_SYS_WAIT_H=1", | ||
| "-DHAVE_SYS_XATTR_H=1", | ||
| "-DHAVE_TERMIOS_H=1", | ||
| "-DHAVE_TERMIO_H=1", | ||
| "-DHAVE_TIME_H=1", | ||
| "-DHAVE_UNISTD_H=1", | ||
| "-DHAVE_UTIME=1", | ||
| "-DHAVE_UTIMES=1", | ||
| "-DHAVE_UTIME_H=1", | ||
| "-DHAVE_VARIADIC_MACROS_C99=1", | ||
| "-DHAVE_VARIADIC_MACROS_GCC=1", | ||
| "-DHAVE_WRITABLE_ARGV=1", | ||
| "-DHAVE_WRITEV=1", | ||
| "-DRECV_TYPE_ARG1=int", | ||
| "-DRECV_TYPE_ARG2=void*", | ||
| "-DRECV_TYPE_ARG3=size_t", | ||
| "-DRECV_TYPE_ARG4=int", | ||
| "-DRECV_TYPE_RETV=ssize_t", | ||
| "-DRETSIGTYPE=void", | ||
| "-DSELECT_QUAL_ARG5=", | ||
| "-DSELECT_TYPE_ARG1=int", | ||
| "-DSELECT_TYPE_ARG234=fd_set*", | ||
| "-DSELECT_TYPE_RETV=int", | ||
| "-DSEND_QUAL_ARG2=const", | ||
| "-DSEND_TYPE_ARG1=int", | ||
| "-DSEND_TYPE_ARG2=void*", | ||
| "-DSEND_TYPE_ARG3=size_t", | ||
| "-DSEND_TYPE_ARG4=int", | ||
| "-DSEND_TYPE_RETV=ssize_t", | ||
| "-DSIZEOF_CURL_OFF_T=8", | ||
| "-DSIZEOF_INT=4", | ||
| "-DSIZEOF_LONG=8", | ||
| "-DSIZEOF_OFF_T=8", | ||
| "-DSIZEOF_SHORT=2", | ||
| "-DSIZEOF_SIZE_T=8", | ||
| "-DSIZEOF_TIME_T=8", | ||
| "-DSTDC_HEADERS=1", | ||
| "-DSTRERROR_R_TYPE_ARG3=size_t", | ||
| "-DTIME_WITH_SYS_TIME=1", | ||
| "-DUSE_THREADS_POSIX=1", | ||
| "-DUSE_UNIX_SOCKETS=1", | ||
|
|
||
| # Extra defines needed by curl | ||
| "-DBUILDING_LIBCURL", | ||
| "-DCURL_HIDDEN_SYMBOLS", | ||
| ] | ||
|
|
||
| LINUX_CURL_COPTS = [ | ||
| "-DHAVE_LINUX_TCP_H=1", | ||
| "-DHAVE_MSG_NOSIGNAL=1", | ||
| ] | ||
|
|
||
| CURL_COPTS = select({ | ||
| "//:windows": [ | ||
| # Disable everything else except HTTP protocol. | ||
| "/DHTTP_ONLY=1", | ||
| "/DCURL_STATICLIB", | ||
| "/DWIN32", | ||
| "/DBUILDING_LIBCURL", | ||
| "/DUSE_WIN32_IDN", | ||
| "/DWANT_IDN_PROTOTYPES", | ||
| "/DUSE_IPV6", | ||
| "/DUSE_WINDOWS_SSPI", | ||
| "/DUSE_SCHANNEL", | ||
| ], | ||
| "//:osx": BASE_CURL_COPTS, | ||
| "//conditions:default": BASE_CURL_COPTS + LINUX_CURL_COPTS, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| cc_test( | ||
| name = "curl_http_test", | ||
| srcs = [ | ||
| "curl_http_test.cc", | ||
| ], | ||
| # TODO: Move copts/linkopts for static CURL usage into shared bzl file. | ||
| copts = [ | ||
| "-DCURL_STATICLIB", | ||
| ], | ||
| linkopts = select({ | ||
| "//bazel:windows": [ | ||
| "-DEFAULTLIB:advapi32.lib", | ||
| "-DEFAULTLIB:crypt32.lib", | ||
| "-DEFAULTLIB:Normaliz.lib", | ||
| ], | ||
| "//conditions:default": [], | ||
| }), | ||
| deps = [ | ||
| "//ext:headers", | ||
| "//sdk/src/trace", | ||
| "@com_google_googletest//:gtest_main", | ||
| "@curl", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| licenses(["notice"]) # Apache 2.0 | ||
|
|
||
| package(default_visibility = ["//:__subpackages__"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Builds CURL from a distribution. | ||
|
|
||
| load("@io_opentelemetry_cpp//bazel:curl.bzl", "CURL_COPTS") | ||
|
|
||
| package(features = ["no_copts_tokenization"]) | ||
|
|
||
| config_setting( | ||
| name = "windows", | ||
| values = {"cpu": "x64_windows"}, | ||
| visibility = ["//visibility:private"], | ||
| ) | ||
|
|
||
| config_setting( | ||
| name = "osx", | ||
| values = {"cpu": "darwin"}, | ||
| visibility = ["//visibility:private"], | ||
| ) | ||
|
|
||
| cc_library( | ||
| name = "curl", | ||
| srcs = glob([ | ||
| "lib/**/*.c", | ||
| ]), | ||
| hdrs = glob([ | ||
| "include/curl/*.h", | ||
| "lib/**/*.h", | ||
| ]), | ||
| copts = CURL_COPTS + [ | ||
| "-DOS=\"os\"", | ||
| "-DCURL_EXTERN_SYMBOL=__attribute__((__visibility__(\"default\")))", | ||
| ], | ||
| includes = [ | ||
| "include/", | ||
| "lib/", | ||
| ], | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.