From 1cad83b7ea3249133f874f44509a9e17724c7079 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Mon, 20 Aug 2018 18:25:32 -0700 Subject: [PATCH 1/2] Alllow access to Flutter engine, Dart & Skia versions in the Shell API. --- build/git_revision.py | 43 ++++++++++++++++++++++++++++++++++++++ shell/common/BUILD.gn | 1 + shell/common/switches.cc | 9 ++++++++ shell/version/BUILD.gn | 18 ++++++++++++++++ shell/version/version.cc | 21 +++++++++++++++++++ shell/version/version.gni | 44 +++++++++++++++++++++++++++++++++++++++ shell/version/version.h | 18 ++++++++++++++++ 7 files changed, 154 insertions(+) create mode 100755 build/git_revision.py create mode 100644 shell/version/BUILD.gn create mode 100644 shell/version/version.cc create mode 100644 shell/version/version.gni create mode 100644 shell/version/version.h diff --git a/build/git_revision.py b/build/git_revision.py new file mode 100755 index 0000000000000..bc58320306d14 --- /dev/null +++ b/build/git_revision.py @@ -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()) diff --git a/shell/common/BUILD.gn b/shell/common/BUILD.gn index 74ab39e06ebb2..0091d5bf02361 100644 --- a/shell/common/BUILD.gn +++ b/shell/common/BUILD.gn @@ -106,6 +106,7 @@ source_set("common") { ] public_deps = [ + "$flutter_root/shell/version", "$flutter_root/third_party/txt", "//third_party/tonic", ] diff --git a/shell/common/switches.cc b/shell/common/switches.cc index e0a7c93271411..80ae36a7e5776 100644 --- a/shell/common/switches.cc +++ b/shell/common/switches.cc @@ -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; diff --git a/shell/version/BUILD.gn b/shell/version/BUILD.gn new file mode 100644 index 0000000000000..0214a4d767bff --- /dev/null +++ b/shell/version/BUILD.gn @@ -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\"", + ] +} diff --git a/shell/version/version.cc b/shell/version/version.cc new file mode 100644 index 0000000000000..86525de620191 --- /dev/null +++ b/shell/version/version.cc @@ -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 diff --git a/shell/version/version.gni b/shell/version/version.gni new file mode 100644 index 0000000000000..66ca9fdd8e10d --- /dev/null +++ b/shell/version/version.gni @@ -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] +} diff --git a/shell/version/version.h b/shell/version/version.h new file mode 100644 index 0000000000000..1c9ca4d1d7c34 --- /dev/null +++ b/shell/version/version.h @@ -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_ From c5cc2b309d42c8e914548ad50f08be111c85bdb5 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Mon, 20 Aug 2018 18:43:10 -0700 Subject: [PATCH 2/2] Licenses --- ci/licenses_golden/licenses_flutter | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index f120888c6b0d7..0256b51e6bea7 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -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.