GYP(Generate Your Project)一个很有价值的构建系统
2012-09-19 09:34
288 查看
转载自:http://blog.csdn.net/bertzhang/article/details/7387954
因为阅读chromium的需要,也熟悉了一下chromium使用的GYP构建系统,其实这个系统和我原来所在的一个公司的构建系统非常相似,因此学习起来也比较容易。
首先看一下gyp的安装,如果你使用ubuntu系统那么安装可以通过下面的命令完成:
[cpp] view
plaincopy
sudo apt-get install gyp
下面我们就通过一个例子来看看gyp的使用,假设我们编写三个文件hello_world.cc, my_class.h, my_class.cc这三个文件内容如下:
hello_world.cc
[cpp] view
plaincopy
#include <stdio.h>
#include "my_class.h"
int main(int argc, char** argv) {
printf("hello world\n");
MyClass my_class(100);
my_class.Fun1();
}
my_class.h
[cpp] view
plaincopy
class MyClass {
public:
MyClass(int value) : value_(value) {}
void Fun1();
private:
int value_;
};
my_class.cc
[cpp] view
plaincopy
#include "my_class.h"
#include <stdio.h>
void MyClass::Fun1() {
printf("the value is %d\n", value_);
}
下面我们编写构建文件foo.gyp
foo.gyp
[cpp] view
plaincopy
{
'targets': [
{
'target_name': 'foo',
'type': 'executable',
'sources': [
'hello_world.cc',
'my_class.h',
'my_class.cc',
],
},
],
}
然后运行命令:
[cpp] view
plaincopy
gyp --depth=. foo.gyp
其中--depth=.虽然没什么用,但必须要加上,参考文献[1]说是chromium遗留问题
命令运行后会生成Makefile文件,这样就可以使用make进行编译了。
注意:最后}后面没有“,”, 开始这个地方写错了,总是出错,耽误了不少时间。
如果涉及到库、编译依赖、跨平台等问题可以详细参考文献[2],这里不一一说明,本文主要演示一个简单的使用过程,更多功能可以参考文献[2]来实现。
文献1比较了gyp和cmake等,也有一定的参考价值。
参考文献:
[1]http://blog.xiaogaozi.org/2011/10/29/introduction-to-gyp
[2]http://code.google.com/p/gyp/wiki/GypUserDocumentation
因为阅读chromium的需要,也熟悉了一下chromium使用的GYP构建系统,其实这个系统和我原来所在的一个公司的构建系统非常相似,因此学习起来也比较容易。
首先看一下gyp的安装,如果你使用ubuntu系统那么安装可以通过下面的命令完成:
[cpp] view
plaincopy
sudo apt-get install gyp
下面我们就通过一个例子来看看gyp的使用,假设我们编写三个文件hello_world.cc, my_class.h, my_class.cc这三个文件内容如下:
hello_world.cc
[cpp] view
plaincopy
#include <stdio.h>
#include "my_class.h"
int main(int argc, char** argv) {
printf("hello world\n");
MyClass my_class(100);
my_class.Fun1();
}
my_class.h
[cpp] view
plaincopy
class MyClass {
public:
MyClass(int value) : value_(value) {}
void Fun1();
private:
int value_;
};
my_class.cc
[cpp] view
plaincopy
#include "my_class.h"
#include <stdio.h>
void MyClass::Fun1() {
printf("the value is %d\n", value_);
}
下面我们编写构建文件foo.gyp
foo.gyp
[cpp] view
plaincopy
{
'targets': [
{
'target_name': 'foo',
'type': 'executable',
'sources': [
'hello_world.cc',
'my_class.h',
'my_class.cc',
],
},
],
}
然后运行命令:
[cpp] view
plaincopy
gyp --depth=. foo.gyp
其中--depth=.虽然没什么用,但必须要加上,参考文献[1]说是chromium遗留问题
命令运行后会生成Makefile文件,这样就可以使用make进行编译了。
注意:最后}后面没有“,”, 开始这个地方写错了,总是出错,耽误了不少时间。
如果涉及到库、编译依赖、跨平台等问题可以详细参考文献[2],这里不一一说明,本文主要演示一个简单的使用过程,更多功能可以参考文献[2]来实现。
文献1比较了gyp和cmake等,也有一定的参考价值。
参考文献:
[1]http://blog.xiaogaozi.org/2011/10/29/introduction-to-gyp
[2]http://code.google.com/p/gyp/wiki/GypUserDocumentation
相关文章推荐
- GYP(Generate Your Project)一个很有价值的构建系统
- GYP(Generate Your Project)一个很有价值的构建系统
- GYP工具Generate Your Projects
- Hudson--一个使用简单的构建系统
- 使用国际开源项目构建一个完整的GIS(地理信息)应用系统
- NServiceBus 一个用于构建企业级 .NET系统的开源通讯框架
- nixyx —— 一个小巧的项目工程/编译文件生成器(构建系统?)
- GYP构建系统总结
- 用busybox构建一个最小根文件系统
- 使用 Ansible 在树莓派上构建一个基于 Linux 的高性能计算系统
- 构建一个简单的CaaS系统
- 如何逐步去构建一个大型网站系统
- 如何开发一个异常检测系统:使用什么特征变量(features)来构建异常检测算法
- 视频版|如何构建一个好的资产管理系统(CMDB)
- chromium之gyp构建系统
- 使用 Ansible 在树莓派上构建一个基于 Linux 的高性能计算系统
- Django在OS X下的编程实战(一)构建一个博客系统
- 如何逐步去构建一个大型网站系统 3ff8
- This wizard generates Hibernate3.0 OR mappings(*.hbm.xml).The project your select is a Hibernate 2 p
- 一步一步用jenkins,ansible,supervisor打造一个web构建发布系统