我编写了一个命令行 OpenCL 编译器。每当我构建包含它们的 C# 项目时,我希望 VS 使用它来编译我的内核源文件。我环顾四周,找到了信息和自定义构建任务、自定义工具等,但我无法让它正常工作。
-
如何告诉 VS 在源文件上运行我的 exe,就像为项目中的其他文件运行 c# 编译器等一样?
-
我通过调用 Console.Error.WriteLine()
报告此工具的错误。这会尽职地将错误放在“输出”窗格中,我可以在其中双击它们,将我带到 .cl 内核源文件中的适当位置。但是,错误不会出现在 VS 错误面板中。 ??
或者,如果有人知道现有的 OpenCL 编译器 - 必须运行主机应用程序来编译内核,这很烦人 - 我会很感激一个链接。
我通过向项目选项添加构建后步骤成功地实现了此功能。但是,我真的更喜欢为项目中的每个 *.cl 文件运行此 exe。
更新 我在格式化错误消息时忽略了包含错误代码。更正它们以匹配 此处列出的任何格式都解决了该问题。不过,仍在尝试找出如何将 exe 与给定的文件扩展名关联起来。
I've written a command-line OpenCL compiler. I'd like to have VS compile my kernel source files using this whenever I build the C# project that includes them. I've looked around and found information and custom build tasks, custom tools, etc, but I haven't been able to get it to work correctly.
-
How can I tell VS to run my exe on the source files in the same way that it runs the c# compiler, etc for other files in the project?
-
I report errors from this tool by calling Console.Error.WriteLine()
. This dutifully places the errors in the Output pane, where I can double-click them, taking me to the appropriate place in the .cl kernel source file. However, the errors don't appear in the VS error panel. ??
Alternatively, if anyone's aware of an existing OpenCL compiler - it's annoying to have to run the host application just to compile the kernel - I'd appreciate a link.
I've managed to get this working by adding a post-build step to the project options. However, I'd really prefer for this exe to be run for every *.cl file in the project.
Update I had neglected to include an error code when formatting my error messages. Correcting them to match any of the formats listed here took care of that issue. Still trying to figure out how to associate an exe with a given file extension, though.
发布评论