Not easily, the way Cycles is integrated requires access to Blender APIs that are not available to addons. In principle it is possible to do all the same things through the Python API, but that would require rewriting a lot of the Blender to Cycles conversion code.
brecht, what do you think about the following idea.
Cycles “add-on”, I mean cycles RenderEngine implementation in python, imports the “_cycles” module. This module is generated by blender.exe on every blender start up.
Can I build _cycles as a .pyd dynamic library. And import it in my CustomCyclesRenderEngine?
Actually, I did it. Now I have CustomCycles.pyd, and I can import it in my add-on. But… I have problems with the RNA access. When I pass scene.as_pointer() to C++ it doesn’t have scene.cycles. And I do not know why.
Please, could you answer this question? And is the idea feasible?
I know that _cycles is part of Blender and uses Blender API.
I have built _cycles as .pyd. More precisely, I slightly changed blender_python.cpp code and cmake lists, so this _cycles.pyd has all blender API inside and it is importable in python.
I think these are just nodes that got renamed, they should all be there. Still for interactive viewport rendering going through XML is not really an option, you need to talk to the API directly.
One way or another, I think making this separation requires quite a lot of work. Either rewriting the Cycles export code to be more Python based like other external renderers that integrate into Blender, or supporting an official C++ Blender API that can be shared with official Cycles. Both would likely be months of work.