forked from firka/flutter
[web] Move unicode properties to third_party (flutter/engine#37440)
* [web] Move unicode properties to third_party * license * fix license check * attempt to fix license golden * more license fixes * even more license fixes * add check mode and readme file * fix licenses + add web_unicode.dart * build web_unicode as an sdk library * remove unnecessary variable * minor fix in license golden * tool signature
This commit is contained in:
@@ -121,7 +121,7 @@ function verify_licenses() (
|
||||
|
||||
local actualLicenseCount
|
||||
actualLicenseCount="$(tail -n 1 flutter/ci/licenses_golden/licenses_flutter | tr -dc '0-9')"
|
||||
local expectedLicenseCount=16 # When changing this number: Update the error message below as well describing all expected license types.
|
||||
local expectedLicenseCount=17 # When changing this number: Update the error message below as well describing all expected license types.
|
||||
|
||||
if [[ $actualLicenseCount -ne $expectedLicenseCount ]]; then
|
||||
echo "=============================== ERROR ==============================="
|
||||
|
||||
@@ -613,6 +613,7 @@ LIBRARY: accessibility
|
||||
LIBRARY: engine
|
||||
LIBRARY: tonic
|
||||
LIBRARY: txt
|
||||
LIBRARY: web_unicode
|
||||
ORIGIN: ../../../flutter/LICENSE
|
||||
TYPE: LicenseType.bsd
|
||||
FILE: ../../../flutter/.clang-tidy
|
||||
@@ -2001,7 +2002,6 @@ FILE: ../../../flutter/lib/web_ui/lib/text.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/tile_mode.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/ui.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/window.dart
|
||||
FILE: ../../../flutter/lib/web_ui/tool/unicode_sync_script.dart
|
||||
FILE: ../../../flutter/runtime/dart_isolate.cc
|
||||
FILE: ../../../flutter/runtime/dart_isolate.h
|
||||
FILE: ../../../flutter/runtime/dart_isolate_group_data.cc
|
||||
@@ -3286,6 +3286,8 @@ FILE: ../../../flutter/third_party/txt/src/txt/platform_fuchsia.cc
|
||||
FILE: ../../../flutter/third_party/txt/src/txt/platform_linux.cc
|
||||
FILE: ../../../flutter/third_party/txt/src/txt/platform_mac.mm
|
||||
FILE: ../../../flutter/third_party/txt/src/txt/platform_windows.cc
|
||||
FILE: ../../../flutter/third_party/web_unicode/lib/web_unicode.dart
|
||||
FILE: ../../../flutter/third_party/web_unicode/tool/unicode_sync_script.dart
|
||||
FILE: ../../../flutter/vulkan/procs/vulkan_handle.cc
|
||||
FILE: ../../../flutter/vulkan/procs/vulkan_handle.h
|
||||
FILE: ../../../flutter/vulkan/procs/vulkan_interface.cc
|
||||
@@ -3704,4 +3706,59 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
====================================================================================================
|
||||
Total license count: 16
|
||||
|
||||
====================================================================================================
|
||||
LIBRARY: web_unicode
|
||||
ORIGIN: ../../../flutter/third_party/web_unicode/LICENSE
|
||||
TYPE: LicenseType.unknown
|
||||
FILE: ../../../flutter/third_party/web_unicode/lib/web_unicode/codegen/line_break_properties.dart
|
||||
FILE: ../../../flutter/third_party/web_unicode/lib/web_unicode/codegen/word_break_properties.dart
|
||||
----------------------------------------------------------------------------------------------------
|
||||
UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
|
||||
|
||||
See Terms of Use <https://www.unicode.org/copyright.html>
|
||||
for definitions of Unicode Inc.’s Data Files and Software.
|
||||
|
||||
NOTICE TO USER: Carefully read the following legal agreement.
|
||||
BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
|
||||
DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
|
||||
YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
|
||||
TERMS AND CONDITIONS OF THIS AGREEMENT.
|
||||
IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
|
||||
THE DATA FILES OR SOFTWARE.
|
||||
|
||||
COPYRIGHT AND PERMISSION NOTICE
|
||||
|
||||
Copyright © 1991-2022 Unicode, Inc. All rights reserved.
|
||||
Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Unicode data files and any associated documentation
|
||||
(the "Data Files") or Unicode software and any associated documentation
|
||||
(the "Software") to deal in the Data Files or Software
|
||||
without restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, and/or sell copies of
|
||||
the Data Files or Software, and to permit persons to whom the Data Files
|
||||
or Software are furnished to do so, provided that either
|
||||
(a) this copyright and permission notice appear with all copies
|
||||
of the Data Files or Software, or
|
||||
(b) this copyright and permission notice appear in associated
|
||||
Documentation.
|
||||
|
||||
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
|
||||
NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
|
||||
DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THE DATA FILES OR SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of a copyright holder
|
||||
shall not be used in advertising or otherwise to promote the sale,
|
||||
use or other dealings in these Data Files or Software without prior
|
||||
written authorization of the copyright holder.
|
||||
====================================================================================================
|
||||
Total license count: 17
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Signature: 9081858dc189235efdea91ba5c55b432
|
||||
Signature: 027af91b165acaa447651bfca8c7c704
|
||||
|
||||
|
||||
@@ -339,3 +339,7 @@ Once you know the version for the Emscripten SDK, change the line in
|
||||
[4]: https://chrome-infra-packages.appspot.com/p/flutter_internal
|
||||
[5]: https://cs.opensource.google/flutter/recipes/+/master:recipes/engine/web_engine.py
|
||||
[6]: https://chromium.googlesource.com/chromium/src.git/+/main/docs/cipd_and_3pp.md#What-is-CIPD
|
||||
|
||||
## Unicode properties
|
||||
|
||||
We pull the unicode properties we need from `third_party/web_unicode`. See `third_party/web_unicode/README.md` for more details on how we generate Dart code from unicode properties.
|
||||
|
||||
@@ -35,7 +35,6 @@ class LicensesCommand extends Command<bool> {
|
||||
'lib',
|
||||
'test',
|
||||
'dev',
|
||||
'tool'
|
||||
]) {
|
||||
final String expectedAbsoluteDirectory =
|
||||
path.join(environment.webUiRootDir.path, expectedDirectory);
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -9,6 +9,9 @@ dependencies:
|
||||
js: 0.6.4
|
||||
meta: ^1.7.0
|
||||
|
||||
web_unicode:
|
||||
path: ../../third_party/web_unicode
|
||||
|
||||
dev_dependencies:
|
||||
archive: 3.1.2
|
||||
args: any
|
||||
|
||||
46
engine/src/flutter/third_party/web_unicode/LICENSE
vendored
Normal file
46
engine/src/flutter/third_party/web_unicode/LICENSE
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
|
||||
|
||||
See Terms of Use <https://www.unicode.org/copyright.html>
|
||||
for definitions of Unicode Inc.’s Data Files and Software.
|
||||
|
||||
NOTICE TO USER: Carefully read the following legal agreement.
|
||||
BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
|
||||
DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
|
||||
YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
|
||||
TERMS AND CONDITIONS OF THIS AGREEMENT.
|
||||
IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
|
||||
THE DATA FILES OR SOFTWARE.
|
||||
|
||||
COPYRIGHT AND PERMISSION NOTICE
|
||||
|
||||
Copyright © 1991-2022 Unicode, Inc. All rights reserved.
|
||||
Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Unicode data files and any associated documentation
|
||||
(the "Data Files") or Unicode software and any associated documentation
|
||||
(the "Software") to deal in the Data Files or Software
|
||||
without restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, and/or sell copies of
|
||||
the Data Files or Software, and to permit persons to whom the Data Files
|
||||
or Software are furnished to do so, provided that either
|
||||
(a) this copyright and permission notice appear with all copies
|
||||
of the Data Files or Software, or
|
||||
(b) this copyright and permission notice appear in associated
|
||||
Documentation.
|
||||
|
||||
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
|
||||
NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
|
||||
DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THE DATA FILES OR SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of a copyright holder
|
||||
shall not be used in advertising or otherwise to promote the sale,
|
||||
use or other dealings in these Data Files or Software without prior
|
||||
written authorization of the copyright holder.
|
||||
25
engine/src/flutter/third_party/web_unicode/README.md
vendored
Normal file
25
engine/src/flutter/third_party/web_unicode/README.md
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
## Usage ##
|
||||
|
||||
To generate code for line/word break properties, follow these steps:
|
||||
|
||||
### 1. **<u>Download the unicode files:</u>**
|
||||
|
||||
The properties files can be found on the unicode.org website, for example [LineBreak.txt](https://www.unicode.org/Public/13.0.0/ucd/LineBreak.txt) and [WordBreakProperty.txt](https://www.unicode.org/Public/13.0.0/ucd/auxiliary/WordBreakProperty.txt). The codegen script expects the files to be located at `third_party/web_unicode/properties/`.
|
||||
|
||||
### 2. **<u>Run the codegen script:</u>**
|
||||
|
||||
Inside the `third_party/web_unicode` directory:
|
||||
```
|
||||
dart tool/unicode_sync_script.dart
|
||||
```
|
||||
|
||||
## Check Mode ##
|
||||
|
||||
If you don't want to generate code, but you want to make sure that the properties files and the codegen files are still in sync, you can run the codegen script in "check mode".
|
||||
|
||||
Inside the `third_party/web_unicode` directory:
|
||||
```
|
||||
dart tool/unicode_sync_script.dart --check
|
||||
```
|
||||
|
||||
This command won't overwite the existing codegen files. It only checks whether they are still in sync with the properties files or not. If not, it exits with a non-zero exit code.
|
||||
8
engine/src/flutter/third_party/web_unicode/lib/web_unicode.dart
vendored
Normal file
8
engine/src/flutter/third_party/web_unicode/lib/web_unicode.dart
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
// 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.
|
||||
|
||||
library web_unicode;
|
||||
|
||||
export 'web_unicode/codegen/line_break_properties.dart';
|
||||
export 'web_unicode/codegen/word_break_properties.dart';
|
||||
61
engine/src/flutter/third_party/web_unicode/lib/web_unicode/codegen/line_break_properties.dart
vendored
Normal file
61
engine/src/flutter/third_party/web_unicode/lib/web_unicode/codegen/line_break_properties.dart
vendored
Normal file
File diff suppressed because one or more lines are too long
40
engine/src/flutter/third_party/web_unicode/lib/web_unicode/codegen/word_break_properties.dart
vendored
Normal file
40
engine/src/flutter/third_party/web_unicode/lib/web_unicode/codegen/word_break_properties.dart
vendored
Normal file
File diff suppressed because one or more lines are too long
3487
engine/src/flutter/third_party/web_unicode/properties/LineBreak.txt
vendored
Normal file
3487
engine/src/flutter/third_party/web_unicode/properties/LineBreak.txt
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1397
engine/src/flutter/third_party/web_unicode/properties/WordBreakProperty.txt
vendored
Normal file
1397
engine/src/flutter/third_party/web_unicode/properties/WordBreakProperty.txt
vendored
Normal file
File diff suppressed because it is too large
Load Diff
10
engine/src/flutter/third_party/web_unicode/pubspec.yaml
vendored
Normal file
10
engine/src/flutter/third_party/web_unicode/pubspec.yaml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
name: web_unicode
|
||||
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: ">=2.12.0-0 <3.0.0"
|
||||
|
||||
dev_dependencies:
|
||||
args: any
|
||||
path: any
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// ignore_for_file: avoid_print
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/args.dart';
|
||||
@@ -11,21 +13,10 @@ const int _kChar_A = 65;
|
||||
const int _kChar_a = 97;
|
||||
|
||||
final ArgParser argParser = ArgParser()
|
||||
..addOption(
|
||||
'words',
|
||||
abbr: 'w',
|
||||
help: 'Sync the word break properties.',
|
||||
)
|
||||
..addOption(
|
||||
'lines',
|
||||
abbr: 'l',
|
||||
help: 'Sync the line break properties.',
|
||||
)
|
||||
..addFlag(
|
||||
'dry',
|
||||
abbr: 'd',
|
||||
help: 'Dry mode does not write anything to disk. '
|
||||
'The output is printed to the console.',
|
||||
'check',
|
||||
help: 'Check mode does not write anything to disk. '
|
||||
'It just checks if the generated files are still in sync or not.',
|
||||
);
|
||||
|
||||
/// A map of properties that could safely be normalized into other properties.
|
||||
@@ -76,33 +67,16 @@ class UnicodeRange {
|
||||
}
|
||||
}
|
||||
|
||||
final String codegenPath = path.join(
|
||||
path.dirname(Platform.script.toFilePath()),
|
||||
'../lib/src/engine/text',
|
||||
);
|
||||
final String wordBreakCodegen =
|
||||
path.join(codegenPath, 'word_break_properties.dart');
|
||||
final String lineBreakCodegen =
|
||||
path.join(codegenPath, 'line_break_properties.dart');
|
||||
final String webUnicodeRoot = path.dirname(path.dirname(Platform.script.toFilePath()));
|
||||
|
||||
final String propertiesDir = path.join(webUnicodeRoot, 'properties');
|
||||
final String wordProperties = path.join(propertiesDir, 'WordBreakProperty.txt');
|
||||
final String lineProperties = path.join(propertiesDir, 'LineBreak.txt');
|
||||
|
||||
final String codegenDir = path.join(webUnicodeRoot, 'lib', 'codegen');
|
||||
final String wordBreakCodegen = path.join(codegenDir, 'word_break_properties.dart');
|
||||
final String lineBreakCodegen = path.join(codegenDir, 'line_break_properties.dart');
|
||||
|
||||
/// Usage (from the root of the web_ui project).
|
||||
///
|
||||
/// To generate code for word break properties:
|
||||
/// ```
|
||||
/// dart tool/unicode_sync_script.dart -w <path/to/word/break/properties>
|
||||
/// ```
|
||||
///
|
||||
/// To generate code for line break properties:
|
||||
/// ```
|
||||
/// dart tool/unicode_sync_script.dart -l <path/to/line/break/properties>
|
||||
/// ```
|
||||
///
|
||||
/// To do a dry run, add the `-d` flag:
|
||||
///
|
||||
/// ```
|
||||
/// dart tool/unicode_sync_script.dart -d ...
|
||||
/// ```
|
||||
///
|
||||
/// This script parses the unicode word/line break properties(1) and generates Dart
|
||||
/// code(2) that can perform lookups in the unicode ranges to find what property
|
||||
/// a letter has.
|
||||
@@ -113,45 +87,21 @@ final String lineBreakCodegen =
|
||||
/// The line break properties file can be downloaded from:
|
||||
/// https://www.unicode.org/Public/13.0.0/ucd/LineBreak.txt
|
||||
///
|
||||
/// (2) The codegen'd Dart files is located at:
|
||||
/// lib/src/engine/text/word_break_properties.dart
|
||||
/// lib/src/engine/text/line_break_properties.dart
|
||||
/// Both files need to be located at third_party/web_unicode/properties.
|
||||
///
|
||||
/// (2) The codegen'd Dart files are located at:
|
||||
/// third_party/web_unicode/lib/codegen/word_break_properties.dart
|
||||
/// third_party/web_unicode/lib/codegen/line_break_properties.dart
|
||||
Future<void> main(List<String> arguments) async {
|
||||
final ArgResults result = argParser.parse(arguments);
|
||||
final PropertiesSyncer syncer = getSyncer(
|
||||
result['words'] as String?,
|
||||
result['lines'] as String?,
|
||||
result['dry'] as bool,
|
||||
);
|
||||
final bool isCheck = result['check'] as bool;
|
||||
final List<PropertiesSyncer> syncers = <PropertiesSyncer>[
|
||||
WordBreakPropertiesSyncer(isCheck: isCheck),
|
||||
LineBreakPropertiesSyncer(isCheck: isCheck),
|
||||
];
|
||||
|
||||
await syncer.perform();
|
||||
}
|
||||
|
||||
PropertiesSyncer getSyncer(
|
||||
String? wordBreakProperties,
|
||||
String? lineBreakProperties,
|
||||
bool dry,
|
||||
) {
|
||||
if (wordBreakProperties == null && lineBreakProperties == null) {
|
||||
print(
|
||||
'Expecting either a word break properties file or a line break properties file. None was given.\n');
|
||||
print(argParser.usage);
|
||||
exit(64);
|
||||
}
|
||||
if (wordBreakProperties != null && lineBreakProperties != null) {
|
||||
print(
|
||||
'Expecting either a word break properties file or a line break properties file. Both were given.\n');
|
||||
print(argParser.usage);
|
||||
exit(64);
|
||||
}
|
||||
if (wordBreakProperties != null) {
|
||||
return dry
|
||||
? WordBreakPropertiesSyncer.dry(wordBreakProperties)
|
||||
: WordBreakPropertiesSyncer(wordBreakProperties, wordBreakCodegen);
|
||||
} else {
|
||||
return dry
|
||||
? LineBreakPropertiesSyncer.dry(lineBreakProperties!)
|
||||
: LineBreakPropertiesSyncer(lineBreakProperties!, lineBreakCodegen);
|
||||
for (final PropertiesSyncer syncer in syncers) {
|
||||
await syncer.perform();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,14 +111,11 @@ PropertiesSyncer getSyncer(
|
||||
/// Subclasses implement the [template] method which receives as argument the
|
||||
/// list of data parsed by [processLines].
|
||||
abstract class PropertiesSyncer {
|
||||
PropertiesSyncer(this._src, this._dest) : _dryRun = false;
|
||||
PropertiesSyncer.dry(this._src)
|
||||
: _dest = null,
|
||||
_dryRun = true;
|
||||
PropertiesSyncer(this._src, this._dest, {required this.isCheck});
|
||||
|
||||
final String _src;
|
||||
final String? _dest;
|
||||
final bool _dryRun;
|
||||
final String _dest;
|
||||
final bool isCheck;
|
||||
|
||||
String get prefix;
|
||||
String get enumDocLink;
|
||||
@@ -179,33 +126,36 @@ abstract class PropertiesSyncer {
|
||||
|
||||
Future<void> perform() async {
|
||||
final List<String> lines = await File(_src).readAsLines();
|
||||
final List<String> header = extractHeader(lines);
|
||||
final PropertyCollection data =
|
||||
PropertyCollection.fromLines(lines, defaultProperty);
|
||||
|
||||
final String output = template(header, data);
|
||||
final String output = template(data);
|
||||
|
||||
if (_dryRun) {
|
||||
print(output);
|
||||
if (isCheck) {
|
||||
// Read from destination and compare to the generated output.
|
||||
final String existing = await File(_dest).readAsString();
|
||||
if (existing != output) {
|
||||
final String relativeDest = path.relative(_dest, from: webUnicodeRoot);
|
||||
print('ERROR: $relativeDest is out of sync.');
|
||||
print('Please run "dart tool/unicode_sync_script.dart" to update it.');
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
final IOSink sink = File(_dest!).openWrite();
|
||||
final IOSink sink = File(_dest).openWrite();
|
||||
sink.write(output);
|
||||
}
|
||||
}
|
||||
|
||||
String template(List<String> header, PropertyCollection data) {
|
||||
String template(PropertyCollection data) {
|
||||
return '''
|
||||
// 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.
|
||||
// Copyright 2022 Google LLC
|
||||
//
|
||||
// For terms of use, see https://www.unicode.org/copyright.html
|
||||
|
||||
// AUTO-GENERATED FILE.
|
||||
// Generated by: tool/unicode_sync_script.dart
|
||||
//
|
||||
// Source:
|
||||
// ${header.join('\n// ')}
|
||||
|
||||
import 'unicode_range.dart';
|
||||
// ignore_for_file: public_member_api_docs
|
||||
|
||||
/// For an explanation of these enum values, see:
|
||||
///
|
||||
@@ -214,17 +164,12 @@ enum ${prefix}CharProperty {
|
||||
${_getEnumValues(data.enumCollection).join('\n ')}
|
||||
}
|
||||
|
||||
const String _packed${prefix}BreakProperties =
|
||||
const String packed${prefix}BreakProperties =
|
||||
'${_packProperties(data)}';
|
||||
|
||||
const int single${prefix}BreakRangesCount = ${_getSingleRangesCount(data)};
|
||||
|
||||
UnicodePropertyLookup<${prefix}CharProperty> ${prefix.toLowerCase()}Lookup =
|
||||
UnicodePropertyLookup<${prefix}CharProperty>.fromPackedData(
|
||||
_packed${prefix}BreakProperties,
|
||||
${_getSingleRangesCount(data)},
|
||||
${prefix}CharProperty.values,
|
||||
${prefix}CharProperty.$defaultProperty,
|
||||
);
|
||||
const ${prefix}CharProperty default${prefix}CharProperty = ${prefix}CharProperty.$defaultProperty;
|
||||
''';
|
||||
}
|
||||
|
||||
@@ -265,8 +210,8 @@ UnicodePropertyLookup<${prefix}CharProperty> ${prefix.toLowerCase()}Lookup =
|
||||
|
||||
/// Syncs Unicode's word break properties.
|
||||
class WordBreakPropertiesSyncer extends PropertiesSyncer {
|
||||
WordBreakPropertiesSyncer(super.src, String super.dest);
|
||||
WordBreakPropertiesSyncer.dry(super.src) : super.dry();
|
||||
WordBreakPropertiesSyncer({required bool isCheck})
|
||||
: super(wordProperties, wordBreakCodegen, isCheck: isCheck);
|
||||
|
||||
@override
|
||||
final String prefix = 'Word';
|
||||
@@ -281,8 +226,8 @@ class WordBreakPropertiesSyncer extends PropertiesSyncer {
|
||||
|
||||
/// Syncs Unicode's line break properties.
|
||||
class LineBreakPropertiesSyncer extends PropertiesSyncer {
|
||||
LineBreakPropertiesSyncer(super.src, String super.dest);
|
||||
LineBreakPropertiesSyncer.dry(super.src) : super.dry();
|
||||
LineBreakPropertiesSyncer({required bool isCheck})
|
||||
: super(lineProperties, lineBreakCodegen, isCheck: isCheck);
|
||||
|
||||
@override
|
||||
final String prefix = 'Line';
|
||||
@@ -477,19 +422,6 @@ void verifyNoOverlappingRanges(List<UnicodeRange> data) {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> extractHeader(List<String> lines) {
|
||||
final List<String> headerLines = <String>[];
|
||||
for (final String line in lines) {
|
||||
if (line.trim() == '#' || line.trim().isEmpty) {
|
||||
break;
|
||||
}
|
||||
if (line.isNotEmpty) {
|
||||
headerLines.add(line);
|
||||
}
|
||||
}
|
||||
return headerLines;
|
||||
}
|
||||
|
||||
String removeCommentFromLine(String line) {
|
||||
final int poundIdx = line.indexOf('#');
|
||||
return (poundIdx == -1) ? line : line.substring(0, poundIdx);
|
||||
@@ -1206,6 +1206,19 @@ final List<MultipleVersionedLicenseReferencePattern> csReferencesByUrl = <Multip
|
||||
caseSensitive: false,
|
||||
)
|
||||
),
|
||||
|
||||
// Unicode terms of use
|
||||
MultipleVersionedLicenseReferencePattern(
|
||||
firstPrefixIndex: 1,
|
||||
indentPrefixIndex: 2,
|
||||
licenseIndices: const <int>[3],
|
||||
checkLocalFirst: false,
|
||||
pattern: RegExp(
|
||||
kIndent +
|
||||
r'\n// For terms of use, see (https://www.unicode.org/copyright.html)\n',
|
||||
caseSensitive: false,
|
||||
)
|
||||
),
|
||||
];
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,15 @@ web_ui_sources = exec_script("//third_party/dart/tools/list_dart_files.py",
|
||||
],
|
||||
"list lines")
|
||||
|
||||
web_engine_libraries = [
|
||||
":skwasm_impl_library",
|
||||
":skwasm_stub_library",
|
||||
":web_engine_library",
|
||||
":web_ui_library",
|
||||
":web_ui_library_sources",
|
||||
":web_unicode_library",
|
||||
]
|
||||
|
||||
group("web_sdk") {
|
||||
deps = [
|
||||
":flutter_ddc_modules",
|
||||
@@ -128,6 +137,13 @@ sdk_rewriter("skwasm_impl_library") {
|
||||
output_dir = "$root_out_dir/flutter_web_sdk/lib/_skwasm_impl/"
|
||||
}
|
||||
|
||||
sdk_rewriter("web_unicode_library") {
|
||||
library_name = "web_unicode"
|
||||
api_file = "//flutter/third_party/web_unicode/lib/web_unicode.dart"
|
||||
input_dir = "//flutter/third_party/web_unicode/lib/web_unicode/"
|
||||
output_dir = "$root_out_dir/flutter_web_sdk/lib/_web_unicode/"
|
||||
}
|
||||
|
||||
copy("web_ui_library") {
|
||||
sources = [ "//flutter/web_sdk/libraries.json" ]
|
||||
|
||||
@@ -147,13 +163,7 @@ template("_dartdevc") {
|
||||
if (flutter_prebuilt_dart_sdk) {
|
||||
action(target_name) {
|
||||
not_needed(invoker, [ "packages" ])
|
||||
deps = [
|
||||
":skwasm_impl_library",
|
||||
":skwasm_stub_library",
|
||||
":web_engine_library",
|
||||
":web_ui_library",
|
||||
":web_ui_library_sources",
|
||||
]
|
||||
deps = web_engine_libraries
|
||||
script = "//build/gn_run_binary.py"
|
||||
|
||||
inputs = invoker.inputs
|
||||
@@ -177,17 +187,12 @@ template("_dartdevc") {
|
||||
prebuilt_dart_action(target_name) {
|
||||
forward_variables_from(invoker, "*")
|
||||
|
||||
deps = [
|
||||
":skwasm_impl_library",
|
||||
":skwasm_stub_library",
|
||||
":web_engine_library",
|
||||
":web_ui_library",
|
||||
":web_ui_library_sources",
|
||||
"//third_party/dart:create_sdk",
|
||||
"//third_party/dart/pkg:pkg_files_stamp",
|
||||
"//third_party/dart/utils/dartdevc:dartdevc_files_stamp",
|
||||
"//third_party/dart/utils/dartdevc:dartdevc_sdk_patch_stamp",
|
||||
]
|
||||
deps = web_engine_libraries + [
|
||||
"//third_party/dart:create_sdk",
|
||||
"//third_party/dart/pkg:pkg_files_stamp",
|
||||
"//third_party/dart/utils/dartdevc:dartdevc_files_stamp",
|
||||
"//third_party/dart/utils/dartdevc:dartdevc_sdk_patch_stamp",
|
||||
]
|
||||
|
||||
script = "//third_party/dart/pkg/dev_compiler/bin/dartdevc.dart"
|
||||
|
||||
@@ -208,13 +213,7 @@ template("_dartdevc") {
|
||||
template("_kernel_worker") {
|
||||
if (flutter_prebuilt_dart_sdk) {
|
||||
action(target_name) {
|
||||
deps = [
|
||||
":skwasm_impl_library",
|
||||
":skwasm_stub_library",
|
||||
":web_engine_library",
|
||||
":web_ui_library",
|
||||
":web_ui_library_sources",
|
||||
]
|
||||
deps = web_engine_libraries
|
||||
script = "//build/gn_run_binary.py"
|
||||
|
||||
inputs = invoker.inputs
|
||||
@@ -239,17 +238,12 @@ template("_kernel_worker") {
|
||||
prebuilt_dart_action(target_name) {
|
||||
forward_variables_from(invoker, "*")
|
||||
|
||||
deps = [
|
||||
":skwasm_impl_library",
|
||||
":skwasm_stub_library",
|
||||
":web_engine_library",
|
||||
":web_ui_library",
|
||||
":web_ui_library_sources",
|
||||
"//third_party/dart:create_sdk",
|
||||
"//third_party/dart/pkg:pkg_files_stamp",
|
||||
"//third_party/dart/utils/dartdevc:dartdevc_files_stamp",
|
||||
"//third_party/dart/utils/dartdevc:dartdevc_sdk_patch_stamp",
|
||||
]
|
||||
deps = web_engine_libraries + [
|
||||
"//third_party/dart:create_sdk",
|
||||
"//third_party/dart/pkg:pkg_files_stamp",
|
||||
"//third_party/dart/utils/dartdevc:dartdevc_files_stamp",
|
||||
"//third_party/dart/utils/dartdevc:dartdevc_sdk_patch_stamp",
|
||||
]
|
||||
|
||||
script = "//third_party/dart/utils/bazel/kernel_worker.dart"
|
||||
|
||||
@@ -306,6 +300,8 @@ template("_compile_platform") {
|
||||
"dart:_engine",
|
||||
"--source",
|
||||
"dart:_skwasm_stub",
|
||||
"--source",
|
||||
"dart:_web_unicode",
|
||||
]
|
||||
if (flutter_prebuilt_dart_sdk) {
|
||||
args += [
|
||||
@@ -477,6 +473,7 @@ template("_compile_ddc_modules") {
|
||||
"dart:ui",
|
||||
"dart:_engine",
|
||||
"dart:_skwasm_stub",
|
||||
"dart:_web_unicode",
|
||||
"--no-summarize",
|
||||
"--packages",
|
||||
"file:///" + rebase_path(dart_sdk_package_config),
|
||||
@@ -579,15 +576,10 @@ if (!is_fuchsia) {
|
||||
output = "flutter-web-sdk-${full_platform_name}.zip"
|
||||
}
|
||||
deps = [
|
||||
":flutter_ddc_modules",
|
||||
":flutter_legacy_platform_dills",
|
||||
":flutter_web_platforms",
|
||||
":skwasm_impl_library",
|
||||
":skwasm_stub_library",
|
||||
":web_engine_library",
|
||||
":web_ui_library",
|
||||
":web_ui_library_sources",
|
||||
]
|
||||
":flutter_ddc_modules",
|
||||
":flutter_legacy_platform_dills",
|
||||
":flutter_web_platforms",
|
||||
] + web_engine_libraries
|
||||
|
||||
if (build_canvaskit) {
|
||||
deps += [ "//third_party/skia/modules/canvaskit" ]
|
||||
@@ -623,11 +615,10 @@ if (!is_fuchsia) {
|
||||
sources += get_target_outputs(":flutter_canvaskit_platform_dart2js_sound")
|
||||
sources += get_target_outputs(":flutter_canvaskit_platform_dart2js_unsound")
|
||||
|
||||
sources += get_target_outputs(":web_ui_library")
|
||||
sources += get_target_outputs(":web_ui_library_sources")
|
||||
sources += get_target_outputs(":skwasm_stub_library")
|
||||
sources += get_target_outputs(":skwasm_impl_library")
|
||||
sources += get_target_outputs(":web_engine_library")
|
||||
foreach(web_engine_library, web_engine_libraries) {
|
||||
sources += get_target_outputs(web_engine_library)
|
||||
}
|
||||
|
||||
tmp_files = []
|
||||
foreach(source, sources) {
|
||||
tmp_files += [
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
},
|
||||
"_skwasm_stub": {
|
||||
"uri": "lib/_skwasm_stub/skwasm_stub.dart"
|
||||
},
|
||||
"_web_unicode": {
|
||||
"uri": "lib/_web_unicode/web_unicode.dart"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -36,6 +39,9 @@
|
||||
},
|
||||
"_skwasm_stub": {
|
||||
"uri": "lib/_skwasm_stub/skwasm_stub.dart"
|
||||
},
|
||||
"_web_unicode": {
|
||||
"uri": "lib/_web_unicode/web_unicode.dart"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -55,6 +61,9 @@
|
||||
},
|
||||
"_skwasm_impl": {
|
||||
"uri": "lib/_skwasm_impl/skwasm_impl.dart"
|
||||
},
|
||||
"_web_unicode": {
|
||||
"uri": "lib/_web_unicode/web_unicode.dart"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ dartdevc:
|
||||
_skwasm_stub:
|
||||
uri: "lib/_skwasm_stub/skwasm_stub.dart"
|
||||
|
||||
_web_unicode:
|
||||
uri: "lib/_web_unicode/web_unicode.dart"
|
||||
|
||||
dart2js:
|
||||
include:
|
||||
- {path: "../dart-sdk/lib/libraries.json", target: dart2js}
|
||||
@@ -41,6 +44,9 @@ dart2js:
|
||||
_skwasm_stub:
|
||||
uri: "lib/_skwasm_stub/skwasm_stub.dart"
|
||||
|
||||
_web_unicode:
|
||||
uri: "lib/_web_unicode/web_unicode.dart"
|
||||
|
||||
wasm:
|
||||
include:
|
||||
- {path: "../dart-sdk/lib/libraries.json", target: wasm}
|
||||
@@ -54,3 +60,6 @@ wasm:
|
||||
|
||||
_skwasm_impl:
|
||||
uri: "lib/_skwasm_impl/skwasm_impl.dart"
|
||||
|
||||
_web_unicode:
|
||||
uri: "lib/_web_unicode/web_unicode.dart"
|
||||
|
||||
@@ -34,7 +34,7 @@ export 'dart:_engine'
|
||||
),
|
||||
];
|
||||
|
||||
List<Replacer> generateApiFilePatterns(String libraryName, String extraImports) {
|
||||
List<Replacer> generateApiFilePatterns(String libraryName, List<String> extraImports) {
|
||||
return <Replacer>[
|
||||
AllReplacer(RegExp('library\\s+$libraryName;'), '''
|
||||
@JS()
|
||||
@@ -49,7 +49,7 @@ import 'dart:_js_annotations';
|
||||
import 'dart:math' as math;
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
$extraImports
|
||||
${extraImports.join('\n')}
|
||||
'''
|
||||
),
|
||||
// Replace exports of engine files with "part" directives.
|
||||
@@ -84,6 +84,18 @@ final List<Replacer> stripMetaPatterns = <Replacer>[
|
||||
AllReplacer('@visibleForTesting', ''),
|
||||
];
|
||||
|
||||
const Set<String> rootLibraryNames = <String>{
|
||||
'engine',
|
||||
'skwasm_stub',
|
||||
'skwasm_impl',
|
||||
};
|
||||
|
||||
final Map<Pattern, String> extraImportsMap = <Pattern, String>{
|
||||
RegExp('skwasm_(stub|impl)'): "import 'dart:_skwasm_stub' if (dart.library.ffi) 'dart:_skwasm_impl';",
|
||||
'engine': "import 'dart:_engine';",
|
||||
'web_unicode': "import 'dart:_web_unicode';",
|
||||
};
|
||||
|
||||
// Rewrites the "package"-style web ui library into a dart:ui implementation.
|
||||
// So far this only requires a replace of the library declarations.
|
||||
void main(List<String> arguments) {
|
||||
@@ -94,6 +106,7 @@ void main(List<String> arguments) {
|
||||
String Function(String source)? preprocessor;
|
||||
List<Replacer> replacementPatterns;
|
||||
String? libraryName;
|
||||
|
||||
if (results['ui'] as bool) {
|
||||
replacementPatterns = uiPatterns;
|
||||
} else {
|
||||
@@ -121,12 +134,8 @@ void main(List<String> arguments) {
|
||||
final String inputFilePath = results['api-file'] as String;
|
||||
final String outputFilePath = path.join(
|
||||
directory.path, path.basename(inputFilePath));
|
||||
String extraImports = '';
|
||||
if (libraryName == 'engine') {
|
||||
extraImports = "import 'dart:_skwasm_stub' if (dart.library.ffi) 'dart:_skwasm_impl';\n";
|
||||
} else if (libraryName == 'skwasm_stub' || libraryName == 'skwasm_impl') {
|
||||
extraImports = "import 'dart:_engine';\n";
|
||||
}
|
||||
|
||||
final List<String> extraImports = getExtraImportsForLibrary(libraryName);
|
||||
replacementPatterns = generateApiFilePatterns(libraryName, extraImports);
|
||||
|
||||
processFile(
|
||||
@@ -143,6 +152,22 @@ void main(List<String> arguments) {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> getExtraImportsForLibrary(String libraryName) {
|
||||
// Only our root libraries should have extra imports.
|
||||
if (!rootLibraryNames.contains(libraryName)) {
|
||||
return <String>[];
|
||||
}
|
||||
|
||||
final List<String> extraImports = <String>[];
|
||||
for (final MapEntry<Pattern, String> entry in extraImportsMap.entries) {
|
||||
// A library shouldn't import itself.
|
||||
if (entry.key.matchAsPrefix(libraryName) == null) {
|
||||
extraImports.add(entry.value);
|
||||
}
|
||||
}
|
||||
return extraImports;
|
||||
}
|
||||
|
||||
void processFile(String inputFilePath, String outputFilePath, String Function(String source)? preprocessor, List<Replacer> replacementPatterns) {
|
||||
final File inputFile = File(inputFilePath);
|
||||
final File outputFile = File(outputFilePath)
|
||||
|
||||
@@ -38,7 +38,6 @@ import 'dart:ui' as ui;
|
||||
import 'dart:extra';
|
||||
|
||||
|
||||
|
||||
// Comment 2
|
||||
|
||||
part 'engine/file1.dart';
|
||||
@@ -52,7 +51,7 @@ part 'engine/file3.dart';
|
||||
'/path/to/lib/web_ui/lib/src/engine.dart',
|
||||
source,
|
||||
'engine'),
|
||||
generateApiFilePatterns('engine', "import 'dart:extra';\n"),
|
||||
generateApiFilePatterns('engine', <String>["import 'dart:extra';"]),
|
||||
);
|
||||
expect(result, expected);
|
||||
});
|
||||
@@ -74,7 +73,7 @@ export 'engine/file3.dart';
|
||||
'/path/to/lib/web_ui/lib/src/engine.dart',
|
||||
source,
|
||||
'engine'),
|
||||
generateApiFilePatterns('engine', ''),
|
||||
generateApiFilePatterns('engine', <String>[]),
|
||||
);
|
||||
} catch(error) {
|
||||
caught = error;
|
||||
@@ -125,4 +124,23 @@ void printSomething() {
|
||||
);
|
||||
expect(result, expected);
|
||||
});
|
||||
|
||||
test('gets correct extra imports', () {
|
||||
// Root libraries.
|
||||
expect(getExtraImportsForLibrary('engine'), <String>[
|
||||
"import 'dart:_skwasm_stub' if (dart.library.ffi) 'dart:_skwasm_impl';",
|
||||
"import 'dart:_web_unicode';",
|
||||
]);
|
||||
expect(getExtraImportsForLibrary('skwasm_stub'), <String>[
|
||||
"import 'dart:_engine';",
|
||||
"import 'dart:_web_unicode';",
|
||||
]);
|
||||
expect(getExtraImportsForLibrary('skwasm_impl'), <String>[
|
||||
"import 'dart:_engine';",
|
||||
"import 'dart:_web_unicode';",
|
||||
]);
|
||||
|
||||
// Other libraries (should not have extra imports).
|
||||
expect(getExtraImportsForLibrary('web_unicode'), isEmpty);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user