main.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "AssetBuilderApplication.h"
  9. #include "TraceMessageHook.h"
  10. #include "AssetBuilderComponent.h"
  11. // the user is not expected to interact with the AssetBuilderApplication directly,
  12. // so it can be always running in the culture-invariant locale.
  13. #include <locale.h>
  14. int main(int argc, char** argv)
  15. {
  16. // globally set the application locale to the culture-invariant locale.
  17. // This should cause all reading and writing under all threads to use the invariant locale
  18. // So that the application can be run in any locale and still produce the same output.
  19. // We would not do this to a front-facing application that needs to actually be localized in a GUI,
  20. // but since this application runs headlessly and its job is to crunch invariant locale files into
  21. // other invariant locale files, setting it to the invariant locale means that individual builders
  22. // don't need to keep track of locale, change it, set it, etc.
  23. setlocale(LC_ALL, "C");
  24. const AZ::Debug::Trace tracer;
  25. AssetBuilderApplication app(&argc, &argv);
  26. AssetBuilder::TraceMessageHook traceMessageHook; // Hook AZ Debug messages and redirect them to stdout
  27. traceMessageHook.EnableTraceContext(true);
  28. AZ::Debug::Trace::HandleExceptions(true);
  29. AZ::ComponentApplication::StartupParameters startupParams;
  30. startupParams.m_loadDynamicModules = false;
  31. app.Start(AzFramework::Application::Descriptor(), startupParams);
  32. traceMessageHook.EnableDebugMode(app.IsInDebugMode());
  33. bool result = false;
  34. BuilderBus::BroadcastResult(result, &BuilderBus::Events::Run);
  35. traceMessageHook.EnableTraceContext(false);
  36. app.Stop();
  37. return result ? 0 : 1;
  38. }