mirror of
https://github.com/makecindy/cindy.git
synced 2026-12-02 13:09:39 +08:00
Windows 模拟器构建恢复 CMake 平台路径缩短,并为 app 代码生成选择较短的独立 staging 缓存。 Assisted-by: Cindy (https://cindy.app) Signed-off-by: DavidShen <david@xd.com>
21 lines
1.2 KiB
Groovy
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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|