From 4df66fdd7a85f7d74d3edfeea549229d8ef92e74 Mon Sep 17 00:00:00 2001 From: "Jonathan M. Henson" Date: Fri, 17 May 2019 15:50:57 -0700 Subject: [PATCH] Added cd scripts, added version option to elasticurl. --- bin/elasticurl/main.c | 31 +++++++----- .../build-elasticurl-manylinux-x64.yml | 48 +++++++++++++++++++ continuous-delivery/build-elasticurl-osx.sh | 33 +++++++++++++ continuous-delivery/build-elasticurl-unix.sh | 38 +++++++++++++++ continuous-delivery/build-elasticurl-win64.sh | 35 ++++++++++++++ 5 files changed, 173 insertions(+), 12 deletions(-) create mode 100644 continuous-delivery/build-elasticurl-manylinux-x64.yml create mode 100755 continuous-delivery/build-elasticurl-osx.sh create mode 100755 continuous-delivery/build-elasticurl-unix.sh create mode 100644 continuous-delivery/build-elasticurl-win64.sh diff --git a/bin/elasticurl/main.c b/bin/elasticurl/main.c index d070a7e51..7a8a64faa 100644 --- a/bin/elasticurl/main.c +++ b/bin/elasticurl/main.c @@ -36,6 +36,8 @@ # pragma warning(disable : 4221) /* Local var in declared initializer */ #endif +#define ELASTICURL_VERSION "0.2.0" + struct elasticurl_ctx { struct aws_allocator *allocator; const char *verb; @@ -60,7 +62,7 @@ struct elasticurl_ctx { bool exchange_completed; }; -static void s_usage(void) { +static void s_usage(int exit_code) { fprintf(stderr, "usage: elasticurl [options] url\n"); fprintf(stderr, " url: url to make a request to. The default is a GET request.\n"); @@ -81,10 +83,11 @@ static void s_usage(void) { fprintf(stderr, " -k, --insecure: turns off SSL/TLS validation.\n"); fprintf(stderr, " -o, --output FILE: dumps content-body to FILE instead of stdout.\n"); fprintf(stderr, " -t, --trace FILE: dumps logs to FILE instead of stderr.\n"); - fprintf(stderr, " -v, --verbose ERROR|INFO|DEBUG|TRACE: log level to configure. Default is none.\n"); + fprintf(stderr, " -v, --verbose: ERROR|INFO|DEBUG|TRACE: log level to configure. Default is none.\n"); + fprintf(stderr, " --version: print the version of elasticurl.\n"); fprintf(stderr, " -h, --help\n"); fprintf(stderr, " Display this message and quit.\n"); - exit(1); + exit(exit_code); } static struct aws_cli_option s_long_options[] = { @@ -105,6 +108,7 @@ static struct aws_cli_option s_long_options[] = { {"output", AWS_CLI_OPTIONS_REQUIRED_ARGUMENT, NULL, 'o'}, {"trace", AWS_CLI_OPTIONS_REQUIRED_ARGUMENT, NULL, 't'}, {"verbose", AWS_CLI_OPTIONS_REQUIRED_ARGUMENT, NULL, 'v'}, + {"version", AWS_CLI_OPTIONS_NO_ARGUMENT, NULL, 'V'}, {"help", AWS_CLI_OPTIONS_NO_ARGUMENT, NULL, 'h'}, /* Per getopt(3) the last element of the array has to be filled with all zeros */ {NULL, AWS_CLI_OPTIONS_NO_ARGUMENT, NULL, 0}, @@ -113,7 +117,7 @@ static struct aws_cli_option s_long_options[] = { static void s_parse_options(int argc, char **argv, struct elasticurl_ctx *ctx) { while (true) { int option_index = 0; - int c = aws_cli_getopt_long(argc, argv, "a:b:c:e:f:H:d:g:M:GPHiko:t:v:h", s_long_options, &option_index); + int c = aws_cli_getopt_long(argc, argv, "a:b:c:e:f:H:d:g:M:GPHiko:t:v:Vh", s_long_options, &option_index); if (c == -1) { break; } @@ -140,7 +144,7 @@ static void s_parse_options(int argc, char **argv, struct elasticurl_ctx *ctx) { case 'H': if (ctx->header_line_count >= sizeof(ctx->header_lines) / sizeof(const char *)) { fprintf(stderr, "currently only 10 header lines are supported.\n"); - s_usage(); + s_usage(1); } ctx->header_lines[ctx->header_line_count++] = aws_cli_optarg; break; @@ -152,7 +156,7 @@ static void s_parse_options(int argc, char **argv, struct elasticurl_ctx *ctx) { ctx->data_file = fopen(aws_cli_optarg, "rb"); if (!ctx->data_file) { fprintf(stderr, "unable to open file %s.\n", aws_cli_optarg); - s_usage(); + s_usage(1); } break; case 'M': @@ -178,7 +182,7 @@ static void s_parse_options(int argc, char **argv, struct elasticurl_ctx *ctx) { if (!ctx->output) { fprintf(stderr, "unable to open file %s.\n", aws_cli_optarg); - s_usage(); + s_usage(1); } break; case 't': @@ -195,15 +199,18 @@ static void s_parse_options(int argc, char **argv, struct elasticurl_ctx *ctx) { ctx->log_level = AWS_LL_ERROR; } else { fprintf(stderr, "unsupported log level %s.\n", aws_cli_optarg); - s_usage(); + s_usage(1); } break; + case 'V': + fprintf(stderr, "elasticurl %s\n", ELASTICURL_VERSION); + exit(0); case 'h': - s_usage(); + s_usage(0); break; default: fprintf(stderr, "Unknown option\n"); - s_usage(); + s_usage(1); } } @@ -216,11 +223,11 @@ static void s_parse_options(int argc, char **argv, struct elasticurl_ctx *ctx) { "Failed to parse uri %s with error %s\n", (char *)uri_cursor.ptr, aws_error_debug_str(aws_last_error())); - s_usage(); + s_usage(1); }; } else { fprintf(stderr, "A URI for the request must be supplied.\n"); - s_usage(); + s_usage(1); } } diff --git a/continuous-delivery/build-elasticurl-manylinux-x64.yml b/continuous-delivery/build-elasticurl-manylinux-x64.yml new file mode 100644 index 000000000..ffd4ca956 --- /dev/null +++ b/continuous-delivery/build-elasticurl-manylinux-x64.yml @@ -0,0 +1,48 @@ +version: 0.2 +#this build spec assumes the manylinux1 image for pypi +#additional packages we installed: cmake 3.5, libcrypto 1.1.0j, gcc 4.8.4 +phases: + install: + commands: + pre_build: + commands: + - export CC=gcc + build: + commands: + - echo Build started on `date` + - mkdir /tmp/install + - mkdir /tmp/aws-c-common-build + - mkdir /tmp/aws-c-compression-build + - mkdir /tmp/aws-c-io-build + - mkdir /tmp/aws-c-http-build + - mkdir /tmp/s2n-build + - cd /tmp/aws-c-common-build + - cmake -DCMAKE_INSTALL_PREFIX=/tmp/install -DBUILD_TESTING=OFF $CODEBUILD_SRC_DIR_aws-c-common + - make -j + - make install + - cd /tmp/aws-c-compression-build + - cmake -DCMAKE_PREFIX_PATH=/tmp/install -DCMAKE_INSTALL_PREFIX=/tmp/install -DBUILD_TESTING=OFF $CODEBUILD_SRC_DIR_aws-c-compression + - make -j + - make install + - cd /tmp/s2n-build + - cmake -DCMAKE_PREFIX_PATH=/opt/openssl;/tmp/install -DCMAKE_INSTALL_PREFIX=/tmp/install -DBUILD_TESTING=OFF $CODEBUILD_SRC_DIR_s2n + - make -j + - make install + - cd /tmp/aws-c-io-build + - cmake -DCMAKE_PREFIX_PATH=/opt/openssl;/tmp/install -DCMAKE_INSTALL_PREFIX=/tmp/install -DBUILD_TESTING=OFF $CODEBUILD_SRC_DIR_aws-c-io + - make -j + - make install + - cd /tmp/aws-c-http-build + - cmake -DCMAKE_PREFIX_PATH=/opt/openssl;/tmp/install -DCMAKE_INSTALL_PREFIX=/tmp/install -DBUILD_TESTING=OFF $CODEBUILD_SRC_DIR_aws-c-http + - make -j + - make install + - /tmp/install/bin/elasticurl --version + - /tmp/install/bin/elasticurl -v TRACE https://example.com + post_build: + commands: + - echo Build completed on `date` + +artifacts: + files: + - '/tmp/install/bin/elasticurl' + diff --git a/continuous-delivery/build-elasticurl-osx.sh b/continuous-delivery/build-elasticurl-osx.sh new file mode 100755 index 000000000..9b0e39572 --- /dev/null +++ b/continuous-delivery/build-elasticurl-osx.sh @@ -0,0 +1,33 @@ +#!/bin/bash +#before running this, you'll need cmake3 and a compiler. +set -e +export MACOSX_DEPLOYMENT_TARGET="10.9" +mkdir install +mkdir aws-c-common-build +mkdir aws-c-io-build +mkdir aws-c-compression-build +mkdir aws-c-http-build +cd aws-c-common-build +cmake -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-common +make -j +make install +cd .. +cd aws-c-compression-build +cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-compression +make -j +make install +cd .. +cd aws-c-io-build +cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-io +make -j +make install +cd .. +cd aws-c-http-build +cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-http +make -j +make install +cd .. + +install/bin/elasticurl --version +install/bin/elasticurl -v TRACE https://example.com + diff --git a/continuous-delivery/build-elasticurl-unix.sh b/continuous-delivery/build-elasticurl-unix.sh new file mode 100755 index 000000000..e9078100e --- /dev/null +++ b/continuous-delivery/build-elasticurl-unix.sh @@ -0,0 +1,38 @@ +#!/bin/bash +#before running this, you'll need cmake3 and a compiler. +set -e +mkdir install +mkdir aws-c-common-build +mkdir aws-c-compression-build +mkdir aws-c-io-build +mkdir aws-c-http-build +mkdir s2n-build +cd aws-c-common-build +cmake -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-common +make -j +make install +cd .. +cd aws-c-compression-build +cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-compression +make -j +make install +cd .. +cd s2n-build +cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../s2n +make -j +make install +cd .. +cd aws-c-io-build +cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-io +make -j +make install +cd .. +cd aws-c-http-build +cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-http +make -j +make install +cd .. + +install/bin/elasticurl --version +install/bin/elasticurl -v TRACE https://example.com + diff --git a/continuous-delivery/build-elasticurl-win64.sh b/continuous-delivery/build-elasticurl-win64.sh new file mode 100644 index 000000000..242f7c1b2 --- /dev/null +++ b/continuous-delivery/build-elasticurl-win64.sh @@ -0,0 +1,35 @@ + +mkdir install +cd install +set INSTALL_DIR %cd% +cd .. +mkdir aws-c-common-build +mkdir aws-c-compression-build +mkdir aws-c-io-build +mkdir aws-c-http-build +cd aws-c-common-build +cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DBUILD_TESTING=OFF ..\aws-c-common || goto error +cmake --build .\ --target install --config RelWithDebInfo || goto error +cd .. +cd aws-c-compression-build +cmake -DCMAKE_PREFIX_PATH=%INSTALL_DIR% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DBUILD_TESTING=OFF ..\aws-c-compression || goto error +cmake --build .\ --target install --config RelWithDebInfo || goto error +cd .. +cd aws-c-io-build +cmake -DCMAKE_PREFIX_PATH=%INSTALL_DIR% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DBUILD_TESTING=OFF ..\aws-c-io || goto error +cmake --build .\ --target install --config RelWithDebInfo || goto error +cd .. +cd aws-c-http-build +cmake -DCMAKE_PREFIX_PATH=%INSTALL_DIR% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DBUILD_TESTING=OFF ..\aws-c-http || goto error +cmake --build .\ --target install --config RelWithDebInfo || goto error +cd .. + +%INSTALL_DIR%\bin\elasticurl --version || goto error +%INSTALL_DIR%\bin\elasticurl -v TRACE https://example.com || goto error + +goto :EOF + +:error +echo Failed with error #%errorlevel%. +exit /b %errorlevel% +