Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[native_assets_cli] Drop Config suffixes v1 #1829

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ class NativeAssetsBuildRunner {
)?.forEach((key, value) => metadata[key] = value);

final configBuilder = configCreator()
..setupHookConfig(
..setupHook(
buildAssetTypes: buildAssetTypes,
packageName: package.name,
packageRoot: packageLayout.packageRoot(package.name),
)
..setupBuildConfig(
..setupBuild(
dryRun: false,
linkingEnabled: linkingEnabled,
metadata: metadata,
Expand All @@ -137,7 +137,7 @@ class NativeAssetsBuildRunner {
package,
);

configBuilder.setupBuildRunConfig(
configBuilder.setupBuildAfterChecksum(
outputDirectory: outDirUri,
outputDirectoryShared: outDirSharedUri,
);
Expand Down Expand Up @@ -216,7 +216,7 @@ class NativeAssetsBuildRunner {
var hookResult = HookResult(encodedAssets: buildResult.encodedAssets);
for (final package in buildPlan) {
final configBuilder = configCreator()
..setupHookConfig(
..setupHook(
buildAssetTypes: buildAssetTypes,
packageName: package.name,
packageRoot: packageLayout.packageRoot(package.name),
Expand All @@ -235,7 +235,7 @@ class NativeAssetsBuildRunner {
await resourcesFile.create();
await File.fromUri(resourceIdentifiers).copy(resourcesFile.path);
}
configBuilder.setupLinkRunConfig(
configBuilder.setupLinkAfterChecksum(
outputDirectory: outDirUri,
outputDirectoryShared: outDirSharedUri,
recordedUsesFile: resourcesFile?.uri,
Expand Down
4 changes: 2 additions & 2 deletions pkgs/native_assets_builder/lib/src/model/hook_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ final class HookResult implements BuildResult, LinkResult {
...encodedAssets2,
]);
final hookOutputAssets = (hookOutput is BuildOutput)
? hookOutput.encodedAssets
: (hookOutput as LinkOutput).encodedAssets;
? hookOutput.assets
: (hookOutput as LinkOutput).assets;
return HookResult(
encodedAssets: [
...encodedAssets,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ void main() async {
final targetOS = OS.current;
const defaultMacOSVersion = 13;
BuildConfigBuilder configCreator() => BuildConfigBuilder()
..setupCodeConfig(
..setupCode(
targetArchitecture: Architecture.current,
targetOS: OS.current,
macOSConfig: targetOS == OS.macOS
macOS: targetOS == OS.macOS
? MacOSConfig(targetVersion: defaultMacOSVersion)
: null,
linkModePreference: LinkModePreference.dynamic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ void main(List<String> args) async {
// Set up the code config, so that the builds for different targets are
// in different directories.
configCreator: () => BuildConfigBuilder()
..setupCodeConfig(
..setupCode(
targetArchitecture: target.architecture,
targetOS: targetOS,
macOSConfig: targetOS == OS.macOS
macOS: targetOS == OS.macOS
? MacOSConfig(targetVersion: defaultMacOSVersion)
: null,
linkModePreference: LinkModePreference.dynamic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ void main(List<String> args) async {
singleHookTimeout: timeout,
).build(
configCreator: () => BuildConfigBuilder()
..setupCodeConfig(
..setupCode(
targetArchitecture: Architecture.current,
targetOS: targetOS,
linkModePreference: LinkModePreference.dynamic,
cCompilerConfig: dartCICompilerConfig,
macOSConfig: targetOS == OS.macOS
cCompiler: dartCICompilerConfig,
macOS: targetOS == OS.macOS
? MacOSConfig(targetVersion: defaultMacOSVersion)
: null,
),
Expand Down
40 changes: 20 additions & 20 deletions pkgs/native_assets_builder/test/build_runner/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,22 @@ Future<BuildResult?> build(
configCreator: () {
final configBuilder = BuildConfigBuilder();
if (buildAssetTypes.contains(CodeAsset.type)) {
configBuilder.setupCodeConfig(
configBuilder.setupCode(
targetArchitecture: target?.architecture ?? Architecture.current,
targetOS: targetOS,
linkModePreference: linkModePreference,
cCompilerConfig: cCompilerConfig ?? dartCICompilerConfig,
iOSConfig: targetOS == OS.iOS
cCompiler: cCompilerConfig ?? dartCICompilerConfig,
iOS: targetOS == OS.iOS
? IOSConfig(
targetSdk: targetIOSSdk!,
targetVersion: targetIOSVersion!,
)
: null,
macOSConfig: targetOS == OS.macOS
macOS: targetOS == OS.macOS
? MacOSConfig(
targetVersion: targetMacOSVersion ?? defaultMacOSVersion)
: null,
androidConfig: targetOS == OS.android
android: targetOS == OS.android
? AndroidConfig(targetNdkApi: targetAndroidNdkApi!)
: null,
);
Expand Down Expand Up @@ -130,22 +130,22 @@ Future<LinkResult?> link(
configCreator: () {
final configBuilder = LinkConfigBuilder();
if (buildAssetTypes.contains(CodeAsset.type)) {
configBuilder.setupCodeConfig(
configBuilder.setupCode(
targetArchitecture: target?.architecture ?? Architecture.current,
targetOS: target?.os ?? OS.current,
linkModePreference: linkModePreference,
cCompilerConfig: cCompilerConfig ?? dartCICompilerConfig,
iOSConfig: targetOS == OS.iOS
cCompiler: cCompilerConfig ?? dartCICompilerConfig,
iOS: targetOS == OS.iOS
? IOSConfig(
targetSdk: targetIOSSdk!,
targetVersion: targetIOSVersion!,
)
: null,
macOSConfig: targetOS == OS.macOS
macOS: targetOS == OS.macOS
? MacOSConfig(
targetVersion: targetMacOSVersion ?? defaultMacOSVersion)
: null,
androidConfig: targetOS == OS.android
android: targetOS == OS.android
? AndroidConfig(targetNdkApi: targetAndroidNdkApi!)
: null,
);
Expand Down Expand Up @@ -200,22 +200,22 @@ Future<(BuildResult?, LinkResult?)> buildAndLink(
final targetOS = target?.os ?? OS.current;
final buildResult = await buildRunner.build(
configCreator: () => BuildConfigBuilder()
..setupCodeConfig(
..setupCode(
targetArchitecture: target?.architecture ?? Architecture.current,
targetOS: targetOS,
linkModePreference: linkModePreference,
cCompilerConfig: cCompilerConfig ?? dartCICompilerConfig,
iOSConfig: targetOS == OS.iOS
cCompiler: cCompilerConfig ?? dartCICompilerConfig,
iOS: targetOS == OS.iOS
? IOSConfig(
targetSdk: targetIOSSdk!,
targetVersion: targetIOSVersion!,
)
: null,
macOSConfig: targetOS == OS.macOS
macOS: targetOS == OS.macOS
? MacOSConfig(
targetVersion: targetMacOSVersion ?? defaultMacOSVersion)
: null,
androidConfig: targetOS == OS.android
android: targetOS == OS.android
? AndroidConfig(targetNdkApi: targetAndroidNdkApi!)
: null,
),
Expand All @@ -241,22 +241,22 @@ Future<(BuildResult?, LinkResult?)> buildAndLink(

final linkResult = await buildRunner.link(
configCreator: () => LinkConfigBuilder()
..setupCodeConfig(
..setupCode(
targetArchitecture: target?.architecture ?? Architecture.current,
targetOS: targetOS,
linkModePreference: linkModePreference,
cCompilerConfig: cCompilerConfig,
iOSConfig: targetOS == OS.iOS
cCompiler: cCompilerConfig,
iOS: targetOS == OS.iOS
? IOSConfig(
targetSdk: targetIOSSdk!,
targetVersion: targetIOSVersion!,
)
: null,
macOSConfig: targetOS == OS.macOS
macOS: targetOS == OS.macOS
? MacOSConfig(
targetVersion: targetMacOSVersion ?? defaultMacOSVersion)
: null,
androidConfig: targetOS == OS.android
android: targetOS == OS.android
? AndroidConfig(targetNdkApi: targetAndroidNdkApi!)
: null,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ void main() async {

final targetOS = OS.current;
final configBuilder = BuildConfigBuilder()
..setupHookConfig(
..setupHook(
packageName: name,
packageRoot: testPackageUri,
buildAssetTypes: [CodeAsset.type],
)
..setupBuildConfig(dryRun: false, linkingEnabled: false)
..setupBuildRunConfig(
..setupBuild(dryRun: false, linkingEnabled: false)
..setupBuildAfterChecksum(
outputDirectory: outputDirectory,
outputDirectoryShared: outputDirectoryShared,
)
..setupCodeConfig(
..setupCode(
targetArchitecture: Architecture.current,
targetOS: targetOS,
macOSConfig: targetOS == OS.macOS
macOS: targetOS == OS.macOS
? MacOSConfig(targetVersion: defaultMacOSVersion)
: null,
linkModePreference: LinkModePreference.dynamic,
cCompilerConfig: cCompiler,
cCompiler: cCompiler,
);

final buildConfigUri = testTempUri.resolve('build_config.json');
Expand All @@ -75,7 +75,7 @@ void main() async {
final buildOutput = BuildOutput(
json.decode(await File.fromUri(buildOutputUri).readAsString())
as Map<String, Object?>);
final assets = buildOutput.encodedAssets;
final assets = buildOutput.assets;
final dependencies = buildOutput.dependencies;

expect(assets.length, 3);
Expand Down
12 changes: 6 additions & 6 deletions pkgs/native_assets_builder/test/test_data/transformer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ void main() async {
final targetOS = OS.current;
Future<void> runBuild(Architecture architecture) async {
final configBuilder = BuildConfigBuilder()
..setupHookConfig(
..setupHook(
packageName: packageName,
packageRoot: packageUri,
buildAssetTypes: [DataAsset.type],
)
..setupBuildConfig(dryRun: false, linkingEnabled: false)
..setupBuildRunConfig(
..setupBuild(dryRun: false, linkingEnabled: false)
..setupBuildAfterChecksum(
outputDirectory: outputDirectory,
outputDirectoryShared: outputDirectoryShared,
)
..setupCodeConfig(
..setupCode(
targetArchitecture: architecture,
targetOS: targetOS,
macOSConfig: targetOS == OS.macOS
macOS: targetOS == OS.macOS
? MacOSConfig(targetVersion: defaultMacOSVersion)
: null,
linkModePreference: LinkModePreference.dynamic,
Expand Down Expand Up @@ -101,7 +101,7 @@ void main() async {
]),
);
expect(
output.dataAssets,
output.assets.data,
contains(
DataAsset(
file: outputDirectoryShared.resolve('data_transformed0.json'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import 'package:native_assets_cli/code_assets.dart';

void main(List<String> arguments) async {
await link(arguments, (config, output) async {
final builtDylib = config.codeAssets.first;
final builtDylib = config.assets.code.first;
output
..codeAssets.add(
..code.addAsset(
CodeAsset(
package: 'add_asset_link',
name: 'dylib_add_link',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void main(List<String> args) async {
.toFilePath(windows: false)
.substring(config.packageRoot.toFilePath(windows: false).length);

output.dataAssets.add(
output.data.addAsset(
DataAsset(
package: packageName,
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void main(List<String> args) async {
await link(
args,
(config, output) async =>
output.dataAssets.addAll(treeshake(config.dataAssets)),
output.data.addAssets(treeshake(config.assets.data)),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main(List<String> args) async {
.substring(config.packageRoot.toFilePath(windows: false).length);

final forLinking = name.contains('2') || name.contains('3');
output.dataAssets.add(
output.data.addAsset(
DataAsset(
package: packageName,
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import 'package:native_assets_cli/code_assets.dart';

void main(List<String> arguments) async {
await link(arguments, (config, output) async {
for (final codeAsset in config.codeAssets) {
for (final codeAsset in config.assets.code) {
print('Got code asset: ${codeAsset.id}');
if (codeAsset.id.endsWith('add')) {
output.codeAssets.add(codeAsset);
output.code.addAsset(codeAsset);
print('-> Keeping ${codeAsset.id}');
} else {
print('-> Dropping ${codeAsset.id}');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,24 @@ const minMacOSVersionForThisPackage = 13;

void main(List<String> arguments) async {
await build(arguments, (config, output) async {
if (config.codeConfig.targetOS == OS.android) {
if (config.codeConfig.androidConfig.targetNdkApi <
minNdkApiVersionForThisPackage) {
if (config.code.targetOS == OS.android) {
if (config.code.android.targetNdkApi < minNdkApiVersionForThisPackage) {
throw UnsupportedError(
'The native assets for this package require at '
'least Android NDK API level $minNdkApiVersionForThisPackage.',
);
}
} else if (config.codeConfig.targetOS == OS.iOS) {
final iosVersion = config.codeConfig.iOSConfig.targetVersion;
} else if (config.code.targetOS == OS.iOS) {
final iosVersion = config.code.iOS.targetVersion;
// iosVersion is nullable to deal with version skew.
if (iosVersion < minIosVersionForThisPackage) {
throw UnsupportedError(
'The native assets for this package require at '
'least iOS version $minIosVersionForThisPackage.',
);
}
} else if (config.codeConfig.targetOS == OS.macOS) {
final macosVersion = config.codeConfig.macOSConfig.targetVersion;
} else if (config.code.targetOS == OS.macOS) {
final macosVersion = config.code.macOS.targetVersion;
// macosVersion is nullable to deal with version skew.
if (macosVersion < minMacOSVersionForThisPackage) {
throw UnsupportedError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:native_assets_cli/data_assets.dart';

void main(List<String> arguments) async {
await build(arguments, (config, output) async {
output.dataAssets.add(
output.data.addAsset(
DataAsset(
name: 'data',
file: config.packageRoot.resolve('assets/data.json'),
Expand Down
Loading
Loading