From dd5e5af4783f4dbfdc292bcc0eb451d9ba6823a9 Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Tue, 7 Jan 2025 22:56:13 +0100 Subject: [PATCH] [native_assets_cli] `InputBuilder.targetConfig..setup` --- .../build_runner_reusability_test.dart | 1 + .../concurrency_shared_test_helper.dart | 8 +++- .../build_runner/concurrency_test_helper.dart | 7 ++- .../test/build_runner/helpers.dart | 24 ++++------ .../native_dynamic_linking_test.dart | 1 + .../test/test_data/transformer_test.dart | 7 ++- .../lib/src/code_assets/config.dart | 3 +- .../lib/src/code_assets/testing.dart | 1 + pkgs/native_assets_cli/lib/src/config.dart | 15 +++---- .../lib/src/data_assets/config.dart | 12 ++--- .../test/api/build_test.dart | 2 +- .../test/build_config_test.dart | 7 +-- .../native_assets_cli/test/checksum_test.dart | 44 +++++++++---------- .../test/code_assets/config_test.dart | 3 ++ .../test/code_assets/validation_test.dart | 5 +++ .../test/data_assets/validation_test.dart | 2 +- .../test/example/local_asset_test.dart | 1 + .../test/example/native_add_library_test.dart | 1 + .../example/native_dynamic_linking_test.dart | 1 + .../test/link_config_test.dart | 4 +- .../test/validation_test.dart | 2 +- .../lib/src/cbuilder/cbuilder.dart | 2 +- .../cbuilder/cbuilder_build_failure_test.dart | 1 + .../cbuilder/cbuilder_cross_android_test.dart | 1 + .../cbuilder/cbuilder_cross_ios_test.dart | 3 ++ .../cbuilder_cross_linux_host_test.dart | 1 + .../cbuilder_cross_macos_host_test.dart | 2 + .../cbuilder_cross_windows_host_test.dart | 1 + .../test/cbuilder/cbuilder_test.dart | 12 +++++ .../test/cbuilder/compiler_resolver_test.dart | 2 + .../test/cbuilder/objective_c_test.dart | 1 + .../test/clinker/build_testfiles.dart | 1 + .../test/clinker/objects_test.dart | 1 + .../test/clinker/throws_test.dart | 1 + .../test/clinker/treeshake_helper.dart | 1 + 35 files changed, 114 insertions(+), 67 deletions(-) diff --git a/pkgs/native_assets_builder/test/build_runner/build_runner_reusability_test.dart b/pkgs/native_assets_builder/test/build_runner/build_runner_reusability_test.dart index 9ca66b181..c6ac8781d 100644 --- a/pkgs/native_assets_builder/test/build_runner/build_runner_reusability_test.dart +++ b/pkgs/native_assets_builder/test/build_runner/build_runner_reusability_test.dart @@ -32,6 +32,7 @@ void main() async { final targetOS = OS.current; const defaultMacOSVersion = 13; BuildInputBuilder inputCreator() => BuildInputBuilder() + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetArchitecture: Architecture.current, targetOS: OS.current, diff --git a/pkgs/native_assets_builder/test/build_runner/concurrency_shared_test_helper.dart b/pkgs/native_assets_builder/test/build_runner/concurrency_shared_test_helper.dart index 819f40af5..02a30f629 100644 --- a/pkgs/native_assets_builder/test/build_runner/concurrency_shared_test_helper.dart +++ b/pkgs/native_assets_builder/test/build_runner/concurrency_shared_test_helper.dart @@ -26,6 +26,10 @@ void main(List args) async { // Set up the code input, so that the builds for different targets are // in different directories. inputCreator: () => BuildInputBuilder() + ..targetConfig.setupTargetConfig(buildAssetTypes: [ + CodeAsset.type, + DataAsset.type, + ]) ..targetConfig.setupCodeConfig( targetArchitecture: target.architecture, targetOS: targetOS, @@ -33,8 +37,8 @@ void main(List args) async { ? MacOSConfig(targetVersion: defaultMacOSVersion) : null, linkModePreference: LinkModePreference.dynamic, - ) - ..targetConfig.setupDataConfig(), + ), + workingDirectory: packageUri, linkingEnabled: false, inputValidator: validateDataAssetBuildInput, diff --git a/pkgs/native_assets_builder/test/build_runner/concurrency_test_helper.dart b/pkgs/native_assets_builder/test/build_runner/concurrency_test_helper.dart index cea462e44..e7959fd16 100644 --- a/pkgs/native_assets_builder/test/build_runner/concurrency_test_helper.dart +++ b/pkgs/native_assets_builder/test/build_runner/concurrency_test_helper.dart @@ -29,6 +29,10 @@ void main(List args) async { fileSystem: const LocalFileSystem(), ).build( inputCreator: () => BuildInputBuilder() + ..targetConfig.setupTargetConfig(buildAssetTypes: [ + CodeAsset.type, + DataAsset.type, + ]) ..targetConfig.setupCodeConfig( targetArchitecture: Architecture.current, targetOS: targetOS, @@ -37,8 +41,7 @@ void main(List args) async { macOSConfig: targetOS == OS.macOS ? MacOSConfig(targetVersion: defaultMacOSVersion) : null, - ) - ..targetConfig.setupDataConfig(), + ), workingDirectory: packageUri, linkingEnabled: false, inputValidator: (input) async => [ diff --git a/pkgs/native_assets_builder/test/build_runner/helpers.dart b/pkgs/native_assets_builder/test/build_runner/helpers.dart index 429c47969..c9c36077a 100644 --- a/pkgs/native_assets_builder/test/build_runner/helpers.dart +++ b/pkgs/native_assets_builder/test/build_runner/helpers.dart @@ -59,7 +59,8 @@ Future build( hookEnvironment: hookEnvironment, ).build( inputCreator: () { - final inputBuilder = BuildInputBuilder(); + final inputBuilder = BuildInputBuilder() + ..targetConfig.setupTargetConfig(buildAssetTypes: buildAssetTypes); if (buildAssetTypes.contains(CodeAsset.type)) { inputBuilder.targetConfig.setupCodeConfig( targetArchitecture: target?.architecture ?? Architecture.current, @@ -81,9 +82,6 @@ Future build( : null, ); } - if (buildAssetTypes.contains(DataAsset.type)) { - inputBuilder.targetConfig.setupDataConfig(); - } return inputBuilder; }, inputValidator: inputValidator, @@ -135,7 +133,8 @@ Future link( fileSystem: const LocalFileSystem(), ).link( inputCreator: () { - final inputBuilder = LinkInputBuilder(); + final inputBuilder = LinkInputBuilder() + ..targetConfig.setupTargetConfig(buildAssetTypes: buildAssetTypes); if (buildAssetTypes.contains(CodeAsset.type)) { inputBuilder.targetConfig.setupCodeConfig( targetArchitecture: target?.architecture ?? Architecture.current, @@ -157,9 +156,6 @@ Future link( : null, ); } - if (buildAssetTypes.contains(DataAsset.type)) { - inputBuilder.targetConfig.setupDataConfig(); - } return inputBuilder; }, inputValidator: inputValidator, @@ -210,7 +206,8 @@ Future<(BuildResult?, LinkResult?)> buildAndLink( final targetOS = target?.os ?? OS.current; final buildResult = await buildRunner.build( inputCreator: () { - final inputBuilder = BuildInputBuilder(); + final inputBuilder = BuildInputBuilder() + ..targetConfig.setupTargetConfig(buildAssetTypes: buildAssetTypes); if (buildAssetTypes.contains(CodeAsset.type)) { inputBuilder.targetConfig.setupCodeConfig( targetArchitecture: target?.architecture ?? Architecture.current, @@ -232,9 +229,6 @@ Future<(BuildResult?, LinkResult?)> buildAndLink( : null, ); } - if (buildAssetTypes.contains(DataAsset.type)) { - inputBuilder.targetConfig.setupDataConfig(); - } return inputBuilder; }, inputValidator: buildInputValidator, @@ -258,7 +252,8 @@ Future<(BuildResult?, LinkResult?)> buildAndLink( final linkResult = await buildRunner.link( inputCreator: () { - final inputBuilder = LinkInputBuilder(); + final inputBuilder = LinkInputBuilder() + ..targetConfig.setupTargetConfig(buildAssetTypes: buildAssetTypes); if (buildAssetTypes.contains(CodeAsset.type)) { inputBuilder.targetConfig.setupCodeConfig( targetArchitecture: target?.architecture ?? Architecture.current, @@ -280,9 +275,6 @@ Future<(BuildResult?, LinkResult?)> buildAndLink( : null, ); } - if (buildAssetTypes.contains(DataAsset.type)) { - inputBuilder.targetConfig.setupDataConfig(); - } return inputBuilder; }, inputValidator: linkInputValidator, diff --git a/pkgs/native_assets_builder/test/test_data/native_dynamic_linking_test.dart b/pkgs/native_assets_builder/test/test_data/native_dynamic_linking_test.dart index 0b46d7122..c172b28b6 100644 --- a/pkgs/native_assets_builder/test/test_data/native_dynamic_linking_test.dart +++ b/pkgs/native_assets_builder/test/test_data/native_dynamic_linking_test.dart @@ -39,6 +39,7 @@ void main() async { outputDirectoryShared: outputDirectoryShared, ) ..targetConfig.setupBuildConfig(dryRun: false, linkingEnabled: false) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetArchitecture: Architecture.current, targetOS: targetOS, diff --git a/pkgs/native_assets_builder/test/test_data/transformer_test.dart b/pkgs/native_assets_builder/test/test_data/transformer_test.dart index 8da68f3f3..e5b62404d 100644 --- a/pkgs/native_assets_builder/test/test_data/transformer_test.dart +++ b/pkgs/native_assets_builder/test/test_data/transformer_test.dart @@ -54,6 +54,10 @@ void main() async { outputDirectoryShared: outputDirectoryShared, ) ..targetConfig.setupBuildConfig(dryRun: false, linkingEnabled: false) + ..targetConfig.setupTargetConfig(buildAssetTypes: [ + CodeAsset.type, + DataAsset.type, + ]) ..targetConfig.setupCodeConfig( targetArchitecture: architecture, targetOS: targetOS, @@ -61,8 +65,7 @@ void main() async { ? MacOSConfig(targetVersion: defaultMacOSVersion) : null, linkModePreference: LinkModePreference.dynamic, - ) - ..targetConfig.setupDataConfig(); + ); final buildInputUri = testTempUri.resolve('build_input.json'); File.fromUri(buildInputUri) diff --git a/pkgs/native_assets_cli/lib/src/code_assets/config.dart b/pkgs/native_assets_cli/lib/src/code_assets/config.dart index a91a9936d..fc7e794e0 100644 --- a/pkgs/native_assets_cli/lib/src/code_assets/config.dart +++ b/pkgs/native_assets_cli/lib/src/code_assets/config.dart @@ -16,6 +16,8 @@ import 'os.dart'; extension CodeAssetTargetConfig on TargetConfig { /// Code asset specific configuration. CodeConfig get codeConfig => CodeConfig.fromJson(json); + + bool get buildCodeAssets => buildAssetTypes.contains(CodeAsset.type); } /// Extension to the [LinkInput] providing access to configuration specific to @@ -254,7 +256,6 @@ extension CodeAssetBuildInputBuilder on TargetConfigBuilder { IOSConfig? iOSConfig, MacOSConfig? macOSConfig, }) { - builder.addBuildAssetType(CodeAsset.type); if (targetArchitecture != null) { json[_targetArchitectureKey] = targetArchitecture.toString(); } diff --git a/pkgs/native_assets_cli/lib/src/code_assets/testing.dart b/pkgs/native_assets_cli/lib/src/code_assets/testing.dart index 5a8277554..81844e714 100644 --- a/pkgs/native_assets_cli/lib/src/code_assets/testing.dart +++ b/pkgs/native_assets_cli/lib/src/code_assets/testing.dart @@ -37,6 +37,7 @@ Future testCodeBuildHook({ await testBuildHook( mainMethod: mainMethod, extraInputSetup: (input) { + input.targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]); input.targetConfig.setupCodeConfig( linkModePreference: linkModePreference ?? LinkModePreference.dynamic, cCompilerConfig: cCompiler, diff --git a/pkgs/native_assets_cli/lib/src/config.dart b/pkgs/native_assets_cli/lib/src/config.dart index 20b55f214..395b29918 100644 --- a/pkgs/native_assets_cli/lib/src/config.dart +++ b/pkgs/native_assets_cli/lib/src/config.dart @@ -92,18 +92,10 @@ sealed class HookInputBuilder { }) { json[_packageNameInputKey] = packageName; json[_packageRootInputKey] = packageRoot.toFilePath(); - json[_buildAssetTypesKey] ??= []; - json[_supportedAssetTypesKey] ??= []; json[_outDirInputKey] = outputDirectory.toFilePath(); json[_outDirSharedInputKey] = outputDirectoryShared.toFilePath(); } - void addBuildAssetType(String assetType) { - ((json[_buildAssetTypesKey] ??= []) as List).add(assetType); - ((json[_supportedAssetTypesKey] ??= []) as List) - .add(assetType); - } - /// Constructs a checksum for a [BuildInput]. /// /// This can be used to construct an output directory name specific to the @@ -178,6 +170,13 @@ final class TargetConfigBuilder { Map get json => builder.json; TargetConfigBuilder._(this.builder); + + void setupTargetConfig({ + required List buildAssetTypes, + }) { + json[_buildAssetTypesKey] = buildAssetTypes; + json[_supportedAssetTypesKey] = buildAssetTypes; + } } final class BuildTargetConfigBuilder extends TargetConfigBuilder { diff --git a/pkgs/native_assets_cli/lib/src/data_assets/config.dart b/pkgs/native_assets_cli/lib/src/data_assets/config.dart index a16da7027..4b2e532de 100644 --- a/pkgs/native_assets_cli/lib/src/data_assets/config.dart +++ b/pkgs/native_assets_cli/lib/src/data_assets/config.dart @@ -6,13 +6,15 @@ import '../config.dart'; import 'data_asset.dart'; -/// Extension to initialize data specific configuration on link/build inputs. -extension DataAssetBuildInputBuilder on TargetConfigBuilder { - void setupDataConfig() { - builder.addBuildAssetType(DataAsset.type); - } +/// Extension to the [TargetConfig] providing access to configuration specific +/// to data assets. +extension CodeAssetTargetConfig on TargetConfig { + bool get buildDataAssets => buildAssetTypes.contains(DataAsset.type); } +/// Extension to initialize data specific configuration on link/build inputs. +extension DataAssetBuildInputBuilder on TargetConfigBuilder {} + /// Link output extension for data assets. extension DataAssetLinkInput on LinkInputAssets { // Returns the data assets that were sent to this linker. diff --git a/pkgs/native_assets_cli/test/api/build_test.dart b/pkgs/native_assets_cli/test/api/build_test.dart index e45987126..bc10e2e31 100644 --- a/pkgs/native_assets_cli/test/api/build_test.dart +++ b/pkgs/native_assets_cli/test/api/build_test.dart @@ -37,7 +37,7 @@ void main() async { outputDirectory: outDirUri, outputDirectoryShared: outputDirectoryShared, ) - ..addBuildAssetType('foo') + ..targetConfig.setupTargetConfig(buildAssetTypes: ['foo']) ..targetConfig.setupBuildConfig( dryRun: false, linkingEnabled: false, diff --git a/pkgs/native_assets_cli/test/build_config_test.dart b/pkgs/native_assets_cli/test/build_config_test.dart index 1c1717bc5..103af4c6a 100644 --- a/pkgs/native_assets_cli/test/build_config_test.dart +++ b/pkgs/native_assets_cli/test/build_config_test.dart @@ -43,7 +43,7 @@ void main() async { outputDirectory: outDirUri, outputDirectoryShared: outputDirectoryShared, ) - ..addBuildAssetType('my-asset-type') + ..targetConfig.setupTargetConfig(buildAssetTypes: ['my-asset-type']) ..targetConfig.setupBuildConfig( linkingEnabled: false, dryRun: false, @@ -98,11 +98,12 @@ void main() async { outputDirectory: outDirUri, outputDirectoryShared: outputDirectoryShared, ) - ..addBuildAssetType('my-asset-type') + ..targetConfig.setupTargetConfig(buildAssetTypes: ['my-asset-type']) ..targetConfig.setupBuildConfig( linkingEnabled: true, dryRun: true, - ); + ) + ..setupBuildInput(); final input = BuildInput(inputBuilder.json); final expectedInputJson = { diff --git a/pkgs/native_assets_cli/test/checksum_test.dart b/pkgs/native_assets_cli/test/checksum_test.dart index 262884e94..1e3e24254 100644 --- a/pkgs/native_assets_cli/test/checksum_test.dart +++ b/pkgs/native_assets_cli/test/checksum_test.dart @@ -32,6 +32,8 @@ void main() { dryRun: dryRun, linkingEnabled: linking, ); + builder.targetConfig + .setupTargetConfig(buildAssetTypes: [assetType]); if (assetType == CodeAsset.type) { builder.targetConfig.setupCodeConfig( targetArchitecture: architecture, @@ -41,8 +43,6 @@ void main() { : null, linkModePreference: LinkModePreference.dynamic, ); - } else if (assetType == DataAsset.type) { - builder.targetConfig.setupDataConfig(); } inputs.add( const JsonEncoder.withIndent(' ').convert(builder.json), @@ -62,26 +62,26 @@ void main() { // needing to update this list). final expectedChecksums = [ - '925d600dcf296b3090580facc3edf2b7', - 'a35c6ee872e040d4ca593607411d55c7', - '7ed08edc547bdbe7c23bfeb784a5d90d', - 'c59378da8732d8620ba1cda6a14fa9cf', - '1613613b3b24c7dac73624418db30f41', - '9f7fe6e014687f1ce831239367b68904', - '128835661e973a964f225e7ff5304bd7', - '3c26493d1d349d36f58742a241d77f46', - 'cb00634068dd970a26a4a47284d21b6d', - 'cb235612943ce5da476fb59b9586d2f9', - '713c68c5c49c82a9dc6beb9a04a91c66', - 'cd13b83470137df0fb784764b37ab354', - 'db469c8d73e15e3101112c69e480c1ff', - 'b61381f045bacd8dba8c7f194d41bdcd', - 'f50070c54e062007738c89fc7cde22a7', - '62de27e9d1c6ed6a413f42d111cc8255', - '58e02cb492c5c5b4ed1a85f6fcfa5819', - 'cc2a451252f53a570c05b392f366c599', - 'f65f000e8501a32c20ec7c0270b0b9ae', - '4ef9faec8957250d56603a9e13c8fe80', + '079353bf7f09a5a78aad5dfb74d160ce', + '3f77f197abd56950f6878720f40f1d78', + '95afb0b082567b75143a5a3fe23ded7f', + '20a82fc01786d82ec2e70c81e384ca53', + '9b4a6923ab07618074631e9ee8ea5451', + '1ba05dccc6b7d760f2c085dfb3b3e9be', + '86ca6c0d669baa2f0d29b81aa9db65d9', + 'ad261f0ea9c06e69eaf9870161da902f', + '4973835d48a96917eb2b4fe3266c60f4', + '1c4bddfe0111033df5fd1903123a759b', + '07d32fc26a66558589bd2ef3d243a1bf', + '6237121ffae0bb44b6489913f859e595', + '5ab1d45dc1b8365df17dc13bfe725e3e', + 'efff82f6321e8f2ad2d83f7b87890d12', + '9939ebdbc70de2750b26857ccdf7a308', + '2ac3ed117b93db3686b51c8d3da6947d', + '47d6a16f82e7dc71156af0578e1cde4c', + '07eaf868dd64ef1ffd717111d7a73263', + '5df468122615987a0daa4da40c3f4e07', + '0e551c890758631dfc1dd549d8278fc8', ]; printOnFailure('final expectedChecksums = ['); printOnFailure(checksums.map((e) => " '$e',").join('\n')); diff --git a/pkgs/native_assets_cli/test/code_assets/config_test.dart b/pkgs/native_assets_cli/test/code_assets/config_test.dart index 8011eeea4..c8e2c1659 100644 --- a/pkgs/native_assets_cli/test/code_assets/config_test.dart +++ b/pkgs/native_assets_cli/test/code_assets/config_test.dart @@ -96,6 +96,7 @@ void main() async { linkingEnabled: true, dryRun: true, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.android, androidConfig: null, // not available in dry run @@ -119,6 +120,7 @@ void main() async { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.android, targetArchitecture: Architecture.arm64, @@ -148,6 +150,7 @@ void main() async { assets: assets, recordedUsesFile: null, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.android, targetArchitecture: Architecture.arm64, diff --git a/pkgs/native_assets_cli/test/code_assets/validation_test.dart b/pkgs/native_assets_cli/test/code_assets/validation_test.dart index 3b2b10e3d..4b13ef010 100644 --- a/pkgs/native_assets_cli/test/code_assets/validation_test.dart +++ b/pkgs/native_assets_cli/test/code_assets/validation_test.dart @@ -48,6 +48,7 @@ void main() { LinkModePreference linkModePreference = LinkModePreference.dynamic, }) { final builder = makeBuildInputBuilder() + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.linux, targetArchitecture: Architecture.arm64, @@ -214,6 +215,7 @@ void main() { group('BuildInput.targetConfig.codeConfig validation', () { test('Missing targetIOSVersion', () async { final builder = makeBuildInputBuilder() + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.iOS, targetArchitecture: Architecture.arm64, @@ -233,6 +235,7 @@ void main() { }); test('Missing targetAndroidNdkApi', () async { final builder = makeBuildInputBuilder() + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.android, targetArchitecture: Architecture.arm64, @@ -247,6 +250,7 @@ void main() { }); test('Missing targetMacOSVersion', () async { final builder = makeBuildInputBuilder() + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.macOS, targetArchitecture: Architecture.arm64, @@ -261,6 +265,7 @@ void main() { test('Nonexisting compiler/archiver/linker/envScript', () async { final nonExistent = outDirUri.resolve('foo baz'); final builder = makeBuildInputBuilder() + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.linux, targetArchitecture: Architecture.arm64, diff --git a/pkgs/native_assets_cli/test/data_assets/validation_test.dart b/pkgs/native_assets_cli/test/data_assets/validation_test.dart index dceb2a0e7..20aa7d0a9 100644 --- a/pkgs/native_assets_cli/test/data_assets/validation_test.dart +++ b/pkgs/native_assets_cli/test/data_assets/validation_test.dart @@ -41,7 +41,7 @@ void main() { linkingEnabled: false, dryRun: false, ) - ..targetConfig.setupDataConfig(); + ..targetConfig.setupTargetConfig(buildAssetTypes: [DataAsset.type]); return BuildInput(inputBuilder.json); } diff --git a/pkgs/native_assets_cli/test/example/local_asset_test.dart b/pkgs/native_assets_cli/test/example/local_asset_test.dart index f334b50ca..82785e5ff 100644 --- a/pkgs/native_assets_cli/test/example/local_asset_test.dart +++ b/pkgs/native_assets_cli/test/example/local_asset_test.dart @@ -49,6 +49,7 @@ void main() async { outputDirectoryShared: outputDirectoryShared, ) ..targetConfig.setupBuildConfig(linkingEnabled: false, dryRun: dryRun) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: targetOS == OS.macOS diff --git a/pkgs/native_assets_cli/test/example/native_add_library_test.dart b/pkgs/native_assets_cli/test/example/native_add_library_test.dart index 84bfe6965..4379de2e2 100644 --- a/pkgs/native_assets_cli/test/example/native_add_library_test.dart +++ b/pkgs/native_assets_cli/test/example/native_add_library_test.dart @@ -49,6 +49,7 @@ void main() async { outputDirectoryShared: outputDirectoryShared, ) ..targetConfig.setupBuildConfig(linkingEnabled: false, dryRun: dryRun) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.current, macOSConfig: targetOS == OS.macOS diff --git a/pkgs/native_assets_cli/test/example/native_dynamic_linking_test.dart b/pkgs/native_assets_cli/test/example/native_dynamic_linking_test.dart index eec510abf..9e463deac 100644 --- a/pkgs/native_assets_cli/test/example/native_dynamic_linking_test.dart +++ b/pkgs/native_assets_cli/test/example/native_dynamic_linking_test.dart @@ -53,6 +53,7 @@ void main() async { outputDirectoryShared: outputDirectoryShared, ) ..targetConfig.setupBuildConfig(linkingEnabled: false, dryRun: dryRun) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: targetOS == OS.macOS diff --git a/pkgs/native_assets_cli/test/link_config_test.dart b/pkgs/native_assets_cli/test/link_config_test.dart index dfcf0b19b..101c4032d 100644 --- a/pkgs/native_assets_cli/test/link_config_test.dart +++ b/pkgs/native_assets_cli/test/link_config_test.dart @@ -36,8 +36,8 @@ void main() async { outputDirectory: outDirUri, outputDirectoryShared: outputDirectoryShared, ) - ..addBuildAssetType('asset-type-1') - ..addBuildAssetType('asset-type-2') + ..targetConfig + .setupTargetConfig(buildAssetTypes: ['asset-type-1', 'asset-type-2']) ..setupLinkInput( assets: assets, recordedUsesFile: null, diff --git a/pkgs/native_assets_cli/test/validation_test.dart b/pkgs/native_assets_cli/test/validation_test.dart index 54194449e..314b7841e 100644 --- a/pkgs/native_assets_cli/test/validation_test.dart +++ b/pkgs/native_assets_cli/test/validation_test.dart @@ -37,7 +37,7 @@ void main() { outputDirectory: outDirUri, outputDirectoryShared: outDirSharedUri, ) - ..addBuildAssetType('my-asset-type') + ..targetConfig.setupTargetConfig(buildAssetTypes: ['my-asset-type']) ..targetConfig.setupBuildConfig( linkingEnabled: false, dryRun: false, diff --git a/pkgs/native_toolchain_c/lib/src/cbuilder/cbuilder.dart b/pkgs/native_toolchain_c/lib/src/cbuilder/cbuilder.dart index 794e06a3a..f311512f9 100644 --- a/pkgs/native_toolchain_c/lib/src/cbuilder/cbuilder.dart +++ b/pkgs/native_toolchain_c/lib/src/cbuilder/cbuilder.dart @@ -117,7 +117,7 @@ class CBuilder extends CTool implements Builder { required Logger? logger, String? linkInPackage, }) async { - if (!input.targetConfig.buildAssetTypes.contains(CodeAsset.type)) { + if (!input.targetConfig.buildCodeAssets) { logger?.info('buildAssetTypes did not contain "${CodeAsset.type}", ' 'skipping CodeAsset $assetName build.'); return; diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_build_failure_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_build_failure_test.dart index 75ee3e3e3..970489050 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_build_failure_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_build_failure_test.dart @@ -41,6 +41,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: targetOS == OS.macOS diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_android_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_android_test.dart index b11d87c22..1a3a1ed19 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_android_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_android_test.dart @@ -155,6 +155,7 @@ Future buildLib( linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.android, targetArchitecture: targetArchitecture, diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_ios_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_ios_test.dart index 9e0e18da1..a647b065d 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_ios_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_ios_test.dart @@ -84,6 +84,8 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig + .setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.iOS, targetArchitecture: target, @@ -238,6 +240,7 @@ Future buildLib( linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.iOS, targetArchitecture: targetArchitecture, diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_linux_host_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_linux_host_test.dart index b96a9cf76..d1223d351 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_linux_host_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_linux_host_test.dart @@ -53,6 +53,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.linux, targetArchitecture: target, diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_macos_host_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_macos_host_test.dart index 043f76271..45e49c275 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_macos_host_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_macos_host_test.dart @@ -68,6 +68,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.macOS, targetArchitecture: target, @@ -167,6 +168,7 @@ Future buildLib( linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.macOS, targetArchitecture: targetArchitecture, diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_windows_host_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_windows_host_test.dart index 50dc97e8c..892d49015 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_windows_host_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_windows_host_test.dart @@ -72,6 +72,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.windows, targetArchitecture: target, diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_test.dart index 8b421b2e8..635c12d4f 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_test.dart @@ -58,6 +58,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: macOSConfig, @@ -140,6 +141,9 @@ void main() { dryRun: dryRun, ); if (buildCodeAssets) { + buildInputBuilder.targetConfig.setupTargetConfig( + buildAssetTypes: [CodeAsset.type], + ); buildInputBuilder.targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: macOSConfig, @@ -148,6 +152,7 @@ void main() { cCompilerConfig: dryRun ? null : cCompiler, ); } + final buildInput = BuildInput(buildInputBuilder.json); final buildOutput = BuildOutputBuilder(); @@ -244,6 +249,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: macOSConfig, @@ -309,6 +315,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: macOSConfig, @@ -365,6 +372,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: macOSConfig, @@ -433,6 +441,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: macOSConfig, @@ -506,6 +515,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: macOSConfig, @@ -589,6 +599,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: macOSConfig, @@ -689,6 +700,7 @@ Future testDefines({ linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: targetOS == OS.macOS diff --git a/pkgs/native_toolchain_c/test/cbuilder/compiler_resolver_test.dart b/pkgs/native_toolchain_c/test/cbuilder/compiler_resolver_test.dart index 853ffd0e0..3a4ad1416 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/compiler_resolver_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/compiler_resolver_test.dart @@ -53,6 +53,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: targetOS == OS.macOS @@ -92,6 +93,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: OS.windows, targetArchitecture: Architecture.arm64, diff --git a/pkgs/native_toolchain_c/test/cbuilder/objective_c_test.dart b/pkgs/native_toolchain_c/test/cbuilder/objective_c_test.dart index a47c05392..4b09e7ffb 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/objective_c_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/objective_c_test.dart @@ -47,6 +47,7 @@ void main() { linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: targetOS, macOSConfig: targetOS == OS.macOS diff --git a/pkgs/native_toolchain_c/test/clinker/build_testfiles.dart b/pkgs/native_toolchain_c/test/clinker/build_testfiles.dart index 9273cc086..79a72ea20 100644 --- a/pkgs/native_toolchain_c/test/clinker/build_testfiles.dart +++ b/pkgs/native_toolchain_c/test/clinker/build_testfiles.dart @@ -37,6 +37,7 @@ Future buildTestArchive( linkingEnabled: false, dryRun: false, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: os, targetArchitecture: architecture, diff --git a/pkgs/native_toolchain_c/test/clinker/objects_test.dart b/pkgs/native_toolchain_c/test/clinker/objects_test.dart index 14fac6c49..0cdbc2120 100644 --- a/pkgs/native_toolchain_c/test/clinker/objects_test.dart +++ b/pkgs/native_toolchain_c/test/clinker/objects_test.dart @@ -42,6 +42,7 @@ Future main() async { assets: [], recordedUsesFile: null, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: os, targetArchitecture: architecture, diff --git a/pkgs/native_toolchain_c/test/clinker/throws_test.dart b/pkgs/native_toolchain_c/test/clinker/throws_test.dart index 542cc0fe9..811979a18 100644 --- a/pkgs/native_toolchain_c/test/clinker/throws_test.dart +++ b/pkgs/native_toolchain_c/test/clinker/throws_test.dart @@ -33,6 +33,7 @@ Future main() async { assets: [], recordedUsesFile: null, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: os, targetArchitecture: Architecture.x64, diff --git a/pkgs/native_toolchain_c/test/clinker/treeshake_helper.dart b/pkgs/native_toolchain_c/test/clinker/treeshake_helper.dart index 700dfd132..aef57509b 100644 --- a/pkgs/native_toolchain_c/test/clinker/treeshake_helper.dart +++ b/pkgs/native_toolchain_c/test/clinker/treeshake_helper.dart @@ -72,6 +72,7 @@ Future runTests(List architectures) async { assets: [], recordedUsesFile: null, ) + ..targetConfig.setupTargetConfig(buildAssetTypes: [CodeAsset.type]) ..targetConfig.setupCodeConfig( targetOS: os, targetArchitecture: architecture,