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

  • 相关阅读:
    poj1113--凸包(Andrew)
    php变量内存完全释放
    php的内存分配还是很智能的
    git 忽略权限记录一下
    开启事务处理插入多条数据 速度也可以
    var_dump(is_writeable(ini_get("session.save_path")));
    要注意一下xss攻击啊
    select *," as A from B union ...
    多次踩坑
    js instanceof运算符
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3223609.html
Copyright © 2011-2022 走看看