Skip to content

Commit

Permalink
Merge pull request #246 from MrMage/fix-build
Browse files Browse the repository at this point in the history
Fix building with a clean Xcode and add a CI run to ensure just that.
  • Loading branch information
timburks authored Jun 4, 2018
2 parents 38b66c3 + 56ecb72 commit 7279202
Show file tree
Hide file tree
Showing 1,434 changed files with 177,153 additions and 164,850 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ project.xcworkspace
xcuserdata
DerivedData/
.build
build
/protoc-gen-swift
/protoc-gen-swiftgrpc
third_party/**
Expand Down
2 changes: 1 addition & 1 deletion .travis-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then
PROTOC_URL=https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-osx-x86_64.zip
else
# Install swift
SWIFT_URL=https://swift.org/builds/swift-4.0.3-release/ubuntu1404/swift-4.0.3-RELEASE/swift-4.0.3-RELEASE-ubuntu14.04.tar.gz
SWIFT_URL=https://swift.org/builds/swift-4.1.1-release/ubuntu1404/swift-4.1.1-RELEASE/swift-4.1.1-RELEASE-ubuntu14.04.tar.gz
echo $SWIFT_URL
curl -fSsL $SWIFT_URL -o swift.tar.gz
tar -xzf swift.tar.gz --strip-components=2 --directory=local
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cache:
# Use Ubuntu 14.04
dist: trusty

osx_image: xcode9
osx_image: xcode9.3

sudo: false

Expand Down Expand Up @@ -57,3 +57,4 @@ script:
- make test
- make test-plugin
- make test-echo
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make xcodebuild; fi
998 changes: 282 additions & 716 deletions Assets/roots.pem

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
UNAME_S = $(shell uname -s)

ifeq ($(UNAME_S),Linux)
CFLAGS = -Xcc -DTSI_OPENSSL_ALPN_SUPPORT=0
else
CFLAGS = -Xcc -ISources/BoringSSL/include
CFLAGS = -Xcc -ISources/BoringSSL/include -Xlinker -lz
endif

all:
Expand All @@ -12,9 +11,8 @@ all:
cp .build/debug/protoc-gen-swiftgrpc .

project:
swift package generate-xcodeproj
# Optional: set the generated project's indentation settings.
-ruby fix-indentation-settings.rb || echo "Consider running 'sudo gem install xcodeproj' to automatically set correct indentation settings for the generated project."
swift package -v $(CFLAGS) generate-xcodeproj
@-ruby fix-project-settings.rb || echo "Consider running 'sudo gem install xcodeproj' to automatically set correct indentation settings for the generated project."

test: all
swift test -v $(CFLAGS)
Expand All @@ -34,9 +32,12 @@ test-plugin:
protoc Sources/Examples/Echo/echo.proto --proto_path=Sources/Examples/Echo --plugin=.build/debug/protoc-gen-swift --plugin=.build/debug/protoc-gen-swiftgrpc --swiftgrpc_out=/tmp --swiftgrpc_opt=TestStubs=true
diff -u /tmp/echo.grpc.swift Sources/Examples/Echo/Generated/echo.grpc.swift

xcodebuild: project
xcodebuild -configuration "Debug" -parallelizeTargets -target SwiftGRPC -target Echo -target Simple -target protoc-gen-swiftgrpc build

clean:
rm -rf Packages
rm -rf .build
rm -rf .build build
rm -rf SwiftGRPC.xcodeproj
rm -rf Package.pins Package.resolved
rm -rf protoc-gen-swift protoc-gen-swiftgrpc
Expand Down
26 changes: 8 additions & 18 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,27 @@
*/
import PackageDescription

var dependencies: [Package.Dependency] = [
var packageDependencies: [Package.Dependency] = [
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.0.2"),
.package(url: "https://github.com/kylef/Commander.git", from: "0.8.0")
.package(url: "https://github.com/kylef/Commander.git", from: "0.8.0"),
.package(url: "https://github.com/apple/swift-nio-zlib-support.git", from: "1.0.0")
]

var cGRPCDependencies: [Target.Dependency] = []
#if os(Linux)
// On Linux, Foundation links with openssl, so we'll need to use that instead of BoringSSL.
// See https://github.com/apple/swift-nio-ssl/issues/16#issuecomment-392705505 for details.
dependencies.append(.package(url: "https://github.com/apple/swift-nio-ssl-support.git", from: "1.0.0"))
packageDependencies.append(.package(url: "https://github.com/apple/swift-nio-ssl-support.git", from: "1.0.0"))
#else
cGRPCDependencies.append("BoringSSL")
#endif

/*
* `swift-nio-zlib-support` uses `pkgConfig` to find `zlib` on
* non-Apple platforms. Details here:
* https://github.com/apple/swift-nio-zlib-support/issues/2#issuecomment-384681975
*
* This doesn't play well with Macports, so require it only for non-Apple
* platforms, until there is a better solution.
* Issue: https://github.com/grpc/grpc-swift/issues/220
*/
#if !os(macOS)
dependencies.append(.package(url: "https://github.com/apple/swift-nio-zlib-support.git", from: "1.0.0"))
#endif

let package = Package(
name: "SwiftGRPC",
products: [
.library(name: "SwiftGRPC", targets: ["SwiftGRPC"]),
],
dependencies: dependencies,
dependencies: packageDependencies,
targets: [
.target(name: "SwiftGRPC",
dependencies: ["CgRPC", "SwiftProtobuf"]),
Expand All @@ -72,4 +60,6 @@ let package = Package(
dependencies: ["SwiftGRPC", "Commander"],
path: "Sources/Examples/Simple"),
.testTarget(name: "SwiftGRPCTests", dependencies: ["SwiftGRPC"])
])
],
cLanguageStandard: .gnu11,
cxxLanguageStandard: .cxx11)
87 changes: 0 additions & 87 deletions Sources/BoringSSL/crypto/aes/internal.h

This file was deleted.

9 changes: 7 additions & 2 deletions Sources/BoringSSL/crypto/asn1/a_bitstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

#include <openssl/asn1.h>

#include <limits.h>
#include <string.h>

#include <openssl/err.h>
Expand Down Expand Up @@ -139,6 +140,11 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
goto err;
}

if (len > INT_MAX) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_LONG);
goto err;
}

if ((a == NULL) || ((*a) == NULL)) {
if ((ret = M_ASN1_BIT_STRING_new()) == NULL)
return (NULL);
Expand Down Expand Up @@ -211,8 +217,7 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
if (a->data == NULL)
c = (unsigned char *)OPENSSL_malloc(w + 1);
else
c = (unsigned char *)OPENSSL_realloc_clean(a->data,
a->length, w + 1);
c = (unsigned char *)OPENSSL_realloc(a->data, w + 1);
if (c == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
return 0;
Expand Down
15 changes: 15 additions & 0 deletions Sources/BoringSSL/crypto/asn1/a_d2i_fp.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,21 @@ void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x)
}
#endif

typedef struct asn1_const_ctx_st
{
const unsigned char *p;/* work char pointer */
int eos; /* end of sequence read for indefinite encoding */
int error; /* error code to use when returning an error */
int inf; /* constructed if 0x20, indefinite is 0x21 */
int tag; /* tag from last 'get object' */
int xclass; /* class from last 'get object' */
long slen; /* length of last 'get object' */
const unsigned char *max; /* largest value of p allowed */
const unsigned char *q;/* temporary variable */
const unsigned char **pp;/* variable */
int line; /* used in error processing */
} ASN1_const_CTX;

#define HEADER_SIZE 8
#define ASN1_CHUNK_INITIAL_SIZE (16 * 1024)
static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
Expand Down
29 changes: 20 additions & 9 deletions Sources/BoringSSL/crypto/asn1/a_enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

#include <openssl/asn1.h>

#include <limits.h>
#include <string.h>

#include <openssl/err.h>
Expand Down Expand Up @@ -110,7 +111,6 @@ int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a)
{
int neg = 0, i;
long r = 0;

if (a == NULL)
return (0L);
Expand All @@ -120,20 +120,31 @@ long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a)
else if (i != V_ASN1_ENUMERATED)
return -1;

if (a->length > (int)sizeof(long)) {
OPENSSL_COMPILE_ASSERT(sizeof(uint64_t) >= sizeof(long),
long_larger_than_uint64_t);

if (a->length > (int)sizeof(uint64_t)) {
/* hmm... a bit ugly */
return (0xffffffffL);
return -1;
}
if (a->data == NULL)
return 0;

for (i = 0; i < a->length; i++) {
r <<= 8;
r |= (unsigned char)a->data[i];
uint64_t r64 = 0;
if (a->data != NULL) {
for (i = 0; i < a->length; i++) {
r64 <<= 8;
r64 |= (unsigned char)a->data[i];
}

if (r64 > LONG_MAX) {
return -1;
}
}

long r = (long) r64;
if (neg)
r = -r;
return (r);

return r;
}

ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
Expand Down
2 changes: 1 addition & 1 deletion Sources/BoringSSL/crypto/asn1/a_gentm.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d)
if (a[o] == 'Z')
o++;
else if ((a[o] == '+') || (a[o] == '-')) {
int offsign = a[o] == '-' ? -1 : 1, offset = 0;
int offsign = a[o] == '-' ? 1 : -1, offset = 0;
o++;
if (o + 4 > l)
goto err;
Expand Down
3 changes: 3 additions & 0 deletions Sources/BoringSSL/crypto/asn1/a_i2d_fp.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, void *x)
int i, j = 0, n, ret = 1;

n = i2d(x, NULL);
if (n <= 0)
return 0;

b = (char *)OPENSSL_malloc(n);
if (b == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
Expand Down
27 changes: 19 additions & 8 deletions Sources/BoringSSL/crypto/asn1/a_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include <openssl/asn1.h>

#include <string.h>
#include <limits.h>

#include <openssl/err.h>
#include <openssl/mem.h>
Expand Down Expand Up @@ -385,7 +386,6 @@ int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
long ASN1_INTEGER_get(const ASN1_INTEGER *a)
{
int neg = 0, i;
long r = 0;

if (a == NULL)
return (0L);
Expand All @@ -395,20 +395,31 @@ long ASN1_INTEGER_get(const ASN1_INTEGER *a)
else if (i != V_ASN1_INTEGER)
return -1;

if (a->length > (int)sizeof(long)) {
OPENSSL_COMPILE_ASSERT(sizeof(uint64_t) >= sizeof(long),
long_larger_than_uint64_t);

if (a->length > (int)sizeof(uint64_t)) {
/* hmm... a bit ugly, return all ones */
return -1;
}
if (a->data == NULL)
return 0;

for (i = 0; i < a->length; i++) {
r <<= 8;
r |= (unsigned char)a->data[i];
uint64_t r64 = 0;
if (a->data != NULL) {
for (i = 0; i < a->length; i++) {
r64 <<= 8;
r64 |= (unsigned char)a->data[i];
}

if (r64 > LONG_MAX) {
return -1;
}
}

long r = (long) r64;
if (neg)
r = -r;
return (r);

return r;
}

ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
Expand Down
Loading

0 comments on commit 7279202

Please sign in to comment.