Skip to content

Commit b94e759

Browse files
authored
Expose the Flutter engine, Dart and Skia versions to Dart. (flutter#7634)
- Moved versions from shell to common - versions singleton contains all the required versions.
1 parent 64e1707 commit b94e759

File tree

17 files changed

+170
-34
lines changed

17 files changed

+170
-34
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ FILE: ../../../flutter/common/settings.cc
2323
FILE: ../../../flutter/common/settings.h
2424
FILE: ../../../flutter/common/task_runners.cc
2525
FILE: ../../../flutter/common/task_runners.h
26+
FILE: ../../../flutter/common/version/version.cc
27+
FILE: ../../../flutter/common/version/version.h
2628
FILE: ../../../flutter/flow/compositor_context.cc
2729
FILE: ../../../flutter/flow/compositor_context.h
2830
FILE: ../../../flutter/flow/debug_print.cc
@@ -307,6 +309,9 @@ FILE: ../../../flutter/lib/ui/text/text_box.h
307309
FILE: ../../../flutter/lib/ui/ui.dart
308310
FILE: ../../../flutter/lib/ui/ui_dart_state.cc
309311
FILE: ../../../flutter/lib/ui/ui_dart_state.h
312+
FILE: ../../../flutter/lib/ui/versions.cc
313+
FILE: ../../../flutter/lib/ui/versions.dart
314+
FILE: ../../../flutter/lib/ui/versions.h
310315
FILE: ../../../flutter/lib/ui/window.dart
311316
FILE: ../../../flutter/lib/ui/window/platform_message.cc
312317
FILE: ../../../flutter/lib/ui/window/platform_message.h
@@ -570,8 +575,6 @@ FILE: ../../../flutter/shell/platform/embedder/embedder_surface_software.h
570575
FILE: ../../../flutter/shell/platform/embedder/fixtures/simple_main.dart
571576
FILE: ../../../flutter/shell/platform/embedder/platform_view_embedder.cc
572577
FILE: ../../../flutter/shell/platform/embedder/platform_view_embedder.h
573-
FILE: ../../../flutter/shell/version/version.cc
574-
FILE: ../../../flutter/shell/version/version.h
575578
FILE: ../../../flutter/sky/packages/flutter_services/lib/empty.dart
576579
FILE: ../../../flutter/sky/tools/roll/patches/chromium/android_build.patch
577580
FILE: ../../../flutter/synchronization/pipeline.cc

shell/version/BUILD.gn renamed to common/version/BUILD.gn

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ source_set("version") {
1111
]
1212

1313
defines = [
14-
"SHELL_FLUTTER_ENGINE_VERSION=\"$shell_engine_version\"",
15-
"SHELL_SKIA_VERSION=\"$shell_skia_version\"",
16-
"SHELL_DART_VERSION=\"$shell_dart_version\"",
14+
"FLUTTER_ENGINE_VERSION=\"$engine_version\"",
15+
"SKIA_VERSION=\"$skia_version\"",
16+
"DART_VERSION=\"$dart_version\"",
1717
]
1818

1919
public_configs = [ "$flutter_root:config" ]

shell/version/version.cc renamed to common/version/version.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#include "flutter/shell/version/version.h"
5+
#include "flutter/common/version/version.h"
66

7-
namespace shell {
7+
namespace blink {
88

99
const char* GetFlutterEngineVersion() {
10-
return SHELL_FLUTTER_ENGINE_VERSION;
10+
return FLUTTER_ENGINE_VERSION;
1111
}
1212

1313
const char* GetSkiaVersion() {
14-
return SHELL_SKIA_VERSION;
14+
return SKIA_VERSION;
1515
}
1616

1717
const char* GetDartVersion() {
18-
return SHELL_DART_VERSION;
18+
return DART_VERSION;
1919
}
2020

21-
} // namespace shell
21+
} // namespace blink

shell/version/version.gni renamed to common/version/version.gni

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,42 @@
33
# found in the LICENSE file.
44

55
declare_args() {
6-
shell_engine_version = ""
6+
engine_version = ""
77

8-
shell_skia_version = ""
8+
skia_version = ""
99

10-
shell_dart_version = ""
10+
dart_version = ""
1111
}
1212

13-
if (shell_engine_version == "") {
14-
shell_engine_version_lines =
13+
if (engine_version == "") {
14+
engine_version_lines =
1515
exec_script("$flutter_root/build/git_revision.py",
1616
[
1717
"--repository",
1818
rebase_path(flutter_root, "", flutter_root),
1919
],
2020
"list lines")
21-
shell_engine_version = shell_engine_version_lines[0]
21+
engine_version = engine_version_lines[0]
2222
}
2323

24-
if (shell_skia_version == "") {
25-
shell_skia_version_lines =
24+
if (skia_version == "") {
25+
skia_version_lines =
2626
exec_script("$flutter_root/build/git_revision.py",
2727
[
2828
"--repository",
2929
rebase_path("//third_party/skia", "", flutter_root),
3030
],
3131
"list lines")
32-
shell_skia_version = shell_skia_version_lines[0]
32+
skia_version = skia_version_lines[0]
3333
}
3434

35-
if (shell_dart_version == "") {
36-
shell_dart_version_lines =
35+
if (dart_version == "") {
36+
dart_version_lines =
3737
exec_script("$flutter_root/build/git_revision.py",
3838
[
3939
"--repository",
4040
rebase_path("//third_party/dart", "", flutter_root),
4141
],
4242
"list lines")
43-
shell_dart_version = shell_dart_version_lines[0]
43+
dart_version = dart_version_lines[0]
4444
}

shell/version/version.h renamed to common/version/version.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#ifndef FLUTTER_SHELL_COMMON_VERSION_H_
6-
#define FLUTTER_SHELL_COMMON_VERSION_H_
5+
#ifndef FLUTTER_COMMON_VERSION_VERSION_H_
6+
#define FLUTTER_COMMON_VERSION_VERSION_H_
77

8-
namespace shell {
8+
namespace blink {
99

1010
const char* GetFlutterEngineVersion();
1111

1212
const char* GetSkiaVersion();
1313

1414
const char* GetDartVersion();
1515

16-
} // namespace shell
16+
} // namespace blink
1717

18-
#endif // FLUTTER_SHELL_COMMON_VERSION_H_
18+
#endif // FLUTTER_COMMON_VERSION_VERSION_H_

lib/ui/BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ source_set("ui") {
8383
"text/text_box.h",
8484
"ui_dart_state.cc",
8585
"ui_dart_state.h",
86+
"versions.cc",
87+
"versions.h",
8688
"window/platform_message.cc",
8789
"window/platform_message.h",
8890
"window/platform_message_response.cc",
@@ -104,6 +106,7 @@ source_set("ui") {
104106
deps = [
105107
"$flutter_root/assets",
106108
"$flutter_root/common",
109+
"$flutter_root/common/version",
107110
"$flutter_root/flow",
108111
"$flutter_root/fml",
109112
"$flutter_root/runtime:test_font",

lib/ui/dart_ui.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "flutter/lib/ui/text/font_collection.h"
2828
#include "flutter/lib/ui/text/paragraph.h"
2929
#include "flutter/lib/ui/text/paragraph_builder.h"
30+
#include "flutter/lib/ui/versions.h"
3031
#include "flutter/lib/ui/window/window.h"
3132
#include "third_party/tonic/converter/dart_converter.h"
3233
#include "third_party/tonic/logging/dart_error.h"
@@ -87,6 +88,7 @@ void DartUI::InitForGlobal() {
8788
SceneHost::RegisterNatives(g_natives);
8889
SemanticsUpdate::RegisterNatives(g_natives);
8990
SemanticsUpdateBuilder::RegisterNatives(g_natives);
91+
Versions::RegisterNatives(g_natives);
9092
Vertices::RegisterNatives(g_natives);
9193
Window::RegisterNatives(g_natives);
9294

lib/ui/dart_ui.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dart_ui_files = [
1616
"$flutter_root/lib/ui/semantics.dart",
1717
"$flutter_root/lib/ui/text.dart",
1818
"$flutter_root/lib/ui/ui.dart",
19+
"$flutter_root/lib/ui/versions.dart",
1920
"$flutter_root/lib/ui/window.dart",
2021
]
2122

lib/ui/ui.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ part 'plugins.dart';
3434
part 'pointer.dart';
3535
part 'semantics.dart';
3636
part 'text.dart';
37+
part 'versions.dart';
3738
part 'window.dart';

lib/ui/versions.cc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 "flutter/lib/ui/versions.h"
6+
#include "flutter/common/version/version.h"
7+
#include "third_party/tonic/converter/dart_converter.h"
8+
#include "third_party/tonic/dart_library_natives.h"
9+
10+
#include <string>
11+
#include <vector>
12+
13+
using tonic::DartConverter;
14+
15+
namespace blink {
16+
17+
// returns a vector with 3 versions.
18+
// Dart, Skia and Flutter engine versions in this order.
19+
void GetVersions(Dart_NativeArguments args) {
20+
const std::vector<std::string> versions_list = {
21+
GetDartVersion(), GetSkiaVersion(), GetFlutterEngineVersion()};
22+
Dart_Handle dart_val =
23+
DartConverter<std::vector<std::string>>::ToDart(versions_list);
24+
Dart_SetReturnValue(args, dart_val);
25+
}
26+
27+
void Versions::RegisterNatives(tonic::DartLibraryNatives* natives) {
28+
natives->Register({{"Versions_getVersions", GetVersions, 1, true}});
29+
}
30+
31+
} // namespace blink

0 commit comments

Comments
 (0)