Flutter Engine
The 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/inspect/component/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"
15#include "lib/async/default.h"
16#include "logging.h"
17#include "platform/utils.h"
18#include "runner.h"
22
23int main(int argc, char const* argv[]) {
25
26 // Setup logging.
28 fml::LogInterestListener listener(fml::LogState::Default().TakeClientEnd(),
29 async_get_default_dispatcher());
31
32 // Create our component context which is served later.
33 auto context = sys::ComponentContext::Create();
35 auto build_info = dart_utils::RootInspectNode::CreateRootChild("build_info");
37
38 // We inject the 'vm' node into the dart vm so that it can add any inspect
39 // data that it needs to the inspect tree.
40 dart::SetDartVmNode(std::make_unique<inspect::Node>(
42
43 std::unique_ptr<trace::TraceProviderWithFdio> provider;
44 {
45 bool already_started;
46 // Use CreateSynchronously to prevent loss of early events.
47 trace::TraceProviderWithFdio::CreateSynchronously(
48 async_get_default_dispatcher(), "flutter_runner", &provider,
49 &already_started);
50 }
51
53 flutter_runner::Runner runner(loop.GetTaskRunner(), context.get());
54
55 // Wait to serve until we have finished all of our setup.
56 context->outgoing()->ServeFromStartupInfo();
57
58 loop.Run();
59
60 return EXIT_SUCCESS;
61}
static sk_sp< Effect > Create()
Definition: RefCntTest.cpp:117
static void Dump(inspect::Node &node)
static void Initialize(sys::ComponentContext *context)
static inspect::Node CreateRootChild(const std::string &name)
void SetTags(const std::initializer_list< std::string > &tags)
Definition: log_state.cc:56
static LogState & Default()
Definition: log_state.cc:61
static void EnsureInitializedForCurrentThread()
Definition: message_loop.cc:27
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
Definition: message_loop.cc:56
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
Definition: message_loop.cc:19
T * get() const
Definition: ref_ptr.h:116
int main(int argc, char **argv)
Definition: main.cc:407
char ** argv
Definition: library.h:9
void SetDartVmNode(std::unique_ptr< inspect::Node > node)
#define LOG_TAG
Definition: logging.h:11