zoukankan      html  css  js  c++  java
  • split_lzo_lib.sh

    split_lzo_lib.sh

    #!/bin/sh
    #输入文件名
    filename=$1
    #分割文件大小
    filesize=4096
    #输出库文件名
    libname="lib"$(echo $filename | tr . _)".a"
    #输出头文件名
    hname=$(echo $filename | tr . _ | awk '{print $0".h"}')
    hdefine=$(echo ${hname}"_" | tr a-z A-Z | tr . _)
    #echo $hname
    #echo $hdefine
    #echo $libname
    #自动分割文件
    echo split
    split -a 2 -d -b $filesize $filename ${filename}"_"
    #压缩并删除原文件
    echo lzo
    ls | grep ${filename}"_.." | awk '{print "minilzo-2.06.exe "$1" rm "$1}' | sh
    #bin2elf
    echo bin2elf
    ls | grep ${filename}"_...lzo" | awk '{print "arm-none-eabi-objcopy -I binary -O elf32-littlearm -B arm --rename-section .data=.text "$1" "$1".o rm "$1}' | sh
    #生成静态库文件
    echo ar
    ls | grep ${filename}"_...lzo.o" | awk '{print "arm-none-eabi-ar -rcs "libn" "$1" rm "$1}' libn=$libname | sh
    #生成头文件
    echo .h
    arm-none-eabi-nm $libname | awk -F ' T | A ' 'BEGIN{count=0}{if(count==0){print "#ifndef "hdef" #define "hdef;count=1}else if($2!=""){print " extern uint32_t "$2";"}}END{print " #define LZO_OUT_LEN ("len") #endif"}' hdef=$hdefine len=$filesize > $hname

    split_lzop_bin2elf.sh

    #!/bin/sh
    # 输入文件名
    filename=$1
    # 分割文件大小
    filesize=$2
    # 输出库文件名
    libname="lib"$(echo $filename | tr A-Z a-z)".a"
    # 输出头文件名
    hname=$(echo $filename | tr A-Z a-z | awk -F '.' '{print $1".h"}')
    hdefine=$(echo ${hname}"_" | tr a-z A-Z | tr . _)
    #echo $hname
    #echo $hdefine
    #echo $libname
    # 自动分割文件
    echo split
    split -a 2 -d -b $filesize $filename ${filename}"_"
    # 压缩并删除原文件
    echo lzo
    ls | grep ${filename}"_.." | awk '{print "lzop.exe -U -1 "$1" -o "$1".LZO"}' | sh
    # bin2elf
    echo bin2elf
    # lzop自动把输出文件名都变成了小写
    filename=$(echo $filename | tr A-Z a-z)
    ls | grep ${filename}"_...lzo" | awk '{print "arm-none-eabi-objcopy -I binary -O elf32-littlearm -B arm --rename-section .data=.text "$1" "$1".o rm "$1}' | sh
    # 生成静态库文件
    echo ar
    ls | grep ${filename}"_...lzo.o" | awk '{print "arm-none-eabi-ar -rcs "libn" "$1" rm "$1}' libn=$libname | sh
    # 生成头文件
    echo .h
    arm-none-eabi-nm $libname | awk -F ' T | A ' 'BEGIN{count=0}{if(count==0){print "#ifndef "hdef" #define "hdef;count=1}else if($2!=""){print " extern uint32_t "$2";"}}END{print "#endif"}' hdef=$hdefine > $hname

  • 相关阅读:
    java导出Excel表格
    移动端下拉刷新上拉加载-mescroll.js插件
    java-生成任意格式的json数据
    原生js版分页插件
    JavaScript实现段落文本高亮
    学习表单重复提交问题
    java 数据库连接 驱动相关参数
    mybatis maven 代码生成器(mysql)
    maven国内镜像
    spring boot redis代码与配置
  • 原文地址:https://www.cnblogs.com/arci/p/10623752.html
Copyright © 2011-2022 走看看