A library to invoke CMake for Dart Native Assets.
This library is experimental and may change without warning, use with caution!
Refer to example
You can configure some options in your pubspec.yaml
hooks:
user_defines:
<YOUR_PACKAGE_NAME_THAT_USES_NATIVE_TOOLCHAIN_CMAKE>: # e.g., dartcv4
env_file: null # e.g., ".env"
cmake_version: null # e.g., "3.22.1", if not specified, use the latest
ninja_version: null # e.g., "1.10.2", if not specified, use the latest
prefer_android_cmake: null # true or false, defaults to true for android
prefer_android_ninja: null # true or false, defaults to true for android
android:
android_home: null # e.g., "C:\\Android\\Sdk" # can be set in .env file
ndk_version: null # e.g., "28.2.13676358"
cmake_version: null # e.g., "3.22.1", if not specified, fallback to global cmake_version
# NOTE: Ninja is the default and only generator for Android
ninja_version: null # e.g., "1.10.2", if not specified, fallback to global ninja_version
ios:
cmake_version: null # e.g., "3.22.1"
# NOTE: you need to use Generator.ninja if you want to use Ninja for platforms except Android
ninja_version: null # e.g., "1.10.2"
windows:
cmake_version: null # e.g., "3.22.1"
ninja_version: null # e.g., "1.10.2"
linux:
cmake_version: null # e.g., "3.22.1"
ninja_version: null # e.g., "1.10.2"
macos:
cmake_version: null # e.g., "3.22.1"
ninja_version: null # e.g., "1.10.2"When targeting Android, the NDK root directory is resolved in the following order (aligned with the Flutter tool's AndroidSdk.locateAndroidSdk):
user_defines.android.android_home(if set inpubspec.yaml)ANDROID_HOMEenvironment variable- Platform-default install location:
- Linux:
$HOME/Android/Sdk - macOS:
$HOME/Library/Android/sdk - Windows:
%USERPROFILE%\AppData\Local\Android\Sdk
- Linux:
<dir>/sdkfallback (for each hit above: if the directory itself is not a valid SDK but<dir>/sdkis, that subdirectory is used).aapton PATH →parent.parent.parentif it looks like an SDK root.adbon PATH →parent.parentif it looks like an SDK root.
A directory qualifies as an SDK root if it contains a platform-tools/ or
licenses/ subdirectory.
For each SDK root found above:
ANDROID_NDK_HOME(exact NDK root — highest priority)ANDROID_NDK_PATH(fallback whenANDROID_NDK_HOMEis unset)ANDROID_NDK_ROOT(additional fallback)<sdk>/ndk/<version>/directories sorted byVersion.parsein descending order (latest first; entries that cannot be parsed as a [Version] are skipped).- Linux-only legacy
<sdk>/ndk-bundle/(single-NDK layout). ndk-buildon PATH → parent directory (lowest priority).
If user_defines.android.ndk_version is specified, only NDK roots whose
basename parses to the requested version are kept; candidates without a
parseable basename (e.g. ANDROID_NDK_HOME pointing at a custom-named
directory, or ndk-bundle) are skipped.
Apache-2.0 License