Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在Generator目录运行 python main.py无法运行通过(附 报错信息) #18

Open
narutosu opened this issue May 31, 2021 · 3 comments

Comments

@narutosu
Copy link

PS E:\Work\puerts_unreal_demo\Plugins\Puerts\Generator> python main.py
('vcxproj_path ', '../../../Intermediate/ProjectFiles/puerts_unreal_demo.vcxproj')
('tree == ', <xml.etree.ElementTree.ElementTree object at 0x03DA6930>)
('root.tag ===', '{http://schemas.microsoft.com/developer/msbuild/2003}Project')
('namespaces ===', {'ns': 'http://schemas.microsoft.com/developer/msbuild/2003'})
Traceback (most recent call last):
File "main.py", line 278, in
main()
File "main.py", line 250, in main
ue_proj = UEProj(opts.project_path)
File "E:\Work\puerts_unreal_demo\Plugins\Puerts\Generator\ue_project.py", line 20, in init
include_search_paths = root.find('ns:PropertyGroup/ns:NMakeIncludeSearchPath', namespaces).text.replace('$(NMakeIncludeSearchPath)', NMakeIncludeSearchPath)
AttributeError: 'NoneType' object has no attribute 'text'

@chexiongsheng
Copy link
Owner

只支持4.24

@raytaylorlin
Copy link

这个工具本质上是需要把生成binding的代码用clang编译一遍,所以需要读取工程的信息
我用的是4.26.2,高版本UE生成的.vcproj文件中,NMakeIncludeSearchPath(include头文件的搜索路径)和NMakePreprocessorDefinitions(一些宏定义)确实是空的,然后我用低版本UE重新打开工程后看到这两项的内容大致是这样:

image

为了能用上这个代码生成器,我把<NMakeIncludeSearchPath><NMakePreprocessorDefinitions>标签的内容复制出来,然后魔改了一下ue_project.py

include_search_paths = '<NMakeIncludeSearchPath>标签中包含的内容,用;隔开'
preprocessor_definitions = '<NMakePreprocessorDefinitions>'标签中包含的内容,用;隔开
# 如果使用过程中found_ue4_dir也有问题,就不要匹配了,直接写死
# found_ue4_dir = "C:\\Program Files\\Epic Games\\UE_4.26\\Engine"

这样就能正常使用了。以上方法仅限个人试用,作者也说了这个工具本来就是未公开的,没有维护也很正常。因为官方的纯C++api的支持静态绑定还是有一些不完善的地方,没法覆盖到我实际遇到的一些需求,这个生成工具恰好能够补足,但要花费一番功夫魔改一番。以上仅供参考

@chexiongsheng
Copy link
Owner

这个工具本质上是需要把生成binding的代码用clang编译一遍,所以需要读取工程的信息 我用的是4.26.2,高版本UE生成的.vcproj文件中,NMakeIncludeSearchPath(include头文件的搜索路径)和NMakePreprocessorDefinitions(一些宏定义)确实是空的,然后我用低版本UE重新打开工程后看到这两项的内容大致是这样:

image

为了能用上这个代码生成器,我把<NMakeIncludeSearchPath><NMakePreprocessorDefinitions>标签的内容复制出来,然后魔改了一下ue_project.py

include_search_paths = '<NMakeIncludeSearchPath>标签中包含的内容,用;隔开'
preprocessor_definitions = '<NMakePreprocessorDefinitions>'标签中包含的内容,用;隔开
# 如果使用过程中found_ue4_dir也有问题,就不要匹配了,直接写死
# found_ue4_dir = "C:\\Program Files\\Epic Games\\UE_4.26\\Engine"

这样就能正常使用了。以上方法仅限个人试用,作者也说了这个工具本来就是未公开的,没有维护也很正常。因为官方的纯C++api的支持静态绑定还是有一些不完善的地方,没法覆盖到我实际遇到的一些需求,这个生成工具恰好能够补足,但要花费一番功夫魔改一番。以上仅供参考

有哪些没完善的地方呢?可以去提个issue啊,理论上模板那个更好完善些。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants