diff --git a/Modules/GPU/Info.plist b/Modules/GPU/Info.plist new file mode 100644 index 00000000..20202aa7 --- /dev/null +++ b/Modules/GPU/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSHumanReadableCopyright + Copyright © 2020 Serhiy Mytrovtsiy. All rights reserved. + + diff --git a/Modules/GPU/config.plist b/Modules/GPU/config.plist new file mode 100644 index 00000000..43302fd6 --- /dev/null +++ b/Modules/GPU/config.plist @@ -0,0 +1,10 @@ + + + + + Name + GPU + State + + + diff --git a/Modules/GPU/main.swift b/Modules/GPU/main.swift new file mode 100644 index 00000000..c6ab28a2 --- /dev/null +++ b/Modules/GPU/main.swift @@ -0,0 +1,45 @@ +// +// main.swift +// GPU +// +// Created by Serhiy Mytrovtsiy on 17/08/2020. +// Using Swift 5.0. +// Running on macOS 10.15. +// +// Copyright © 2020 Serhiy Mytrovtsiy. All rights reserved. +// + +import Cocoa +import ModuleKit +import StatsKit + +public struct GPU_Load {} + +public class GPU: Module { + private let smc: UnsafePointer? + private let store: UnsafePointer + + private var loadReader: LoadReader? = nil + + public init(_ store: UnsafePointer, _ smc: UnsafePointer) { + self.store = store + self.smc = smc + + super.init( + store: store, + popup: nil, + settings: nil + ) + guard self.available else { return } + + self.loadReader = LoadReader() + + self.loadReader?.readyCallback = { [unowned self] in + self.readyHandler() + } + + if let reader = self.loadReader { + self.addReader(reader) + } + } +} diff --git a/Modules/GPU/reader.swift b/Modules/GPU/reader.swift new file mode 100644 index 00000000..879b7966 --- /dev/null +++ b/Modules/GPU/reader.swift @@ -0,0 +1,21 @@ +// +// reader.swift +// GPU +// +// Created by Serhiy Mytrovtsiy on 17/08/2020. +// Using Swift 5.0. +// Running on macOS 10.15. +// +// Copyright © 2020 Serhiy Mytrovtsiy. All rights reserved. +// + +import Cocoa +import StatsKit +import ModuleKit +import os.log + +internal class LoadReader: Reader { + public override func read() { + + } +} diff --git a/Stats.xcodeproj/project.pbxproj b/Stats.xcodeproj/project.pbxproj index 78961cae..5b1473d3 100644 --- a/Stats.xcodeproj/project.pbxproj +++ b/Stats.xcodeproj/project.pbxproj @@ -57,6 +57,15 @@ 9A81C76B2449AE9400825D92 /* StatsKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A0C82DA24460F7200FAE3D4 /* StatsKit.framework */; }; 9A81C76C2449AE9400825D92 /* StatsKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9A0C82DA24460F7200FAE3D4 /* StatsKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 9A81C7702449B8D500825D92 /* Charts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A81C76F2449B8D500825D92 /* Charts.swift */; }; + 9A90E19024EAD2BB00471E9A /* GPU.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A90E18924EAD2BB00471E9A /* GPU.framework */; }; + 9A90E19124EAD2BB00471E9A /* GPU.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9A90E18924EAD2BB00471E9A /* GPU.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9A90E19624EAD35F00471E9A /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A90E19524EAD35F00471E9A /* main.swift */; }; + 9A90E19824EAD3B000471E9A /* config.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9A90E19724EAD3B000471E9A /* config.plist */; }; + 9A90E19924EAD3E300471E9A /* ModuleKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AABEADD243FB13500668CB0 /* ModuleKit.framework */; }; + 9A90E19A24EAD3E300471E9A /* ModuleKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9AABEADD243FB13500668CB0 /* ModuleKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9A90E19D24EAD3E300471E9A /* StatsKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A0C82DA24460F7200FAE3D4 /* StatsKit.framework */; }; + 9A90E19E24EAD3E300471E9A /* StatsKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9A0C82DA24460F7200FAE3D4 /* StatsKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9A90E1A324EAD66600471E9A /* reader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A90E1A224EAD66600471E9A /* reader.swift */; }; 9A944D55244920690058F32A /* reader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A944D54244920690058F32A /* reader.swift */; }; 9A944D59244920FE0058F32A /* readers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A944D58244920FE0058F32A /* readers.swift */; }; 9A944D5B244925720058F32A /* widget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A944D5A244925720058F32A /* widget.swift */; }; @@ -191,6 +200,27 @@ remoteGlobalIDString = 9A0C82D924460F7200FAE3D4; remoteInfo = StatsKit; }; + 9A90E18E24EAD2BB00471E9A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 9A1410ED229E721100D29793 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 9A90E18824EAD2BB00471E9A; + remoteInfo = GPU; + }; + 9A90E19B24EAD3E300471E9A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 9A1410ED229E721100D29793 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 9AABEADC243FB13500668CB0; + remoteInfo = ModuleKit; + }; + 9A90E19F24EAD3E300471E9A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 9A1410ED229E721100D29793 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 9A0C82D924460F7200FAE3D4; + remoteInfo = StatsKit; + }; 9AABEAE2243FB13500668CB0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 9A1410ED229E721100D29793 /* Project object */; @@ -310,6 +340,7 @@ 9AABEAE5243FB13500668CB0 /* ModuleKit.framework in Embed Frameworks */, 9A3E17D4247A94AF00449CD1 /* Net.framework in Embed Frameworks */, 9A0C82E224460F7200FAE3D4 /* StatsKit.framework in Embed Frameworks */, + 9A90E19124EAD2BB00471E9A /* GPU.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -326,6 +357,18 @@ name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; }; + 9A90E1A124EAD3E300471E9A /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 9A90E19A24EAD3E300471E9A /* ModuleKit.framework in Embed Frameworks */, + 9A90E19E24EAD3E300471E9A /* StatsKit.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; 9AABEB76243FCEEF00668CB0 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 12; @@ -437,6 +480,11 @@ 9A81C7672449A43600825D92 /* main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; 9A81C7682449A43600825D92 /* readers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = readers.swift; sourceTree = ""; }; 9A81C76F2449B8D500825D92 /* Charts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Charts.swift; sourceTree = ""; }; + 9A90E18924EAD2BB00471E9A /* GPU.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GPU.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 9A90E18C24EAD2BB00471E9A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 9A90E19524EAD35F00471E9A /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 9A90E19724EAD3B000471E9A /* config.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = config.plist; sourceTree = ""; }; + 9A90E1A224EAD66600471E9A /* reader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = reader.swift; sourceTree = ""; }; 9A944D54244920690058F32A /* reader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = reader.swift; sourceTree = ""; }; 9A944D58244920FE0058F32A /* readers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = readers.swift; sourceTree = ""; }; 9A944D5A244925720058F32A /* widget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = widget.swift; sourceTree = ""; }; @@ -508,6 +556,7 @@ 9A0C82E124460F7200FAE3D4 /* StatsKit.framework in Frameworks */, 9A3E17D3247A94AF00449CD1 /* Net.framework in Frameworks */, 9AABEB6B243FCE8A00668CB0 /* CPU.framework in Frameworks */, + 9A90E19024EAD2BB00471E9A /* GPU.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -537,6 +586,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 9A90E18624EAD2BB00471E9A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9A90E19924EAD3E300471E9A /* ModuleKit.framework in Frameworks */, + 9A90E19D24EAD3E300471E9A /* StatsKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 9AABEADA243FB13500668CB0 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -628,6 +686,7 @@ 9A3E17CC247A94AF00449CD1 /* Net.framework */, 9ABFF8F6248BEBCB00C9041A /* Battery.framework */, 9AE29AD5249A50350071B02D /* Sensors.framework */, + 9A90E18924EAD2BB00471E9A /* GPU.framework */, ); name = Products; sourceTree = ""; @@ -713,6 +772,17 @@ path = Memory; sourceTree = ""; }; + 9A90E18A24EAD2BB00471E9A /* GPU */ = { + isa = PBXGroup; + children = ( + 9A90E19524EAD35F00471E9A /* main.swift */, + 9A90E1A224EAD66600471E9A /* reader.swift */, + 9A90E18C24EAD2BB00471E9A /* Info.plist */, + 9A90E19724EAD3B000471E9A /* config.plist */, + ); + path = GPU; + sourceTree = ""; + }; 9A998CD622A199920087ADE7 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -765,6 +835,7 @@ isa = PBXGroup; children = ( 9AABEB65243FCE8A00668CB0 /* CPU */, + 9A90E18A24EAD2BB00471E9A /* GPU */, 9A81C7572449A41400825D92 /* Memory */, 9AF9EE0324648751005D2270 /* Disk */, 9AE29AD6249A50350071B02D /* Sensors */, @@ -840,6 +911,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 9A90E18424EAD2BB00471E9A /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 9AABEAD8243FB13500668CB0 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -919,6 +997,7 @@ 9A3E17D2247A94AF00449CD1 /* PBXTargetDependency */, 9ABFF8FC248BEBCB00C9041A /* PBXTargetDependency */, 9AE29ADB249A50350071B02D /* PBXTargetDependency */, + 9A90E18F24EAD2BB00471E9A /* PBXTargetDependency */, ); name = Stats; productName = "Mini Stats"; @@ -984,6 +1063,27 @@ productReference = 9A81C7562449A41400825D92 /* Memory.framework */; productType = "com.apple.product-type.framework"; }; + 9A90E18824EAD2BB00471E9A /* GPU */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9A90E19424EAD2BB00471E9A /* Build configuration list for PBXNativeTarget "GPU" */; + buildPhases = ( + 9A90E18424EAD2BB00471E9A /* Headers */, + 9A90E18524EAD2BB00471E9A /* Sources */, + 9A90E18624EAD2BB00471E9A /* Frameworks */, + 9A90E18724EAD2BB00471E9A /* Resources */, + 9A90E1A124EAD3E300471E9A /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 9A90E19C24EAD3E300471E9A /* PBXTargetDependency */, + 9A90E1A024EAD3E300471E9A /* PBXTargetDependency */, + ); + name = GPU; + productName = GPU; + productReference = 9A90E18924EAD2BB00471E9A /* GPU.framework */; + productType = "com.apple.product-type.framework"; + }; 9AABEADC243FB13500668CB0 /* ModuleKit */ = { isa = PBXNativeTarget; buildConfigurationList = 9AABEAE8243FB13500668CB0 /* Build configuration list for PBXNativeTarget "ModuleKit" */; @@ -1128,6 +1228,10 @@ CreatedOnToolsVersion = 11.4.1; LastSwiftMigration = 1140; }; + 9A90E18824EAD2BB00471E9A = { + CreatedOnToolsVersion = 11.6; + LastSwiftMigration = 1160; + }; 9AABEADC243FB13500668CB0 = { CreatedOnToolsVersion = 11.4; LastSwiftMigration = 1140; @@ -1172,6 +1276,7 @@ 9A3E17CB247A94AF00449CD1 /* Net */, 9ABFF8F5248BEBCB00C9041A /* Battery */, 9AE29AD4249A50350071B02D /* Sensors */, + 9A90E18824EAD2BB00471E9A /* GPU */, ); }; /* End PBXProject section */ @@ -1216,6 +1321,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 9A90E18724EAD2BB00471E9A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9A90E19824EAD3B000471E9A /* config.plist in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 9AABEADB243FB13500668CB0 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -1316,6 +1429,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 9A90E18524EAD2BB00471E9A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9A90E1A324EAD66600471E9A /* reader.swift in Sources */, + 9A90E19624EAD35F00471E9A /* main.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 9AABEAD9243FB13500668CB0 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -1434,6 +1556,21 @@ target = 9A0C82D924460F7200FAE3D4 /* StatsKit */; targetProxy = 9A81C76D2449AE9400825D92 /* PBXContainerItemProxy */; }; + 9A90E18F24EAD2BB00471E9A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 9A90E18824EAD2BB00471E9A /* GPU */; + targetProxy = 9A90E18E24EAD2BB00471E9A /* PBXContainerItemProxy */; + }; + 9A90E19C24EAD3E300471E9A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 9AABEADC243FB13500668CB0 /* ModuleKit */; + targetProxy = 9A90E19B24EAD3E300471E9A /* PBXContainerItemProxy */; + }; + 9A90E1A024EAD3E300471E9A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 9A0C82D924460F7200FAE3D4 /* StatsKit */; + targetProxy = 9A90E19F24EAD3E300471E9A /* PBXContainerItemProxy */; + }; 9AABEAE3243FB13500668CB0 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 9AABEADC243FB13500668CB0 /* ModuleKit */; @@ -1928,6 +2065,69 @@ }; name = Release; }; + 9A90E19224EAD2BB00471E9A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = RP2S87B72W; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = Modules/GPU/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = eu.exelban.Stats.GPU; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 9A90E19324EAD2BB00471E9A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = RP2S87B72W; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = Modules/GPU/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = eu.exelban.Stats.GPU; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; 9AABEAE6243FB13500668CB0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -2315,6 +2515,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 9A90E19424EAD2BB00471E9A /* Build configuration list for PBXNativeTarget "GPU" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9A90E19224EAD2BB00471E9A /* Debug */, + 9A90E19324EAD2BB00471E9A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 9AABEAE8243FB13500668CB0 /* Build configuration list for PBXNativeTarget "ModuleKit" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Stats/AppDelegate.swift b/Stats/AppDelegate.swift index ae81a7f7..57044f1e 100755 --- a/Stats/AppDelegate.swift +++ b/Stats/AppDelegate.swift @@ -16,12 +16,13 @@ import Disk import Net import Battery import Sensors +import GPU var store: Store = Store() let updater = macAppUpdater(user: "exelban", repo: "stats") let systemKit: SystemKit = SystemKit() var smc: SMCService = SMCService() -var modules: [Module] = [Battery(&store), Network(&store), Sensors(&store, &smc), Disk(&store), Memory(&store), CPU(&store, &smc)].reversed() +var modules: [Module] = [Battery(&store), Network(&store), Sensors(&store, &smc), Disk(&store), Memory(&store), GPU(&store, &smc), CPU(&store, &smc)].reversed() var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "Stats") class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDelegate {