Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Testing Support
We now build `swift-test`, which will create a test runner based on the layout of your Test modules as per our testing proposal:

https://github.com/apple/swift-evolution/blob/master/proposals/0019-package-manager-testing.md

Also includes a significant refactor. I am sorry this is not more atomic, but the work just kept expanding in scope and keeping history straight was too much work.

Notable improvements aside from the testing propopsal:

 * Whole Module Optimization is applied to release builds
 * A single llbuild.yaml file is created for all packages in a project, this allows llbuild to properly manage build dependencies
 * A new products feature has been added to Package.swift which allows you to define product targets (like dynamic libraries) that consist of a series of modules

The refactor involved creating many more modules with much more refined and defined scope and responsibility. The code is now much more maintainable.
  • Loading branch information
mxcl committed Feb 16, 2016
1 parent f7f0d74 commit ae91219
Show file tree
Hide file tree
Showing 126 changed files with 3,226 additions and 3,693 deletions.
10 changes: 10 additions & 0 deletions Fixtures/DependencyResolution/External/Complex/app/Package.swift
@@ -1,3 +1,13 @@
/*
This source file is part of the Swift.org open source project
Copyright 2015 - 2016 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

import PackageDescription

let package = Package(
Expand Down
10 changes: 10 additions & 0 deletions Fixtures/DependencyResolution/External/Complex/app/main.swift
@@ -1,3 +1,13 @@
/*
This source file is part of the Swift.org open source project
Copyright 2015 - 2016 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

import FisherYates
import PlayingCard
import DeckOfPlayingCards
Expand Down
@@ -1,3 +1,13 @@
/*
This source file is part of the Swift.org open source project
Copyright 2015 - 2016 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

import FisherYates
import PlayingCard

Expand Down
File renamed without changes.
@@ -0,0 +1,5 @@
import PackageDescription

let package = Package(
name: "FooLib1",
targets: [Target(name: "cli", dependencies: ["FooLib1"])])
@@ -0,0 +1,3 @@
import FooLib1

print(FooLib1())
51 changes: 41 additions & 10 deletions Package.swift
Expand Up @@ -11,21 +11,52 @@
import PackageDescription

let package = Package(
name: "SwiftPackageManager",
name: "SwiftPM",
targets: [
Target(
name: "sys",
dependencies: [.Target(name: "POSIX")]),
Target(
/** “Swifty” POSIX functions from libc */
name: "POSIX",
dependencies: [.Target(name: "libc")]),
dependencies: ["libc"]),
Target(
/** Abstractions for common operations */
name: "Utility",
dependencies: ["POSIX"]),
Target(
/** Base types for the package-engine */
name: "PackageType",
dependencies: ["PackageDescription", "Utility"]), //FIXME dependency on PackageDescription sucks
Target( //FIXME Carpet is too general, we only need `Path`
name: "ManifestParser",
dependencies: ["PackageDescription", "PackageType"]),
Target(
/** Turns Packages into Modules & Products */
name: "Transmute",
dependencies: ["PackageDescription", "PackageType"]),
Target(
/** Fetches Packages and their dependencies */
name: "Get",
dependencies: ["ManifestParser"]),
Target(
name: "dep",
dependencies: [.Target(name: "sys"), .Target(name: "PackageDescription")]),
/** Builds Modules and Products */
name: "Build",
dependencies: ["PackageType"]),
Target(
name: "swift-get",
dependencies: [.Target(name: "dep")]),
/** Common components of both executables */
name: "Multitool",
dependencies: ["PackageType"]),
Target(
name: "swift-build",
dependencies: [.Target(name: "dep")]),
dependencies: ["Get", "Transmute", "Build", "Multitool"]),
Target(
name: "swift-test",
dependencies: ["Multitool"]),
])


// otherwise executables are auto-determined you could
// prevent this by asking for the auto-determined list
// here and editing it.

let dylib = Product(name: "PackageDescription", type: .Library(.Dynamic), modules: "PackageDescription")

products.append(dylib)
4 changes: 1 addition & 3 deletions README.md
Expand Up @@ -54,8 +54,6 @@ following options:
swiftpm/Utilities/bootstrap --swiftc path/to/snapshot/usr/bin/swiftc --sbt path/to/snapshot/usr/bin/swift-build-tool

`swiftc` and `swift-build-tool` are both executables provided as part of Swift downloadable snapshots, *they are **not** built from the sources in this repository*.

Please note, that the 2.2 release snapshot does not come with `swift-build-tool`, either download the *development* snapshot or build your own copy of `swift-llbuild`.

3. Using the Xcode Project in [Support](Support), this option requires:
* Xcode 7.3 (beta)
Expand All @@ -67,7 +65,7 @@ There is further development-oriented documentation in [Documentation/Internals]

## System Requirements

The package manager’s system requirements are the same as [those for Swift](https://github.com/apple/swift#system-requirements).
The package manager’s system requirements are the same as [those for Swift](https://github.com/apple/swift#system-requirements) with the caveat that the package manager requires Git at runtime as well as build-time.

## Contributing

Expand Down
11 changes: 10 additions & 1 deletion Sources/POSIX/exit.swift → Sources/Build/Configuration.swift
Expand Up @@ -8,4 +8,13 @@
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

@_exported import func libc.exit
public enum Configuration {
case Debug, Release

var dirname: String {
switch self {
case .Debug: return "debug"
case .Release: return "release"
}
}
}
41 changes: 41 additions & 0 deletions Sources/Build/IncrementalNode.swift
@@ -0,0 +1,41 @@
/*
This source file is part of the Swift.org open source project
Copyright 2015 - 2016 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

import Utility
import PackageType

struct IncrementalNode {
let module: SwiftModule
let prefix: String

var tempsPath: String {
return Path.join(prefix, "\(module.c99name).build")
}

var swiftModuleName: String {
return "\(module.c99name).swiftmodule"
}

var objectPaths: [String] {
return module.sources.relativePaths.map{ Path.join(tempsPath, "\($0).o") }
}

var outputs: [String] {
return [module.targetName] + objectPaths
}

var inputs: [String] {
return module.recursiveDependencies.map{ $0.targetName }
}

var moduleOutputPath: String {
return Path.join(prefix, swiftModuleName)
}
}
63 changes: 63 additions & 0 deletions Sources/Build/YAML.swift
@@ -0,0 +1,63 @@
/*
This source file is part of the Swift.org open source project
Copyright 2015 - 2016 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

import struct Utility.Path
import struct libc.FILE
import func libc.fclose
import POSIX

class YAML {
let path: String
private let fp: UnsafeMutablePointer<FILE>

init(path: String...) throws {
self.path = Path.join(path)
fp = try fopen(self.path, mode: .Write)
}

func close() {
fclose(fp)
}

func write(anys: Any...) throws {
var anys = anys
try fputs(anys.removeFirst() as! String, fp)
if !anys.isEmpty {
try fputs(anys.map(toYAML).joinWithSeparator(""), fp)
}
try fputs("\n", fp)

}
}

private func toYAML(any: Any) -> String {

func quote(input: String) -> String {
for c in input.characters {
if c == "@" || c == " " || c == "-" {
return "\"\(input)\""
}
}
return input
}

switch any {
case let string as String where string == "":
return "\"\""
case let string as String:
return string
case let array as [String]:
return "[" + array.map(quote).joinWithSeparator(", ") + "]"
case let bool as Bool:
return bool ? "true" : "false"
default:
fatalError("Unimplemented YAML type")
}
}

0 comments on commit ae91219

Please sign in to comment.