Skip to content

Commit

Permalink
Use gnu for ruby build because strptime is provided by posix (protoco…
Browse files Browse the repository at this point in the history
…lbuffers#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
  • Loading branch information
TeBoring authored Feb 1, 2019
1 parent 1ee15ba commit 7d9377e
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 6 deletions.
8 changes: 8 additions & 0 deletions kokoro/release/python/linux/continuous.cfg
Original file line number Diff line number Diff line change
@@ -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/**"
}
}
8 changes: 8 additions & 0 deletions kokoro/release/python/linux/presubmit.cfg
Original file line number Diff line number Diff line change
@@ -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/**"
}
}
8 changes: 8 additions & 0 deletions kokoro/release/python/macos/continuous.cfg
Original file line number Diff line number Diff line change
@@ -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/**"
}
}
8 changes: 8 additions & 0 deletions kokoro/release/python/macos/presubmit.cfg
Original file line number Diff line number Diff line change
@@ -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/**"
}
}
8 changes: 8 additions & 0 deletions kokoro/release/ruby/linux/continuous.cfg
Original file line number Diff line number Diff line change
@@ -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/**"
}
}
8 changes: 8 additions & 0 deletions kokoro/release/ruby/linux/presubmit.cfg
Original file line number Diff line number Diff line change
@@ -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/**"
}
}
2 changes: 2 additions & 0 deletions kokoro/release/ruby/linux/ruby/ruby_build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -ex

# Build protoc
if test ! -e src/protoc; then
./autogen.sh
Expand Down
8 changes: 8 additions & 0 deletions kokoro/release/ruby/macos/continuous.cfg
Original file line number Diff line number Diff line change
@@ -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/**"
}
}
8 changes: 8 additions & 0 deletions kokoro/release/ruby/macos/presubmit.cfg
Original file line number Diff line number Diff line change
@@ -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/**"
}
}
2 changes: 2 additions & 0 deletions kokoro/release/ruby/macos/ruby/ruby_build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -ex

# Build protoc
if test ! -e src/protoc; then
./autogen.sh
Expand Down
8 changes: 7 additions & 1 deletion ruby/ext/google/protobuf_c/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
12 changes: 7 additions & 5 deletions ruby/ext/google/protobuf_c/upb.c
Original file line number Diff line number Diff line change
Expand Up @@ -12610,11 +12610,6 @@ upb_decoderet upb_vdecode_max8_branch64(upb_decoderet r) {
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Need to define __USE_XOPEN before including time.h to make strptime work. */
#ifndef __USE_XOPEN
#define __USE_XOPEN
#endif
#include <time.h>


Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7d9377e

Please sign in to comment.