From 50ecb955bf4229fd4107d160957e428a494f2e58 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 7 May 2024 10:25:52 +0200 Subject: [PATCH] Add test project adding assets in link --- .../test_data/add_dylib_link/.gitignore | 4 ++++ .../test_data/add_dylib_link/README.md | 1 + .../test_data/add_dylib_link/assets/test.txt | 1 + .../add_dylib_link/bin/add_dylib_link.dart | 9 +++++++++ .../test_data/add_dylib_link/hook/link.dart | 19 +++++++++++++++++++ .../test_data/add_dylib_link/pubspec.yaml | 19 +++++++++++++++++++ 6 files changed, 53 insertions(+) create mode 100644 pkgs/native_assets_builder/test_data/add_dylib_link/.gitignore create mode 100644 pkgs/native_assets_builder/test_data/add_dylib_link/README.md create mode 100644 pkgs/native_assets_builder/test_data/add_dylib_link/assets/test.txt create mode 100644 pkgs/native_assets_builder/test_data/add_dylib_link/bin/add_dylib_link.dart create mode 100644 pkgs/native_assets_builder/test_data/add_dylib_link/hook/link.dart create mode 100644 pkgs/native_assets_builder/test_data/add_dylib_link/pubspec.yaml diff --git a/pkgs/native_assets_builder/test_data/add_dylib_link/.gitignore b/pkgs/native_assets_builder/test_data/add_dylib_link/.gitignore new file mode 100644 index 000000000..6858c2ff6 --- /dev/null +++ b/pkgs/native_assets_builder/test_data/add_dylib_link/.gitignore @@ -0,0 +1,4 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ +bin/add_dylib_link/ diff --git a/pkgs/native_assets_builder/test_data/add_dylib_link/README.md b/pkgs/native_assets_builder/test_data/add_dylib_link/README.md new file mode 100644 index 000000000..8b3ebd965 --- /dev/null +++ b/pkgs/native_assets_builder/test_data/add_dylib_link/README.md @@ -0,0 +1 @@ +This sample adds a native library in the link step. \ No newline at end of file diff --git a/pkgs/native_assets_builder/test_data/add_dylib_link/assets/test.txt b/pkgs/native_assets_builder/test_data/add_dylib_link/assets/test.txt new file mode 100644 index 000000000..74158754f --- /dev/null +++ b/pkgs/native_assets_builder/test_data/add_dylib_link/assets/test.txt @@ -0,0 +1 @@ +My test text \ No newline at end of file diff --git a/pkgs/native_assets_builder/test_data/add_dylib_link/bin/add_dylib_link.dart b/pkgs/native_assets_builder/test_data/add_dylib_link/bin/add_dylib_link.dart new file mode 100644 index 000000000..a7b90cc9e --- /dev/null +++ b/pkgs/native_assets_builder/test_data/add_dylib_link/bin/add_dylib_link.dart @@ -0,0 +1,9 @@ +// Copyright (c) 2024, 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'; + +void main(List arguments) { + print(File('assets/test.txt').readAsStringSync()); +} diff --git a/pkgs/native_assets_builder/test_data/add_dylib_link/hook/link.dart b/pkgs/native_assets_builder/test_data/add_dylib_link/hook/link.dart new file mode 100644 index 000000000..a43f5debe --- /dev/null +++ b/pkgs/native_assets_builder/test_data/add_dylib_link/hook/link.dart @@ -0,0 +1,19 @@ +// Copyright (c) 2024, 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 'package:native_assets_cli/native_assets_cli.dart'; + +void main(List arguments) async { + await link(arguments, (config, output) async { + output + ..addAsset( + DataAsset( + package: 'add_dylib_link', + name: 'test_text_file', + file: config.packageRoot.resolve('assets/test.txt'), + ), + ) + ..addDependency(config.packageRoot.resolve('hook/link.dart')); + }); +} diff --git a/pkgs/native_assets_builder/test_data/add_dylib_link/pubspec.yaml b/pkgs/native_assets_builder/test_data/add_dylib_link/pubspec.yaml new file mode 100644 index 000000000..59e22d0fb --- /dev/null +++ b/pkgs/native_assets_builder/test_data/add_dylib_link/pubspec.yaml @@ -0,0 +1,19 @@ +name: add_dylib_link +description: Add a dylib in the link step. +version: 1.0.0 + +publish_to: none + +environment: + sdk: ^3.0.0 + +dependencies: + logging: ^1.1.1 + # native_assets_cli: ^0.5.0 + meta: ^1.12.0 + native_assets_cli: + path: ../../../native_assets_cli/ + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0