Skip to content

Commit

Permalink
[native_assets_cli] Separate out public API
Browse files Browse the repository at this point in the history
  • Loading branch information
dcharkes committed Jan 10, 2024
1 parent d275ca6 commit a013b98
Show file tree
Hide file tree
Showing 48 changed files with 1,078 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dart:async';
import 'dart:io';

import 'package:logging/logging.dart';
import 'package:native_assets_cli/native_assets_cli.dart';
import 'package:native_assets_cli/native_assets_cli_internal.dart';
import 'package:package_config/package_config.dart';

import '../package_layout/package_layout.dart';
Expand Down
2 changes: 1 addition & 1 deletion pkgs/native_assets_builder/lib/src/model/asset.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// 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';
import 'package:native_assets_cli/native_assets_cli_internal.dart';

import '../utils/yaml.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'dart:io';

import 'package:file_testing/file_testing.dart';
import 'package:native_assets_cli/native_assets_cli.dart';
import 'package:native_assets_cli/native_assets_cli_internal.dart';
import 'package:test/test.dart';

import '../helpers.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:native_assets_builder/src/build_runner/build_runner.dart';
import 'package:native_assets_cli/native_assets_cli.dart';
import 'package:native_assets_cli/native_assets_cli_internal.dart';
import 'package:test/test.dart';

import '../helpers.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'dart:io';

import 'package:native_assets_cli/native_assets_cli.dart';
import 'package:native_assets_cli/native_assets_cli_internal.dart';
import 'package:test/test.dart';

import '../helpers.dart';
Expand Down
2 changes: 1 addition & 1 deletion pkgs/native_assets_builder/test/build_runner/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'dart:io';
import 'package:file_testing/file_testing.dart';
import 'package:logging/logging.dart';
import 'package:native_assets_builder/native_assets_builder.dart';
import 'package:native_assets_cli/native_assets_cli.dart';
import 'package:native_assets_cli/native_assets_cli_internal.dart';
import 'package:test/test.dart';

import '../helpers.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// 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';
import 'package:native_assets_cli/native_assets_cli_internal.dart';
import 'package:test/test.dart';

import '../helpers.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'dart:io';

import 'package:native_assets_cli/native_assets_cli.dart';
import 'package:native_assets_cli/native_assets_cli_internal.dart';

void main(List<String> args) async {
final buildConfig = await BuildConfig.fromArgs(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'dart:io';

import 'package:native_assets_cli/native_assets_cli.dart';
import 'package:native_assets_cli/native_assets_cli_internal.dart';

void main(List<String> args) async {
final buildConfig = await BuildConfig.fromArgs(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'dart:io';

import 'package:native_assets_cli/native_assets_cli.dart';
import 'package:native_assets_cli/native_assets_cli_internal.dart';

void main(List<String> args) async {
final buildConfig = await BuildConfig.fromArgs(args);
Expand Down
2 changes: 1 addition & 1 deletion pkgs/native_assets_builder/test/model/asset_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ignore_for_file: undefined_hidden_name

import 'package:native_assets_builder/src/model/asset.dart';
import 'package:native_assets_cli/native_assets_cli.dart'
import 'package:native_assets_cli/native_assets_cli_internal.dart'
hide AssetIterable, AssetRelativePath;
import 'package:test/test.dart';

Expand Down
5 changes: 3 additions & 2 deletions pkgs/native_assets_cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

- Added [example/use_dart_api/](example/use_dart_api/) detailing how to use
`dart_api_dl.h` from the Dart SDK in native code.
- **Breaking change** Moved code not used in `build.dart` to
`package:native_assets_builder`.
- **Breaking change** Removed all code not used in `build.dart` scripts out of
the public API.



## 0.3.2
Expand Down
20 changes: 10 additions & 10 deletions pkgs/native_assets_cli/lib/native_assets_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
/// native assets CLI.
library native_assets_cli;

export 'src/model/asset.dart';
export 'src/model/build_config.dart';
export 'src/model/build_mode.dart';
export 'src/model/build_output.dart';
export 'src/model/dependencies.dart';
export 'src/model/ios_sdk.dart';
export 'src/model/link_mode.dart';
export 'src/model/link_mode_preference.dart';
export 'src/model/metadata.dart';
export 'src/model/target.dart';
export 'src/api/asset.dart';
export 'src/api/build_config.dart';
export 'src/api/build_mode.dart';
export 'src/api/build_output.dart';
export 'src/api/dependencies.dart';
export 'src/api/ios_sdk.dart';
export 'src/api/link_mode.dart';
export 'src/api/link_mode_preference.dart';
export 'src/api/metadata.dart';
export 'src/api/target.dart';
17 changes: 17 additions & 0 deletions pkgs/native_assets_cli/lib/native_assets_cli_internal.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.

/// These files should not be accessed from `build.dart`.
library native_assets_cli_internal;

export 'src/model/asset.dart';
export 'src/model/build_config.dart';
export 'src/model/build_mode.dart';
export 'src/model/build_output.dart';
export 'src/model/dependencies.dart';
export 'src/model/ios_sdk.dart';
export 'src/model/link_mode.dart';
export 'src/model/link_mode_preference.dart';
export 'src/model/metadata.dart';
export 'src/model/target.dart';
59 changes: 59 additions & 0 deletions pkgs/native_assets_cli/lib/src/api/asset.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 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 '../model/asset.dart' as model;
import '../model/link_mode.dart' as model;
import '../model/target.dart' as model;
import 'link_mode.dart';
import 'target.dart';

abstract class AssetPath {}

/// Asset at absolute path [uri].
abstract class AssetAbsolutePath implements AssetPath {
Uri get uri;

factory AssetAbsolutePath(Uri uri) = model.AssetAbsolutePath;
}

/// Asset is avaliable on the system `PATH`.
///
/// [uri] only contains a file name.
abstract class AssetSystemPath implements AssetPath {
Uri get uri;

factory AssetSystemPath(Uri uri) = model.AssetSystemPath;
}

/// Asset is loaded in the process and symbols are available through
/// `DynamicLibrary.process()`.
abstract class AssetInProcess implements AssetPath {
factory AssetInProcess() = model.AssetInProcess;
}

/// Asset is embedded in executable and symbols are available through
/// `DynamicLibrary.executable()`.
abstract class AssetInExecutable implements AssetPath {
factory AssetInExecutable() = model.AssetInExecutable;
}

abstract class Asset {
LinkMode get linkMode;
String get id;
Target get target;
AssetPath get path;

factory Asset({
required String id,
required LinkMode linkMode,
required Target target,
required AssetPath path,
}) =>
model.Asset(
id: id,
linkMode: linkMode as model.LinkMode,
target: target as model.Target,
path: path as model.AssetPath,
);
}
Loading

0 comments on commit a013b98

Please sign in to comment.