Alllow access to Flutter engine, Dart & Skia versions in the Shell API. (#6060)

This commit is contained in:
Chinmay Garde 2018-08-21 08:52:24 -07:00 committed by GitHub
parent 4b271b2e02
commit 140a5b7575
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 156 additions and 0 deletions

43
build/git_revision.py Executable file
View File

@ -0,0 +1,43 @@
#!/usr/bin/env python
#
# Copyright 2018 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.
"""Get the Git HEAD revision of a specified Git repository."""
import sys
import subprocess
import os
import argparse
def main():
parser = argparse.ArgumentParser();
parser.add_argument('--repository',
action='store',
help='Path to the Git repository.',
required=True)
args = parser.parse_args()
repository = os.path.abspath(args.repository)
if not os.path.exists(repository):
exit -1
version = subprocess.check_output([
'git',
'-C',
repository,
'rev-parse',
'--short',
'HEAD',
])
print version.strip()
return 0
if __name__ == '__main__':
sys.exit(main())

View File

@ -609,6 +609,8 @@ FILE: ../../../flutter/shell/platform/android/platform_message_response_android.
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate_Internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm
FILE: ../../../flutter/shell/version/version.cc
FILE: ../../../flutter/shell/version/version.h
----------------------------------------------------------------------------------------------------
Copyright 2018 The Flutter Authors. All rights reserved.

View File

@ -106,6 +106,7 @@ source_set("common") {
]
public_deps = [
"$flutter_root/shell/version",
"$flutter_root/third_party/txt",
"//third_party/tonic",
]

View File

@ -11,6 +11,7 @@
#include "flutter/fml/paths.h"
#include "flutter/fml/string_view.h"
#include "flutter/shell/version/version.h"
// Include once for the default enum definition.
#include "flutter/shell/common/switches.h"
@ -42,6 +43,14 @@ namespace shell {
void PrintUsage(const std::string& executable_name) {
std::cerr << std::endl << " " << executable_name << std::endl << std::endl;
std::cerr << "Versions: " << std::endl << std::endl;
std::cerr << "Flutter Engine Version: " << GetFlutterEngineVersion()
<< std::endl;
std::cerr << "Skia Version: " << GetSkiaVersion() << std::endl;
std::cerr << "Dart Version: " << GetDartVersion() << std::endl << std::endl;
std::cerr << "Available Flags:" << std::endl;
const uint32_t column_width = 80;

18
shell/version/BUILD.gn Normal file
View File

@ -0,0 +1,18 @@
# Copyright 2018 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.
import("version.gni")
source_set("version") {
sources = [
"version.cc",
"version.h",
]
defines = [
"SHELL_FLUTTER_ENGINE_VERSION=\"$shell_engine_version\"",
"SHELL_SKIA_VERSION=\"$shell_skia_version\"",
"SHELL_DART_VERSION=\"$shell_dart_version\"",
]
}

21
shell/version/version.cc Normal file
View File

@ -0,0 +1,21 @@
// Copyright 2018 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 "flutter/shell/version/version.h"
namespace shell {
const char* GetFlutterEngineVersion() {
return SHELL_FLUTTER_ENGINE_VERSION;
}
const char* GetSkiaVersion() {
return SHELL_SKIA_VERSION;
}
const char* GetDartVersion() {
return SHELL_DART_VERSION;
}
} // namespace shell

44
shell/version/version.gni Normal file
View File

@ -0,0 +1,44 @@
# Copyright 2018 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.
declare_args() {
shell_engine_version = ""
shell_skia_version = ""
shell_dart_version = ""
}
if (shell_engine_version == "") {
shell_engine_version_lines =
exec_script("$flutter_root/build/git_revision.py",
[
"--repository",
rebase_path(flutter_root, "", flutter_root),
],
"list lines")
shell_engine_version = shell_engine_version_lines[0]
}
if (shell_skia_version == "") {
shell_skia_version_lines =
exec_script("$flutter_root/build/git_revision.py",
[
"--repository",
rebase_path("//third_party/skia", "", flutter_root),
],
"list lines")
shell_skia_version = shell_skia_version_lines[0]
}
if (shell_dart_version == "") {
shell_dart_version_lines =
exec_script("$flutter_root/build/git_revision.py",
[
"--repository",
rebase_path("//third_party/dart", "", flutter_root),
],
"list lines")
shell_dart_version = shell_dart_version_lines[0]
}

18
shell/version/version.h Normal file
View File

@ -0,0 +1,18 @@
// Copyright 2018 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.
#ifndef FLUTTER_SHELL_COMMON_VERSION_H_
#define FLUTTER_SHELL_COMMON_VERSION_H_
namespace shell {
const char* GetFlutterEngineVersion();
const char* GetSkiaVersion();
const char* GetDartVersion();
} // namespace shell
#endif // FLUTTER_SHELL_COMMON_VERSION_H_