WELCOME TO DFC
==============
Learn DFC In Three Chapters...
* Chapter One: What Is DFC?
* Chapter Two: Getting Start
* Chapter Three: Introduction Of Modules
* Chapter Four: Compile On Windows Platform
1 What Is DFC?
DFC is a short for Dust, Farm, and Crop. It provides a develop flow for C/C++ project. In a nutshell, Dust is source code of platform, Farm is a platform, Crop is a running environment. First, Dust is a integration of modules, such as communication module, log module, error manage module, debug outside module, and so on. User can add a new module to insert into Dust. It can generate a platform named Farm easily via executing a script in Dust. Farm provides some simple interfaces for user to add its own business code. Farm use 'cmake' to generate executable files. This can let user avoid writing complex makefiles and pay their attention to kernel code. It can pack all executable files, config files, tools scripts into a published media named crop_x.y.z.tar.gz. This compression package can pass to maintenance personnel. Crop unpacked will be a complete running environment.
DFC use a globally-unique config file: dfc.conf, which contains config infomation of every submodule. dust, farm and crop use dfc.conf as its config file.
Dust and Farm use 'build.sh' in respective build directory to generate executable file and lower platform.
General catalogue of DFC:
[root@localhost dust]# tree -L 2
.
|-- README
|-- build
| `-- build.sh //compile dust, publish farm, and so on,Input './build.sh help' to get more help infomation.
|-- moduleComm //submodule -- communication
|-- moduleErr //submodule -- error manage
|-- moduleLg //submodule -- communication with outside
|-- moduleLog //submodule -- log
|-- moduleMem //submodule -- memory leak check
|-- moduleTools //submodule -- tools
|-- script //contains useful script
|-- unity //test assistant tool for TDD
`-- platform
|-- dfc.conf //globally-unique config file
|-- main.c //dust platform main module
|-- main.h //dust platform main module
|-- userapp.c //demo
|-- userapp.h //demo
|-- crop_README //README of crop
|-- crop_install.sh //setup script of crop
|-- dust2farm.sh //package dust to farm, called by build.sh
|-- farm2crop.sh //package farm to crop, called by farm_build.sh
|-- farm_README //README of farm
|-- farm_build.sh //compile script of farm
|-- farm_CMakeLists.txt //cmake config file of farm
`-- farm_src_CMakeLists.txt //cmake config file of farm
More complete develop process like following:
(Dust developer)
dust_1.0.0 --> ./build.sh dust --> dfc(test demo) --> develop finished! --> ./build.sh farm --> farm_1.0.0.tar.gz
(Farm developer)
farm_1.0.0.tar.gz --> farm_1.0.0 --> ./build.sh farm --> dfc(test demo) --> develop finished! --> ./build.sh crop --> crop_1.0.0.tar.gz
(Operational people)
crop_1.0.0.tar.gz --> crop_1.0.0 --> ./install.sh --> a complete running environment.
2 Getting Start
2.1 Use Dust
2.1.1 hello world!
a. modify line 23 in'dust/platform/userapp.c' as:
const char* appVersion = "hello world!";
b. cd dust/build/ && ./build.sh
c. [root@localhost build]# ./dfc -v
gcc: 4.1.2 20080704 (Red Hat 4.1.2-48)
module: app, version: hello world!, compile: Feb 21 2013 22:15:12
module: comm, version: 1.0.0, compile: Feb 21 2013 22:10:00
module: log, version: 1.0.0, compile: Feb 21 2013 22:10:00
module: lg, version: 1.0.0, compile: Feb 21 2013 22:10:00
d. ok, we modified version as 'hello world!', and we got a show by dfc.
2.1.2 add a new submodule
TO BE ADDED ...
2.1.3 test your new submodule
TO BE ADDED ...
2.2 Use Farm
See dust/platform/farm_README.
2.3 Use Crop
See dust/platfrom/crop_README.
3 Introduction Of Modules
Every introduction of modules will be found in the header file of module. Try "cat logModule/logModule.h" for example.
4 Compile On Windows Platform
You can also compile DFC on windows platform easily, it means that you can use DFC into your windows project.
Step:
a. Download and install cmake-2.8.10.2-win32-x86 and VS2008 (also you can chose any other version of Visual Studio or cmake)
b. Open cmake for win32, chose directory where is the source code, e.g. D:/dust
and directory where to build the binaries, e.g. D:/dust/build_win
c. Configure --specify the generator: Visual Studio 9 2008, Use default native compiler.
If you didn't install VS2008, there will be a error tip.
d. Generate.
e. Enter D:/dust/build_win and you will find *.sln, which can be opened by VS2008.
欢迎使用DFC
===========
通过三个章节了解DFC:
1、什么是DFC?
2、开始使用
3、模块介绍
4、在windows平台上编译
1 什么是DFC?
DFC是Dust、Farm和Crop的缩写,为C/C++项目提供了一个开发流。概括地说,Dust是平台源码,Farm是开发平台,Crop是运行环境。首先,Dust是一个基础模块的集合,如通信模块、日志模块、错误管理模块、与外部通讯模块等,用户可以很方便的集成新的模块到Dust中。通过执行Dust中的脚本,可以很方便的生成一个名为Farm的开发平台。Farm提供了简单的接口让用户增加自己的业务代码,通过执行Farm中的脚本,可以生成可执行程序,并将可执行程序、配置文件、辅助工具等打包为发布介质Crop。解压后的Crop将是一个完整的运行环境。
DFC使用一个全局唯一的配置文件dfc.conf,包含各个子模块的配置信息,dust、farm和crop均使用该配置文件。
dust和farm均使用各自build目录下的build.sh脚本完成可执行文件及下游平台的生成。
DFC大体的目录结构:
[root@localhost dust]# tree -L 2
.
|-- README
|-- build
| `-- build.sh //编译dust、发布farm等,输入./build.sh help可得到较为详尽的帮助信息
|-- moduleComm //子模块--通信
|-- moduleErr //子模块--错误管理
|-- moduleLg //子模块--与外部通讯
|-- moduleLog //子模块--日志
|-- moduleMem //子模块--内存泄漏查找
|-- moduleTools //子模块--常用工具库
|-- script //包含各种有用的脚本
|-- unity //测试驱动开发的测试辅助工具
`-- platform
|-- dfc.conf //DFC平台唯一的配置文件
|-- main.c //dust平台总模块--源文件
|-- main.h //dust平台总模块--头文件
|-- userapp.c //demo--源文件
|-- userapp.h //demo--头文件
|-- crop_README //crop的README
|-- crop_install.sh //crop的安装脚本
|-- dust2farm.sh //dust到farm的打包脚本,由build.sh调用
|-- farm2crop.sh //farm到crop的打包脚本,由farm_build.sh调用
|-- farm_README //farm的README
|-- farm_build.sh //farm的编译脚本
|-- farm_CMakeLists.txt //farm的cmake总配置文件
`-- farm_src_CMakeLists.txt //farm的cmake用户配置文件
一个较为完整的开发过程如下:
(Dust开发者)
dust_1.0.0 --> ./build.sh dust --> dfc(测试demo) --> 开发完成 --> ./build.sh farm --> farm_1.0.0.tar.gz
(Farm开发者)
farm_1.0.0.tar.gz --> farm_1.0.0 --> ./build.sh farm --> dfc(测试demo) --> 开发完成 --> ./build.sh crop --> crop_1.0.0.tar.gz
(运维人员)
crop_1.0.0.tar.gz --> crop_1.0.0 --> ./install.sh --> 完整的运行环境
2 开始使用
2.1 Dust的使用
2.1.1 hello world!
a. 修改dust/platform/userapp.c的23行为:
const char* appVersion = "hello world!";
b. 进入dust/build/,执行./build.sh
c. 再执行./dfc -v,即可获得如下内容:
[root@localhost build]# ./dfc -v
gcc: 4.1.2 20080704 (Red Hat 4.1.2-48)
module: app, version: hello world!, compile: Feb 21 2013 22:15:12
module: comm, version: 1.0.0, compile: Feb 21 2013 22:10:00
module: log, version: 1.0.0, compile: Feb 21 2013 22:10:00
module: lg, version: 1.0.0, compile: Feb 21 2013 22:10:00
d. 好了,我们在修改了业务代码中的版本号为hello world!,并在最终的可执行文件中得到显示。今后,如果要测试你新加或已有的子模块代码,可以在userapp.c/h中进行修改。
2.1.2 增加一个新的子模块
待补充...
2.1.3 测试你的新模块
待补充...
2.2 Farm的使用
参见 dust/platform/farm_README.
2.3 Crop的使用
参见 dust/platform/crop_README.
3 模块介绍
每个模块的介绍及使用均可以在模块的头文件里找到。你可以试一下"cat moduleLog/moduleLog.h"这个命令。
4 在windows平台上编译
你可以在windows平台上非常容易的编译DFC,也就是说可以将DFC应用在你的windows项目中。
步骤:
a. 下载并安装 cmake-2.8.10.2-win32-x86 以及 VS2008 (当然你也可以选择其他版本)
b. 打开cmake,选择源文件目录,如 D:/dust
以及编译二进制文件的目录,如 D:/dust/build_win
c. Configure --指定生成器: Visual Studio 9 2008, 选择Use default native compiler.
如果你没有安装VS2008,会看到一个错误提示。
d. Generate.
e. 进入 D:/dust/build_win 你可以看到*.sln, 该文件可以由VS2008打开。