Add a version display based on the git tag.
This commit is contained in:
parent
3d6eb112e6
commit
e57fa5d28e
@ -100,6 +100,10 @@ extern "C" SMX_API void SMX_ForceRecalibration(int pad);
|
||||
extern "C" SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode);
|
||||
extern "C" SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data);
|
||||
|
||||
// Return the build version of the DLL, which is based on the git tag at build time. This
|
||||
// is only intended for diagnostic logging, and it's also the version we show in SMXConfig.
|
||||
extern "C" SMX_API const char *SMX_Version();
|
||||
|
||||
// General info about a connected controller. This can be retrieved with SMX_GetInfo.
|
||||
struct SMXInfo
|
||||
{
|
||||
|
3
sdk/Windows/.gitignore
vendored
Normal file
3
sdk/Windows/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Ignore updates to the auto-generated build version.
|
||||
SMXBuildVersion.h
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "../SMX.h"
|
||||
#include "SMXManager.h"
|
||||
#include "SMXDevice.h"
|
||||
#include "SMXBuildVersion.h"
|
||||
using namespace std;
|
||||
using namespace SMX;
|
||||
|
||||
@ -63,3 +64,4 @@ SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode) { g_pSMX->GetDevice(p
|
||||
SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data) { return g_pSMX->GetDevice(pad)->GetTestData(*data); }
|
||||
SMX_API void SMX_SetLights(const char lightsData[864]) { g_pSMX->SetLights(string(lightsData, 864)); }
|
||||
SMX_API void SMX_ReenableAutoLights() { g_pSMX->ReenableAutoLights(); }
|
||||
SMX_API const char *SMX_Version() { return SMX_BUILD_VERSION; }
|
||||
|
@ -13,6 +13,7 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\SMX.h" />
|
||||
<ClInclude Include="Helpers.h" />
|
||||
<ClInclude Include="SMXBuildVersion.h" />
|
||||
<ClInclude Include="SMXDevice.h" />
|
||||
<ClInclude Include="SMXDeviceConnection.h" />
|
||||
<ClInclude Include="SMXDeviceSearch.h" />
|
||||
@ -90,6 +91,10 @@
|
||||
<AdditionalDependencies>hid.lib;setupapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(SolutionDir)/out/$(TargetName)$(TargetExt)</OutputFile>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>$(SolutionDir)sdk\Windows\update-build-version.bat
|
||||
</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
@ -125,6 +130,10 @@
|
||||
<Inputs>
|
||||
</Inputs>
|
||||
</CustomBuildStep>
|
||||
<PreBuildEvent>
|
||||
<Command>$(SolutionDir)sdk\Windows\update-build-version.bat
|
||||
</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
@ -31,6 +31,9 @@
|
||||
<ClInclude Include="Helpers.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SMXBuildVersion.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="SMX.cpp">
|
||||
|
43
sdk/Windows/update-build-version.bat
Normal file
43
sdk/Windows/update-build-version.bat
Normal file
@ -0,0 +1,43 @@
|
||||
@echo off
|
||||
setlocal ENABLEDELAYEDEXPANSION
|
||||
|
||||
rem A good old 80s batch file, because it's guaranteed to always be available.
|
||||
rem This assumes git is in the path.
|
||||
|
||||
for /F %%I in ('git describe --always --dirty') do set GITVER=%%I
|
||||
if "%GITVER%" == "" goto git_error
|
||||
|
||||
rem Replace -dirty with -devel, to indicate builds with uncommitted changes.
|
||||
set GITVER=%GITVER:-dirty=-devel%
|
||||
|
||||
goto continue
|
||||
|
||||
:git_error
|
||||
rem If calling git fails for some reason, put a message in the version instead of
|
||||
rem letting it be blank.
|
||||
set GITVER=git failed
|
||||
|
||||
:continue
|
||||
|
||||
rem Output the current version to a temp file.
|
||||
set TEMP_FILE=%TEMP%\temp-SMXBuildVersion.h
|
||||
set OUTPUT_FILE=SMXBuildVersion.h
|
||||
|
||||
echo // This file is auto-generated by update-build-version.bat. > %TEMP_FILE%
|
||||
echo. >> %TEMP_FILE%
|
||||
echo #ifndef SMXBuildVersion_h >> %TEMP_FILE%
|
||||
echo #define SMXBuildVersion_h >> %TEMP_FILE%
|
||||
echo. >> %TEMP_FILE%
|
||||
echo #define SMX_BUILD_VERSION "%GITVER%" >> %TEMP_FILE%
|
||||
echo. >> %TEMP_FILE%
|
||||
echo #endif >> %TEMP_FILE%
|
||||
|
||||
rem Compare the temp file to any existing file. Only copy the new file over the old
|
||||
rem one if it's different, so we don't trigger dependency rebuilds every time.
|
||||
fc %TEMP_FILE% %OUTPUT_FILE% > nul
|
||||
if %errorlevel% == 0 goto end
|
||||
|
||||
echo Updated to version %GITVER%
|
||||
copy %TEMP_FILE% %OUTPUT_FILE% > nul
|
||||
|
||||
:end
|
@ -636,8 +636,11 @@ Use if the platform is too sensitive.</clr:String>
|
||||
<Grid x:Name="Searching" Visibility="Hidden" Background="#DDD">
|
||||
<Label Content="Searching for controller..."
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="33.333"/>
|
||||
<Label x:Name="Version1" Content="Version"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Bottom" FontSize="15" Margin="0 0 0 10" />
|
||||
</Grid>
|
||||
<TabControl x:Name="Main" Margin="0,0,0,0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
|
||||
|
||||
<TabControl x:Name="Main" Margin="0,0,0,0" Visibility='Visible' HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
|
||||
<TabItem Header="Settings">
|
||||
<Grid Background="#FFE5E5E5" RenderTransformOrigin="0.5,0.5">
|
||||
|
||||
@ -709,6 +712,13 @@ Use if the platform is too sensitive.</clr:String>
|
||||
|
||||
<Button x:Name="SetAllPanelsToCurrentColor" Content="Set all panels to this color" HorizontalAlignment="Center" Padding="6,2" Margin="0,6,0,0" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- This version label is tweaked so it's in the same place as the one on the
|
||||
connecting screen. If we use the same margin, the tab container's border
|
||||
shifts it by a couple pixels, which makes it fidget around when we connect
|
||||
and disconnect. -->
|
||||
<Label x:Name="Version2" Content="Version"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Bottom" FontSize="15" Margin="0 0 0 7" />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
@ -806,7 +816,5 @@ Input will be disabled from deselected panels.</TextBlock>
|
||||
<Label x:Name="P1Connected" Style="{StaticResource EnabledIcon}" Content="P1" Margin="1,0,4,0" FontSize="10"/>
|
||||
<Label x:Name="P2Connected" Style="{StaticResource EnabledIcon}" Content="P2" Margin="0,0,4,0" FontSize="10"/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -24,6 +24,9 @@ namespace smx_config
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
Version1.Content = "SMXConfig version " + SMX.SMX.Version();
|
||||
Version2.Content = "SMXConfig version " + SMX.SMX.Version();
|
||||
|
||||
AutoLightsColor.StartedDragging += delegate() { showAutoLightsColor.Start(); };
|
||||
AutoLightsColor.StoppedDragging += delegate() { showAutoLightsColor.Stop(); };
|
||||
AutoLightsColor.StoppedDragging += delegate() { showAutoLightsColor.Stop(); };
|
||||
|
@ -246,12 +246,29 @@ namespace SMX
|
||||
private static extern bool SMX_SetLights(byte[] buf);
|
||||
[DllImport("SMX.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern bool SMX_ReenableAutoLights();
|
||||
[DllImport("SMX.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
private static extern IntPtr SMX_Version();
|
||||
|
||||
public static string Version()
|
||||
{
|
||||
if(!DLLAvailable()) return "";
|
||||
|
||||
// I can't find any way to marshal a simple null-terminated string. Marshalling
|
||||
// UnmanagedType.LPStr tries to deallocate the string, which crashes since it's
|
||||
// a static string.
|
||||
unsafe {
|
||||
sbyte *p = (sbyte *) SMX_Version();
|
||||
int length = 0;
|
||||
while(p[length] != 0)
|
||||
++length;
|
||||
return new string(p, 0, length);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the native DLL is available. This is mostly to avoid exceptions in the designer.
|
||||
// This returns false if the DLL doesn't load.
|
||||
public static bool DLLAvailable()
|
||||
{
|
||||
|
||||
return LoadLibrary("SMX.dll") != IntPtr.Zero;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<LangVersion>default</LangVersion>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user