From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Utilities/Argv.cpp | 129 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 Runtime/Utilities/Argv.cpp (limited to 'Runtime/Utilities/Argv.cpp') diff --git a/Runtime/Utilities/Argv.cpp b/Runtime/Utilities/Argv.cpp new file mode 100644 index 0000000..b05da23 --- /dev/null +++ b/Runtime/Utilities/Argv.cpp @@ -0,0 +1,129 @@ +#include "UnityPrefix.h" +#include "Argv.h" +#if UNITY_WIN +#include "PlatformDependent/Win/WinUtils.h" +#endif + +using namespace std; + +static int argc; +static const char** argv; +static vector relaunchArguments; + +struct KnownArguments +{ + bool isBatchmode; + bool isAutomated; +}; + +static KnownArguments knownArgs; + +void SetupArgv (int a, const char** b) +{ + argc = a; + argv = b; + knownArgs.isBatchmode = HasARGV ("batchmode"); + knownArgs.isAutomated = HasARGV ("automated"); +} + +bool HasARGV (const string& name) +{ + for (int i=0;i GetValuesForARGV (const string& name) +{ + vector values; + values.reserve (argc); + + bool found = false; + for (int i=0;i values = GetValuesForARGV (name); + if (values.empty ()) + return string (); + else + return values[0]; +} + +vector GetAllArguments() +{ + vector values; + values.reserve (argc); + for (int i=1;i& args) +{ + relaunchArguments = args; +} + +vector GetRelaunchApplicationArguments () +{ + return relaunchArguments; +} + +void CheckBatchModeErrorString (const string& error) +{ + if (error.empty ()) + return; + + ErrorString(error); + + if (!IsBatchmode()) + return; + +#if UNITY_WIN && UNITY_EDITOR + winutils::RedirectStdoutToConsole(); +#elif UNITY_OSX + ResetStdout(); +#endif + printf_console ("\nAborting batchmode due to failure:\n%s\n\n", error.c_str()); + exit(1); +} -- cgit v1.1-26-g67d0