GYP(Generate Your Project)一个很有价值的构建系统
2012-09-19 09:34
465 查看
转载自: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--一个使用简单的构建系统
- 如何逐步去构建一个大型网站系统 3ff8
- This wizard generates Hibernate3.0 OR mappings(*.hbm.xml).The project your select is a Hibernate 2 p
- 打造一个全命令行的Android构建系统
- 【MEF】构建一个WPF版的ERP系统
- mingw 构建 mysql-connector-c-6.1.9记录(26种不同的编译错误,甚至做了一个windows系统返回错误码与System V错误码的一个对照表)
- 构建一个轻量级的嵌入式虚拟平台,开发工程用板stm32 picoc解释器,大量自定义函数,sarm拓展,lwip移植,nes模拟器移植,系统优化,等等技术的融合
- 打造一个全命令行的Android构建系统
- 从零开始构建分布式日志系统:设计一个新系统
- 看菜鸟诉说,构建一个前端生态化的模块组件系统思路
- Spring Framework5.0 学习(1)—— 用Gradle构建一个Java Project
- 【转帖】menuconfig的执行流程,构建一个menuconfig系统的方法
- 未能加载文件或程序集“projectname, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。系统找不到指定的文件。
- 一个软件构建系统的设想
- 克隆 BSP –构建并运行一个新的WinCE 映像系统
- 深度学习与神经网络实战:快速构建一个基于神经网络的手写数字识别系统
- 菜鸟如何构建一个入门级***检测系统