Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Use ccache for all native modules (#1787)
Browse files Browse the repository at this point in the history
  • Loading branch information
yujincheng08 committed Mar 23, 2022
1 parent 4d60973 commit 57c1b8b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
16 changes: 16 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import com.android.build.api.variant.ApplicationAndroidComponentsExtension
import com.android.build.gradle.BaseExtension
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.internal.storage.file.FileRepository
import java.nio.file.Paths
import org.gradle.internal.os.OperatingSystem

plugins {
id("com.android.application") apply false
Expand Down Expand Up @@ -63,6 +65,16 @@ tasks.register("Delete", Delete::class) {
delete(rootProject.buildDir)
}

fun findInPath(executable: String): String? {
val pathEnv = System.getenv("PATH")
return pathEnv.split(File.pathSeparator).map { folder ->
Paths.get("${folder}${File.separator}${executable}${if (OperatingSystem.current().isWindows) ".exe" else ""}")
.toFile()
}.firstOrNull { path ->
path.exists()
}?.absolutePath
}

fun Project.configureBaseExtension() {
extensions.findByType(BaseExtension::class)?.run {
compileSdkVersion(androidCompileSdkVersion)
Expand Down Expand Up @@ -102,6 +114,10 @@ fun Project.configureBaseExtension() {
"-DVERSION_CODE=$verCode",
"-DVERSION_NAME=$verName",
)
findInPath("ccache")?.let {
println("Using ccache $it")
arguments += "-DANDROID_CCACHE=$it"
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.4.1)
project(daemon)
cmake_minimum_required(VERSION 3.4.1)

add_subdirectory(${EXTERNAL_ROOT} external)

Expand Down
7 changes: 0 additions & 7 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
project(external)

find_program(CCACHE ccache)

if (CCACHE)
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE})
endif ()

macro(SET_OPTION option value)
set(${option} ${value} CACHE INTERNAL "" FORCE)
endmacro()
Expand Down

0 comments on commit 57c1b8b

Please sign in to comment.