Skip to content

Commit

Permalink
Use static libcurl build with conan (#4445)
Browse files Browse the repository at this point in the history
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
  • Loading branch information
whyoleg authored and osipxd committed Dec 11, 2024
1 parent 935c175 commit dda993a
Show file tree
Hide file tree
Showing 49 changed files with 373 additions and 5,710 deletions.
40 changes: 10 additions & 30 deletions ktor-client/ktor-client-curl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,40 +1,20 @@
apply<test.server.TestServerPlugin>()
import org.jetbrains.kotlin.gradle.plugin.mpp.*

val paths = listOf(
"/opt/homebrew/opt/curl/include/",
"/opt/local/include/",
"/usr/local/include/",
"/usr/include/",
"/usr/local/opt/curl/include/",
"/usr/include/x86_64-linux-gnu/",
"/usr/local/Cellar/curl/7.62.0/include/",
"/usr/local/Cellar/curl/7.63.0/include/",
"/usr/local/Cellar/curl/7.65.3/include/",
"/usr/local/Cellar/curl/7.66.0/include/",
"/usr/local/Cellar/curl/7.80.0/include/",
"/usr/local/Cellar/curl/7.80.0_1/include/",
"/usr/local/Cellar/curl/7.81.0/include/",
"desktop/interop/mingwX64/include/",
)
apply<test.server.TestServerPlugin>()

plugins {
id("kotlinx-serialization")
}

kotlin {
createCInterop("libcurl", listOf("macosX64", "linuxX64", "mingwX64")) {
definitionFile = File(projectDir, "desktop/interop/libcurl.def")
includeDirs.headerFilterOnly(paths)
}

createCInterop("libcurl", listOf("macosArm64")) {
definitionFile = File(projectDir, "desktop/interop/libcurl_arm64.def")
includeDirs.headerFilterOnly(paths)
}

createCInterop("libcurl", listOf("linuxArm64")) {
definitionFile = File(projectDir, "desktop/interop/libcurl_linux_arm64.def")
includeDirs.headerFilterOnly(listOf("desktop/interop/linuxArm64/include/"))
targets.withType<KotlinNativeTarget>().configureEach {
compilations.named("main") {
cinterops.create("libcurl") {
definitionFile = file("desktop/interop/libcurl.def")
includeDirs(file("desktop/interop/include"))
extraOpts("-libraryPath", file("desktop/interop/lib/${target.name}"))
}
}
}

sourceSets {
Expand Down
318 changes: 182 additions & 136 deletions ...op/interop/linuxArm64/include/curl/curl.h → ...-curl/desktop/interop/include/curl/curl.h
100755 → 100644

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@

/* This is the version number of the libcurl package from which this header
file origins: */
#define LIBCURL_VERSION "7.88.1"
#define LIBCURL_VERSION "8.10.1"

/* The numeric version number is also available "in parts" by using these
defines: */
#define LIBCURL_VERSION_MAJOR 7
#define LIBCURL_VERSION_MINOR 88
#define LIBCURL_VERSION_MAJOR 8
#define LIBCURL_VERSION_MINOR 10
#define LIBCURL_VERSION_PATCH 1

/* This is the numeric version of the libcurl version number, meant for easier
Expand All @@ -48,7 +48,7 @@
Where XX, YY and ZZ are the main version, release and patch numbers in
hexadecimal (using 8 bits each). All three numbers are always represented
using two digits. 1.2 would appear as "0x010200" while version 9.11.7
using two digits. 1.2 would appear as "0x010200" while version 9.11.7
appears as "0x090b07".
This 6-digit (24 bits) hexadecimal number does not show pre-release number,
Expand All @@ -59,7 +59,7 @@
CURL_VERSION_BITS() macro since curl's own configure script greps for it
and needs it to contain the full number.
*/
#define LIBCURL_VERSION_NUM 0x075801
#define LIBCURL_VERSION_NUM 0x080a01

/*
* This is the date and time when the full source package was created. The
Expand All @@ -70,7 +70,7 @@
*
* "2007-11-23"
*/
#define LIBCURL_TIMESTAMP "2023-02-20"
#define LIBCURL_TIMESTAMP "2024-09-18"

#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z))
#define CURL_AT_LEAST_VERSION(x,y,z) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ CURL_EXTERN void curl_easy_cleanup(CURL *curl);
*
* DESCRIPTION
*
* Request internal information from the curl session with this function. The
* third argument MUST be a pointer to a long, a pointer to a char * or a
* pointer to a double (as the documentation describes elsewhere). The data
* pointed to will be filled in accordingly and can be relied upon only if the
* function returns CURLE_OK. This function is intended to get used *AFTER* a
* performed transfer, all results from this function are undefined until the
* transfer is completed.
* Request internal information from the curl session with this function.
* The third argument MUST be pointing to the specific type of the used option
* which is documented in each manpage of the option. The data pointed to
* will be filled in accordingly and can be relied upon only if the function
* returns CURLE_OK. This function is intended to get used *AFTER* a performed
* transfer, all results from this function are undefined until the transfer
* is completed.
*/
CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);

Expand Down
File renamed without changes.
53 changes: 43 additions & 10 deletions ...interop/linuxArm64/include/curl/mprintf.h → ...rl/desktop/interop/include/curl/mprintf.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,51 @@
extern "C" {
#endif

CURL_EXTERN int curl_mprintf(const char *format, ...);
CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...);
CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...);
#ifndef CURL_TEMP_PRINTF
#if (defined(__GNUC__) || defined(__clang__) || \
defined(__IAR_SYSTEMS_ICC__)) && \
defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
!defined(CURL_NO_FMT_CHECKS)
#if defined(__MINGW32__) && !defined(__clang__)
#if defined(__MINGW_PRINTF_FORMAT) /* mingw-w64 3.0.0+. Needs stdio.h. */
#define CURL_TEMP_PRINTF(fmt, arg) \
__attribute__((format(__MINGW_PRINTF_FORMAT, fmt, arg)))
#else
#define CURL_TEMP_PRINTF(fmt, arg)
#endif
#else
#define CURL_TEMP_PRINTF(fmt, arg) \
__attribute__((format(printf, fmt, arg)))
#endif
#else
#define CURL_TEMP_PRINTF(fmt, arg)
#endif
#endif

CURL_EXTERN int curl_mprintf(const char *format, ...)
CURL_TEMP_PRINTF(1, 2);
CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...)
CURL_TEMP_PRINTF(2, 3);
CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...)
CURL_TEMP_PRINTF(2, 3);
CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength,
const char *format, ...);
CURL_EXTERN int curl_mvprintf(const char *format, va_list args);
CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args);
CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args);
const char *format, ...)
CURL_TEMP_PRINTF(3, 4);
CURL_EXTERN int curl_mvprintf(const char *format, va_list args)
CURL_TEMP_PRINTF(1, 0);
CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args)
CURL_TEMP_PRINTF(2, 0);
CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args)
CURL_TEMP_PRINTF(2, 0);
CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
const char *format, va_list args);
CURL_EXTERN char *curl_maprintf(const char *format, ...);
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
const char *format, va_list args)
CURL_TEMP_PRINTF(3, 0);
CURL_EXTERN char *curl_maprintf(const char *format, ...)
CURL_TEMP_PRINTF(1, 2);
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args)
CURL_TEMP_PRINTF(1, 0);

#undef CURL_TEMP_PRINTF

#ifdef __cplusplus
} /* end of extern "C" */
Expand Down
43 changes: 34 additions & 9 deletions ...p/interop/linuxArm64/include/curl/multi.h → ...curl/desktop/interop/include/curl/multi.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
***************************************************************************/
/*
This is an "external" header file. Don't give away any internals here!
This is an "external" header file. Do not give away any internals here!
GOALS
Expand Down Expand Up @@ -66,7 +66,7 @@ typedef enum {
CURLM_OK,
CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
CURLM_OUT_OF_MEMORY, /* if you ever get this, you are in deep sh*t */
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
Expand Down Expand Up @@ -109,7 +109,7 @@ struct CURLMsg {
typedef struct CURLMsg CURLMsg;

/* Based on poll(2) structure and values.
* We don't use pollfd and POLL* constants explicitly
* We do not use pollfd and POLL* constants explicitly
* to cover platforms without poll(). */
#define CURL_WAIT_POLLIN 0x0001
#define CURL_WAIT_POLLPRI 0x0002
Expand All @@ -118,7 +118,7 @@ typedef struct CURLMsg CURLMsg;
struct curl_waitfd {
curl_socket_t fd;
short events;
short revents; /* not supported yet */
short revents;
};

/*
Expand Down Expand Up @@ -205,7 +205,7 @@ CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle);
/*
* Name: curl_multi_perform()
*
* Desc: When the app thinks there's data available for curl it calls this
* Desc: When the app thinks there is data available for curl it calls this
* function to read/write whatever there is right now. This returns
* as soon as the reads and writes are done. This function does not
* require that there actually is data available for reading or that
Expand Down Expand Up @@ -236,7 +236,7 @@ CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
/*
* Name: curl_multi_info_read()
*
* Desc: Ask the multi handle if there's any messages/informationals from
* Desc: Ask the multi handle if there is any messages/informationals from
* the individual transfers. Messages include informationals such as
* error code from the transfer or just the fact that a transfer is
* completed. More details on these should be written down as well.
Expand All @@ -253,7 +253,7 @@ CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
* we will provide the particular "transfer handle" in that struct
* and that should/could/would be used in subsequent
* curl_easy_getinfo() calls (or similar). The point being that we
* must never expose complex structs to applications, as then we'll
* must never expose complex structs to applications, as then we will
* undoubtably get backwards compatibility problems in the future.
*
* Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
Expand All @@ -268,7 +268,7 @@ CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
* Name: curl_multi_strerror()
*
* Desc: The curl_multi_strerror function may be used to turn a CURLMcode
* value into the equivalent human readable error string. This is
* value into the equivalent human readable error string. This is
* useful for printing meaningful error messages.
*
* Returns: A pointer to a null-terminated error message.
Expand All @@ -282,7 +282,7 @@ CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
* Desc: An alternative version of curl_multi_perform() that allows the
* application to pass in one of the file descriptors that have been
* detected to have "action" on them and let libcurl perform.
* See man page for details.
* See manpage for details.
*/
#define CURL_POLL_NONE 0
#define CURL_POLL_IN 1
Expand Down Expand Up @@ -426,6 +426,17 @@ CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
curl_socket_t sockfd, void *sockp);

/*
* Name: curl_multi_get_handles()
*
* Desc: Returns an allocated array holding all handles currently added to
* the multi handle. Marks the final entry with a NULL pointer. If
* there is no easy handle added to the multi handle, this function
* returns an array with the first entry as a NULL pointer.
*
* Returns: NULL on failure, otherwise a CURL **array pointer
*/
CURL_EXTERN CURL **curl_multi_get_handles(CURLM *multi_handle);

/*
* Name: curl_push_callback
Expand Down Expand Up @@ -453,6 +464,20 @@ typedef int (*curl_push_callback)(CURL *parent,
struct curl_pushheaders *headers,
void *userp);

/*
* Name: curl_multi_waitfds()
*
* Desc: Ask curl for fds for polling. The app can use these to poll on.
* We want curl_multi_perform() called as soon as one of them are
* ready. Passing zero size allows to get just a number of fds.
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_waitfds(CURLM *multi,
struct curl_waitfd *ufds,
unsigned int size,
unsigned int *fd_count);

#ifdef __cplusplus
} /* end of extern "C" */
#endif
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit dda993a

Please sign in to comment.