网上看到一个脚本
#!/bin/bashset -e
set -o pipefail
git ls-tree -r HEAD --name-only |tee | xargs touch
touch 
echo 'echo -00122-g512f9aa; exit 0' > ./tools/setlocalversion 
(cd $(lookup-file .repo/..); . build/envsetup.sh; cd boot; BUILD_UBOOT_OBM=true; set -x; . ../.buildenv.sh; cd uboot; time make -j8 ${1:-kunlun_ff_config}; time make -j8 -k) 2>&1 | tee ~/1.txt find . -type f -anewer  -print -o -type l -print | perl -npe 's!^\./!!' > newer
file-arg1-arg2  newer | pn 1 | xargs git rm -f
应该是稍微修改一下make方式,会根据make时候访问的文件来删除其余多余的源码的,不过我的linux里面touch不支持这种方式,不知道哪位大仙有更好的办法。
脚本是http://baohaojun.github.io/remove-unneeded-files-for-code-reading.html这里看到的,里面还有内核的筛选删除脚本,暂时还没用到,请问哪位大牛有这方面经验的。

解决方案 »

  1.   

    别乱删, 说不定什么时候有用
    真删的话可以把cpu相关的删了, 比如你是arm就把什么x86.ppc,mips什么的都删了
      

  2.   

    自己写了个这个还凑合用,删除arch和board里面的无关c和S文件,头文件就无能为力了
    #!/bin/bash
    echo "All uncompiled programs will be deleted!"
    cd ${PWD} || exit
    read -r -p "Have you confirmed the compilation,Invalid input is NO! [Y/n] " input
    case $input in
             [yY][eE][sS]|[yY])
                       echo "Yes"
                       ;;
                    [nN][oO]|[nN])
                       echo "No"
       exit
                       ;;
    *)
       echo "No"
       exit
       ;;
            esac
    find ./arch ./board -name *.o > tmp.txt
    sed 's/.$//' tmp.txt > tmp2.txt || exit
    sed 's/$/&*/g' tmp2.txt > tmp3.txt || exit
    cat tmp3.txt
    tar -zcvf bk.tar.gz `cat tmp3.txt` || exit
    find ./arch ./board -name *.S | xargs rm -rf
    find ./arch ./board -name *.c | xargs rm -rf
    rm -rf tmp.txt tmp2.txt tmp3.txt
    tar -zxvf bk.tar.gz
    rm -rf bk.tar.gz