利用shell脚本生成qt 项目的项目文件列表
2016-06-18 11:14
609 查看
1. 前言
最近想要在阅读有关nginx的内容, 但是平常用惯了vs, eclipse 这类的IDE 之后, 对直接拿到手的一堆nginx 代码, 一点感觉都没有, 于是, 我们希望能够找到一款IDE, 将nginx 的代码倒入进来, 方便我们阅读 nginx 的源码, 并进行相应的编写开发。2. 遇到的问题
网上搜索到了一篇文章, 是讲如何将nginx 导入 qt 的。http://www.ithao123.cn/content-678221.html, 以及 http://blog.csdn.net/zpl891011/article/details/18556185这两篇文章, 本质是一样的, 不过一个有图, 一个没图。
我们按照文章中所说的方法进行配置, 发现文中所用的nginx 版本和我们的不太一样, 因而, 并没有将所有需要的文件导入到工程中来,但是我们又比较懒, 不希望手工输入所有的文件名, 于是我们想到了下面这个方法。
3. 用到的一些shell指令
我们可以使用shell脚本来实现这个功能, 但是我们对shell指令又不太熟悉, 所以写的也比较费尽, 这里列出一些基本的shell指令的用法3.1 反引号
在shell中, 我们可以使用反引号, 将shell指令得到的结果返回给一个变量3.2 awk
主要用来以列为单位进行操作一些参考文章:
http://coolshell.cn/articles/9070.html
http://www.ahlinux.com/shell/5859.html
3.3 sed
主要以行为单位操作, 可以进行词条的替换等操作, 功能非常强大一些参考文章:
http://coolshell.cn/articles/9104.html
http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856901.html
4. shell 代码
#!/usr/bin/sh # 设置导出文件 headers=`pwd`"/"headers sources=`pwd`"/"sources function recursive { # 遍历src 文件夹中 的 文件夹 for subdir in `ls -l | grep ^d | awk {'print $9'}` do #echo $subdir # 进入子文件夹 cd $subdir # 获取路径的前缀, pwd 得到 /home/zhyh2010/nginx/src/core, 这里prefix 提取得到 src/core prefix=`pwd | sed 's/^.*nginx\///g'` #echo $prefix # 获取文件夹中所有文件项 items=`ls -l | grep ^- | awk {'print $9'}` for subitems in $items do # 将后缀名为 .h, .c 的文件信息提取出来, 放到相应文件中去 echo $prefix"/"$subitems | grep .h$ | awk {'print $1" \\"'} >> $headers echo $prefix"/"$subitems | grep .c$ | awk {'print $1" \\"'}>> $sources done # 对子文件夹作递归操作 for subitems in `ls -l | grep ^d | awk {'print $9'}` do recursive done cd .. done } # 删除原始文件 rm -rf $headers rm -rf $sources recursive
5. 配置qt
我们这里的qt 的配置文件 pro中的代码如下:ps: objs 中还有一个modules.c 需要手动导入, INCLUDEPATH 也需要作一定修改, 配置完之后, 基本的一些提示信息, 链接跳转都有了。不过线程池的相关代码, 还是有问题, 不能正常编译生成。
再继续寻找解决方案把。
TARGET = nginx DESTDIR = ./objs LIBS = -lpthread -lcrypt -lpcre -lcrypto -lcrypto -lz INCLUDEPATH += \ src/core \ src/event \ src/event/modules \ src/os/unix \ src/http/modules \ src/http \ src/mymodules/http/hello \ src/mail \ src/misc \ objs SOURCES += \ src/core/nginx.c \ src/core/ngx_array.c \ src/core/ngx_buf.c \ src/core/ngx_conf_file.c \ src/core/ngx_connection.c \ src/core/ngx_cpuinfo.c \ src/core/ngx_crc32.c \ src/core/ngx_crypt.c \ src/core/ngx_cycle.c \ src/core/ngx_file.c \ src/core/ngx_hash.c \ src/core/ngx_inet.c \ src/core/ngx_list.c \ src/core/ngx_log.c \ src/core/ngx_md5.c \ src/core/ngx_murmurhash.c \ src/core/ngx_open_file_cache.c \ src/core/ngx_output_chain.c \ src/core/ngx_palloc.c \ src/core/ngx_parse.c \ src/core/ngx_proxy_protocol.c \ src/core/ngx_queue.c \ src/core/ngx_radix_tree.c \ src/core/ngx_rbtree.c \ src/core/ngx_regex.c \ src/core/ngx_resolver.c \ src/core/ngx_shmtx.c \ src/core/ngx_slab.c \ src/core/ngx_spinlock.c \ src/core/ngx_string.c \ src/core/ngx_syslog.c \ src/core/ngx_thread_pool.c \ src/core/ngx_times.c \ src/event/ngx_event_accept.c \ src/event/ngx_event.c \ src/event/ngx_event_connect.c \ src/event/ngx_event_openssl.c \ src/event/ngx_event_openssl_stapling.c \ src/event/ngx_event_pipe.c \ src/event/ngx_event_posted.c \ src/event/ngx_event_timer.c \ src/event/modules/ngx_aio_module.c \ src/event/modules/ngx_devpoll_module.c \ src/event/modules/ngx_epoll_module.c \ src/event/modules/ngx_eventport_module.c \ src/event/modules/ngx_kqueue_module.c \ src/event/modules/ngx_poll_module.c \ src/event/modules/ngx_rtsig_module.c \ src/event/modules/ngx_select_module.c \ src/event/modules/ngx_win32_select_module.c \ src/http/ngx_http.c \ src/http/ngx_http_copy_filter_module.c \ src/http/ngx_http_core_module.c \ src/http/ngx_http_file_cache.c \ src/http/ngx_http_header_filter_module.c \ src/http/ngx_http_parse.c \ src/http/ngx_http_parse_time.c \ src/http/ngx_http_postpone_filter_module.c \ src/http/ngx_http_request_body.c \ src/http/ngx_http_request.c \ src/http/ngx_http_script.c \ src/http/ngx_http_spdy.c \ src/http/ngx_http_spdy_filter_module.c \ src/http/ngx_http_spdy_module.c \ src/http/ngx_http_special_response.c \ src/http/ngx_http_upstream.c \ src/http/ngx_http_upstream_round_robin.c \ src/http/ngx_http_variables.c \ src/http/ngx_http_write_filter_module.c \ src/http/modules/ngx_http_access_module.c \ src/http/modules/ngx_http_addition_filter_module.c \ src/http/modules/ngx_http_auth_basic_module.c \ src/http/modules/ngx_http_auth_request_module.c \ src/http/modules/ngx_http_autoindex_module.c \ src/http/modules/ngx_http_browser_module.c \ src/http/modules/ngx_http_charset_filter_module.c \ src/http/modules/ngx_http_chunked_filter_module.c \ src/http/modules/ngx_http_dav_module.c \ src/http/modules/ngx_http_degradation_module.c \ src/http/modules/ngx_http_empty_gif_module.c \ src/http/modules/ngx_http_fastcgi_module.c \ src/http/modules/ngx_http_flv_module.c \ src/http/modules/ngx_http_geoip_module.c \ src/http/modules/ngx_http_geo_module.c \ src/http/modules/ngx_http_gunzip_filter_module.c \ src/http/modules/ngx_http_gzip_filter_module.c \ src/http/modules/ngx_http_gzip_static_module.c \ src/http/modules/ngx_http_headers_filter_module.c \ src/http/modules/ngx_http_image_filter_module.c \ src/http/modules/ngx_http_index_module.c \ src/http/modules/ngx_http_limit_conn_module.c \ src/http/modules/ngx_http_limit_req_module.c \ src/http/modules/ngx_http_log_module.c \ src/http/modules/ngx_http_map_module.c \ src/http/modules/ngx_http_memcached_module.c \ src/http/modules/ngx_http_mp4_module.c \ src/http/modules/ngx_http_not_modified_filter_module.c \ src/http/modules/ngx_http_proxy_module.c \ src/http/modules/ngx_http_random_index_module.c \ src/http/modules/ngx_http_range_filter_module.c \ src/http/modules/ngx_http_realip_module.c \ src/http/modules/ngx_http_referer_module.c \ src/http/modules/ngx_http_rewrite_module.c \ src/http/modules/ngx_http_scgi_module.c \ src/http/modules/ngx_http_secure_link_module.c \ src/http/modules/ngx_http_split_clients_module.c \ src/http/modules/ngx_http_ssi_filter_module.c \ src/http/modules/ngx_http_ssl_module.c \ src/http/modules/ngx_http_static_module.c \ src/http/modules/ngx_http_stub_status_module.c \ src/http/modules/ngx_http_sub_filter_module.c \ src/http/modules/ngx_http_upstream_hash_module.c \ src/http/modules/ngx_http_upstream_ip_hash_module.c \ src/http/modules/ngx_http_upstream_keepalive_module.c \ src/http/modules/ngx_http_upstream_least_conn_module.c \ src/http/modules/ngx_http_userid_filter_module.c \ src/http/modules/ngx_http_uwsgi_module.c \ src/http/modules/ngx_http_xslt_filter_module.c \ src/http/modules/perl/ngx_http_perl_module.c \ src/mail/ngx_mail_auth_http_module.c \ src/mail/ngx_mail.c \ src/mail/ngx_mail_core_module.c \ src/mail/ngx_mail_handler.c \ src/mail/ngx_mail_imap_handler.c \ src/mail/ngx_mail_imap_module.c \ src/mail/ngx_mail_parse.c \ src/mail/ngx_mail_pop3_handler.c \ src/mail/ngx_mail_pop3_module.c \ src/mail/ngx_mail_proxy_module.c \ src/mail/ngx_mail_smtp_handler.c \ src/mail/ngx_mail_smtp_module.c \ src/mail/ngx_mail_ssl_module.c \ src/misc/ngx_google_perftools_module.c \ src/mymodules/http/hello/ngx_http_mytest_module.c \ src/os/unix/ngx_aio_read.c \ src/os/unix/ngx_aio_read_chain.c \ src/os/unix/ngx_aio_write.c \ src/os/unix/ngx_aio_write_chain.c \ src/os/unix/ngx_alloc.c \ src/os/unix/ngx_channel.c \ src/os/unix/ngx_daemon.c \ src/os/unix/ngx_darwin_init.c \ src/os/unix/ngx_darwin_sendfile_chain.c \ src/os/unix/ngx_errno.c \ src/os/unix/ngx_file_aio_read.c \ src/os/unix/ngx_files.c \ src/os/unix/ngx_freebsd_init.c \ src/os/unix/ngx_freebsd_sendfile_chain.c \ src/os/unix/ngx_linux_aio_read.c \ src/os/unix/ngx_linux_init.c \ src/os/unix/ngx_linux_sendfile_chain.c \ src/os/unix/ngx_posix_init.c \ src/os/unix/ngx_process.c \ src/os/unix/ngx_process_cycle.c \ src/os/unix/ngx_readv_chain.c \ src/os/unix/ngx_recv.c \ src/os/unix/ngx_send.c \ src/os/unix/ngx_setaffinity.c \ src/os/unix/ngx_setproctitle.c \ src/os/unix/ngx_shmem.c \ src/os/unix/ngx_socket.c \ src/os/unix/ngx_solaris_init.c \ src/os/unix/ngx_solaris_sendfilev_chain.c \ src/os/unix/ngx_thread_cond.c \ src/os/unix/ngx_thread_id.c \ src/os/unix/ngx_thread_mutex.c \ src/os/unix/ngx_time.c \ src/os/unix/ngx_udp_recv.c \ src/os/unix/ngx_user.c \ src/os/unix/ngx_writev_chain.c \ objs/ngx_modules.c HEADERS += \ src/core/nginx.h \ src/core/ngx_array.h \ src/core/ngx_buf.h \ src/core/ngx_conf_file.h \ src/core/ngx_config.h \ src/core/ngx_connection.h \ src/core/ngx_core.h \ src/core/ngx_crc32.h \ src/core/ngx_crc.h \ src/core/ngx_crypt.h \ src/core/ngx_cycle.h \ src/core/ngx_file.h \ src/core/ngx_hash.h \ src/core/ngx_inet.h \ src/core/ngx_list.h \ src/core/ngx_log.h \ src/core/ngx_md5.h \ src/core/ngx_murmurhash.h \ src/core/ngx_open_file_cache.h \ src/core/ngx_palloc.h \ src/core/ngx_parse.h \ src/core/ngx_proxy_protocol.h \ src/core/ngx_queue.h \ src/core/ngx_radix_tree.h \ src/core/ngx_rbtree.h \ src/core/ngx_regex.h \ src/core/ngx_resolver.h \ src/core/ngx_sha1.h \ src/core/ngx_shmtx.h \ src/core/ngx_slab.h \ src/core/ngx_string.h \ src/core/ngx_syslog.h \ src/core/ngx_thread_pool.h \ src/core/ngx_times.h \ src/event/ngx_event_connect.h \ src/event/ngx_event.h \ src/event/ngx_event_openssl.h \ src/event/ngx_event_pipe.h \ src/event/ngx_event_posted.h \ src/event/ngx_event_timer.h \ src/http/ngx_http_cache.h \ src/http/ngx_http_config.h \ src/http/ngx_http_core_module.h \ src/http/ngx_http.h \ src/http/ngx_http_request.h \ src/http/ngx_http_script.h \ src/http/ngx_http_spdy.h \ src/http/ngx_http_spdy_module.h \ src/http/ngx_http_upstream.h \ src/http/ngx_http_upstream_round_robin.h \ src/http/ngx_http_variables.h \ src/http/modules/ngx_http_ssi_filter_module.h \ src/http/modules/ngx_http_ssl_module.h \ src/http/modules/perl/ngx_http_perl_module.h \ src/mail/ngx_mail.h \ src/mail/ngx_mail_imap_module.h \ src/mail/ngx_mail_pop3_module.h \ src/mail/ngx_mail_smtp_module.h \ src/mail/ngx_mail_ssl_module.h \ src/os/unix/ngx_alloc.h \ src/os/unix/ngx_atomic.h \ src/os/unix/ngx_channel.h \ src/os/unix/ngx_darwin_config.h \ src/os/unix/ngx_darwin.h \ src/os/unix/ngx_errno.h \ src/os/unix/ngx_files.h \ src/os/unix/ngx_freebsd_config.h \ src/os/unix/ngx_freebsd.h \ src/os/unix/ngx_gcc_atomic_amd64.h \ src/os/unix/ngx_gcc_atomic_ppc.h \ src/os/unix/ngx_gcc_atomic_sparc64.h \ src/os/unix/ngx_gcc_atomic_x86.h \ src/os/unix/ngx_linux_config.h \ src/os/unix/ngx_linux.h \ src/os/unix/ngx_os.h \ src/os/unix/ngx_posix_config.h \ src/os/unix/ngx_process_cycle.h \ src/os/unix/ngx_process.h \ src/os/unix/ngx_setaffinity.h \ src/os/unix/ngx_setproctitle.h \ src/os/unix/ngx_shmem.h \ src/os/unix/ngx_socket.h \ src/os/unix/ngx_solaris_config.h \ src/os/unix/ngx_solaris.h \ src/os/unix/ngx_sunpro_atomic_sparc64.h \ src/os/unix/ngx_thread.h \ src/os/unix/ngx_time.h \ src/os/unix/ngx_user.h
相关文章推荐
- android wifi 无线调试
- nginx代理指定目录
- 访问Nginx发生SSL connection error的一种情况
- 运维入门
- 动态清空 nohup 输出文件
- install scrapy with pip and easy_install
- Nginx+Naxsi部署专业级Web应用防火墙
- CentOS 6.2实战部署Nginx+MySQL+PHP
- QT学习 第一章:基本对话框
- 使用Shiboken为C++和Qt库创建Python绑定
- Linux Shell常用技巧
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- Shell 脚本编程陷阱
- Nginx 学习笔记(一)
- Qt 5.6更新至RC版,最终版本近在咫尺
- 网站502与504错误分析