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/sys/inspect/cpp/component.h>
7 #include <lib/trace-provider/provider.h>
8 #include <lib/trace/event.h>
9 
10 #include <cstdlib>
11 
12 #include "fml/message_loop.h"
13 #include "lib/async/default.h"
14 #include "platform/utils.h"
15 #include "runner.h"
19 
20 int main(int argc, char const* argv[]) {
22 
23  // Create our component context which is served later.
24  auto context = sys::ComponentContext::Create();
26  auto build_info = dart_utils::RootInspectNode::CreateRootChild("build_info");
27  dart_utils::BuildInfo::Dump(build_info);
28 
29  // We inject the 'vm' node into the dart vm so that it can add any inspect
30  // data that it needs to the inspect tree.
31  dart::SetDartVmNode(std::make_unique<inspect::Node>(
33 
34  std::unique_ptr<trace::TraceProviderWithFdio> provider;
35  {
36  bool already_started;
37  // Use CreateSynchronously to prevent loss of early events.
38  trace::TraceProviderWithFdio::CreateSynchronously(
39  async_get_default_dispatcher(), "flutter_runner", &provider,
40  &already_started);
41  }
42 
43  // Set up the process-wide /tmp memfs.
44  dart_utils::RunnerTemp runner_temp;
45 
46  FML_DLOG(INFO) << "Flutter application services initialized.";
47 
49  flutter_runner::Runner runner(loop.GetTaskRunner(), context.get());
50 
51  // Wait to serve until we have finished all of our setup.
52  context->outgoing()->ServeFromStartupInfo();
53 
54  loop.Run();
55  FML_DLOG(INFO) << "Flutter application services terminated.";
56 
57  return EXIT_SUCCESS;
58 }
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
Definition: message_loop.cc:19
static void EnsureInitializedForCurrentThread()
Definition: message_loop.cc:27
static void Dump(inspect::Node &node)
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
Definition: message_loop.cc:56
int main(int argc, const char **argv)
Definition: main.cc:37
T * get() const
Definition: ref_ptr.h:112
#define FML_DLOG(severity)
Definition: logging.h:85
static void Initialize(sys::ComponentContext *context)
static inspect::Node CreateRootChild(const std::string &name)