mirror of
https://github.com/curl/curl.git
synced 2026-07-26 11:47:22 +03:00
cmake: separate target for examples, optimize CI, fix fallouts
- Move `docs/examples` builds under a separate target.
- Make `BUILD_EXAMPLES` default to `ON`. It means to generate the rules
for `docs/examples` by default, but not build them. To build them,
an explicit `make curl-examples` (or ninja, etc) command is necessary.
This syncs behaviour with autotools, and also how both cmake and
autotools are building tests.
- GHA: update cmake jobs to use the new way of building examples.
- GHA: move examples build step at the end of the job, after building
and running tests. This allows to have build and test run results
faster, and leave the seldom-changing examples build to the end.
Building examples is the slowest build step with no practical way to
make them fast.
- appveyor: enable building examples in two old-MSVC jobs.
- examples: fix examples to build cleanly with old MSVC versions.
- GHA/non-native: move example build log under a GHA foldable section.
- GHA/windows: move building examples into separate step for Linux cross
jobs.
Follow-up to dfdd978f7c #13491
Closes #14906
This commit is contained in:
parent
caefaecaad
commit
45202cbba4
13 changed files with 116 additions and 53 deletions
|
|
@ -22,13 +22,16 @@
|
|||
#
|
||||
###########################################################################
|
||||
|
||||
add_custom_target(curl-examples)
|
||||
|
||||
# Get 'check_PROGRAMS' variable
|
||||
transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
|
||||
include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
|
||||
|
||||
foreach(_target IN LISTS check_PROGRAMS)
|
||||
set(_target_name "curl-example-${_target}")
|
||||
add_executable(${_target_name} "${_target}.c")
|
||||
add_executable(${_target_name} EXCLUDE_FROM_ALL "${_target}.c")
|
||||
add_dependencies(curl-examples ${_target_name})
|
||||
target_link_libraries(${_target_name} ${LIB_SELECTED} ${CURL_LIBS})
|
||||
target_compile_definitions(${_target_name} PRIVATE "CURL_NO_OLDIES")
|
||||
if(LIB_SELECTED STREQUAL LIB_STATIC AND WIN32)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include <time.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/mprintf.h>
|
||||
|
||||
static void
|
||||
print_cookies(CURL *curl)
|
||||
|
|
@ -90,14 +91,11 @@ main(void)
|
|||
|
||||
printf("-----------------------------------------------\n"
|
||||
"Setting a cookie \"PREF\" via cookie interface:\n");
|
||||
#ifdef _WIN32
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
/* Netscape format cookie */
|
||||
snprintf(nline, sizeof(nline), "%s\t%s\t%s\t%s\t%.0f\t%s\t%s",
|
||||
".example.com", "TRUE", "/", "FALSE",
|
||||
difftime(time(NULL) + 31337, (time_t)0),
|
||||
"PREF", "hello example, i like you!");
|
||||
curl_msnprintf(nline, sizeof(nline), "%s\t%s\t%s\t%s\t%.0f\t%s\t%s",
|
||||
".example.com", "TRUE", "/", "FALSE",
|
||||
difftime(time(NULL) + 31337, (time_t)0),
|
||||
"PREF", "hello example, i like you!");
|
||||
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
|
||||
if(res != CURLE_OK) {
|
||||
fprintf(stderr, "Curl curl_easy_setopt failed: %s\n",
|
||||
|
|
@ -110,7 +108,7 @@ main(void)
|
|||
modified, likely not what you intended. For more information refer to
|
||||
the CURLOPT_COOKIELIST documentation.
|
||||
*/
|
||||
snprintf(nline, sizeof(nline),
|
||||
curl_msnprintf(nline, sizeof(nline),
|
||||
"Set-Cookie: OLD_PREF=3d141414bf4209321; "
|
||||
"expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.example.com");
|
||||
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
/* curl stuff */
|
||||
#include <curl/curl.h>
|
||||
#include <curl/mprintf.h>
|
||||
|
||||
#ifndef CURLPIPE_MULTIPLEX
|
||||
#error "too old libcurl, cannot do HTTP/2 server push!"
|
||||
|
|
@ -172,7 +173,7 @@ static int server_push_callback(CURL *parent,
|
|||
|
||||
(void)parent; /* we have no use for this */
|
||||
|
||||
snprintf(filename, 128, "push%u", count++);
|
||||
curl_msnprintf(filename, 128, "push%u", count++);
|
||||
|
||||
/* here's a new stream, save it in a new file for each new push */
|
||||
out = fopen(filename, "wb");
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@ static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
|
|||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127) /* conditional expression is constant */
|
||||
#endif
|
||||
FD_SET(sockfd, &errfd); /* always check for error */
|
||||
|
||||
|
|
@ -62,6 +65,8 @@ static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
|
|||
}
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
/* select() returns the number of signalled sockets or -1 */
|
||||
|
|
|
|||
|
|
@ -83,6 +83,10 @@ int main(void)
|
|||
curl_easy_setopt(curl, CURLOPT_URL, "HTTPS://your.favourite.ssl.site");
|
||||
curl_easy_setopt(curl, CURLOPT_HEADERDATA, headerfile);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127) /* conditional expression is constant */
|
||||
#endif
|
||||
do { /* dummy loop, just to break out from */
|
||||
if(pEngine) {
|
||||
/* use crypto engine */
|
||||
|
|
@ -133,6 +137,9 @@ int main(void)
|
|||
|
||||
/* we are done... */
|
||||
} while(0);
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue