diff --git a/build/git_revision.py b/build/git_revision.py new file mode 100755 index 00000000000..bc58320306d --- /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/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index f120888c6b0..0256b51e6be 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. diff --git a/shell/common/BUILD.gn b/shell/common/BUILD.gn index 74ab39e06eb..0091d5bf023 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 e0a7c932714..80ae36a7e57 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 00000000000..0214a4d767b --- /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 00000000000..86525de6201 --- /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 00000000000..66ca9fdd8e1 --- /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 00000000000..1c9ca4d1d7c --- /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_