From 7d9377e7f3226f53afa36432a7f1a641b61c582d Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 1 Feb 2019 10:09:34 -0800 Subject: [PATCH] Use gnu for ruby build because strptime is provided by posix (#5660) * Use gnu for ruby build because strptime is provided by posix * Move option to extconf.rb * Remove unused code in Rakefile * Add config files for kokoro test * Use gnu 11 * Define _XOPEN_SOURCE * Add gnu11 option * Remove XOPEN * Try base_cc_flags * Try config_options * Move time.h to top * Try -D_XOPEN_SOURCE=700 * Define XOPEN_SOURCE directly * Try extconf.rb * Try CFLAGS * Try ext.cross_config_options * Make mac ruby release job fail on error * Try again * Try define _XOPEN_SOURCE in extconf.rb * Try again * Define __USE_XOPEN * Remove 2.6.0 * No mingw * Throw error on mingw * Remove XOPEN_SOURCE in upb * Add back mingw * Remove comment --- kokoro/release/python/linux/continuous.cfg | 8 ++++++++ kokoro/release/python/linux/presubmit.cfg | 8 ++++++++ kokoro/release/python/macos/continuous.cfg | 8 ++++++++ kokoro/release/python/macos/presubmit.cfg | 8 ++++++++ kokoro/release/ruby/linux/continuous.cfg | 8 ++++++++ kokoro/release/ruby/linux/presubmit.cfg | 8 ++++++++ kokoro/release/ruby/linux/ruby/ruby_build.sh | 2 ++ kokoro/release/ruby/macos/continuous.cfg | 8 ++++++++ kokoro/release/ruby/macos/presubmit.cfg | 8 ++++++++ kokoro/release/ruby/macos/ruby/ruby_build.sh | 2 ++ ruby/ext/google/protobuf_c/extconf.rb | 8 +++++++- ruby/ext/google/protobuf_c/upb.c | 12 +++++++----- 12 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 kokoro/release/python/linux/continuous.cfg create mode 100644 kokoro/release/python/linux/presubmit.cfg create mode 100644 kokoro/release/python/macos/continuous.cfg create mode 100644 kokoro/release/python/macos/presubmit.cfg create mode 100644 kokoro/release/ruby/linux/continuous.cfg create mode 100644 kokoro/release/ruby/linux/presubmit.cfg create mode 100644 kokoro/release/ruby/macos/continuous.cfg create mode 100644 kokoro/release/ruby/macos/presubmit.cfg diff --git a/kokoro/release/python/linux/continuous.cfg b/kokoro/release/python/linux/continuous.cfg new file mode 100644 index 0000000000..c0b9a018f1 --- /dev/null +++ b/kokoro/release/python/linux/continuous.cfg @@ -0,0 +1,8 @@ +# Config file for running tests in Kokoro +build_file: "protobuf/kokoro/release/python/linux/build_artifacts.sh" + +action { + define_artifacts { + regex: "github/protobuf/artifacts/**" + } +} diff --git a/kokoro/release/python/linux/presubmit.cfg b/kokoro/release/python/linux/presubmit.cfg new file mode 100644 index 0000000000..c0b9a018f1 --- /dev/null +++ b/kokoro/release/python/linux/presubmit.cfg @@ -0,0 +1,8 @@ +# Config file for running tests in Kokoro +build_file: "protobuf/kokoro/release/python/linux/build_artifacts.sh" + +action { + define_artifacts { + regex: "github/protobuf/artifacts/**" + } +} diff --git a/kokoro/release/python/macos/continuous.cfg b/kokoro/release/python/macos/continuous.cfg new file mode 100644 index 0000000000..85cf81b507 --- /dev/null +++ b/kokoro/release/python/macos/continuous.cfg @@ -0,0 +1,8 @@ +# Configuration for Mac OSX release builds +build_file: "protobuf/kokoro/release/python/macos/build_artifacts.sh" + +action { + define_artifacts { + regex: "github/protobuf/artifacts/**" + } +} diff --git a/kokoro/release/python/macos/presubmit.cfg b/kokoro/release/python/macos/presubmit.cfg new file mode 100644 index 0000000000..85cf81b507 --- /dev/null +++ b/kokoro/release/python/macos/presubmit.cfg @@ -0,0 +1,8 @@ +# Configuration for Mac OSX release builds +build_file: "protobuf/kokoro/release/python/macos/build_artifacts.sh" + +action { + define_artifacts { + regex: "github/protobuf/artifacts/**" + } +} diff --git a/kokoro/release/ruby/linux/continuous.cfg b/kokoro/release/ruby/linux/continuous.cfg new file mode 100644 index 0000000000..dbc71b2ceb --- /dev/null +++ b/kokoro/release/ruby/linux/continuous.cfg @@ -0,0 +1,8 @@ +# Configuration for Linux release builds +build_file: "protobuf/kokoro/release/ruby/linux/build_artifacts.sh" + +action { + define_artifacts { + regex: "github/protobuf/artifacts/**" + } +} diff --git a/kokoro/release/ruby/linux/presubmit.cfg b/kokoro/release/ruby/linux/presubmit.cfg new file mode 100644 index 0000000000..dbc71b2ceb --- /dev/null +++ b/kokoro/release/ruby/linux/presubmit.cfg @@ -0,0 +1,8 @@ +# Configuration for Linux release builds +build_file: "protobuf/kokoro/release/ruby/linux/build_artifacts.sh" + +action { + define_artifacts { + regex: "github/protobuf/artifacts/**" + } +} diff --git a/kokoro/release/ruby/linux/ruby/ruby_build.sh b/kokoro/release/ruby/linux/ruby/ruby_build.sh index cf6b433d06..9fc42b13eb 100755 --- a/kokoro/release/ruby/linux/ruby/ruby_build.sh +++ b/kokoro/release/ruby/linux/ruby/ruby_build.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -ex + # Build protoc if test ! -e src/protoc; then ./autogen.sh diff --git a/kokoro/release/ruby/macos/continuous.cfg b/kokoro/release/ruby/macos/continuous.cfg new file mode 100644 index 0000000000..cb1c08bb88 --- /dev/null +++ b/kokoro/release/ruby/macos/continuous.cfg @@ -0,0 +1,8 @@ +# Configuration for Mac OSX release builds +build_file: "protobuf/kokoro/release/ruby/macos/build_artifacts.sh" + +action { + define_artifacts { + regex: "github/protobuf/artifacts/**" + } +} diff --git a/kokoro/release/ruby/macos/presubmit.cfg b/kokoro/release/ruby/macos/presubmit.cfg new file mode 100644 index 0000000000..cb1c08bb88 --- /dev/null +++ b/kokoro/release/ruby/macos/presubmit.cfg @@ -0,0 +1,8 @@ +# Configuration for Mac OSX release builds +build_file: "protobuf/kokoro/release/ruby/macos/build_artifacts.sh" + +action { + define_artifacts { + regex: "github/protobuf/artifacts/**" + } +} diff --git a/kokoro/release/ruby/macos/ruby/ruby_build.sh b/kokoro/release/ruby/macos/ruby/ruby_build.sh index cf6b433d06..9fc42b13eb 100755 --- a/kokoro/release/ruby/macos/ruby/ruby_build.sh +++ b/kokoro/release/ruby/macos/ruby/ruby_build.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -ex + # Build protoc if test ! -e src/protoc; then ./autogen.sh diff --git a/ruby/ext/google/protobuf_c/extconf.rb b/ruby/ext/google/protobuf_c/extconf.rb index 0886e60708..04eaa4bad9 100644 --- a/ruby/ext/google/protobuf_c/extconf.rb +++ b/ruby/ext/google/protobuf_c/extconf.rb @@ -2,7 +2,13 @@ require 'mkmf' -$CFLAGS += " -std=c99 -O3 -DNDEBUG" +if RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/ + # XOPEN_SOURCE needed for strptime: + # https://stackoverflow.com/questions/35234152/strptime-giving-implicit-declaration-and-undefined-reference + $CFLAGS += " -std=c99 -O3 -DNDEBUG -D_XOPEN_SOURCE=700" +else + $CFLAGS += " -std=c99 -O3 -DNDEBUG" +end if RUBY_PLATFORM =~ /linux/ diff --git a/ruby/ext/google/protobuf_c/upb.c b/ruby/ext/google/protobuf_c/upb.c index b001d7a591..64369cfe4d 100644 --- a/ruby/ext/google/protobuf_c/upb.c +++ b/ruby/ext/google/protobuf_c/upb.c @@ -12610,11 +12610,6 @@ done: #include #include #include - -/* Need to define __USE_XOPEN before including time.h to make strptime work. */ -#ifndef __USE_XOPEN -#define __USE_XOPEN -#endif #include @@ -14127,12 +14122,19 @@ static bool end_timestamp_base(upb_json_parser *p, const char *ptr) { memcpy(timestamp_buf + UPB_TIMESTAMP_BASE_SIZE, "GMT", 3); timestamp_buf[UPB_TIMESTAMP_BASE_SIZE + 3] = 0; +#if defined __MINGW32__ || defined __MINGW64__ + upb_status_seterrf( + &p->status, "error parsing timestamp: mingw doesn't support strptime"); + upb_env_reporterror(p->env, &p->status); + return false; +#else /* Parse seconds */ if (strptime(timestamp_buf, "%FT%H:%M:%S%Z", &p->tm) == NULL) { upb_status_seterrf(&p->status, "error parsing timestamp: %s", buf); upb_env_reporterror(p->env, &p->status); return false; } +#endif /* Clean up buffer */ multipart_end(p);