android 7.0 如何节省编译时间

1. 在~/.bashrc中添加(或者/etc/profile文件中):
#ccache
export USE_CCACHE=1
export CCACHE_DIR=~/.ccache

2. 使用Android源码prebuilts目录下面的ccache工具初始化该文件夹 
推荐的cache目录大小为50-100GB,在命令行执行以下命令:
prebuilts/misc/linux-x86/ccache/ccache -M 50G

3. 查看ccahe使用情况
watch -n1 -d prebuilts/misc/linux-x86/ccache/ccache -s

4. 开启kernel ccache 
(2). kernel/xx/Makefile文件中的

AS      = $(CROSS_COMPILE)as
LD      = $(CROSS_COMPILE)ld
CC      = $(CROSS_COMPILE)gcc
CPP     = $(CC) -E

之后添加:

ifneq ($(USE_CCACHE),)
  export CCACHE_COMPILERCHECK := content
  export CCACHE_SLOPPINESS := time_macros,include_file_mtime,file_macro
  export CCACHE_BASEDIR := /
  ccache := $(strip $(wildcard $(PWD)/../prebuilts/misc/linux-x86/ccache/ccache))
  ifdef ccache
    ifneq ($(ccache),$(firstword $(CC)))
      CC := $(ccache) $(CC)
    endif
    ccache =
  endif
endif

上述方法除了第一次会编译时间长,以后每次重编大概可以节约40%~50%时间
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值