Skip to content

Commit cdb6af9

Browse files
committed
[Product] Make product type cases as lower case
Since this is no longer in public API change the cases according to swift 3 API guidelines.
1 parent c793a42 commit cdb6af9

File tree

7 files changed

+48
-48
lines changed

7 files changed

+48
-48
lines changed

Sources/Build/BuildPlan.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,19 @@ public final class ProductBuildDescription {
280280
args += ["-module-name", product.name]
281281

282282
switch product.type {
283-
case .Library(.Static):
283+
case .library(.static):
284284
// No arguments for static libraries.
285285
return []
286-
case .Test:
286+
case .test:
287287
// Test products are bundle on macOS, executable on linux.
288288
#if os(macOS)
289289
args += ["-Xlinker", "-bundle"]
290290
#else
291291
args += ["-emit-executable"]
292292
#endif
293-
case .Library(.Dynamic):
293+
case .library(.dynamic):
294294
args += ["-emit-library"]
295-
case .Executable:
295+
case .executable:
296296
args += ["-emit-executable"]
297297
}
298298
args += objects.map{$0.asString}
@@ -376,7 +376,7 @@ public class BuildPlan {
376376
var objects = allModules.filter{ $0.type == .library }.flatMap{ targetMap[$0]!.objects }
377377

378378
// Add objects from main module, if product is an executable.
379-
if product.type == .Executable {
379+
if product.type == .executable {
380380
// FIXME: This should come from product type enum instead of manual search.
381381
let mainModule = product.modules.first{$0.type == .executable}!
382382
objects += targetMap[mainModule]!.objects
@@ -386,7 +386,7 @@ public class BuildPlan {
386386
// FIXME: Create a module and target for LinuxMain file on linux.
387387
// This module just contains one source file (LinuxMain.swift) which acts as manifest to the tests on linux.
388388
// This will go away once it is possible to auto detect tests.
389-
if product.type == .Test {
389+
if product.type == .test {
390390
let module = SwiftModule(linuxMain: product.linuxMainTest, name: product.name, dependencies: product.modules)
391391
let target = SwiftTargetDescription(module: module, buildParameters: buildParameters)
392392
targetMap[module] = .swift(target)

Sources/Build/Buildable.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ extension Module: Buildable {
2424

2525
extension Product: Buildable {
2626
var isTest: Bool {
27-
if case .Test = type {
27+
if case .test = type {
2828
return true
2929
}
3030
return false
3131
}
3232

3333
var targetName: String {
3434
switch type {
35-
case .Library(.Dynamic):
35+
case .library(.dynamic):
3636
return "<\(name).dylib>"
37-
case .Test:
37+
case .test:
3838
return "<\(name).test>"
39-
case .Library(.Static):
39+
case .library(.static):
4040
return "<\(name).a>"
41-
case .Executable:
41+
case .executable:
4242
return "<\(name).exe>"
4343
}
4444
}

Sources/Build/llbuild.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public struct LLbuildManifestGenerator {
9494
private func createLinkCommand(_ buildProduct: ProductBuildDescription) -> Command {
9595
let tool: ToolProtocol
9696
// Create archive tool for static library and shell tool for rest of the products.
97-
if buildProduct.product.type == .Library(.Static) {
97+
if buildProduct.product.type == .library(.static) {
9898
tool = ArchiveTool(inputs: buildProduct.objects.map{$0.asString}, outputs: [buildProduct.binary.asString])
9999
} else {
100100
tool = ShellTool(

Sources/Commands/SwiftTestTool.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public class SwiftTestTool: SwiftTool<TestToolOptions> {
132132
// FIXME: We should also check if the package has any test
133133
// modules, which isn't trivial (yet).
134134
let testProducts = graph.products.filter{
135-
if case .Test = $0.type {
135+
if case .test = $0.type {
136136
return true
137137
} else {
138138
return false

Sources/PackageLoading/PackageBuilder.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ public struct PackageBuilder {
567567

568568
for case let module as SwiftModule in modules {
569569
if module.type == .executable {
570-
let product = Product(name: module.name, type: .Executable, modules: [module])
570+
let product = Product(name: module.name, type: .executable, modules: [module])
571571
products.append(product)
572572
}
573573
}
@@ -576,7 +576,7 @@ public struct PackageBuilder {
576576

577577
for case let module as ClangModule in modules {
578578
if module.type == .executable {
579-
let product = Product(name: module.name, type: .Executable, modules: [module])
579+
let product = Product(name: module.name, type: .executable, modules: [module])
580580
products.append(product)
581581
}
582582
}
@@ -599,7 +599,7 @@ public struct PackageBuilder {
599599
// TODO and then we should prefix all modules with their package probably.
600600
// Add suffix 'PackageTests' to test product so the module name of linux executable don't collide with
601601
// main package, if present.
602-
let product = Product(name: manifest.name + "PackageTests", type: .Test, modules: testModules)
602+
let product = Product(name: manifest.name + "PackageTests", type: .test, modules: testModules)
603603
products.append(product)
604604
}
605605

@@ -626,15 +626,15 @@ public struct PackageBuilder {
626626
switch product {
627627
case .exe(let p):
628628
// FIXME: We should handle/diagnose name collisions between local and vended executables (SR-3562).
629-
products += [Product(name: p.name, type: .Executable, modules: try modulesFrom(targetNames: p.targets, product: p.name))]
629+
products += [Product(name: p.name, type: .executable, modules: try modulesFrom(targetNames: p.targets, product: p.name))]
630630
case .lib(let p):
631631
// Get the library type.
632632
let type: ProductType
633633
switch p.type {
634-
case .static?: type = .Library(.Static)
635-
case .dynamic?: type = .Library(.Dynamic)
634+
case .static?: type = .library(.static)
635+
case .dynamic?: type = .library(.dynamic)
636636
// FIXME: For now infer nil as dylibs, we need to expand PackageModel.Product to store this information.
637-
case nil: type = .Library(.Dynamic)
637+
case nil: type = .library(.dynamic)
638638
}
639639
products += [Product(name: p.name, type: type, modules: try modulesFrom(targetNames: p.targets, product: p.name))]
640640
}

Sources/PackageModel/Product.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@
1111
import Basic
1212

1313
public enum LibraryType {
14-
case Static
15-
case Dynamic
14+
case `static`
15+
case `dynamic`
1616
}
1717

1818
public enum ProductType {
19-
case Test
20-
case Executable
21-
case Library(LibraryType)
19+
case test
20+
case executable
21+
case library(LibraryType)
2222
}
2323

2424
extension ProductType: CustomStringConvertible {
2525
public var description: String {
2626
switch self {
27-
case .Test:
27+
case .test:
2828
return "test"
29-
case .Executable:
29+
case .executable:
3030
return "exe"
31-
case .Library(.Static):
31+
case .library(.static):
3232
return "a"
33-
case .Library(.Dynamic):
33+
case .library(.dynamic):
3434
return "dylib"
3535
}
3636
}
@@ -51,7 +51,7 @@ public class Product {
5151

5252
/// Path to the main file for test product on linux.
5353
public var linuxMainTest: AbsolutePath {
54-
precondition(type == .Test, "This property is only valid for test product type")
54+
precondition(type == .test, "This property is only valid for test product type")
5555
// FIXME: This is hacky, we should get this from package builder.
5656
let testDirectory = modules.first{$0.isTest}!.sources.root.parentDirectory
5757
return testDirectory.appending(component: "LinuxMain.swift")
@@ -66,13 +66,13 @@ public class Product {
6666

6767
public var outname: RelativePath {
6868
switch type {
69-
case .Executable:
69+
case .executable:
7070
return RelativePath(name)
71-
case .Library(.Static):
71+
case .library(.static):
7272
return RelativePath("lib\(name).a")
73-
case .Library(.Dynamic):
73+
case .library(.dynamic):
7474
return RelativePath("lib\(name).\(Product.dynamicLibraryExtension)")
75-
case .Test:
75+
case .test:
7676
let base = "\(name).xctest"
7777
#if os(macOS)
7878
return RelativePath("\(base)/Contents/MacOS/\(name)")
@@ -95,7 +95,7 @@ extension Product: CustomStringConvertible {
9595
public var description: String {
9696
let base = outname.basename
9797
switch type {
98-
case .Test:
98+
case .test:
9999
return "\(base).xctest"
100100
default:
101101
return base
@@ -106,17 +106,17 @@ extension Product: CustomStringConvertible {
106106
extension ProductType: Equatable {}
107107
public func ==(lhs: ProductType, rhs: ProductType) -> Bool {
108108
switch (lhs, rhs) {
109-
case (.Executable, .Executable):
109+
case (.executable, .executable):
110110
return true
111-
case (.Executable, _):
111+
case (.executable, _):
112112
return false
113-
case (.Test, .Test):
113+
case (.test, .test):
114114
return true
115-
case (.Test, _):
115+
case (.test, _):
116116
return false
117-
case (.Library(let lhsType), .Library(let rhsType)):
117+
case (.library(let lhsType), .library(let rhsType)):
118118
return lhsType == rhsType
119-
case (.Library(_), _):
119+
case (.library(_), _):
120120
return false
121121
}
122122
}

Tests/PackageLoadingTests/ConventionTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -678,23 +678,23 @@ class ConventionTests: XCTestCase {
678678
}
679679

680680
result.checkProduct("libpmS") { productResult in
681-
productResult.check(type: .Library(.Static), modules: ["Bar", "Foo"])
681+
productResult.check(type: .library(.static), modules: ["Bar", "Foo"])
682682
}
683683

684684
result.checkProduct("libpmD") { productResult in
685-
productResult.check(type: .Library(.Dynamic), modules: ["Bar", "Foo"])
685+
productResult.check(type: .library(.dynamic), modules: ["Bar", "Foo"])
686686
}
687687

688688
result.checkProduct("libpmA") { productResult in
689-
productResult.check(type: .Library(.Dynamic), modules: ["Foo"])
689+
productResult.check(type: .library(.dynamic), modules: ["Foo"])
690690
}
691691

692692
result.checkProduct("executable") { productResult in
693-
productResult.check(type: .Executable, modules: ["Foo", "exe"])
693+
productResult.check(type: .executable, modules: ["Foo", "exe"])
694694
}
695695

696696
result.checkProduct("exe") { productResult in
697-
productResult.check(type: .Executable, modules: ["exe"])
697+
productResult.check(type: .executable, modules: ["exe"])
698698
}
699699
}
700700
}
@@ -717,7 +717,7 @@ class ConventionTests: XCTestCase {
717717
}
718718

719719
result.checkProduct("FooPackageTests") { productResult in
720-
productResult.check(type: .Test, modules: ["FooTests"])
720+
productResult.check(type: .test, modules: ["FooTests"])
721721
}
722722
}
723723

@@ -750,7 +750,7 @@ class ConventionTests: XCTestCase {
750750
}
751751

752752
result.checkProduct("FooPackageTests") { productResult in
753-
productResult.check(type: .Test, modules: ["BarTests", "FooTests"])
753+
productResult.check(type: .test, modules: ["BarTests", "FooTests"])
754754
}
755755
}
756756
}

0 commit comments

Comments
 (0)