Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲

用 ccache 顯著縮短 Android 源碼的重新編譯時間

編輯:Android 省電與效能提升

當你刪掉 out/target 目錄,或者用 make clean 清空輸出之後重新編譯源碼,等待時間往往非常漫長。

這個問題其實很好解決,Android 官方本身就提供了方案——ccache 編譯器快取。官方的說法是:

You can optionally tell the build to use the ccache compilation tool. Ccache acts as a compiler cache that can be used to speed-up rebuilds. This works very well if you do "make clean" often, or if you frequently switch between different build products.

啟用方式

在 home 主目錄的 .bashrc 中加入:

export USE_CCACHE=1

如果想指定一個特定的快取目錄,同樣寫進 .bashrc;不指定的話預設是當前使用者目錄下的 .ccache:

export CCACHE_DIR=/home/mokee/.ccache

接著在 MoKee OpenSource 主目錄中執行下面指令,手動把快取上限設在 50G~100G 之間:

prebuilts/misc/linux-x86/ccache/ccache -M 50G

設定完成,就可以開始編譯了。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © Android教程網 All Rights Reserved