-
Notifications
You must be signed in to change notification settings - Fork 261
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 #45 from RobertGummesson/Standalone-for-Xcode-8
Standalone for Xcode 8
- Loading branch information
Showing
45 changed files
with
2,082 additions
and
1,467 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
BuildTimeAnalyzer.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,58 @@ | ||
// | ||
// AppDelegate.swift | ||
// BuildTimeAnalyzer | ||
// | ||
|
||
import Cocoa | ||
|
||
@NSApplicationMain | ||
class AppDelegate: NSObject, NSApplicationDelegate { | ||
|
||
@IBOutlet weak var projectSelectionMenuItem: NSMenuItem! | ||
@IBOutlet weak var buildTimesMenuItem: NSMenuItem! | ||
@IBOutlet weak var alwaysInFrontMenuItem: NSMenuItem! | ||
|
||
func applicationDidFinishLaunching(_ notification: Notification) { | ||
alwaysInFrontMenuItem.state = UserSettings.windowShouldBeTopMost ? NSOnState : NSOffState | ||
} | ||
|
||
var viewController: ViewController? { | ||
return NSApplication.shared().mainWindow?.contentViewController as? ViewController | ||
} | ||
|
||
func configureMenuItems(showBuildTimesMenuItem: Bool) { | ||
projectSelectionMenuItem.isEnabled = !showBuildTimesMenuItem | ||
buildTimesMenuItem.isEnabled = showBuildTimesMenuItem | ||
} | ||
|
||
// MARK: Actions | ||
|
||
@IBAction func navigateToProjectSelection(_ sender: NSMenuItem) { | ||
configureMenuItems(showBuildTimesMenuItem: true) | ||
|
||
viewController?.cancelProcessing() | ||
viewController?.showInstructions(true) | ||
} | ||
|
||
@IBAction func navigateToBuildTimes(_ sender: NSMenuItem) { | ||
configureMenuItems(showBuildTimesMenuItem: false) | ||
viewController?.showInstructions(false) | ||
} | ||
|
||
@IBAction func visitGitHubPage(_ sender: AnyObject) { | ||
let path = "https://github.com/RobertGummesson/BuildTimeAnalyzer-for-Xcode" | ||
if let url = URL(string: path) { | ||
NSWorkspace.shared().open(url) | ||
} | ||
} | ||
|
||
@IBAction func toggleAlwaysInFront(_ sender: NSMenuItem) { | ||
let alwaysInFront = sender.state == NSOffState | ||
|
||
sender.state = alwaysInFront ? NSOnState : NSOffState | ||
UserSettings.windowShouldBeTopMost = alwaysInFront | ||
|
||
viewController?.makeWindowTopMost(topMost: alwaysInFront) | ||
} | ||
} | ||
|
68 changes: 68 additions & 0 deletions
68
BuildTimeAnalyzer/Assets.xcassets/AppIcon.appiconset/Contents.json
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,68 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"size" : "16x16", | ||
"idiom" : "mac", | ||
"filename" : "logo16.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"size" : "16x16", | ||
"idiom" : "mac", | ||
"filename" : "logo32-1.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"size" : "32x32", | ||
"idiom" : "mac", | ||
"filename" : "logo32.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"size" : "32x32", | ||
"idiom" : "mac", | ||
"filename" : "logo64.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"size" : "128x128", | ||
"idiom" : "mac", | ||
"filename" : "logo128.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"size" : "128x128", | ||
"idiom" : "mac", | ||
"filename" : "logo256-1.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"size" : "256x256", | ||
"idiom" : "mac", | ||
"filename" : "logo256.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"size" : "256x256", | ||
"idiom" : "mac", | ||
"filename" : "logo512-1.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"size" : "512x512", | ||
"idiom" : "mac", | ||
"filename" : "logo512.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"size" : "512x512", | ||
"idiom" : "mac", | ||
"filename" : "logo512@2x.png", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes
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,77 @@ | ||
// | ||
// BuildManager.swift | ||
// BuildTimeAnalyzer | ||
// | ||
|
||
import Cocoa | ||
|
||
protocol BuildManagerDelegate: class { | ||
func derivedDataDidChange() | ||
func buildManager(_ buildManager: BuildManager, shouldParseLogWithDatabase database: XcodeDatabase) | ||
} | ||
|
||
class BuildManager: NSObject { | ||
|
||
weak var delegate: BuildManagerDelegate? | ||
|
||
private let derivedDataDirectoryMonitor = DirectoryMonitor(isDerivedData: true) | ||
private let logFolderDirectoryMonitor = DirectoryMonitor(isDerivedData: false) | ||
|
||
private var currentDataBase: XcodeDatabase? | ||
|
||
override func awakeFromNib() { | ||
super.awakeFromNib() | ||
|
||
derivedDataDirectoryMonitor.delegate = self | ||
logFolderDirectoryMonitor.delegate = self | ||
|
||
startMonitoring() | ||
} | ||
|
||
func startMonitoring() { | ||
stopMonitoring() | ||
derivedDataDirectoryMonitor.startMonitoring(path: UserSettings.derivedDataLocation) | ||
} | ||
|
||
func stopMonitoring() { | ||
derivedDataDirectoryMonitor.stopMonitoring() | ||
} | ||
|
||
func database(forFolder URL: URL) -> XcodeDatabase? { | ||
let databaseURL = URL.appendingPathComponent("Cache.db") | ||
return XcodeDatabase(fromPath: databaseURL.path) | ||
} | ||
|
||
func processDerivedData() { | ||
guard let mostRecent = DerivedDataManager.derivedData().first else { return } | ||
|
||
let logFolder = mostRecent.url.appendingPathComponent("Logs/Build").path | ||
guard logFolderDirectoryMonitor.path != logFolder else { return } | ||
|
||
logFolderDirectoryMonitor.stopMonitoring() | ||
logFolderDirectoryMonitor.startMonitoring(path: logFolder) | ||
} | ||
|
||
func processLogFolder(with url: URL) { | ||
guard let activeDatabase = database(forFolder: url), | ||
activeDatabase.isBuildType, | ||
activeDatabase != currentDataBase else { return } | ||
|
||
currentDataBase = activeDatabase | ||
delegate?.buildManager(self, shouldParseLogWithDatabase: activeDatabase) | ||
} | ||
} | ||
|
||
extension BuildManager: DirectoryMonitorDelegate { | ||
func directoryMonitorDidObserveChange(_ directoryMonitor: DirectoryMonitor, isDerivedData: Bool) { | ||
if isDerivedData { | ||
delegate?.derivedDataDidChange() | ||
processDerivedData() | ||
} else if let path = directoryMonitor.path { | ||
// TODO: If we don't dispatch, it seems it fires off too soon | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { | ||
self.processLogFolder(with: URL(fileURLWithPath: path)) | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.