-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor ManifestResources into simpler ToolchainConfiguration
motivation: improve code readability, prep work for further api refactoring for configuration changes: * remove ManifestResources abstraction and impl into plain struct named ToolchainConfiguration * udpate test module to define defaults for ToolchainConfiguration and UserToolchain to simplify and clean code * update call-sites, tests
- Loading branch information
Showing
30 changed files
with
211 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
|
||
Copyright (c) 2021 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 Foundation | ||
import PackageModel | ||
import Workspace | ||
import TSCBasic | ||
|
||
#if os(macOS) | ||
private func bundleRoot() -> AbsolutePath { | ||
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") { | ||
return AbsolutePath(bundle.bundlePath).parentDirectory | ||
} | ||
fatalError() | ||
} | ||
#endif | ||
|
||
private func binDir() -> AbsolutePath { | ||
#if os(macOS) | ||
return bundleRoot() | ||
#else | ||
return AbsolutePath(CommandLine.arguments[0], relativeTo: localFileSystem.currentWorkingDirectory!).parentDirectory | ||
#endif | ||
} | ||
|
||
extension ToolchainConfiguration { | ||
public static var `default`: Self { | ||
get { | ||
let toolchain = UserToolchain.default | ||
return .init( | ||
swiftCompiler: toolchain.configuration.swiftCompiler, | ||
swiftCompilerFlags: [], | ||
libDir: toolchain.configuration.libDir, | ||
binDir: toolchain.configuration.binDir | ||
) | ||
} | ||
} | ||
|
||
#if os(macOS) | ||
public var sdkPlatformFrameworksPath: AbsolutePath { | ||
return Destination.sdkPlatformFrameworkPaths()!.fwk | ||
} | ||
#endif | ||
|
||
} | ||
|
||
extension UserToolchain { | ||
public static var `default`: Self { | ||
get { | ||
let binDir = binDir() | ||
return try! .init(destination: Destination.hostDestination(binDir)) | ||
} | ||
} | ||
} |
Oops, something went wrong.