Flutter Engine
main.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <lib/async-loop/cpp/loop.h>
6 #include <lib/async-loop/default.h>
7 #include <lib/syslog/global.h>
8 #include <lib/trace-provider/provider.h>
9 #include <lib/trace/event.h>
10 
11 #include "dart_runner.h"
12 #include "flutter/fml/logging.h"
13 #include "flutter/fml/trace_event.h"
14 #include "logging.h"
15 #include "platform/utils.h"
18 #include "third_party/dart/runtime/include/dart_api.h"
19 
20 #if !defined(DART_PRODUCT)
21 // Register native symbol information for the Dart VM's profiler.
22 static void RegisterProfilerSymbols(const char* symbols_path,
23  const char* dso_name) {
24  std::string* symbols = new std::string();
25  if (dart_utils::ReadFileToString(symbols_path, symbols)) {
26  Dart_AddSymbols(dso_name, symbols->data(), symbols->size());
27  } else {
28  FML_LOG(ERROR) << "Failed to load " << symbols_path;
29  FML_CHECK(false);
30  }
31 }
32 #endif // !defined(DART_PRODUCT)
33 
34 int main(int argc, const char** argv) {
35  async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
36 
37  std::unique_ptr<trace::TraceProviderWithFdio> provider;
38  {
39  bool already_started;
40  // Use CreateSynchronously to prevent loss of early events.
41  trace::TraceProviderWithFdio::CreateSynchronously(
42  loop.dispatcher(), "dart_runner", &provider, &already_started);
43  }
44 
45 #if !defined(DART_PRODUCT)
46 #if defined(AOT_RUNTIME)
47  RegisterProfilerSymbols("pkg/data/dart_aot_runner.dartprofilersymbols", "");
48 #else
49  RegisterProfilerSymbols("pkg/data/dart_jit_runner.dartprofilersymbols", "");
50 #endif // defined(AOT_RUNTIME)
51 #endif // !defined(DART_PRODUCT)
52 
53  dart_utils::RunnerTemp runner_temp;
54  dart_runner::DartRunner runner(dart::ComponentContext());
55  loop.Run();
56  return 0;
57 }
static void RegisterProfilerSymbols(const char *symbols_path, const char *dso_name)
Definition: main.cc:22
#define FML_LOG(severity)
Definition: logging.h:65
int main(int argc, const char **argv)
Definition: main.cc:34
bool ReadFileToString(const std::string &path, std::string *result)
Definition: files.cc:56
#define FML_CHECK(condition)
Definition: logging.h:68