-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from ikesyo/introduce-packagelocator-protocol
Factor out DescriptionPackage's path-related functions to PackageLocator protocol
- Loading branch information
Showing
7 changed files
with
84 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import TSCBasic | ||
import PackageModel | ||
|
||
/// Holds the packageDirectory Scipio works on, and defines some path-related functionalities. | ||
protocol PackageLocator { | ||
var packageDirectory: ScipioAbsolutePath { get } | ||
} | ||
|
||
extension PackageLocator { | ||
var buildDirectory: ScipioAbsolutePath { | ||
packageDirectory.appending(component: ".build") | ||
} | ||
|
||
var workspaceDirectory: ScipioAbsolutePath { | ||
buildDirectory.appending(component: "scipio") | ||
} | ||
|
||
var derivedDataPath: ScipioAbsolutePath { | ||
workspaceDirectory.appending(component: "DerivedData") | ||
} | ||
|
||
func generatedModuleMapPath(of target: ScipioResolvedModule, sdk: SDK) throws -> ScipioAbsolutePath { | ||
let relativePath = try TSCBasic.RelativePath(validating: "ModuleMapsForFramework/\(sdk.settingValue)") | ||
return workspaceDirectory | ||
.appending(relativePath) | ||
.appending(component: target.modulemapName) | ||
} | ||
|
||
/// Returns an Products directory path | ||
/// It should be the default setting of `TARGET_BUILD_DIR` | ||
func productsDirectory(buildConfiguration: BuildConfiguration, sdk: SDK) -> ScipioAbsolutePath { | ||
let intermediateDirectoryName = productDirectoryName( | ||
buildConfiguration: buildConfiguration, | ||
sdk: sdk | ||
) | ||
return derivedDataPath.appending(components: ["Products", intermediateDirectoryName]) | ||
} | ||
|
||
/// Returns a directory path which contains assembled frameworks | ||
var assembledFrameworksRootDirectory: ScipioAbsolutePath { | ||
workspaceDirectory.appending(component: "AssembledFrameworks") | ||
} | ||
|
||
/// Returns a directory path of the assembled frameworks path for the specific Configuration/Platform | ||
func assembledFrameworksDirectory(buildConfiguration: BuildConfiguration, sdk: SDK) -> ScipioAbsolutePath { | ||
let intermediateDirName = productDirectoryName(buildConfiguration: buildConfiguration, sdk: sdk) | ||
return assembledFrameworksRootDirectory | ||
.appending(component: intermediateDirName) | ||
} | ||
|
||
/// Returns an intermediate directory name in the Products dir. | ||
/// e.g. `Debug` / `Debug-iphoneos` | ||
private func productDirectoryName(buildConfiguration: BuildConfiguration, sdk: SDK) -> String { | ||
if sdk == .macOS { | ||
return buildConfiguration.settingsValue | ||
} else { | ||
return "\(buildConfiguration.settingsValue)-\(sdk.settingValue)" | ||
} | ||
} | ||
} |
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