Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions build/git_revision.py
Original file line number Diff line number Diff line change
@@ -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())
2 changes: 2 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ source_set("common") {
]

public_deps = [
"$flutter_root/shell/version",
"$flutter_root/third_party/txt",
"//third_party/tonic",
]
Expand Down
9 changes: 9 additions & 0 deletions shell/common/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions shell/version/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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 changes: 21 additions & 0 deletions shell/version/version.cc
Original file line number Diff line number Diff line change
@@ -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 changes: 44 additions & 0 deletions shell/version/version.gni
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions shell/version/version.h
Original file line number Diff line number Diff line change
@@ -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_