cmake和configure file设置错误导致parser_header.h生成错误
Describe the bug | Bug描述
build/parser_header.h 中 runtime的最后一个头文件和editor的第一个头文件inlcude时混杂在了一起,并且出现额外的逗号,如下所示
...
#include "C:/path/to/engine/Piccolo/engine/source/runtime/resource/res_type/global/global_particle.h"
#include "C:/path/to/engine/Piccolo/engine/source/runtime/resource/res_type/global/global_rendering.h,“C:/path/to/engine/Piccolo/engine/source/editor/include/axis.h"
#include "C:/path/to/engine/Piccolo/engine/source/editor/include/editor.h"
...
Steps to reproduce | 如何复现 生成PiccoloEditor项目即可
解决办法
在 engine/source/editor/CMakeLists.txt 的第48行(最后一行)
set(PICCOLO_EDITOR_HEADS “${EDITOR_HEADERS}” PARENT_SCOPE)
改为
set(PICCOLO_EDITOR_HEADS ${EDITOR_HEADERS} PARENT_SCOPE)
去掉双引号。
同时将 engine/source/precompile/precompile.json.in 第一行
@PICCOLO_RUNTIME_HEADS@,@PICCOLO_EDITOR_HEADS@
改为
@PICCOLO_RUNTIME_HEADS@;@PICCOLO_EDITOR_HEADS@
这样才能让engine/source/precompile/precompile.cmake第5行configure_file(${PICCOLO_PRECOMPILE_PARAMS_IN_PATH} ${PICCOLO_PRECOMPILE_PARAMS_PATH}) 生成的engine/bin/precompile.json文件中的头文件名均被';'分隔开,得以被engine/source/meta_parser/parser/parser.cpp中的MetaParser::parseProject()正确解析。该函数在文件第101行解析include_files时采用的';'分隔。
修改后生成的build/parser_header.h文件中对应位置变为
...
#include "C:/path/to/engine/Piccolo/engine/source/runtime/resource/res_type/global/global_particle.h"
#include "C:/path/to/engine/Piccolo/engine/source/runtime/resource/res_type/global/global_rendering.h“
#include “C:/path/to/engine/Piccolo/engine/source/editor/include/axis.h"
#include "C:/path/to/engine/Piccolo/engine/source/editor/include/editor.h"
...