Skip to content

[native_assets_cli] Make BuildInput JSON hierarchical #1872

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

Merged
merged 3 commits into from
Jan 8, 2025
Merged

Conversation

dcharkes
Copy link
Collaborator

@dcharkes dcharkes commented Jan 8, 2025

This changes the BuildInputBuilder to make a json with hierarchy.

The old JSON structure is also emitted in addition to prevent breaking the world.

The checksum is changed to only consume config.

The new JSON hierarchy with code config looks as follows:

  Map<String, Object> inputJson({
    String hookType = 'build',
    OS targetOS = OS.android,
  }) =>
      {
        'out_dir_shared': outputDirectoryShared.toFilePath(),
        'out_dir': outDirUri.toFilePath(),
        'package_name': packageName,
        'package_root': packageRootUri.toFilePath(),
        'version': '1.7.0',
        'config': {
          'build_asset_types': ['native_code'],
          if (hookType == 'build') 'linking_enabled': false,
          'code': {
            'target_architecture': 'arm64',
            'target_os': targetOS.name,
            'link_mode_preference': 'prefer-static',
            'c_compiler': {
              'ar': fakeAr.toFilePath(),
              'ld': fakeLd.toFilePath(),
              'cc': fakeClang.toFilePath(),
              'env_script': fakeVcVars.toFilePath(),
              'env_script_arguments': ['arg0', 'arg1'],
            },
            if (targetOS == OS.android) 'android': {'target_ndk_api': 30},
            if (targetOS == OS.macOS) 'macos': {'target_version': 13},
            if (targetOS == OS.iOS)
              'ios': {
                'target_sdk': 'iphoneos',
                'target_version': 13,
              },
          },
        },
      };

Testing:

  • Ensuring we can parse the new hierarchical JSON with this code: pkgs/native_assets_cli/test/code_assets/config_test.dart with includeDeprecated: false
  • Version skew parsing old inputs in hooks with this code: pkgs/native_assets_builder/test/build_runner/version_skew_test.dart

Follow up PRs:

  • remove env_script

Closes: #993

@dcharkes dcharkes requested a review from mkustermann January 8, 2025 14:06
@dcharkes dcharkes changed the title Input json [native_assets_cli] Make BuildInput JSON hierarchical Jan 8, 2025
Copy link

github-actions bot commented Jan 8, 2025

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbols
License Headers ✔️
// 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.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/jni/lib/src/third_party/generated_bindings.dart
pkgs/native_assets_builder/test_data/native_dynamic_linking/bin/native_dynamic_linking.dart
pkgs/objective_c/lib/src/ns_input_stream.dart

@dcharkes dcharkes marked this pull request as ready for review January 8, 2025 14:10
@coveralls
Copy link

coveralls commented Jan 8, 2025

Coverage Status

coverage: 87.981% (+0.09%) from 87.893%
when pulling cdb29b8 on input-json
into e4c4bd6 on main.

@liamappelbe liamappelbe merged commit 14368a8 into main Jan 8, 2025
34 checks passed
@liamappelbe liamappelbe deleted the input-json branch January 8, 2025 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[native_assets_cli] JSON protocol nest per asset type
3 participants