[ffigen] Add Header Files to CBuilder Sources#2098
[ffigen] Add Header Files to CBuilder Sources#2098MiniPiku wants to merge 4 commits intodart-lang:mainfrom
Conversation
- Added .h files to sources list in example/build/native_add_library/hook/build.dart - Documented sources parameter in CBuilder.library constructor to include .h files - Added note to native_assets_cli/README.md about including .h files in sources
|
The PR resolves the issue: #1332 |
| /// headers when `.h` files are included. If a compiler does not support this, | ||
| /// the build system may filter `.h` files from the compilation step while | ||
| /// still tracking them as dependencies. | ||
| super.sources = const [], |
There was a problem hiding this comment.
I think the comment should go on the field rather than the constructor argument.
There was a problem hiding this comment.
should the whole segment be moved or just this portion?
There was a problem hiding this comment.
We comment fields not constructor params, so all of it.
pkgs/native_assets_cli/README.md
Outdated
| We do breaking changes regularly! So frequently bump `package:native_assets_cli` | ||
| and use dev/master SDK for CI. | ||
|
|
||
| **Note:** When configuring `CBuilder` in your `hook/build.dart`, |
There was a problem hiding this comment.
We should not have CBuilder documentation here. The native assets cli can be used with other builders. Add the documentation to the CBuilder instead.
| /// sources: [ | ||
| /// 'src/native_add_library.c', | ||
| /// 'src/native_add_library.h', | ||
| /// 'src/dart_api_dl.c', |
There was a problem hiding this comment.
Omit dart_api_dl from the documentation, it doesn't add extra info but it does complicate things. That's not great for documentation.
| /// 'src/dart_api_dl.h', | ||
| /// ], | ||
| /// ``` | ||
| /// Supported by Clang-like compilers, which can optimize with precompiled |
There was a problem hiding this comment.
The CBuilder should work for all currently supported compilers. If this doesn't work for example for MSVC we need to filter the header files. Please remove this comment and test if it works for Windows.
pkgs/native_assets_cli/README.md
Outdated
|
|
||
| To use native assets in Flutter, use | ||
| `flutter config --enable-experiment=native-assets` and then | ||
| `flutter config --enable-experiment=native-assets` and t |
PR HealthBreaking changes ✔️
Changelog Entry ✔️
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.
License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
|
|
@dcharkes just a follow up ,i have fixed the areas of concern |
|
Please go over all the Also, in many places in the unit tests only the |
|
Closing this to clean up the backlog. For further discussion see #1332. |
This pull request fixes an issue where changes to header files (
.h) in native asset builds did not invalidate the build cache, causing stale builds withCBuilder. As noted by @dcharkes in #1332, thesourceslist previously omitted header files, missing their dependency updates. This PR implements Option 1 from the issue: adding.hfiles tosourcesto ensure rebuilds occur when headers change. Along with updating theREADME.mdfor reflecting the necessary changes made.Changes Made
Updated Example and Test Projects
CBuilderconfigurations to include.hfiles in thesourceslist across multiple projects:pkgs/native_assets_cli/example/build/native_add_library/hook/build.dart:'src/$packageName.h'and'src/dart_api_dl.h'.pkgs/native_assets_cli/example/build/use_dart_api/hook/build.dart:.hfiles (e.g.,use_dart_api.h,dart_api_dl.h).Documented
CBuilder.sourcesAdded documentation to the sources parameter in the
CBuilder.libraryconstructor inpkgs/native_toolchain_c/lib/src/cbuilder/cbuilder.dart:.cand.hfiles, aligning with the new behavior and Clang compatibility notes from the issue.Added a note to
pkgs/native_assets_cli/README.mdunder "Usage"