Skip to content

Commit

Permalink
Merge pull request RobertGummesson#45 from RobertGummesson/Standalone…
Browse files Browse the repository at this point in the history
…-for-Xcode-8

Standalone for Xcode 8
  • Loading branch information
Robert Gummesson authored Sep 14, 2016
2 parents 2af975e + 75998a3 commit 4074c7c
Show file tree
Hide file tree
Showing 45 changed files with 2,082 additions and 1,467 deletions.
420 changes: 225 additions & 195 deletions BuildTimeAnalyzer.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions BuildTimeAnalyzer/AppDelegate.swift
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 BuildTimeAnalyzer/Assets.xcassets/AppIcon.appiconset/Contents.json
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" : "[email protected]",
"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.
77 changes: 77 additions & 0 deletions BuildTimeAnalyzer/BuildManager.swift
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))
}
}
}
}
30 changes: 0 additions & 30 deletions BuildTimeAnalyzer/CMBuildOperation.swift

This file was deleted.

136 changes: 0 additions & 136 deletions BuildTimeAnalyzer/CMLogProcessor.swift

This file was deleted.

Loading

0 comments on commit 4074c7c

Please sign in to comment.