-
Notifications
You must be signed in to change notification settings - Fork 65
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] Validate conditionally required fields #2126
Conversation
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
|
62df51b
to
7a550bf
Compare
Are these available in json schemas? |
Yes, that's where we are generating them from. Search for "if" in the schemas: {
"if": {
"properties": {
"target_os": {
"const": "macos"
}
}
},
"then": {
"required": [
"macos"
]
}
}, |
Object? tryTraverse(List<String> path) { | ||
Object? json = this.json; | ||
while (path.isNotEmpty) { | ||
final key = path.removeAt(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's slightly inefficient to remove the first element from the list (O(N^2)
). Why not just loop over the path?
Closes: #1826
This PR adds the final step to the generated syntax validation: conditionally required fields:
x
, then requirex
config in code config.windows
, then requirewindows
in the c compiler config (more info [native_assets_cli] IntroduceCCompilerConfig.windows
#1913).We could consider trying to nest the fields under the condition, but that has other downsides:
RE 1: Then the OS is no longer an enum usable in the code-asset as OS field. (We could consider this if we remove the OS/arch from code asset outputs. We should be able to do this due to the code config always having a single OS and architecture anyway. #2127)
RE 2: That would mean the compiler config would be split over two places.
input.config.code.cCompiler
andinputconfig.code.windows.cCompiler
. Maybe that's better? Maybe not?RE 3: Treating a group of files in assets would then become
input.assets.code.switch( ... )
instead of simplyinput.assets.code.map((a) => a.file)
. Maybe that's okay because we don't often use files in such way anyway?WDYT @mosuem @HosseinYousefi?
(I'd probably do any of those refactorings in follow up PRs.)