WebKit之chrome的构建系统工具gyp(类比于qmake)
2015-12-03 22:19
246 查看
因为阅读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的安装,如果你使用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
相关文章推荐
- svn报错:Cannot negotiate authentication mechanism
- 泛型的基本介绍和使用
- OC基础(27)
- if 语句练习 身高体重问题
- 理解长短期记忆网络(LSTM NetWorks)
- 黑马程序员——Java笔记——String类的面试题
- HDU 1016Presentation Error
- 国外程序员整理的Java资源大全
- jqueryHTML相关方法
- OC基础(26)
- 原型设计(“留拍”Axure整体操作过程)
- CoffeeScript ------ 问号
- ZABBIX安装配置过程
- Quora上关于P, NP, NP-complete, and NP-hard问题的解答
- R语言数据处理(一)
- Mac使用技巧
- windows10安装ubuntu15.10后只有ubuntu启动项
- 闭包(1)初识闭包
- 用文章和视频的app例子简介React-Native
- 通俗理解马尔科夫链