Fix build for Linux (#2257)
* Fix build for Linux. * Fix Linux runtime issues. * PR review + fix for Windows.
This commit is contained in:
@@ -28,6 +28,7 @@ internal class BatteryGroup : IGroup
|
||||
if (Software.OperatingSystem.IsUnix)
|
||||
return;
|
||||
|
||||
#if WINDOWS
|
||||
SetupDiDestroyDeviceInfoListSafeHandle hdev = PInvoke.SetupDiGetClassDevs(PInvoke.GUID_DEVICE_BATTERY,
|
||||
null,
|
||||
HWND.Null,
|
||||
@@ -129,11 +130,13 @@ internal class BatteryGroup : IGroup
|
||||
|
||||
hdev.Dispose();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<IHardware> Hardware => _hardware;
|
||||
|
||||
#if WINDOWS
|
||||
private static unsafe bool QueryStringFromBatteryInfo(SafeFileHandle battery, BATTERY_QUERY_INFORMATION bqi, out string value)
|
||||
{
|
||||
value = null;
|
||||
@@ -161,6 +164,7 @@ internal class BatteryGroup : IGroup
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Close()
|
||||
|
||||
@@ -512,7 +512,9 @@ public class Computer : IComputer
|
||||
|
||||
_smbios = new SMBios();
|
||||
|
||||
Mutexes.Open();
|
||||
if (Software.OperatingSystem.IsWindows8OrGreater)
|
||||
Mutexes.Open();
|
||||
|
||||
OpCode.Open();
|
||||
|
||||
AddGroups();
|
||||
|
||||
@@ -38,6 +38,9 @@ internal sealed class IntelCpu : GenericCpu
|
||||
|
||||
public IntelCpu(int processorIndex, CpuId[][] cpuId, ISettings settings) : base(processorIndex, cpuId, settings)
|
||||
{
|
||||
if (Software.OperatingSystem.IsUnix)
|
||||
return;
|
||||
|
||||
_pawnModule = new IntelMsr();
|
||||
|
||||
uint eax;
|
||||
@@ -569,7 +572,7 @@ internal sealed class IntelCpu : GenericCpu
|
||||
float coreAvg = 0;
|
||||
uint eax;
|
||||
|
||||
for (int i = 0; i < _coreTemperatures.Length; i++)
|
||||
for (int i = 0; i < _coreTemperatures?.Length; i++)
|
||||
{
|
||||
// if reading is valid
|
||||
if (_pawnModule.ReadMsr(IA32_THERM_STATUS_MSR, out eax, out _, _cpuId[i][0].Affinity) && (eax & 0x80000000) != 0)
|
||||
@@ -704,7 +707,7 @@ internal sealed class IntelCpu : GenericCpu
|
||||
_coreVoltage.Value = ((edx >> 32) & 0xFFFF) / (float)(1 << 13);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _coreVIDs.Length; i++)
|
||||
for (int i = 0; i < _coreVIDs?.Length; i++)
|
||||
{
|
||||
if (_pawnModule.ReadMsr(IA32_PERF_STATUS, out _, out edx, _cpuId[i][0].Affinity) && ((edx >> 32) & 0xFFFF) > 0)
|
||||
{
|
||||
|
||||
@@ -51,6 +51,7 @@ public static class Stm32PortFinder
|
||||
{
|
||||
var result = new List<string>();
|
||||
|
||||
#if WINDOWS
|
||||
//Setup
|
||||
SetupDiDestroyDeviceInfoListSafeHandle devInfo = PInvoke.SetupDiGetClassDevs(PInvoke.GUID_DEVCLASS_PORTS, null, HWND.Null, SETUP_DI_GET_CLASS_DEVS_FLAGS.DIGCF_PRESENT);
|
||||
|
||||
@@ -102,8 +103,6 @@ public static class Stm32PortFinder
|
||||
devInfo.Dispose();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
static string GetProperty(SafeHandle hDevInfo, SETUP_DI_REGISTRY_PROPERTY property, SP_DEVINFO_DATA devInfoData)
|
||||
{
|
||||
byte[] buffer = new byte[BufferSize];
|
||||
@@ -116,6 +115,9 @@ public static class Stm32PortFinder
|
||||
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string NormalizeString(string str)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net472;netstandard2.0;net8.0;net9.0;net10.0</TargetFrameworks>
|
||||
<Platforms>x64;x86;ARM64</Platforms>
|
||||
<RuntimeIdentifiers>win-x64;win-x86;win-arm64</RuntimeIdentifiers>
|
||||
<RuntimeIdentifiers>win-x64;win-x86;win-arm64;linux-x64;linux-arm64</RuntimeIdentifiers>
|
||||
<AssemblyName>LibreHardwareMonitorLib</AssemblyName>
|
||||
<RootNamespace>LibreHardwareMonitor</RootNamespace>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
@@ -38,6 +38,14 @@
|
||||
<OutputPath>..\bin\Release\$(Platform)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(OS)' == 'Windows_NT'">
|
||||
<DefineConstants>$(DefineConstants);WINDOWS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
|
||||
<DefineConstants>$(DefineConstants);LINUX</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\PawnIo\AMDFamily0F.bin" />
|
||||
<EmbeddedResource Include="Resources\PawnIo\AMDFamily10.bin" />
|
||||
|
||||
Reference in New Issue
Block a user