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

Add cppfront's header(*.h2) support #4943

Merged
merged 4 commits into from
Apr 7, 2024
Merged

Add cppfront's header(*.h2) support #4943

merged 4 commits into from
Apr 7, 2024

Conversation

shaoxie1986
Copy link
Contributor

添加cppfront对于.h2的支持 #4938

@@ -35,31 +35,58 @@ rule("cppfront.build")
end
end
end)
on_buildcmd_file(function (target, batchcmds, sourcefile_cpp2, opt)
on_buildcmd_files(function (target, batchcmds, sourcebatch, opt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要一起处理,on_buildcmd_file 拆成单文件粒度,是可以并行编译,这么搞,只能串行编译了,会很慢。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

主要是如果cpp2先处理,如果依赖的h2后处理,生成的cpp编译的时候可能提示缺少头文件。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

补充提交了,使用add_deps方式的

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那应该拆成两个 rule ,一个处理 cpp2 一个处理 h2 ,然后通过 add_deps("", {order = true}) 配置依赖关系,确保执行顺序

cpp2_files = {}
all_files = {}
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
if string.endswith(sourcefile, ".h2") then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用 path.extension

batchcmds:set_depmtime(os.mtime(sourcefile_h))
batchcmds:set_depcache(target:dependfile(sourcefile_h))
end)

-- define rule: cppfront.build
rule("cppfront.build")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那这里也得改成 cppfront.build.cpp2 ,跟 .h2 保持命名风格一致

@waruqi
Copy link
Member

waruqi commented Apr 7, 2024

另外,测下增量编译是否 work

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Also, test whether incremental compilation works.

@waruqi waruqi merged commit 1cdbbde into xmake-io:dev Apr 7, 2024
19 checks passed
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

Successfully merging this pull request may close these issues.

3 participants