mirror of https://github.com/axmolengine/axmol.git
Merge pull request #19522 from PatriceJiang/lua_binding
[tolua] make genbinding.py to work with newer versions of NDK
This commit is contained in:
commit
e1f4ef6ccf
|
@ -37,6 +37,62 @@ def _check_python_bin_env():
|
||||||
|
|
||||||
return PYTHON_BIN
|
return PYTHON_BIN
|
||||||
|
|
||||||
|
def _find_first_file_in_dir(dir, fn):
|
||||||
|
if os.path.isfile(dir):
|
||||||
|
if os.path.basename(dir) == fn:
|
||||||
|
return os.path.join(os.path.dirname(dir), fn)
|
||||||
|
else :
|
||||||
|
return None
|
||||||
|
elif os.path.isdir(dir):
|
||||||
|
for subdir in os.listdir(dir):
|
||||||
|
searchPath = _find_first_file_in_dir(os.path.join(dir, subdir), fn)
|
||||||
|
if searchPath is not None:
|
||||||
|
return searchPath
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _find_all_files_match(dir, cond, all):
|
||||||
|
if cond(dir):
|
||||||
|
all.append(dir)
|
||||||
|
elif os.path.isdir(dir):
|
||||||
|
for subdir in os.listdir(dir):
|
||||||
|
_find_all_files_match(os.path.join(dir, subdir), cond, all)
|
||||||
|
|
||||||
|
|
||||||
|
def _find_toolchain_include_path():
|
||||||
|
'''
|
||||||
|
Search gcc prebuilt include path
|
||||||
|
for instance: "$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/include"
|
||||||
|
'''
|
||||||
|
foundFiles = []
|
||||||
|
_find_all_files_match(os.path.join(_check_ndk_root_env(), "toolchains"), lambda x : os.path.basename(x) == "stdarg.h" and "arm-linux-androideabi" in x , foundFiles)
|
||||||
|
if len(foundFiles) == 0:
|
||||||
|
return ""
|
||||||
|
else:
|
||||||
|
return "-I" + os.path.dirname(foundFiles[0])
|
||||||
|
|
||||||
|
def _find_llvm_include_path():
|
||||||
|
'''
|
||||||
|
Search llvm prebuilt include path.
|
||||||
|
for instance: "$NDK_ROOT/toolchains/llvm/prebuilt/windows-x86_64/lib64/clang/6.0.2/include"
|
||||||
|
'''
|
||||||
|
versionFile = _find_first_file_in_dir(_check_ndk_root_env(), "AndroidVersion.txt")
|
||||||
|
if versionFile is None:
|
||||||
|
return ""
|
||||||
|
versionDir = os.path.dirname(versionFile)
|
||||||
|
includeDir = _find_first_file_in_dir(versionDir, "stdarg.h")
|
||||||
|
llvmIncludePath = os.path.dirname(includeDir)
|
||||||
|
return "-I"+llvmIncludePath
|
||||||
|
|
||||||
|
|
||||||
|
def _defaultIncludePath():
|
||||||
|
'''default include path for libclang, llvm & gcc include path
|
||||||
|
'''
|
||||||
|
llvmInclude = _find_llvm_include_path()
|
||||||
|
toolchainInclude = _find_toolchain_include_path()
|
||||||
|
exactIncludes = llvmInclude + " " + toolchainInclude
|
||||||
|
return exactIncludes
|
||||||
|
|
||||||
|
|
||||||
class CmdError(Exception):
|
class CmdError(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -112,6 +168,7 @@ def main():
|
||||||
cocos_root = os.path.abspath(os.path.join(project_root, ''))
|
cocos_root = os.path.abspath(os.path.join(project_root, ''))
|
||||||
cxx_generator_root = os.path.abspath(os.path.join(project_root, 'tools/bindings-generator'))
|
cxx_generator_root = os.path.abspath(os.path.join(project_root, 'tools/bindings-generator'))
|
||||||
|
|
||||||
|
extraFlags = _defaultIncludePath()
|
||||||
# save config to file
|
# save config to file
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
config.set('DEFAULT', 'androidndkdir', ndk_root)
|
config.set('DEFAULT', 'androidndkdir', ndk_root)
|
||||||
|
@ -119,7 +176,7 @@ def main():
|
||||||
config.set('DEFAULT', 'gcc_toolchain_dir', gcc_toolchain_path)
|
config.set('DEFAULT', 'gcc_toolchain_dir', gcc_toolchain_path)
|
||||||
config.set('DEFAULT', 'cocosdir', cocos_root)
|
config.set('DEFAULT', 'cocosdir', cocos_root)
|
||||||
config.set('DEFAULT', 'cxxgeneratordir', cxx_generator_root)
|
config.set('DEFAULT', 'cxxgeneratordir', cxx_generator_root)
|
||||||
config.set('DEFAULT', 'extra_flags', '')
|
config.set('DEFAULT', 'extra_flags', extraFlags)
|
||||||
|
|
||||||
conf_ini_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'userconf.ini'))
|
conf_ini_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'userconf.ini'))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue