Skip to content

Commit 9c129eb

Browse files
authored
Use outputDir for build logs. (#2992)
* Use outputDir for build logs. Use the already existing outputDir specified by the command line parameters as the output directory for build logs (for frameworks that are compiled). * Make logsOutputDir name consistent.
1 parent 7ae2af4 commit 9c129eb

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

ZipBuilder/Sources/ZipBuilder/FrameworkBuilder.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ struct FrameworkBuilder {
7575
/// - cacheKey: The key used for caching this framework build. If nil, the framework name will
7676
/// be used.
7777
/// - cacheEnabled: Flag for enabling the cache. Defaults to false.
78+
/// - Parameter logsOutputDir: The path to the directory to place build logs.
7879
/// - Returns: A URL to the framework that was built (or pulled from the cache).
7980
public func buildFramework(withName podName: String,
8081
version: String,
8182
cacheKey: String?,
82-
cacheEnabled: Bool = false) -> URL {
83+
cacheEnabled: Bool = false,
84+
logsOutputDir: URL? = nil) -> URL {
8385
print("Building \(podName)")
8486

8587
// Cache is temporarily disabled due to pod cache list issues.
@@ -332,11 +334,13 @@ struct FrameworkBuilder {
332334
/// This will compile all architectures and use the lipo command to create a "fat" archive.
333335
///
334336
/// - Parameter framework: The name of the framework to be built.
337+
/// - Parameter logsOutputDir: The path to the directory to place build logs.
335338
/// - Returns: A path to the newly compiled framework (with any included Resources embedded).
336-
private func compileFrameworkAndResources(withName framework: String) -> URL {
339+
private func compileFrameworkAndResources(withName framework: String,
340+
logsOutputDir: URL? = nil) -> URL {
337341
let fileManager = FileManager.default
338-
let outputDir = fileManager.temporaryDirectory(withName: "frameworkBeingBuilt")
339-
let logsDir = fileManager.temporaryDirectory(withName: "buildLogs")
342+
let outputDir = fileManager.temporaryDirectory(withName: "frameworks_being_built")
343+
let logsDir = logsOutputDir ?? fileManager.temporaryDirectory(withName: "build_logs")
340344
do {
341345
// Remove the compiled frameworks directory, this isn't the cache we're using.
342346
if fileManager.directoryExists(at: outputDir) {

ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ struct ZipBuilder {
8282
/// expected version numbers.
8383
var currentReleasePath: URL?
8484

85+
/// The path to a directory to move all build logs to. If nil, a temporary directory will be
86+
/// used.
87+
var logsOutputDir: URL?
88+
8589
/// Default initializer with all required paths.
8690
init(templateDir: URL, coreDiagnosticsDir: URL) {
8791
self.templateDir = templateDir
@@ -704,7 +708,8 @@ struct ZipBuilder {
704708
let framework = builder.buildFramework(withName: pod.name,
705709
version: pod.version,
706710
cacheKey: pod.cacheKey,
707-
cacheEnabled: useCache)
711+
cacheEnabled: useCache,
712+
logsOutputDir: paths.logsOutputDir)
708713

709714
frameworks = [framework]
710715
} else {

ZipBuilder/Sources/ZipBuilder/main.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var paths = ZipBuilder.FilesystemPaths(templateDir: args.templateDir,
4343
coreDiagnosticsDir: args.coreDiagnosticsDir)
4444
paths.allSDKsPath = args.allSDKsPath
4545
paths.currentReleasePath = args.currentReleasePath
46+
paths.logsOutputDir = args.outputDir?.appendingPathComponent("build_logs")
4647
let builder = ZipBuilder(paths: paths,
4748
customSpecRepos: args.customSpecRepos,
4849
useCache: args.cacheEnabled)

0 commit comments

Comments
 (0)