mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This functionality is added in issue #41523. Allows runners to request the singleton instance of `sys::ComponentContext`, while it remains also accessible to component-specific code that does not have direct access to top-level objects. Fixes #41523
58 lines
1.9 KiB
C++
58 lines
1.9 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include <lib/async-loop/cpp/loop.h>
|
|
#include <lib/async-loop/default.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/files.h"
|
|
#include "runtime/dart/utils/tempfs.h"
|
|
#include "third_party/dart/runtime/include/dart_api.h"
|
|
|
|
#if !defined(DART_PRODUCT)
|
|
// Register native symbol information for the Dart VM's profiler.
|
|
static void RegisterProfilerSymbols(const char* symbols_path,
|
|
const char* dso_name) {
|
|
std::string* symbols = new std::string();
|
|
if (dart_utils::ReadFileToString(symbols_path, symbols)) {
|
|
Dart_AddSymbols(dso_name, symbols->data(), symbols->size());
|
|
} else {
|
|
FML_LOG(ERROR) << "Failed to load " << symbols_path;
|
|
FML_CHECK(false);
|
|
}
|
|
}
|
|
#endif // !defined(DART_PRODUCT)
|
|
|
|
int main(int argc, const char** argv) {
|
|
async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
|
|
|
|
std::unique_ptr<trace::TraceProviderWithFdio> provider;
|
|
{
|
|
bool already_started;
|
|
// Use CreateSynchronously to prevent loss of early events.
|
|
trace::TraceProviderWithFdio::CreateSynchronously(
|
|
loop.dispatcher(), "dart_runner", &provider, &already_started);
|
|
}
|
|
|
|
#if !defined(DART_PRODUCT)
|
|
#if defined(AOT_RUNTIME)
|
|
RegisterProfilerSymbols("pkg/data/dart_aot_runner.dartprofilersymbols", "");
|
|
#else
|
|
RegisterProfilerSymbols("pkg/data/dart_jit_runner.dartprofilersymbols", "");
|
|
#endif // defined(AOT_RUNTIME)
|
|
#endif // !defined(DART_PRODUCT)
|
|
|
|
dart_utils::RunnerTemp runner_temp;
|
|
dart_runner::DartRunner runner(dart::ComponentContext());
|
|
loop.Run();
|
|
return 0;
|
|
}
|