Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete manifest generation #724

Merged
merged 2 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/

## Next

### Removed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth marking this as "breaking" ?

For anyone that did a tuist init in prior versions and upgrades to this version, tuist generate may fail as it won't recognise .generateManifest option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth marking this as "breaking" ?

Good point. We should definitively mark this one as breaking.

- **Breaking** Generate manifests target as part of the generated project https://github.com/tuist/tuist/pull/724 by @pepibumur.

### Added

- Add `ProjectDescription.Settings.defaultSettings` none case that don't override any `Project` or `Target` settings. https://github.com/tuist/tuist/pull/698 by @rowwingman.
Expand Down
10 changes: 0 additions & 10 deletions Sources/ProjectDescription/TuistConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import Foundation
public struct TuistConfig: Codable, Equatable {
/// Contains options related to the project generation.
///
/// - generateManifestElement: When passed, Tuist generates the projects, targets and schemes to compile the project manifest.
/// - xcodeProjectName(TemplateString): When passed, Tuist generates the project with the specific name on disk instead of using the project name.
public enum GenerationOptions: Encodable, Decodable, Equatable {
case generateManifest
case xcodeProjectName(TemplateString)
}

Expand Down Expand Up @@ -39,10 +37,6 @@ extension TuistConfig.GenerationOptions {
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

if container.allKeys.contains(.generateManifest), try container.decodeNil(forKey: .generateManifest) == false {
self = .generateManifest
return
}
if container.allKeys.contains(.xcodeProjectName), try container.decodeNil(forKey: .xcodeProjectName) == false {
var associatedValues = try container.nestedUnkeyedContainer(forKey: .xcodeProjectName)
let templateProjectName = try associatedValues.decode(TemplateString.self)
Expand All @@ -56,8 +50,6 @@ extension TuistConfig.GenerationOptions {
var container = encoder.container(keyedBy: CodingKeys.self)

switch self {
case .generateManifest:
_ = container.nestedContainer(keyedBy: CodingKeys.self, forKey: .generateManifest)
case let .xcodeProjectName(templateProjectName):
var associatedValues = container.nestedUnkeyedContainer(forKey: .xcodeProjectName)
try associatedValues.encode(templateProjectName)
Expand All @@ -72,8 +64,6 @@ public func == (lhs: TuistConfig, rhs: TuistConfig) -> Bool {

public func == (lhs: TuistConfig.GenerationOptions, rhs: TuistConfig.GenerationOptions) -> Bool {
switch (lhs, rhs) {
case (.generateManifest, .generateManifest):
return true
case let (.xcodeProjectName(lhs), .xcodeProjectName(rhs)):
return lhs.rawString == rhs.rawString
default: return false
Expand Down
4 changes: 1 addition & 3 deletions Sources/TuistCore/Models/TuistConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class TuistConfig: Equatable, Hashable {
/// Returns the default Tuist configuration.
public static var `default`: TuistConfig {
return TuistConfig(compatibleXcodeVersions: .all,
generationOptions: [.generateManifest])
generationOptions: [])
}

/// Initializes the tuist cofiguration.
Expand Down Expand Up @@ -60,8 +60,6 @@ public class TuistConfig: Equatable, Hashable {

public func == (lhs: TuistConfig.GenerationOption, rhs: TuistConfig.GenerationOption) -> Bool {
switch (lhs, rhs) {
case (.generateManifest, .generateManifest):
return true
case let (.xcodeProjectName(lhs), .xcodeProjectName(rhs)):
return lhs == rhs
default: return false
Expand Down
2 changes: 1 addition & 1 deletion Sources/TuistGenerator/Generator/SchemesGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ final class SchemesGenerator: SchemesGenerating {
postActions: schemeExecutionActions(actions: archiveAction.postActions,
project: project,
generatedProject: generatedProject))
}
}

/// Generates the array of BuildableReference for targets that the
/// coverage report should be generated for them.
Expand Down
5 changes: 1 addition & 4 deletions Sources/TuistKit/Commands/FocusCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ class FocusCommand: NSObject, Command {
let resourceLocator = ResourceLocator()
let manifestLoader = GraphManifestLoader(resourceLocator: resourceLocator)
let manifestLinter = ManifestLinter()
let manifestTargetGenerator = ManifestTargetGenerator(manifestLoader: manifestLoader,
resourceLocator: resourceLocator)
let modelLoader = GeneratorModelLoader(manifestLoader: manifestLoader,
manifestLinter: manifestLinter,
manifestTargetGenerator: manifestTargetGenerator)
manifestLinter: manifestLinter)
let generator = Generator(modelLoader: modelLoader)
self.init(parser: parser,
generator: generator,
Expand Down
6 changes: 1 addition & 5 deletions Sources/TuistKit/Commands/GenerateCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ class GenerateCommand: NSObject, Command {
required convenience init(parser: ArgumentParser) {
let resourceLocator = ResourceLocator()
let manifestLoader = GraphManifestLoader(resourceLocator: resourceLocator)
let manifestTargetGenerator = ManifestTargetGenerator(manifestLoader: manifestLoader,
resourceLocator: resourceLocator)
let manifestLinter = ManifestLinter()
let modelLoader = GeneratorModelLoader(manifestLoader: manifestLoader,
manifestLinter: manifestLinter,
manifestTargetGenerator: manifestTargetGenerator)
let modelLoader = GeneratorModelLoader(manifestLoader: manifestLoader, manifestLinter: manifestLinter)
let generator = Generator(modelLoader: modelLoader)
self.init(parser: parser,
generator: generator,
Expand Down
1 change: 0 additions & 1 deletion Sources/TuistKit/Commands/InitCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ class InitCommand: NSObject, Command {
import ProjectDescription

let config = TuistConfig(generationOptions: [
.generateManifest
])
"""
let setupPath = path.appending(component: Manifest.tuistConfig.fileName)
Expand Down
6 changes: 1 addition & 5 deletions Sources/TuistKit/Extensions/Generator+TuistKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ extension Generator {
convenience init() {
let resourceLocator = ResourceLocator()
let manifestLoader = GraphManifestLoader(resourceLocator: resourceLocator)
let manifestTargetGenerator = ManifestTargetGenerator(manifestLoader: manifestLoader,
resourceLocator: resourceLocator)
let manifestLinter = ManifestLinter()
let modelLoader = GeneratorModelLoader(manifestLoader: manifestLoader,
manifestLinter: manifestLinter,
manifestTargetGenerator: manifestTargetGenerator)
let modelLoader = GeneratorModelLoader(manifestLoader: manifestLoader, manifestLinter: manifestLinter)
self.init(modelLoader: modelLoader)
}
}
22 changes: 5 additions & 17 deletions Sources/TuistKit/Generator/GeneratorModelLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@ enum GeneratorModelLoaderError: Error, Equatable, FatalError {

class GeneratorModelLoader: GeneratorModelLoading {
private let manifestLoader: GraphManifestLoading
private let manifestTargetGenerator: ManifestTargetGenerating?
private let manifestLinter: ManifestLinting

init(manifestLoader: GraphManifestLoading,
manifestLinter: ManifestLinting,
manifestTargetGenerator: ManifestTargetGenerating? = nil) {
manifestLinter: ManifestLinting) {
self.manifestLoader = manifestLoader
self.manifestLinter = manifestLinter
self.manifestTargetGenerator = manifestTargetGenerator
}

/// Load a Project model at the specified path
Expand Down Expand Up @@ -79,13 +76,6 @@ class GeneratorModelLoader: GeneratorModelLoading {
with config: TuistCore.TuistConfig) throws -> TuistCore.Project {
var enrichedModel = model

// Manifest target
if let manifestTargetGenerator = manifestTargetGenerator, config.generationOptions.contains(.generateManifest) {
let manifestTarget = try manifestTargetGenerator.generateManifestTarget(for: enrichedModel.name,
at: enrichedModel.path)
enrichedModel = enrichedModel.adding(target: manifestTarget)
}

// Xcode project file name
let xcodeFileName = xcodeFileNameOverride(from: config, for: model)
enrichedModel = enrichedModel.replacing(fileName: xcodeFileName)
Expand Down Expand Up @@ -127,8 +117,6 @@ extension TuistCore.TuistConfig.GenerationOption {
static func from(manifest: ProjectDescription.TuistConfig.GenerationOptions,
path _: AbsolutePath) throws -> TuistCore.TuistConfig.GenerationOption {
switch manifest {
case .generateManifest:
return .generateManifest
case let .xcodeProjectName(templateString):
return .xcodeProjectName(templateString.description)
}
Expand Down Expand Up @@ -647,10 +635,10 @@ extension TuistCore.ArchiveAction {
let postActions = manifest.postActions.map { TuistCore.ExecutionAction.from(manifest: $0) }

return TuistCore.ArchiveAction(configurationName: configurationName,
revealArchiveInOrganizer: revealArchiveInOrganizer,
customArchiveName: customArchiveName,
preActions: preActions,
postActions: postActions)
revealArchiveInOrganizer: revealArchiveInOrganizer,
customArchiveName: customArchiveName,
preActions: preActions,
postActions: postActions)
}
}

Expand Down
49 changes: 0 additions & 49 deletions Sources/TuistKit/Generator/ManifestTargetGenerator.swift

This file was deleted.

12 changes: 6 additions & 6 deletions Sources/TuistSupport/Utils/SHA256Digest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by Maksym Prokopchuk on 23.11.19.
//

import Foundation
import CommonCrypto
import Foundation

// https://inneka.com/programming/swift/sha256-in-swift/

Expand Down Expand Up @@ -48,23 +48,23 @@ final class SHA256Digest {
while true {
let bytesRead = inputStream.read(buffer, maxLength: bufferSize)
if bytesRead < 0 {
//Stream error occured
// Stream error occured
throw (inputStream.streamError ?? InputStreamError.readFailed)
} else if bytesRead == 0 {
//EOF
// EOF
break
}
self.update(bytes: buffer, length: bytesRead)
update(bytes: buffer, length: bytesRead)
}
}

private func update(bytes: UnsafeRawPointer?, length: Int) {
_ = CC_SHA256_Update(&self.context, bytes, CC_LONG(length))
_ = CC_SHA256_Update(&context, bytes, CC_LONG(length))
}

private func finalize() -> Data {
var resultBuffer = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
CC_SHA256_Final(&resultBuffer, &self.context)
CC_SHA256_Final(&resultBuffer, &context)
return Data(resultBuffer)
}
}
3 changes: 1 addition & 2 deletions Tests/ProjectDescriptionTests/TuistConfigTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import XCTest
final class TuistConfigTests: XCTestCase {
func test_tuistconfig_toJSON() throws {
let tuistConfig = TuistConfig(generationOptions:
[.generateManifest,
.xcodeProjectName("someprefix-\(.projectName)")])
[.xcodeProjectName("someprefix-\(.projectName)")])

XCTAssertCodable(tuistConfig)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class GraphManifestLoaderTests: TuistTestCase {
let temporaryPath = try self.temporaryPath()
let content = """
import ProjectDescription
let config = TuistConfig(generationOptions: [.generateManifest])
let config = TuistConfig(generationOptions: [])
"""

let manifestPath = temporaryPath.appending(component: Manifest.tuistConfig.fileName)
Expand All @@ -33,10 +33,7 @@ final class GraphManifestLoaderTests: TuistTestCase {
encoding: .utf8)

// When
let got = try subject.loadTuistConfig(at: temporaryPath)

// Then
XCTAssertTrue(got.generationOptions.contains(.generateManifest))
_ = try subject.loadTuistConfig(at: temporaryPath)
}

func test_loadProject() throws {
Expand Down
16 changes: 4 additions & 12 deletions Tests/TuistKitTests/Generator/GeneratorModelLoaderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@ class GeneratorModelLoaderTest: TuistUnitTestCase {
typealias RunActionManifest = ProjectDescription.RunAction
typealias ArgumentsManifest = ProjectDescription.Arguments

private var manifestTargetGenerator: MockManifestTargetGenerator!
private var manifestLinter: MockManifestLinter!

override func setUp() {
super.setUp()
manifestTargetGenerator = MockManifestTargetGenerator()
manifestLinter = MockManifestLinter()
}

override func tearDown() {
manifestTargetGenerator = nil
manifestLinter = nil
super.tearDown()
}
Expand All @@ -51,7 +48,6 @@ class GeneratorModelLoaderTest: TuistUnitTestCase {

// Then
XCTAssertEqual(model.name, "SomeProject")
XCTAssertEqual(model.targets.map { $0.name }, ["SomeProject-Manifest"])
}

func test_loadProject_withTargets() throws {
Expand All @@ -75,10 +71,9 @@ class GeneratorModelLoaderTest: TuistUnitTestCase {
let model = try subject.loadProject(at: temporaryPath)

// Then
XCTAssertEqual(model.targets.count, 3)
XCTAssertEqual(model.targets.count, 2)
assert(target: model.targets[0], matches: targetA, at: temporaryPath, generatorPaths: generatorPaths)
assert(target: model.targets[1], matches: targetB, at: temporaryPath, generatorPaths: generatorPaths)
XCTAssertEqual(model.targets[2].name, "Project-Manifest")
}

func test_loadProject_withManifestTargetOptionDisabled() throws {
Expand Down Expand Up @@ -179,8 +174,7 @@ class GeneratorModelLoaderTest: TuistUnitTestCase {
]
let manifestLoader = createManifestLoader(with: manifests, configs: configs)
let subject = GeneratorModelLoader(manifestLoader: manifestLoader,
manifestLinter: manifestLinter,
manifestTargetGenerator: manifestTargetGenerator)
manifestLinter: manifestLinter)

// When
let model = try subject.loadProject(at: temporaryPath)
Expand Down Expand Up @@ -208,8 +202,7 @@ class GeneratorModelLoaderTest: TuistUnitTestCase {
]
let manifestLoader = createManifestLoader(with: manifests, configs: configs)
let subject = GeneratorModelLoader(manifestLoader: manifestLoader,
manifestLinter: manifestLinter,
manifestTargetGenerator: manifestTargetGenerator)
manifestLinter: manifestLinter)

// When
let model = try subject.loadProject(at: temporaryPath)
Expand Down Expand Up @@ -680,8 +673,7 @@ class GeneratorModelLoaderTest: TuistUnitTestCase {

func createGeneratorModelLoader(with manifestLoader: GraphManifestLoading) -> GeneratorModelLoader {
return GeneratorModelLoader(manifestLoader: manifestLoader,
manifestLinter: manifestLinter,
manifestTargetGenerator: manifestTargetGenerator)
manifestLinter: manifestLinter)
}

func createManifestLoader(with projects: [AbsolutePath: ProjectDescription.Project],
Expand Down