zoukankan      html  css  js  c++  java
  • (ubuntu)在andorid andk工程中使用ccache加速编译速度

    环境

    系统:Linux luogw-pc 3.5.0-36-generic #57~precise1-Ubuntu SMP Thu Jun 20 18:21:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

    ndk:   ndk-r8d

    cache: ccache version 3.1.6


    第一步:安装ccache

    sudo apt-get install ccache


    第二步:配置ccache

    添加环境变量 export NDK_CCACHE=ccache


    第三步:修改 android-ndk-r8e/build/core/default-build-commands.mk

    注:红色部份为修改的内容,原内容被注释掉

    #
    # IMPORTANT: The following definitions must use lazy assignment because
    # the value of TOOLCHAIN_PREFIX or TARGET_CFLAGS can be changed later by
    # the toolchain's setup.mk script.
    #


    ifneq ($(findstring ccc-analyzer,$(CC)),)
    TARGET_CC       = $(CC)
    else
    #TARGET_CC       = $(TOOLCHAIN_PREFIX)gcc
    TARGET_CC       = ccache $(TOOLCHAIN_PREFIX)gcc
    endif
    TARGET_CFLAGS   =


    ifneq ($(findstring c++-analyzer,$(CXX)),)
    TARGET_CXX      = $(CXX)
    else
    #TARGET_CXX      = $(TOOLCHAIN_PREFIX)g++
    TARGET_CXX      = ccache $(TOOLCHAIN_PREFIX)g++
    endif
    TARGET_CXXFLAGS = $(TARGET_CFLAGS) -fno-exceptions -fno-rtti

    实践对比:

    使用ccache前后情况对比如下

    luogw@luogw-pc:~/study/bitmap-plasma$ ccache -s
    cache directory                     /home/luogw/.ccache
    cache hit (direct)                     0
    cache hit (preprocessed)               0
    cache miss                             0
    files in cache                         0
    cache size                             0 Kbytes
    max cache size                       1.0 Gbytes
    luogw@luogw-pc:~/study/bitmap-plasma$ time ndk-build
    Gdbserver      : [arm-linux-androideabi-4.7] libs/armeabi/gdbserver
    Gdbsetup       : libs/armeabi/gdb.setup
    Gdbserver      : [arm-linux-androideabi-4.7] libs/armeabi-v7a/gdbserver
    Gdbsetup       : libs/armeabi-v7a/gdb.setup
    Compile thumb  : plasma <= plasma.c
    SharedLibrary  : libplasma.so
    Install        : libplasma.so => libs/armeabi/libplasma.so
    Compile thumb  : plasma <= plasma.c
    SharedLibrary  : libplasma.so
    Install        : libplasma.so => libs/armeabi-v7a/libplasma.so
    
    real	0m0.226s
    user	0m0.128s
    sys	0m0.032s
    luogw@luogw-pc:~/study/bitmap-plasma$ ccache -s
    cache directory                     /home/luogw/.ccache
    cache hit (direct)                     0
    cache hit (preprocessed)               0
    cache miss                             2
    called for link                        2
    multiple source files                  2
    files in cache                         6
    cache size                           108 Kbytes
    max cache size                       1.0 Gbytes
    luogw@luogw-pc:~/study/bitmap-plasma$ rm -r libs/ obj/
    luogw@luogw-pc:~/study/bitmap-plasma$ time ndk-build
    Gdbserver      : [arm-linux-androideabi-4.7] libs/armeabi/gdbserver
    Gdbsetup       : libs/armeabi/gdb.setup
    Gdbserver      : [arm-linux-androideabi-4.7] libs/armeabi-v7a/gdbserver
    Gdbsetup       : libs/armeabi-v7a/gdb.setup
    Compile thumb  : plasma <= plasma.c
    SharedLibrary  : libplasma.so
    Install        : libplasma.so => libs/armeabi/libplasma.so
    Compile thumb  : plasma <= plasma.c
    SharedLibrary  : libplasma.so
    Install        : libplasma.so => libs/armeabi-v7a/libplasma.so
    
    real	0m0.114s
    user	0m0.052s
    sys	0m0.008s
    luogw@luogw-pc:~/study/bitmap-plasma$ ccache -s
    cache directory                     /home/luogw/.ccache
    cache hit (direct)                     2
    cache hit (preprocessed)               0
    cache miss                             2
    called for link                        4
    multiple source files                  4
    files in cache                         6
    cache size                           108 Kbytes
    max cache size                       1.0 Gbytes
    


    参考文章:

    1)http://www.41post.com/4509/programming/android-use-ccache-with-android-ndk-in-cygwin

    2)http://www.mirwing.com/2011/11/android-android-ndk-revision-7.html

  • 相关阅读:
    送给每天用电脑超4小时的朋友!!
    股票技术指标分析详细
    2003安装新版MSN9的方法 / MSN9 for 2003
    买卖股票基本原则新手参考
    更改Windows软件默认安装路径
    永不套牢的方法(教你正确止损)
    股票的技术参数很多,图线参数常见的有这些
    教育网ftp大全
    【笔记】【汇编语言】第4章 第一个程序
    【笔记】【汇编语言】第2章 寄存器
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3223609.html
Copyright © 2011-2022 走看看