Files
cindy/apps/mobile/scripts/sim-windows-native.gradle
DavidShen ae0c959fe1 fix(mobile): 修复 Windows Android 原生构建长路径
Windows 模拟器构建恢复 CMake 平台路径缩短,并为 app 代码生成选择较短的独立 staging 缓存。

Assisted-by: Cindy (https://cindy.app)
Signed-off-by: DavidShen <david@xd.com>
2026-11-10 13:53:31 +08:00

21 lines
1.2 KiB
Groovy

// Loaded only by the Windows simulator build command, not by app prebuild.
// App codegen target names leave too little room for CMake's path hashing under
// apps/mobile/android/app/.cxx. Prefer a short, reusable per-worktree cache.
gradle.beforeProject { project ->
if (project.path == ':app') {
project.pluginManager.withPlugin('com.android.application') {
project.extensions.getByName('androidComponents').finalizeDsl { android ->
if (android.externalNativeBuild.cmake.buildStagingDirectory == null) {
def worktreeCache = new File(project.rootProject.projectDir, '../../../.cxx').canonicalFile
def cacheKey = java.security.MessageDigest.getInstance('SHA-256')
.digest(project.projectDir.canonicalPath.getBytes('UTF-8'))
.encodeHex().toString().take(12)
def tempCache = new File(System.getProperty('java.io.tmpdir'), "cx-${cacheKey}").canonicalFile
android.externalNativeBuild.cmake.buildStagingDirectory =
worktreeCache.path.length() <= tempCache.path.length() ? worktreeCache : tempCache
}
}
}
}
}