cocos:C++ 导出到lua, genbindings.py修改
cocos:C++ 导出到lua, genbindings.py修改
1. 准备
把tools目录下的cocos2dx_extension.ini, genbindings.py, userconf.ini拷贝到
一个新的目录下,作为修改模板
2. 修改genbindings.py -> build.py
2.1
NDK_ROOT = "/Users/staff/Documents/worksoft/android-ndk-r9"
必须是r9的不能用最新的r10
2.2 三个目录,都是绝对路径
1、 工程目录,根据自己的实际情况获取
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
2. cocos_root 目录,也就是cococ2dx所在的目录
cocos_root = os.path.abspath(os.path.join(project_root, '../cocos2dx'))
3. cxx_generator_root目录,tools/bindings-generator目录,也就是generator.py所在目录,tolua的工具路径
cxx_generator_root = os.path.abspath(os.path.join(project_root, 'tools/bindings-generator'))
2.3 保存设置到userconf.ini文件,所以这个文件不需要拷贝
保存的配置信息都是上面获取,基本保持和genbindings.py一样,这里值添加了一个zqdir目录,也就是我们的工程目录,这里的配置是在cocos2dx_extension.ini这样的配置文件中使用的
# save config to file
config = ConfigParser.ConfigParser()
config.set('DEFAULT', 'androidndkdir', ndk_root)
config.set('DEFAULT', 'clangllvmdir', llvm_path)
config.set('DEFAULT', 'cocosdir', cocos_root)
config.set('DEFAULT', 'cxxgeneratordir', cxx_generator_root)
config.set('DEFAULT', "zqdir", project_root)
config.set('DEFAULT', 'extra_flags', '')
conf_ini_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'userconf.ini'))
print 'generating userconf.ini...'
with open(conf_ini_file, 'w') as configfile:
config.write(configfile)
2.4 两个目录,都是绝对路径
1. tolua_root类似于tools/tolua目录,也就是cocos2dx_extension.ini文件所在目录
tolua_root = '%s/auto_build' % project_root
2. output_dir 输出目录,也就生成的.h 和 .cpp文件的目录
output_dir = '%s/bindings' % project_root
2.5 cmd_args 配置
//zq.ini配置文件名
//'zq' -s SECTION sets a specific section to be converted, 我们知道ini的配置文件都需要有section,每个section下面有很多配置项,这里对应zq.ini中的[zq] section,zq.ini中
>>[zq] //zq section
>>the prefix to be added to the generated functions. You might or might not
>>use this in your own
>>templates
>>prefix = zq
//lua_zq_auto 生成的.h 和 .cpp文件名
cmd_args = {
'zq.ini': ('zq', 'lua_zq_auto')
}
//下面这些没有改动
target = 'lua' //生成目标
//generator.py文件
generator_py = '%s/generator.py' % cxx_generator_root
//循环生成
for key in cmd_args.keys():
args = cmd_args[key]
cfg = '%s/%s' % (tolua_root, key) //配置文件zq.ini文件
print 'Generating bindings for %s...' % (key[:-4])
//执行generator.py [options] {configfile} 命令
//generator.py --help
// Usage: generator.py [options] {configfile}
// Options:
// -h, --help show this help message and exit
// -s SECTION sets a specific section to be converted
// -t TARGET specifies the target vm. Will search for TARGET.yaml
// -o OUTDIR specifies the output directory for generated C++ code
// -n OUT_FILE specifcies the name of the output file, defaults to the prefix
in the .ini file
command = '%s %s %s -s %s -t %s -o %s -n %s' % (python_bin, generator_py, cfg, args[0], target, output_dir, args[1])
_run_cmd(command)
cocos:C++ 导出到lua, genbindings.py修改的更多相关文章
- cocos:C++ 导出到lua, cocos2dx_extension.ini修改
cocos:C++ 导出到lua, cocos2dx_extension.ini修改 [zq] //zq section, 需要和genbindings.py中的配置相同 # the prefix t ...
- cocos执行tolua/genbindings.py文件,错误搜集:
1.PYTHON_BIN not defined, use current python.这个不是错误 2.llvm toolchain not found!path: /Users/staff/Do ...
- cocos进阶教程(1)Lua调用自定义C++类和函数的最佳实践
第一层:纯C环境下,把C函数注册进Lua环境 a.lua 文件 )) a.c 文件 #include <lua.h> #include <lualib.h> #include ...
- c++对象导出到lua
转自:http://www.cnblogs.com/ringofthec/archive/2010/10/26/luabindobj.html 虽然有tolua++, luabind等等, 不过自己手 ...
- hiredis异步接口封装并导出到Lua
hiredis异步接口封装并导出到Lua(金庆的专栏 2017.1)hiredis 不支持 Windows, Windows 下使用 wasppdotorg / hiredis-for-windows ...
- cocos2d-x中CCEditbox导出到lua
自从工作后感觉时间较少(每天工作9-22,晚上就不想动了,早上想多睡点),工作中用的是 cocos2d-x.cocos2d-x是一款手机游戏引擎,虽然支持lua,但和love2d相比非纯lua游戏引 ...
- cocos studio UI 1.6.0.0 修改导出项目路径
因为cocos studio UI 1.6.0.0版本没有自动修改默认导出路径的功能,新建项目后默认导出的路径还是上一个项目的,每次导出都要重新设置路径很麻烦.于是考虑是否可以找到默认配置文件,终于还 ...
- 学习cocos code ide 的lua编程
装上了cocos code ide,配了路径之后,建立一个默认lua工程,发现无法调试,报错. 问了别人,在cocos2dconstants.lua的613行插入cc.AsyncTaskPool = ...
- Cocos Code IDE新建lua工程报错解决方案
今天想用cocos code IDE新建一个工程,但是控制台报错:Read json file null failed, the reason is:null.我下载的是官方3.5源码,sdk,ndk ...
随机推荐
- Linux(centOS6.5)安装RabbitMQ
第一.下载erlang和rabbitmq-server的rpm: wget http://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el7.c ...
- Java 中要将 String 类型转化为 int 类型
在 Java 中要将 String 类型转化为 int 类型时,需要使用 Integer 类中的 parseInt() 方法或者 valueOf() 方法进行转换. 例1: 1 2 3 4 5 6 S ...
- C++ 中 string和char* 的区别
C++ 中 string和char* 的区别 1.定义: string:string是STL当中的一个容器,对其进行了封装,所以操作起来非常方便. char*:char *是一个指针,可以指向一个字符 ...
- 2019-11-29-C#-性能分析-反射-VS-配置文件-VS-预编译
原文:2019-11-29-C#-性能分析-反射-VS-配置文件-VS-预编译 title author date CreateTime categories C# 性能分析 反射 VS 配置文件 V ...
- C#中的System.Type和System.RuntimeType之间的区别
string str = string.Empty; Type strType = str.GetType(); Type strTypeType = strType.GetType(); strTy ...
- JS 对象属性名排序
问题,对象属性名排序,如: var data = { A:[], D:[], B:{} } 调整为=> var data = { A:[], B:[], D:{} } 方法一: for,in,把 ...
- JS--插件: 树Tree 开发与实现
日常在Web项目开发时,经常会碰到树形架构数据的显示,从数据库中获取数据,并且显示成树形.为了方便,我们可以写一个javascript的一个跨浏览器树控件,后续可以重复使用.本节分享一个自己开发的JS ...
- js生成一定范围内的随机整数
Math.floor(Math.random()*(m-n+1)+n) Math.floor(Math.random() * (50 - 1 + 1) + 1): 生成1-50内的随机整数
- Angular4 innerHtml呈现富文本内容样式
import { Pipe, PipeTransform } from "@angular/core"; import { DomSanitizer } from '@angula ...
- preflight request预检请求
preflight request预检请求,负责检查是否允许跨域请求,但是注意并不是所有的跨域请求都会发送preflight请求.对与那些幂等的请求,如GET请求,就不会发送preflight请求.只 ...