2
0

BeefBoot.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //#define USE_OLD_BEEFBUILD
  2. #pragma warning(disable:4996)
  3. #include <iostream>
  4. #include "BeefySysLib/Common.h"
  5. #include "BeefySysLib/util/Array.h"
  6. #include "BeefySysLib/util/SizedArray.h"
  7. #include "BeefySysLib/util/Dictionary.h"
  8. #include "BeefySysLib/util/CabUtil.h"
  9. #include "BeefySysLib/util/BeefPerf.h"
  10. #include "BeefySysLib/util/Deque.h"
  11. #include "BeefySysLib/util/HashSet.h"
  12. #include "BeefySysLib/util/MultiHashSet.h"
  13. //#define TEST_CRASH
  14. #ifdef TEST_CRASH
  15. #include "CrashCatcher.h"
  16. #endif
  17. //#include <mmsystem.h>
  18. //#include <shellapi.h>
  19. //#include <Objbase.h>
  20. #define BF_DBG_64
  21. #include "IDEHelper/StrHashMap.h"
  22. using namespace Beefy;
  23. #include "BootApp.h"
  24. BF_IMPORT void BF_CALLTYPE IDEHelper_ProgramStart();
  25. BF_IMPORT void BF_CALLTYPE IDEHelper_ProgramDone();
  26. int main(int argc, char* argv[])
  27. {
  28. #ifdef TEST_CRASH
  29. CrashCatcher catcher;
  30. catcher.SetCrashReportKind(BfpCrashReportKind_GUI);
  31. catcher.Test();
  32. #endif
  33. BfpSystem_SetCommandLine(argc, argv);
  34. BfpThread_SetName(NULL, "MainThread", NULL);
  35. BfpSystem_Init(BFP_VERSION, BfpSystemInitFlag_InstallCrashCatcher);
  36. IDEHelper_ProgramStart();
  37. gApp = new BootApp();
  38. /*for (int i = 0; i < argc; i++)
  39. {
  40. if (i != 0)
  41. std::cout << " ";
  42. std::cout << argv[i];
  43. }
  44. std::cout << std::endl;*/
  45. String cmd;
  46. bool success = true;
  47. for (int i = 1; i < argc; i++)
  48. {
  49. String arg = argv[i];
  50. if (arg.StartsWith("--"))
  51. arg.Remove(0, 1);
  52. if (!cmd.IsEmpty())
  53. {
  54. cmd.Append('=');
  55. arg.Insert(0, cmd);
  56. cmd.Clear();
  57. }
  58. if (arg[0] == '"')
  59. {
  60. arg.Remove(0, 1);
  61. if ((arg.length() > 1) && (arg[arg.length() - 1] == '"'))
  62. arg.RemoveToEnd(arg.length() - 1);
  63. success &= gApp->HandleCmdLine(arg, "");
  64. continue;
  65. }
  66. int eqPos = (int)arg.IndexOf('=');
  67. if (eqPos == -1)
  68. {
  69. success &= gApp->HandleCmdLine(arg, "");
  70. continue;
  71. }
  72. cmd = arg.Substring(0, eqPos);
  73. if (eqPos == arg.length() - 1)
  74. continue;
  75. String param = arg.Substring(eqPos + 1);
  76. if ((param.length() > 1) && (param[0] == '"'))
  77. {
  78. param.Remove(0, 1);
  79. if ((param.length() > 1) && (param[param.length() - 1] == '"'))
  80. param.Remove(param.length() - 1);
  81. }
  82. success &= gApp->HandleCmdLine(cmd, param);
  83. cmd.Clear();
  84. }
  85. if (!gApp->mShowedHelp)
  86. {
  87. if (success)
  88. success = gApp->Init();
  89. if (success)
  90. success = gApp->Compile();
  91. if (success)
  92. gApp->OutputLine("SUCCESS", OutputPri_Critical);
  93. else
  94. gApp->OutputLine("FAILED", OutputPri_Critical);
  95. }
  96. delete gApp;
  97. IDEHelper_ProgramDone();
  98. BfpSystem_Shutdown();
  99. BP_SHUTDOWN();
  100. return success ? 0 : 1;
  101. }