main.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #include <AzCore/Settings/CommandLineParser_Platform.h>
  12. // the user is not expected to interact with the AssetBuilderApplication directly,
  13. // so it can be always running in the culture-invariant locale.
  14. #include <locale.h>
  15. int main(int argc, char** argv)
  16. {
  17. // globally set the application locale to the culture-invariant locale.
  18. // This should cause all reading and writing under all threads to use the invariant locale
  19. // So that the application can be run in any locale and still produce the same output.
  20. // We would not do this to a front-facing application that needs to actually be localized in a GUI,
  21. // but since this application runs headlessly and its job is to crunch invariant locale files into
  22. // other invariant locale files, setting it to the invariant locale means that individual builders
  23. // don't need to keep track of locale, change it, set it, etc.
  24. setlocale(LC_ALL, "C");
  25. // Make sure utf-8 commandline parameters can be used on all platforms
  26. AZ::Settings::Platform::CommandLineConverter converter(argc, argv);
  27. const AZ::Debug::Trace tracer;
  28. AssetBuilderApplication app(&argc, &argv);
  29. AssetBuilder::TraceMessageHook traceMessageHook; // Hook AZ Debug messages and redirect them to stdout
  30. traceMessageHook.EnableTraceContext(true);
  31. AZ::Debug::Trace::HandleExceptions(true);
  32. AZ::ComponentApplication::StartupParameters startupParams;
  33. startupParams.m_loadDynamicModules = false;
  34. app.Start(AzFramework::Application::Descriptor(), startupParams);
  35. traceMessageHook.EnableDebugMode(app.IsInDebugMode());
  36. bool result = false;
  37. BuilderBus::BroadcastResult(result, &BuilderBus::Events::Run);
  38. traceMessageHook.EnableTraceContext(false);
  39. app.Stop();
  40. return result ? 0 : 1;
  41. }