Flutter Engine
main.cc File Reference
#include <lib/async-loop/cpp/loop.h>
#include <lib/async-loop/default.h>
#include <lib/sys/inspect/cpp/component.h>
#include <lib/syslog/global.h>
#include <lib/trace-provider/provider.h>
#include <lib/trace/event.h>
#include "dart_runner.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/trace_event.h"
#include "logging.h"
#include "platform/utils.h"
#include "runtime/dart/utils/build_info.h"
#include "runtime/dart/utils/files.h"
#include "runtime/dart/utils/root_inspect_node.h"
#include "runtime/dart/utils/tempfs.h"
#include "third_party/dart/runtime/include/dart_api.h"

Go to the source code of this file.

Functions

static void RegisterProfilerSymbols (const char *symbols_path, const char *dso_name)
 
int main (int argc, const char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
const char **  argv 
)

Definition at line 37 of file main.cc.

References dart_utils::RootInspectNode::CreateRootChild(), dart_utils::BuildInfo::Dump(), dart_utils::RootInspectNode::Initialize(), and RegisterProfilerSymbols().

37  {
38  async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
39 
40  // Create our component context which is served later.
41  auto context = sys::ComponentContext::Create();
43  auto build_info = dart_utils::RootInspectNode::CreateRootChild("build_info");
44  dart_utils::BuildInfo::Dump(build_info);
45 
46  dart::SetDartVmNode(std::make_unique<inspect::Node>(
48 
49  std::unique_ptr<trace::TraceProviderWithFdio> provider;
50  {
51  bool already_started;
52  // Use CreateSynchronously to prevent loss of early events.
53  trace::TraceProviderWithFdio::CreateSynchronously(
54  loop.dispatcher(), "dart_runner", &provider, &already_started);
55  }
56 
57 #if !defined(DART_PRODUCT)
58 #if defined(AOT_RUNTIME)
59  RegisterProfilerSymbols("pkg/data/dart_aot_runner.dartprofilersymbols", "");
60 #else
61  RegisterProfilerSymbols("pkg/data/dart_jit_runner.dartprofilersymbols", "");
62 #endif // defined(AOT_RUNTIME)
63 #endif // !defined(DART_PRODUCT)
64 
65  dart_utils::RunnerTemp runner_temp;
66  dart_runner::DartRunner runner(context.get());
67 
68  // Wait to serve until we have finished all of our setup.
69  context->outgoing()->ServeFromStartupInfo();
70 
71  loop.Run();
72  return 0;
73 }
static void RegisterProfilerSymbols(const char *symbols_path, const char *dso_name)
Definition: main.cc:25
static void Dump(inspect::Node &node)
static void Initialize(sys::ComponentContext *context)
static inspect::Node CreateRootChild(const std::string &name)

◆ RegisterProfilerSymbols()

static void RegisterProfilerSymbols ( const char *  symbols_path,
const char *  dso_name 
)
static

Definition at line 25 of file main.cc.

References FML_CHECK, FML_LOG, and dart_utils::ReadFileToString().

Referenced by main().

26  {
27  std::string* symbols = new std::string();
28  if (dart_utils::ReadFileToString(symbols_path, symbols)) {
29  Dart_AddSymbols(dso_name, symbols->data(), symbols->size());
30  } else {
31  FML_LOG(ERROR) << "Failed to load " << symbols_path;
32  FML_CHECK(false);
33  }
34 }
#define FML_LOG(severity)
Definition: logging.h:65
bool ReadFileToString(const std::string &path, std::string *result)
Definition: files.cc:56
#define FML_CHECK(condition)
Definition: logging.h:68