fix(builder): properly resolve user-defines for android_home on Windows - #38
Merged
Conversation
…ws (#37) Two related bugs conspired to make android_home silently ignored on Windows when configured via pubspec.yaml user_defines: 1. package:glob treats \ as an escape character, not a path separator. Windows paths from Platform.environment['ANDROID_HOME'], env files, or Directory.absolute.path were interpolated into glob patterns verbatim, so Glob('C:\\Users\\...\\Sdk/ndk/*/') matched nothing (or threw an 'expected more input' parser error). 2. input.json['user_defines'] is wrapped as {workspace_pubspec: {base_path: ..., defines: {...}}} by package:hooks, but un() forwarded the whole envelope to parseFromUserDefines, which reads keys off the top level — so �ndroid_home, cmake_version, etc. were never observed. Fixes: - UserConfig.androidHome is now normalised at construction time (backslashes -> forward slashes, trailing slash stripped, empty collapses to null). The three ad-hoc eplaceAll(r'\', '/') sites in android_ndk.dart / cmake.dart / ninja.dart are removed; the glob patterns now consume the already-normalised value directly. ool_resolver.dart::tryResolvePath is left untouched so the intentional \(x86\) escape in msvc.dart keeps working. - runStandalone peels workspace_pubspec.defines before parsing; both flat (direct callers / tests) and enveloped (hooks_runner / flutter build) shapes are accepted. Wrong-typed values are logged at WARNING and ignored instead of throwing TypeError. - Priority chain for android_home is now explicit: user_defines.android.android_home -> env_file ANDROID_HOME (only when above is null) -> Platform.environment['ANDROID_HOME'] (last resort). Tests: - New test/builder/user_config_test.dart covers parseFromUserDefines, per-OS overrides, type-tolerance, env-var non-leak, path normalisation, and the workspace_pubspec unwrap helper. - New test/native_toolchain/ndk_test.dart::issue-37-windows-backslash builds a fake on-disk SDK tree and asserts the resolver finds it through the normalised androidHome path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes: #37