forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose the Flutter engine, Dart and Skia versions to Dart. (flutter#7634
- Loading branch information
1 parent
64e1707
commit b94e759
Showing
17 changed files
with
170 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2013 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/lib/ui/versions.h" | ||
#include "flutter/common/version/version.h" | ||
#include "third_party/tonic/converter/dart_converter.h" | ||
#include "third_party/tonic/dart_library_natives.h" | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
using tonic::DartConverter; | ||
|
||
namespace blink { | ||
|
||
// returns a vector with 3 versions. | ||
// Dart, Skia and Flutter engine versions in this order. | ||
void GetVersions(Dart_NativeArguments args) { | ||
const std::vector<std::string> versions_list = { | ||
GetDartVersion(), GetSkiaVersion(), GetFlutterEngineVersion()}; | ||
Dart_Handle dart_val = | ||
DartConverter<std::vector<std::string>>::ToDart(versions_list); | ||
Dart_SetReturnValue(args, dart_val); | ||
} | ||
|
||
void Versions::RegisterNatives(tonic::DartLibraryNatives* natives) { | ||
natives->Register({{"Versions_getVersions", GetVersions, 1, true}}); | ||
} | ||
|
||
} // namespace blink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2013 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. | ||
|
||
part of dart.ui; | ||
|
||
/// Wraps version information for Dart, Skia and Flutter. | ||
class Versions { | ||
|
||
/// Builds a versions object using the information | ||
/// we get from calling the native getVersions. | ||
factory Versions._internal() { | ||
final List<String> versions = _getVersions(); | ||
return Versions._(versions[0], versions[1], versions[2]); | ||
} | ||
|
||
/// Private constructor to capture the versions. | ||
Versions._( | ||
this.dartVersion, | ||
this.skiaVersion, | ||
this.flutterEngineVersion | ||
) : assert(dartVersion != null), | ||
assert(skiaVersion != null), | ||
assert(flutterEngineVersion != null); | ||
|
||
/// returns a vector with 3 versions. | ||
/// Dart, Skia and Flutter engine versions in this order. | ||
static List<String> _getVersions() native 'Versions_getVersions'; | ||
|
||
final String dartVersion; | ||
final String skiaVersion; | ||
final String flutterEngineVersion; | ||
} | ||
|
||
/// [Versions] singleton. This object exposes Dart, Skia and | ||
/// Flutter engine versions. | ||
final Versions versions = Versions._internal(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2013 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_LIB_UI_VERSIONS_H_ | ||
#define FLUTTER_LIB_UI_VERSIONS_H_ | ||
|
||
namespace tonic { | ||
class DartLibraryNatives; | ||
} // namespace tonic | ||
|
||
namespace blink { | ||
|
||
class Versions final { | ||
public: | ||
static void RegisterNatives(tonic::DartLibraryNatives* natives); | ||
}; | ||
|
||
} // namespace blink | ||
|
||
#endif // FLUTTER_LIB_UI_VERSIONS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2013 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. | ||
|
||
// HACK: pretend to be dart.ui in order to access its internals | ||
library dart.ui; | ||
|
||
import 'package:test/test.dart'; | ||
|
||
part '../../lib/ui/versions.dart'; | ||
|
||
bool _isNotEmpty(String s) { | ||
if (s == null || s.isEmpty) { | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
void main() { | ||
test('dartVersion should not be empty', () { | ||
final String dartVersion = versions.dartVersion; | ||
expect(_isNotEmpty(dartVersion), equals(true)); | ||
}); | ||
|
||
test('skiaVersion should not be empty', () { | ||
final String skiaVersion = versions.skiaVersion; | ||
expect(_isNotEmpty(skiaVersion), equals(true)); | ||
}); | ||
|
||
test('flutterEngineVersion should not be empty', () { | ||
final String flutterEngineVersion = versions.flutterEngineVersion; | ||
expect(_isNotEmpty(flutterEngineVersion), equals(true)); | ||
}); | ||
} |