Skip to content

Commit 2570edd

Browse files
authored
Merge pull request #18 from apple/master
merge
2 parents c6c0a6d + 82301a5 commit 2570edd

File tree

195 files changed

+5195
-2973
lines changed

Some content is hidden

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

195 files changed

+5195
-2973
lines changed

CMakeLists.txt

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -459,31 +459,20 @@ if(CMAKE_C_COMPILER_ID MATCHES Clang)
459459
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Werror=gnu>)
460460
endif()
461461

462-
if(CMAKE_SYSTEM_NAME STREQUAL Darwin OR
463-
EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
464-
set(SWIFT_BUILD_SYNTAXPARSERLIB_default TRUE)
465-
set(SWIFT_BUILD_SOURCEKIT_default TRUE)
466-
else()
467-
set(SWIFT_BUILD_SYNTAXPARSERLIB_default FALSE)
468-
set(SWIFT_BUILD_SOURCEKIT_default FALSE)
469-
endif()
470-
option(SWIFT_BUILD_SYNTAXPARSERLIB
471-
"Build the Swift Syntax Parser library"
472-
${SWIFT_BUILD_SYNTAXPARSERLIB_default})
473-
option(SWIFT_BUILD_ONLY_SYNTAXPARSERLIB
474-
"Only build the Swift Syntax Parser library" FALSE)
475-
option(SWIFT_BUILD_SOURCEKIT
476-
"Build SourceKit"
477-
${SWIFT_BUILD_SOURCEKIT_default})
478-
option(SWIFT_ENABLE_SOURCEKIT_TESTS
479-
"Enable running SourceKit tests"
480-
${SWIFT_BUILD_SOURCEKIT_default})
481-
482-
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" AND
483-
(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT))
484-
set(SWIFT_NEED_EXPLICIT_LIBDISPATCH TRUE)
485-
else()
486-
set(SWIFT_NEED_EXPLICIT_LIBDISPATCH FALSE)
462+
option(SWIFT_BUILD_SYNTAXPARSERLIB "Build the Swift Syntax Parser library" TRUE)
463+
option(SWIFT_BUILD_ONLY_SYNTAXPARSERLIB "Only build the Swift Syntax Parser library" FALSE)
464+
option(SWIFT_BUILD_SOURCEKIT "Build SourceKit" TRUE)
465+
option(SWIFT_ENABLE_SOURCEKIT_TESTS "Enable running SourceKit tests" ${SWIFT_BUILD_SOURCEKIT})
466+
467+
if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT)
468+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
469+
set(SWIFT_NEED_EXPLICIT_LIBDISPATCH FALSE)
470+
else()
471+
set(SWIFT_NEED_EXPLICIT_LIBDISPATCH TRUE)
472+
if(NOT EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
473+
message(SEND_ERROR "SyntaxParserLib and SourceKit require libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
474+
endif()
475+
endif()
487476
endif()
488477

489478
#

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,26 +155,26 @@ First, make sure that you're in the swift directory:
155155

156156
To build using Ninja, run:
157157

158-
swift/utils/build-script --release-debuginfo
158+
utils/build-script --release-debuginfo
159159

160160
When developing Swift, it helps to build what you're working on in a debug
161161
configuration while building the rest of the project with optimizations. Below
162162
are some examples of using debug variants:
163163

164-
swift/utils/build-script --release-debuginfo --debug-swift # Swift frontend built in debug
165-
swift/utils/build-script --release-debuginfo --debug-swift-stdlib # Standard library built in debug
166-
swift/utils/build-script --release-debuginfo --debug-swift --force-optimized-typechecker # Swift frontend sans type checker built in debug
164+
utils/build-script --release-debuginfo --debug-swift # Swift frontend built in debug
165+
utils/build-script --release-debuginfo --debug-swift-stdlib # Standard library built in debug
166+
utils/build-script --release-debuginfo --debug-swift --force-optimized-typechecker # Swift frontend sans type checker built in debug
167167

168168
Limiting the amount of debug code in the compiler has a very large impact on
169169
Swift compile times, and in turn the test execution time. If you want to build
170170
the entire project in debug, you can run:
171171

172-
swift/utils/build-script --debug
172+
utils/build-script --debug
173173

174174
For documentation of all available arguments, as well as additional usage
175175
information, see the inline help:
176176

177-
swift/utils/build-script -h
177+
utils/build-script -h
178178

179179
#### Xcode
180180

benchmark/single-source/NSStringConversion.swift

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import TestsUtils
1717
import Foundation
1818

1919
fileprivate var test:NSString = ""
20+
fileprivate var mutableTest = ""
2021

2122
public let NSStringConversion = [
2223
BenchmarkInfo(name: "NSStringConversion",
@@ -65,7 +66,44 @@ public let NSStringConversion = [
6566
BenchmarkInfo(name: "NSStringConversion.Rebridge.LongUTF8",
6667
runFunction: run_NSStringConversion_longNonASCII_rebridge,
6768
tags: [.validation, .api, .String, .bridging],
68-
setUpFunction: { test = NSString(cString: "Thë qüick bröwn föx jumps over the lazy dög", encoding: String.Encoding.utf8.rawValue)! })]
69+
setUpFunction: { test = NSString(cString: "Thë qüick bröwn föx jumps over the lazy dög", encoding: String.Encoding.utf8.rawValue)! } ),
70+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.UTF8",
71+
runFunction: run_NSStringConversion_nonASCIIMutable,
72+
tags: [.validation, .api, .String, .bridging],
73+
setUpFunction: { mutableTest = "tëst" }),
74+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Medium",
75+
runFunction: run_NSStringConversion_mediumMutable,
76+
tags: [.validation, .api, .String, .bridging],
77+
setUpFunction: { mutableTest = "aaaaaaaaaaaaaaa" } ),
78+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Long",
79+
runFunction: run_NSStringConversion_longMutable,
80+
tags: [.validation, .api, .String, .bridging],
81+
setUpFunction: { mutableTest = "The quick brown fox jumps over the lazy dog" } ),
82+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.LongUTF8",
83+
runFunction: run_NSStringConversion_longNonASCIIMutable,
84+
tags: [.validation, .api, .String, .bridging],
85+
setUpFunction: { mutableTest = "Thë qüick bröwn föx jumps over the lazy dög" } ),
86+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Rebridge",
87+
runFunction: run_NSStringConversion_rebridgeMutable,
88+
tags: [.validation, .api, .String, .bridging],
89+
setUpFunction: { mutableTest = "test" }),
90+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Rebridge.UTF8",
91+
runFunction: run_NSStringConversion_nonASCII_rebridgeMutable,
92+
tags: [.validation, .api, .String, .bridging],
93+
setUpFunction: { mutableTest = "tëst" }),
94+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Rebridge.Medium",
95+
runFunction: run_NSStringConversion_medium_rebridgeMutable,
96+
tags: [.validation, .api, .String, .bridging],
97+
setUpFunction: { mutableTest = "aaaaaaaaaaaaaaa" } ),
98+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Rebridge.Long",
99+
runFunction: run_NSStringConversion_long_rebridgeMutable,
100+
tags: [.validation, .api, .String, .bridging],
101+
setUpFunction: { mutableTest = "The quick brown fox jumps over the lazy dog" } ),
102+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Rebridge.LongUTF8",
103+
runFunction: run_NSStringConversion_longNonASCII_rebridgeMutable,
104+
tags: [.validation, .api, .String, .bridging],
105+
setUpFunction: { mutableTest = "Thë qüick bröwn föx jumps over the lazy dög" } )
106+
]
69107

70108
public func run_NSStringConversion(_ N: Int) {
71109
let test:NSString = NSString(cString: "test", encoding: String.Encoding.ascii.rawValue)!
@@ -103,6 +141,31 @@ public func run_NSStringConversion_longNonASCII(_ N: Int) {
103141
innerLoop(test, N, 300)
104142
}
105143

144+
fileprivate func innerMutableLoop(_ str: String, _ N: Int, _ scale: Int = 5000) {
145+
for _ in 1...N * scale {
146+
let copy = (str as NSString).mutableCopy() as! NSMutableString
147+
for char in (identity(copy) as String).utf8 {
148+
blackHole(char)
149+
}
150+
}
151+
}
152+
153+
public func run_NSStringConversion_nonASCIIMutable(_ N: Int) {
154+
innerMutableLoop(mutableTest, N, 500)
155+
}
156+
157+
public func run_NSStringConversion_mediumMutable(_ N: Int) {
158+
innerMutableLoop(mutableTest, N, 500)
159+
}
160+
161+
public func run_NSStringConversion_longMutable(_ N: Int) {
162+
innerMutableLoop(mutableTest, N, 250)
163+
}
164+
165+
public func run_NSStringConversion_longNonASCIIMutable(_ N: Int) {
166+
innerMutableLoop(mutableTest, N, 150)
167+
}
168+
106169
fileprivate func innerRebridge(_ str: NSString, _ N: Int, _ scale: Int = 5000) {
107170
for _ in 1...N * scale {
108171
let bridged = identity(str) as String
@@ -135,4 +198,33 @@ public func run_NSStringConversion_longNonASCII_rebridge(_ N: Int) {
135198
innerRebridge(test, N, 300)
136199
}
137200

201+
fileprivate func innerMutableRebridge(_ str: String, _ N: Int, _ scale: Int = 5000) {
202+
for _ in 1...N * scale {
203+
let copy = (str as NSString).mutableCopy() as! NSMutableString
204+
let bridged = identity(copy) as String
205+
blackHole(bridged)
206+
blackHole(bridged as NSString)
207+
}
208+
}
209+
210+
public func run_NSStringConversion_rebridgeMutable(_ N: Int) {
211+
innerMutableRebridge(mutableTest, N, 1000)
212+
}
213+
214+
public func run_NSStringConversion_nonASCII_rebridgeMutable(_ N: Int) {
215+
innerMutableRebridge(mutableTest, N, 500)
216+
}
217+
218+
public func run_NSStringConversion_medium_rebridgeMutable(_ N: Int) {
219+
innerMutableRebridge(mutableTest, N, 500)
220+
}
221+
222+
public func run_NSStringConversion_long_rebridgeMutable(_ N: Int) {
223+
innerMutableRebridge(mutableTest, N, 500)
224+
}
225+
226+
public func run_NSStringConversion_longNonASCII_rebridgeMutable(_ N: Int) {
227+
innerMutableRebridge(mutableTest, N, 300)
228+
}
229+
138230
#endif

docs/Android.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ To follow along with this guide, you'll need:
4242
turn on remote debugging by following the official instructions:
4343
https://developer.chrome.com/devtools/docs/remote-debugging.
4444

45-
## Part One: "Hello, world" on Android
45+
## "Hello, world" on Android
4646

4747
### 1. Downloading (or building) the Swift Android stdlib dependencies
4848

@@ -189,7 +189,7 @@ Hello, Android
189189

190190
Congratulations! You've just run your first Swift program on Android.
191191

192-
## Part Two: Running the Swift test suite hosted on an Android device
192+
## Running the Swift test suite hosted on an Android device
193193

194194
When running the test suite, build products are automatically pushed to your
195195
device. As in part one, you'll need to connect your Android device via USB:
@@ -213,3 +213,19 @@ $ utils/build-script \
213213
--android-icu-i18n ~/libicu-android/armeabi-v7a/libicui18n.so \
214214
--android-icu-i18n-include ~/libicu-android/armeabi-v7a/icu/source/i18n/
215215
```
216+
217+
## Build Android Toolchain
218+
219+
This toolchain will generate the .so and .swiftmodule files of the Swift standard library and Foundation framework for the Android environment, armv7 architecture. Those files are needed when building any Swift library to be included in an application for Android.
220+
221+
To build the toolchain run:
222+
223+
```
224+
$ utils/android/build-toolchain
225+
```
226+
227+
It will be built on:
228+
229+
```
230+
path/to/swift-source/swift-android-toolchain
231+
```

0 commit comments

Comments
 (0)