-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
148 additions
and
31 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
42 changes: 42 additions & 0 deletions
42
pkgs/native_assets_cli/example/build/download_asset/lib/src/hook_helpers/download.dart
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,42 @@ | ||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:crypto/crypto.dart'; | ||
import 'package:native_assets_cli/code_assets_builder.dart'; | ||
|
||
import 'c_build.dart'; | ||
import 'version.dart'; | ||
|
||
Uri downloadUri(String target) => Uri.parse( | ||
'https://github.com/dart-lang/native/releases/download/$version/$target'); | ||
|
||
Future<File> downloadAsset( | ||
OS targetOS, | ||
Architecture targetArchitecture, | ||
IOSSdk? iOSSdk, | ||
Directory outputDirectory, | ||
) async { | ||
final targetName = targetOS.dylibFileName(createTargetName( | ||
targetOS.name, | ||
targetArchitecture.name, | ||
iOSSdk?.type, | ||
)); | ||
final uri = downloadUri(targetName); | ||
final request = await HttpClient().getUrl(uri); | ||
final response = await request.close(); | ||
if (response.statusCode != 200) { | ||
throw ArgumentError('The request to $uri failed.'); | ||
} | ||
final library = File.fromUri(outputDirectory.uri.resolve(targetName)); | ||
await library.create(); | ||
await response.pipe(library.openWrite()); | ||
return library; | ||
} | ||
|
||
Future<String> hashAsset(File assetFile) async { | ||
final fileHash = md5.convert(await assetFile.readAsBytes()).toString(); | ||
return fileHash; | ||
} |
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
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
pkgs/native_assets_cli/example/build/download_asset/lib/src/hook_helpers/targets.dart
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 (c, null) 2025, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS AUTOGENERATED. TO UPDATE, RUN | ||
// | ||
// dart --enable-experiment=native-assets tool/generate_asset_hashes.dart | ||
// | ||
|
||
import 'package:native_assets_cli/code_assets_builder.dart'; | ||
|
||
const supportedTargets = [ | ||
(OS.android, Architecture.arm, null), | ||
(OS.android, Architecture.arm64, null), | ||
(OS.android, Architecture.ia32, null), | ||
(OS.android, Architecture.riscv64, null), | ||
(OS.android, Architecture.x64, null), | ||
(OS.iOS, Architecture.arm64, IOSSdk.iPhoneOS), | ||
(OS.iOS, Architecture.arm64, IOSSdk.iPhoneSimulator), | ||
(OS.iOS, Architecture.x64, IOSSdk.iPhoneSimulator), | ||
(OS.linux, Architecture.arm, null), | ||
(OS.linux, Architecture.arm64, null), | ||
(OS.linux, Architecture.ia32, null), | ||
(OS.linux, Architecture.riscv64, null), | ||
(OS.linux, Architecture.x64, null), | ||
(OS.macOS, Architecture.arm64, null), | ||
(OS.macOS, Architecture.x64, null), | ||
(OS.windows, Architecture.arm64, null), | ||
(OS.windows, Architecture.ia32, null), | ||
(OS.windows, Architecture.x64, null), | ||
]; |
13 changes: 13 additions & 0 deletions
13
pkgs/native_assets_cli/example/build/download_asset/lib/src/hook_helpers/version.dart
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,13 @@ | ||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'download.dart'; | ||
import 'hashes.dart'; | ||
|
||
/// The GitHub release to use for downloading assets. | ||
/// | ||
/// Assets are downloaded from [downloadUri]. | ||
/// | ||
/// After changing [assetHashes] must be updated. | ||
const version = 'download_asset-prebuild-assets-v0.1.0-try-3'; |
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