Desktop command args support fixes and auto git versioning for VS and make

This commit is contained in:
David Miller 2018-08-20 23:31:37 -04:00 committed by Ender's Games
parent 4000b88771
commit b58e866b6b
7 changed files with 1087 additions and 989 deletions

View File

@ -1,7 +1,7 @@
#pragma once
#include "types.h"
#include "version.h"
/*
** cfg* prototypes, if you pass NULL to a cfgSave* it will wipe out the section
** } if you pass it to lpKey it will wipe out that particular entry

View File

@ -6,8 +6,12 @@
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <string.h>
#ifndef linux
#include <conio.h>
#endif
#include "cfg/cfg.h"
@ -101,27 +105,45 @@ int setconfig(wchar** arg,int cl)
int showhelp(wchar** arg,int cl)
{
printf("Available commands :\n");
printf("\nAvailable commands :\n");
printf("-config section:key=value [, ..]: add a virtual config value\n Virtual config values won't be saved to the .cfg file\n unless a different value is written to em\nNote :\n You can specify many settings in the xx:yy=zz , gg:hh=jj , ...\n format.The spaces between the values and ',' are needed.");
printf("-config section:key=value [, ..]: add a virtual config value\n Virtual config values won't be saved to the .cfg file\n unless a different value is written to em\nNote :\n You can specify many settings in the xx:yy=zz , gg:hh=jj , ...\n format.The spaces between the values and ',' are needed.\n");
printf("\n-help: show help info\n");
printf("\n-version: show current version #\n\n");
#if !defined(DEF_CONSOLE) && !defined(linux)
getch();
#endif
return 0;
}
int showversion(wchar** arg,int cl)
{
printf("\nReicast Version: # %s built on %s \n", REICAST_VERSION, __DATE__);
#if !defined(DEF_CONSOLE) && !defined(linux)
getch();
#endif
return 0;
}
bool ParseCommandLine(int argc,wchar* argv[])
{
int cl=argc-2;
wchar** arg=argv+1;
while(cl>=0)
{
if (stricmp(*arg,"-help")==0)
if (stricmp(*arg,"-help")==0 || stricmp(*arg,"--help")==0)
{
int as=showhelp(arg,cl);
cl-=as;
arg+=as;
showhelp(arg,cl);
return true;
}
else if (stricmp(*arg,"-config")==0)
if (stricmp(*arg,"-version")==0 || stricmp(*arg,"--version")==0)
{
showversion(arg,cl);
return true;
}
else if (stricmp(*arg,"-config")==0 || stricmp(*arg,"--config")==0)
{
int as=setconfig(arg,cl);
cl-=as;

View File

@ -381,6 +381,11 @@ int main(int argc, wchar* argv[])
signal(SIGKILL, clean_exit);
#endif
if(ParseCommandLine(argc,argv)) {
return 69;
}
/* Set directories */
set_user_config_dir(find_user_config_dir());
set_user_data_dir(find_user_data_dir());

View File

@ -1,6 +1,8 @@
#include "oslib\oslib.h"
#include "oslib\audiostream.h"
#include "imgread\common.h"
#include "stdclass.h"
#include "cfg/cfg.h"
#define _WIN32_WINNT 0x0500
#include <windows.h>
@ -152,7 +154,7 @@ LONG ExeptionHandler(EXCEPTION_POINTERS *ExceptionInfo)
#endif
else
{
printf("[GPF]Unhandled access to : 0x%X\n",address);
printf("[GPF]Unhandled access to : 0x%X\n",(unat)address);
}
return EXCEPTION_CONTINUE_SEARCH;
@ -446,7 +448,7 @@ void os_consume(double t)
if ((cycl_glob+cyc)<10*1000*1000)
{
InterlockedExchangeAdd(&cycl_glob,cyc);
InterlockedExchangeAdd(&cycl_glob,(u64)cyc);
}
else
{
@ -667,12 +669,23 @@ void setup_seh() {
}
#endif
int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShowCmd)
// DEF_CONSOLE allows you to override linker subsystem and therefore default console //
// : pragma isn't pretty but def's are configurable
#ifdef DEF_CONSOLE
#pragma comment(linker, "/subsystem:console")
int main(int argc, char **argv)
{
ReserveBottomMemory();
tick_thd.Start();
#else
#pragma comment(linker, "/subsystem:windows")
int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShowCmd)
{
int argc=0;
wchar* cmd_line=GetCommandLineA();
wchar** argv=CommandLineToArgvA(cmd_line,&argc);
@ -687,6 +700,15 @@ int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine
SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE );
}
#endif
if(ParseCommandLine(argc,argv)) {
return 69;
}
ReserveBottomMemory();
tick_thd.Start();
SetupPath();
//SetUnhandledExceptionFilter(&ExeptionHandler);
@ -695,14 +717,14 @@ int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine
int dc_init(int argc,wchar* argv[]);
void dc_run();
void dc_term();
dc_init(argc,argv);
#ifdef _WIN64
setup_seh();
#endif
dc_run();
dc_term();
if (0 == dc_init(argc, argv))
{
#ifdef _WIN64
setup_seh();
#endif
dc_run();
dc_term();
}
}
__except( ExeptionHandler(GetExceptionInformation()) )
{

View File

@ -370,7 +370,11 @@ ifneq (,$(findstring gcwz,$(platform)))
mksquashfs $(EXECUTABLE_STRIPPED) $(GCWZ_PKG_FILES) $(GCWZ_PKG) -all-root
endif
$(EXECUTABLE): $(OBJECTS)
VERSION_HEADER=$(RZDCY_SRC_DIR)/version.h
$(VERSION_HEADER):
echo \#define REICAST_VERSION \"$(shell git describe)\" >$(RZDCY_SRC_DIR)/version.h
$(EXECUTABLE): $(VERSION_HEADER) $(OBJECTS)
$(CXX) $(MFLAGS) $(EXTRAFLAGS) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@
$(EXECUTABLE_STRIPPED): $(EXECUTABLE)
@ -422,4 +426,4 @@ uninstall:
rm -f $(DESTDIR)$(ICON_DIR)/reicast.png
clean:
rm -f $(OBJECTS) $(EXECUTABLE) $(EXECUTABLE_STRIPPED) .map
rm -f $(VERSION_HEADER) $(OBJECTS) $(EXECUTABLE) $(EXECUTABLE_STRIPPED) .map

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Fast|Win32">
@ -337,6 +337,7 @@
<ClInclude Include="..\core\rend\TexCache.h" />
<ClInclude Include="..\core\stdclass.h" />
<ClInclude Include="..\core\types.h" />
<ClInclude Include="..\core\version.h" />
<ClInclude Include="..\core\webui\server.h" />
</ItemGroup>
<ItemGroup>
@ -359,6 +360,7 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>reicast</RootNamespace>
<ProjectName>reicast</ProjectName>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Fast|Win32'" Label="Configuration">
@ -459,6 +461,16 @@
<AdditionalLibraryDirectories>$(SolutionDir)..\pvrframe</AdditionalLibraryDirectories>
<AdditionalDependencies>Dsound.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
<PreBuildEvent>
<Command>for /f "delims=" %%i in ('git describe') do echo #define REICAST_VERSION "%%i" &gt;$(ProjectDir)\..\core\version.h</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Setting Version git describe &gt;$(ProjectDir)\version.txt &amp;&amp; set r_ver=%%i &amp;&amp; </Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Fast|x64'">
<ClCompile>
@ -466,7 +478,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Full</Optimization>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
@ -493,6 +505,16 @@
<AdditionalLibraryDirectories>$(SolutionDir)..\pvrframe</AdditionalLibraryDirectories>
<AdditionalDependencies>Dsound.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
<PreBuildEvent>
<Command>for /f "delims=" %%i in ('git describe') do echo #define REICAST_VERSION "%%i" &gt;$(ProjectDir)\..\core\version.h</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Setting Version git describe &gt;$(ProjectDir)\version.txt &amp;&amp; set r_ver=%%i &amp;&amp; </Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Slow|Win32'">
<ClCompile>
@ -500,7 +522,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>DEF_CONSOLE;TARGET_NO_WEBUI;WIN32;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
@ -514,6 +536,16 @@
<AdditionalLibraryDirectories>$(SolutionDir)..\pvrframe</AdditionalLibraryDirectories>
<AdditionalDependencies>Dsound.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
<PreBuildEvent>
<Command>for /f "delims=" %%i in ('git describe') do echo #define REICAST_VERSION "%%i" &gt;$(ProjectDir)\..\core\version.h</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Setting Version git describe &gt;$(ProjectDir)\version.txt &amp;&amp; set r_ver=%%i &amp;&amp; </Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Slow|x64'">
<ClCompile>
@ -521,7 +553,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
@ -537,7 +569,19 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)..\pvrframe</AdditionalLibraryDirectories>
<AdditionalDependencies>Dsound.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<EntryPointSymbol>
</EntryPointSymbol>
</Link>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
<PreBuildEvent>
<Command>for /f "delims=" %%i in ('git describe') do echo #define REICAST_VERSION "%%i" &gt;$(ProjectDir)\..\core\version.h</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Setting Version git describe &gt;$(ProjectDir)\version.txt &amp;&amp; set r_ver=%%i &amp;&amp; </Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>

File diff suppressed because it is too large Load Diff