diff --git a/bin/internal/engine.ohos.version b/bin/internal/engine.ohos.version index bc98d0949e060be690e40094a7f66a5032723ba9..ed63886244974d2b312f02721c0a9bf13a958560 100644 --- a/bin/internal/engine.ohos.version +++ b/bin/internal/engine.ohos.version @@ -1 +1 @@ -804c70a21f2a284868eb88f4bb7f22bc280a39cb +22e6beb953c7b5b1446d5a00eeba78c5d996c5c2 diff --git a/bin/internal/shared.bat b/bin/internal/shared.bat index 26fea942199a60517e4f448257e946d794cf5bb9..8f1e38b0e126e1dc5a32976644ede7b2dcc060ca 100644 --- a/bin/internal/shared.bat +++ b/bin/internal/shared.bat @@ -21,7 +21,7 @@ SET stamp_path=%cache_dir%\flutter_tools.stamp SET script_path=%flutter_tools_dir%\bin\flutter_tools.dart SET dart_sdk_path=%cache_dir%\dart-sdk SET engine_stamp=%cache_dir%\engine-dart-sdk.stamp -SET engine_version_path=%FLUTTER_ROOT%\bin\internal\engine.version +SET engine_version_path=%FLUTTER_ROOT%\bin\internal\engine.ohos.version SET pub_cache_path=%FLUTTER_ROOT%\.pub-cache SET dart=%dart_sdk_path%\bin\dart.exe diff --git a/bin/internal/update_dart_sdk.ps1 b/bin/internal/update_dart_sdk.ps1 index f4e2e77a55886435e4fe753a93913ab589f9ba06..ebca4a4b02e93f85b03ef3dfe49ce2e24c377c9c 100644 --- a/bin/internal/update_dart_sdk.ps1 +++ b/bin/internal/update_dart_sdk.ps1 @@ -19,7 +19,9 @@ $flutterRoot = (Get-Item $progName).parent.parent.FullName $cachePath = "$flutterRoot\bin\cache" $dartSdkPath = "$cachePath\dart-sdk" $engineStamp = "$cachePath\engine-dart-sdk.stamp" -$engineVersion = (Get-Content "$flutterRoot\bin\internal\engine.version") +$engineVersionFile = "engine.ohos.version" + +$engineVersion = (Get-Content "$flutterRoot\bin\internal\$engineVersionFile") $oldDartSdkPrefix = "dart-sdk.old" @@ -38,13 +40,30 @@ if ((Test-Path $engineStamp) -and ($engineVersion -eq (Get-Content $engineStamp) return } -$dartSdkBaseUrl = $Env:FLUTTER_STORAGE_BASE_URL +$dartSdkBaseUrl = $Env:FLUTTER_OHOS_STORAGE_BASE_URL if (-not $dartSdkBaseUrl) { - $dartSdkBaseUrl = "https://storage.googleapis.com" + $dartSdkBaseUrl = "https://flutter-ohos.obs.cn-south-1.myhuaweicloud.com" +} +if($Env:FLUTTER_OHOS_STORAGE_BASE_URL) { + $dartSdkBaseUrl = $Env:FLUTTER_OHOS_STORAGE_BASE_URL +} +# It's important to use the native Dart SDK as the default target architecture +# for Flutter Windows builds depend on the Dart executable's architecture. +$dartZipNameX64 = "dart-sdk-windows-x64.zip" +$dartZipNameArm64 = "dart-sdk-windows-arm64.zip" +$dartZipName = $dartZipNameX64 +if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { + $dartSdkArm64Url = "$dartSdkBaseUrl/flutter_infra_release/flutter/$engineVersion/$dartZipNameArm64" + Try { + Invoke-WebRequest -Uri $dartSdkArm64Url -UseBasicParsing -Method Head | Out-Null + $dartZipName = $dartZipNameArm64 + } + Catch { + Write-Host "The current channel's Dart SDK does not support Windows Arm64, falling back to Windows x64..." + } } -$dartZipName = "dart-sdk-windows-x64.zip" $dartSdkUrl = "$dartSdkBaseUrl/flutter_infra_release/flutter/$engineVersion/$dartZipName" - +Write-Host "dart-sdk-url: $dartSdkUrl" if (Test-Path $dartSdkPath) { # Move old SDK to a new location instead of deleting it in case it is still in use (e.g. by IntelliJ). $oldDartSdkSuffix = 1 diff --git a/bin/internal/update_dart_sdk.sh b/bin/internal/update_dart_sdk.sh index 49e4698a824ec24d0fc85963b32ef468ebd635b0..2224a8f9e139ed8171c3439f72debb8fc6a224c5 100755 --- a/bin/internal/update_dart_sdk.sh +++ b/bin/internal/update_dart_sdk.sh @@ -16,10 +16,13 @@ set -e FLUTTER_ROOT="$(dirname "$(dirname "$(dirname "${BASH_SOURCE[0]}")")")" +ENGINE_VERSION_FILE="engine.ohos.version" +FLUTTER_OHOS_STORAGE_BASE_URL=${FLUTTER_OHOS_STORAGE_BASE_URL:-https://flutter-ohos.obs.cn-south-1.myhuaweicloud.com} + DART_SDK_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk" DART_SDK_PATH_OLD="$DART_SDK_PATH.old" ENGINE_STAMP="$FLUTTER_ROOT/bin/cache/engine-dart-sdk.stamp" -ENGINE_VERSION=`cat "$FLUTTER_ROOT/bin/internal/engine.version"` +ENGINE_VERSION=$(cat "$FLUTTER_ROOT/bin/internal/$ENGINE_VERSION_FILE") OS="$(uname -s)" if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; then @@ -121,9 +124,10 @@ if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; t FIND=find fi - DART_SDK_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-https://storage.googleapis.com}" + DART_SDK_BASE_URL="${FLUTTER_OHOS_STORAGE_BASE_URL:-https://storage.googleapis.com}" DART_SDK_URL="$DART_SDK_BASE_URL/flutter_infra_release/flutter/$ENGINE_VERSION/$DART_ZIP_NAME" + echo 'dart-sdk-url:' $DART_SDK_URL # if the sdk path exists, copy it to a temporary location if [ -d "$DART_SDK_PATH" ]; then rm -rf "$DART_SDK_PATH_OLD" diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart index c99e24cd5f8378f88064585295ce2f0994fe712b..78e827ae3f7a6494a22be6dd86e5e2ecfefeb237 100644 --- a/packages/flutter_tools/lib/src/artifacts.dart +++ b/packages/flutter_tools/lib/src/artifacts.dart @@ -646,6 +646,9 @@ class CachedArtifacts implements Artifacts { assert(platform != null); switch (artifact) { case Artifact.genSnapshot: + if (platform == TargetPlatform.ohos_arm64) { + return _getAndroidArtifactPath(artifact, TargetPlatform.ohos_arm64, mode!); + } // For script snapshots any gen_snapshot binary will do. Returning gen_snapshot for // android_arm in profile mode because it is available on all supported host platforms. return _getAndroidArtifactPath(artifact, TargetPlatform.android_arm, BuildMode.profile); diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart index 0102b3ea083b926d688036977f31a8b7f7031c5f..7f5e804a34f2d4fa541ff19a668ad94fc0a2d6c7 100644 --- a/packages/flutter_tools/lib/src/cache.dart +++ b/packages/flutter_tools/lib/src/cache.dart @@ -22,6 +22,7 @@ import 'base/user_messages.dart'; import 'build_info.dart'; import 'convert.dart'; import 'features.dart'; +import 'globals.dart'; const String kFlutterRootEnvironmentVariableName = 'FLUTTER_ROOT'; // should point to //flutter/ (root of flutter/flutter repo) const String kFlutterEngineEnvironmentVariableName = 'FLUTTER_ENGINE'; // should point to //engine/src/ (root of flutter/engine repo) @@ -893,6 +894,7 @@ abstract class EngineCachedArtifact extends CachedArtifact { List getPackageDirs(); String get storageBaseUrl => cache.storageBaseUrl; + String get ohosStorageBaseUrl => cache.ohosStorageBaseUrl; @override bool isUpToDateInner(FileSystem fileSystem) { @@ -927,21 +929,30 @@ abstract class EngineCachedArtifact extends CachedArtifact { OperatingSystemUtils operatingSystemUtils, ) async { final String url = '$storageBaseUrl/flutter_infra_release/flutter/$version/'; - + final String ohosEngineVersion = cache.getVersionFor('engine.ohos')!; + // New platform Ohos is supported, so flutter needs to download + // sky_engine.zip, flutter_patched_sdk.zip and flutter_patched_sdk_product.zip from ohos URL + final String ohosUrl = '$ohosStorageBaseUrl/flutter_infra_release/flutter/$ohosEngineVersion/'; final Directory pkgDir = cache.getCacheDir('pkg'); for (final String pkgName in getPackageDirs()) { - await artifactUpdater.downloadZipArchive('Downloading package $pkgName...', Uri.parse('$url$pkgName.zip'), pkgDir); + if (pkgName == 'sky_engine') { + await artifactUpdater.downloadZipArchive('Downloading package $pkgName...', Uri.parse('$ohosUrl$pkgName.zip'), pkgDir); + } else { + await artifactUpdater.downloadZipArchive('Downloading package $pkgName...', Uri.parse('$url$pkgName.zip'), pkgDir); + } } for (final List toolsDir in getBinaryDirs()) { final String cacheDir = toolsDir[0]; final String urlPath = toolsDir[1]; final Directory dir = fileSystem.directory(fileSystem.path.join(location.path, cacheDir)); - // Avoid printing things like 'Downloading linux-x64 tools...' multiple times. final String friendlyName = urlPath.replaceAll('/artifacts.zip', '').replaceAll('.zip', ''); - await artifactUpdater.downloadZipArchive('Downloading $friendlyName tools...', Uri.parse(url + urlPath), dir); - + if (urlPath.startsWith('flutter_patched_sdk')) { + await artifactUpdater.downloadZipArchive('Downloading $friendlyName tools...', Uri.parse(ohosUrl + urlPath), dir); + } else { + await artifactUpdater.downloadZipArchive('Downloading $friendlyName tools...', Uri.parse(url + urlPath), dir); + } _makeFilesExecutable(dir, operatingSystemUtils); final File frameworkZip = fileSystem.file(fileSystem.path.join(dir.path, 'FlutterMacOS.framework.zip')); diff --git a/packages/flutter_tools/lib/src/flutter_cache.dart b/packages/flutter_tools/lib/src/flutter_cache.dart index 7822ffbe9b4daf3879bb32b1702d455f5cfc0ec5..e71d8059010b07806f2c32ca156926d7915f4aad 100644 --- a/packages/flutter_tools/lib/src/flutter_cache.dart +++ b/packages/flutter_tools/lib/src/flutter_cache.dart @@ -1021,25 +1021,31 @@ const List> _androidBinaryDirs = >[ const List> _osxBinaryDirsForOhos = >[ ['ohos-arm64-profile/darwin-x64', 'ohos-arm64-profile/darwin-x64.zip'], ['ohos-arm64-release/darwin-x64', 'ohos-arm64-release/darwin-x64.zip'], + ['ohos-x64-profile/darwin-x64', 'ohos-x64-profile/darwin-x64.zip'], + ['ohos-x64-release/darwin-x64', 'ohos-x64-release/darwin-x64.zip'], ]; const List> _linuxBinaryDirsForOhos = >[ ['ohos-arm64-profile/linux-x64', 'ohos-arm64-profile/linux-x64.zip'], ['ohos-arm64-release/linux-x64', 'ohos-arm64-release/linux-x64.zip'], + ['ohos-x64-profile/linux-x64', 'ohos-x64-profile/linux-x64.zip'], + ['ohos-x64-release/linux-x64', 'ohos-x64-release/linux-x64.zip'], ]; const List> _windowsBinaryDirsForOhos = >[ ['ohos-arm64-profile/windows-x64', 'ohos-arm64-profile/windows-x64.zip'], ['ohos-arm64-release/windows-x64', 'ohos-arm64-release/windows-x64.zip'], + ['ohos-x64-profile/windows-x64', 'ohos-x64-profile/windows-x64.zip'], + ['ohos-x64-release/windows-x64', 'ohos-x64-release/windows-x64.zip'], ]; const List> _ohosBinaryDirs = >[ ['ohos-arm64', 'ohos-arm64/artifacts.zip'], ['ohos-arm64-profile', 'ohos-arm64-profile/artifacts.zip'], ['ohos-arm64-release', 'ohos-arm64-release/artifacts.zip'], - // ['ohos-x64', 'ohos-x64/artifacts.zip'], - // ['ohos-x64-profile', 'ohos-x64-profile/artifacts.zip'], - // ['ohos-x64-release', 'ohos-x64-release/artifacts.zip'], + ['ohos-x64', 'ohos-x64/artifacts.zip'], + ['ohos-x64-profile', 'ohos-x64-profile/artifacts.zip'], + ['ohos-x64-release', 'ohos-x64-release/artifacts.zip'], ]; const List> _dartSdks = > [ diff --git a/packages/flutter_tools/lib/src/ohos/hvigor.dart b/packages/flutter_tools/lib/src/ohos/hvigor.dart index bd03033053e012aae22c1a453be639fc332e6d2d..99e0560836482d1ae352a0f86d54170e0220c99c 100644 --- a/packages/flutter_tools/lib/src/ohos/hvigor.dart +++ b/packages/flutter_tools/lib/src/ohos/hvigor.dart @@ -390,9 +390,16 @@ void cleanAndCopyFlutterAsset( ensureParentExists(desAppSoPath); appSoFile.copySync(desAppSoPath); } else { - final File appSo = globals.fs.file(desAppSoPath); - if (appSo.existsSync()) { - appSo.deleteSync(); + // delete libapp.so + final String dir = globals.fs.path.join(ohosProject.flutterModuleDirectory.path, 'libs'); + if (globals.fs.directory(dir).existsSync()) { + final List files = globals.fs.directory(dir) + .listSync(recursive: true); + for (final FileSystemEntity item in files) { + if (item.basename == APP_SO && item.existsSync()) { + item.deleteSync(); + } + } } } logger?.printTrace('copy flutter assets to project end');