Skip to content

Commit b359115

Browse files
authored
Merge pull request #46 from SomaticLabs/protobuf
add `writeTimeline` functionality
2 parents aa53ae7 + b2210ba commit b359115

File tree

480 files changed

+392148
-287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

480 files changed

+392148
-287
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "Carthage/Checkouts/SwiftyBluetooth"]
55
path = Carthage/Checkouts/SwiftyBluetooth
66
url = https://github.com/jordanebelanger/SwiftyBluetooth.git
7+
[submodule "SwiftyZorb/Internal/zorb-protocol"]
8+
path = SwiftyZorb/Internal/zorb-protocol
9+
url = https://github.com/SomaticLabs/zorb-protocol.git

Cartfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
github "jordanebelanger/SwiftyBluetooth" ~> 1.0
22
github "Alamofire/Alamofire" ~> 4.5
33
github "SwiftyJSON/SwiftyJSON" ~> 4.0
4+
github "apple/swift-protobuf" ~> 1.0

Cartfile.resolved

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
github "Alamofire/Alamofire" "4.7.3"
22
github "SwiftyJSON/SwiftyJSON" "4.1.0"
3+
github "apple/swift-protobuf" "1.1.2"
34
github "jordanebelanger/SwiftyBluetooth" "1.0.0"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Please be sure to include:
2+
3+
* what OS you are developing on (Linux or macOS, including the version)
4+
5+
* for macOS, what version of Xcode you are using (`xcodebuild -version`),
6+
for Linux, what version of Swift (`swift --version`)
7+
8+
* what version of Swift is your code set to compile with (i.e. from project
9+
settings, etc.)
10+
11+
* what branch/tag of SwiftProtobuf you are using (1.0.0, etc.)
12+
13+
* if you are getting compile errors, please be sure include all errors/warnings,
14+
sometimes the error before the one you are stuck on is important.
15+
16+
* lastly, if it all possible, provide a snippet of `.proto` and/or source
17+
that shows the problem.
18+
19+
Thank you!
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
*~
5+
xcuserdata
6+
xcbaselines
7+
/_test
8+
/docs
9+
/build
10+
mined_words.txt
11+
/DescriptorTestData.bin
12+
13+
# Intermediate conformance test outputs
14+
failing_tests.txt
15+
nonexistent_tests.txt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
documentation: "Documentation/{API,GENERATED_CODE,PLUGIN}.md"
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/awk -f
2+
3+
# ProtobufRuntime/Sources/Protobuf/ProtobufBinaryEncoding.swift - Binary encoding support
4+
#
5+
# This source file is part of the Swift.org open source project
6+
#
7+
# Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
8+
# Licensed under Apache License v2.0 with Runtime Library Exception
9+
#
10+
# See http://swift.org/LICENSE.txt for license information
11+
# See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
12+
#
13+
# -----------------------------------------------------------------------------
14+
#
15+
# The Linux version of XCTest cannot automatically
16+
# discover tests at run-time. So you can either manually
17+
# maintain lists of tests or collect them at build time.
18+
#
19+
# This script is used by the Makefile to do the latter:
20+
# = Scans each XCTest source file for 'class Foo: XCTestCase'
21+
# = Looks for 'func test*' within those classes
22+
# = Emits a class extension with the necessary 'allTests' property
23+
# = Emits an XCTMain invocation to run all the classes
24+
#
25+
# The macOS version of XCTest has another mechanism for
26+
# finding tests at run-time, so this is not needed there.
27+
#
28+
# -----------------------------------------------------------------------------
29+
30+
BEGIN {
31+
CLASS=""
32+
TESTCASES=""
33+
TESTCASE_separator=""
34+
printf("//\n")
35+
printf("// GENERATED FILE\n")
36+
printf("// DO NOT EDIT\n")
37+
printf("//\n")
38+
printf("\n")
39+
printf("import XCTest\n")
40+
printf("@testable import SwiftProtobufTests\n")
41+
printf("@testable import SwiftProtobufPluginLibraryTests\n")
42+
printf("\n")
43+
}
44+
45+
/class .*:.* XCTestCase/ {
46+
if (CLASS != "") {
47+
printf("\n ]\n")
48+
printf("}\n")
49+
}
50+
split($0, a, ":")
51+
split(a[1], words, " ")
52+
CLASS=words[2]
53+
TESTCASES = TESTCASES TESTCASE_separator "\n" " testCase(" CLASS ".allTests)"
54+
TESTCASE_separator = ","
55+
printf("\n")
56+
printf("extension %s {\n", CLASS)
57+
printf(" static var allTests = [")
58+
FUNC_separator=""
59+
}
60+
61+
62+
/^ *func *test.*/ {
63+
split($0, a, "(")
64+
split(a[1], words, " ")
65+
FUNC=words[2]
66+
printf("")
67+
printf("%s\n (\"%s\", %s)", FUNC_separator, FUNC, FUNC)
68+
FUNC_separator = ","
69+
}
70+
71+
END {
72+
if (CLASS != "") {
73+
printf("\n ]\n")
74+
printf("}\n")
75+
}
76+
printf("\n")
77+
78+
printf("XCTMain(\n")
79+
printf(" [")
80+
printf(TESTCASES)
81+
printf("\n ]\n)\n")
82+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
readonly DevToolsDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
6+
readonly RootDir="${DevToolsDir}/.."
7+
8+
cd "${RootDir}"
9+
10+
for f in `find . -name '*.swift' -o -name '*.cc' | sed -e 's|./||' | grep -v '.pb.swift'`; do
11+
if head -n 4 $f | grep 'DO NOT EDIT' > /dev/null; then
12+
# If the first lines contain 'DO NOT EDIT', then
13+
# this is a generated file and we should not
14+
# try to check or edit the copyright message.
15+
# But: print the filename; all such files should be .pb.swift
16+
# files that we're not even looking at here.
17+
echo "DO NOT EDIT: $f"
18+
else
19+
tmp=$f~
20+
mv $f $tmp
21+
if head -n 10 $tmp | grep 'Copyright.*Apple' > /dev/null; then
22+
# This has a copyright message, update it
23+
# Edit the first line to have the correct filename
24+
head -n 1 $tmp | sed "s|// [^-]* - \(.*\)|// $f - \1|" >$f
25+
# Followed by the current copyright text:
26+
cat <<EOF >>$f
27+
//
28+
// Copyright (c) 2014 - 2016 Apple Inc. and the project authors
29+
// Licensed under Apache License v2.0 with Runtime Library Exception
30+
//
31+
// See LICENSE.txt for license information:
32+
// https://github.com/apple/swift-protobuf/blob/master/LICENSE.txt
33+
EOF
34+
# Followed by the body of the file
35+
# The copyright message ends at the first blank comment line after
36+
# the first line containing "LICENSE.txt":
37+
cat $tmp | sed -n '/LICENSE.txt/,$ p' | sed -n '/^\/\/$/,$ p' >> $f
38+
rm $tmp
39+
else
40+
# This does not have a copyright message, insert one
41+
echo "Inserting copyright >> $f"
42+
cat <<EOF >>$f
43+
// $f - description
44+
//
45+
// Copyright (c) 2014 - 2017 Apple Inc. and the project authors
46+
// Licensed under Apache License v2.0 with Runtime Library Exception
47+
//
48+
// See LICENSE.txt for license information:
49+
// https://github.com/apple/swift-protobuf/blob/master/LICENSE.txt
50+
//
51+
52+
EOF
53+
cat $tmp >> $f
54+
fi
55+
fi
56+
done
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#! /usr/bin/python
2+
# DevTools/LibraryVersions.py - Helper for the library's version number
3+
#
4+
# Copyright (c) 2014 - 2017 Apple Inc. and the project authors
5+
# Licensed under Apache License v2.0 with Runtime Library Exception
6+
#
7+
# See LICENSE.txt for license information:
8+
# https://github.com/apple/swift-protobuf/blob/master/LICENSE.txt
9+
#
10+
11+
"""Helper script to for the versions numbers in the project sources."""
12+
13+
import optparse
14+
import os
15+
import re
16+
import sys
17+
18+
_VERSION_RE = re.compile(r'^(?P<major>\d+)\.(?P<minor>\d+)(.(?P<revision>\d+))?$')
19+
20+
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
21+
_PODSPEC_PATH = os.path.join(_PROJECT_ROOT, 'SwiftProtobuf.podspec')
22+
_VERSION_SWIFT_PATH = os.path.join(_PROJECT_ROOT, 'Sources/SwiftProtobuf/Version.swift')
23+
_XCODE_PROJECT_PATH = os.path.join(_PROJECT_ROOT, 'SwiftProtobuf.xcodeproj/project.pbxproj')
24+
25+
def Fail(message):
26+
sys.stderr.write('Error: %s\n' % message)
27+
sys.exit(1)
28+
29+
30+
def ExtractVersion(s):
31+
match = _VERSION_RE.match(s)
32+
return (match.group('major'), match.group('minor'), match.group('revision') or '0')
33+
34+
35+
def ValidateFiles():
36+
# Extra from SwiftProtobuf.podspec
37+
pod_content = open(_PODSPEC_PATH).read()
38+
match = re.search(r'version = \'(\d+.\d+.\d+)\'', pod_content)
39+
if not match:
40+
Fail('Failed to extract a version from SwiftProtobuf.podspec')
41+
(major, minor, revision) = ExtractVersion(match.group(1))
42+
43+
# Test Sources/SwiftProtobuf/Version.swift
44+
version_swift_content = open(_VERSION_SWIFT_PATH).read()
45+
major_line = 'static public let major = %s\n' % major
46+
minor_line = 'static public let minor = %s\n' % minor
47+
revision_line = 'static public let revision = %s\n' % revision
48+
had_major = major_line in version_swift_content
49+
had_minor = minor_line in version_swift_content
50+
had_revision = revision_line in version_swift_content
51+
if not had_major or not had_minor or not had_revision:
52+
Fail('Version in Sources/SwiftProtobuf/Version.swift did not match SwiftProtobuf.podspec')
53+
54+
# Test SwiftProtobuf.xcodeproj/project.pbxproj
55+
xcode_project_content = open(_XCODE_PROJECT_PATH).read()
56+
matches = re.findall(r'CURRENT_PROJECT_VERSION = %s\.%s\.%s;' % (major, minor, revision),
57+
xcode_project_content)
58+
if len(matches) != 2:
59+
Fail('Version in SwiftProtobuf.xcodeproj/project.pbxproj did not match SwiftProtobuf.podspec')
60+
61+
62+
def UpdateFiles(version_string):
63+
(major, minor, revision) = ExtractVersion(version_string)
64+
65+
# Update SwiftProtobuf.podspec
66+
pod_content = open(_PODSPEC_PATH).read()
67+
pod_content = re.sub(r'version = \'(\d+\.\d+\.\d+)\'',
68+
'version = \'%s.%s.%s\'' % (major, minor, revision),
69+
pod_content)
70+
open(_PODSPEC_PATH, 'w').write(pod_content)
71+
72+
# Update Sources/SwiftProtobuf/Version.swift
73+
version_swift_content = open(_VERSION_SWIFT_PATH).read()
74+
version_swift_content = re.sub(r'static public let major = \d+\n',
75+
'static public let major = %s\n' % major,
76+
version_swift_content)
77+
version_swift_content = re.sub(r'static public let minor = \d+\n',
78+
'static public let minor = %s\n' % minor,
79+
version_swift_content)
80+
version_swift_content = re.sub(r'static public let revision = \d+\n',
81+
'static public let revision = %s\n' % revision,
82+
version_swift_content)
83+
open(_VERSION_SWIFT_PATH, 'w').write(version_swift_content)
84+
85+
# Update SwiftProtobuf.xcodeproj/project.pbxproj
86+
xcode_project_content = open(_XCODE_PROJECT_PATH).read()
87+
xcode_project_content = re.sub(r'CURRENT_PROJECT_VERSION = \d+\.\d+\.\d+',
88+
'CURRENT_PROJECT_VERSION = %s.%s.%s' % (major, minor, revision),
89+
xcode_project_content)
90+
open(_XCODE_PROJECT_PATH, 'w').write(xcode_project_content)
91+
92+
93+
def main(args):
94+
usage = '%prog [OPTIONS] [VERSION]'
95+
description = (
96+
'Helper for the version numbers in the project sources.'
97+
)
98+
parser = optparse.OptionParser(usage=usage, description=description)
99+
parser.add_option('--validate',
100+
default=False, action='store_true',
101+
help='Check if the versions in all the files match.')
102+
opts, extra_args = parser.parse_args(args)
103+
104+
if opts.validate:
105+
if extra_args:
106+
parser.error('No version can be given when using --validate.')
107+
else:
108+
if len(extra_args) != 1:
109+
parser.error('Expected one argument, the version number to ensure is in the sources.')
110+
if not _VERSION_RE.match(extra_args[0]):
111+
parser.error('Version does not appear to be in the form of x.y.z.')
112+
113+
# Always validate, just use the flag to tell if we're expected to also have set something.
114+
if not opts.validate:
115+
UpdateFiles(extra_args[0])
116+
ValidateFiles()
117+
return 0
118+
119+
120+
if __name__ == '__main__':
121+
sys.exit(main(sys.argv[1:]))

0 commit comments

Comments
 (0)