Linux-Shell获取未编译的工程文件并分类
来源:互联网 发布:域名解析和域名绑定 编辑:程序博客网 时间:2024/04/29 08:05
2016年10月22日 星期六
T.s.road总结笔记
项目源码:https://github.com/Tsroad/Linux-Shell-C/
作者说明:
When running this programme, the author’sPC setting is:
Ubuntu14.04 LTS+CPU 3.6GHz + RAM 8.0GB.
(form Lab 2204; Check by Keung Charteris& T.s.road CZQ)
题目
使用脚本mv_src实现将不需要的代码(以.c,.h结尾)去除。以linux 代码为例,可正常编译后,执行脚本,移动所有不是编译所需的文件和目录到指定的文件目录下。
例如:
./mv_src ./linux-src/ ./test_src/
执行脚本后,删除linux-src任一源文件,均导至编译出错。
需要提供脚本和测试过程的输出log.
对问题进行简化如下:
1. 文件夹内只包含未编译工程文件(*.c *.h Makefile etc.);
2. 子目录只做了一层,当然只要有Makefile子目录都不是问题;
3. 工程文件较少,仅为实验所用。
思路整理如下:
1. 确认哪些文件是编译所需,解决方案如下:
Gcc –M object.c >> temp.txt#会列出文件的依赖关系只有*.h文件
Gcc –H -c object.c >> temp.txt #会列出文件的依赖关系调用关系–c参数不链接,有些c文件不含main函数可用-c解决错误信息
2. 找出依赖关系后,接下来就是串的处理了,一系列的文本操作
详情见mv_src.
运行命令如下$ tar xzvf linux-src.tar.gz$ cd linux-src/$ patch -p1 < ../patchfile $ cd ../$ ./mv_src ./linux-src/ ./test_src/Done !
处理结果
系统log:
subdirmake -C subdirmake[1]: Entering directory `/home/tsroad/tsroad/linux-src/subdir'echo /home/tsroad/tsroad/linux-src/subdir"/"iolib.c >> ../../temp.txtcc -c iolib.c -o iolib.o cc -H -c iolib.c 2>> ../../temp.txtmake[1]: Leaving directory `/home/tsroad/tsroad/linux-src/subdir'echo /home/tsroad/tsroad/linux-src"/"iolib.c >> ../temp.txtcc -H -c iolib.c 2>> ../temp.txtcc -c iolib.c -o iolib.oecho /home/tsroad/tsroad/linux-src"/"main.c >> ../temp.txtcc -H -c main.c 2>> ../temp.txtcc -c main.c -o main.oecho /home/tsroad/tsroad/linux-src"/"web_server.c >> ../temp.txtcc -H -c web_server.c 2>> ../temp.txtcc -c web_server.c -o web_server.omake -C subdir cleanmake[1]: Entering directory `/home/tsroad/tsroad/linux-src/subdir'make[1]: Leaving directory `/home/tsroad/tsroad/linux-src/subdir'
参考文献:
Linux and Unix make command——http://www.computerhope.com/unix/umake.htm
How do I make a simple makefile for gcc on Linux?——http://stackoverflow.com/questions/1484817/how-do-i-make-a-simple-makefile-for-gcc-on-linux
Replace a string in shell script ——http://stackoverflow.com/questions/3306007/replace-a-string-in-shell-script-using-a-variable
cat option——https://en.wikipedia.org/wiki/Cat_(Unix)
Gcc compile argument ——https://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_3.html
linux shell String Operation——http://www.cnblogs.com/chengmo/archive/2010/10/02/1841355.html
Linux shell scripts——http://linuxcommand.org/wss0090.php
Gcc详解——http://blog.chinaunix.net/uid-21411227-id-1826747.html
Using 'sed' to find and replace ——http://unix.stackexchange.com/questions/159367/using-sed-to-find-and-replace
- Linux-Shell获取未编译的工程文件并分类
- Linux下获取文件编译的时间
- 把 VC 工程的编译配置写在一个文件中,并影响 VC 的编译
- Linux下多个文件的C++工程编写、编译要点
- linux shell, 三行命令:查找并删除重复的文件
- Linux的文件分类
- linux shell 命令获取字符串/文件的MD5值
- linux shell 命令获取字符串/文件的MD5值
- linux shell 命令获取字符串/文件的MD5值
- linux shell 命令获取字符串/文件的MD5值
- Linux shell获取执行脚本文件所在的目录
- linux shell 命令获取字符串/文件的MD5值
- lua51的编译工程文件(VC71编译)
- 静态编译FFMPEG的指令并在工程引用.a文件
- 项目工程文件分类
- 利用反射动态获取当前工程下的文件路径_并打成jar包
- 获取未安装APK文件的图标
- Qt工程在Linux下编译时出现.ui文件编译不通过的问题
- java web(1)
- 28.用户登录(1.圆形头像的设置)
- WCF并发:2
- TLV协议
- 对struts.xml中属性的分析
- Linux-Shell获取未编译的工程文件并分类
- java web(2)
- Android中的IPC机制和多线程开发模式
- First day
- 一次性把DataTable中的数据插入数据库
- java web(3)
- Java并发编程实战笔记(二)
- cocos2d-事件派发机制
- Javascript初试