Someone requested information about writing a C++ binding some time ago. I'm pasting my mail:
To: Tim Brooks
From: Daniel Grunwald
Date: Sun, 28 May 2006 20:32:20 +0200
>No one else is working on C++ bindings. The SharpDevelop 1.1 C++
>binding was very primitive: you could enter code and compile it;
>there was no class browser support etc.
>SharpDevelop 2.0 is using MSBuild for compiling, so the old C++
>binding is no help for that. That means you have to start at zero.
>What complicates this even more is that Visual Studio uses some
>trick to compile C++ projects using MSBuild - their project files
>are not MSBuild files. That means you probably have to make a new
>project format for SharpDevelop 2.0 C++ projects.
>
>I just responded to a request
for help writing an IronPython
>binding. The same instructions apply to any new language binding, so
>I'll paste a copy for you:
>
>Sorry, there currently is no documentation about backend bindings
>now.
>The first step is creating a project type and the compiler binding.
>For the compiler, you need to write a MSBuild task for the compiler.
>Then you'll need a targets file that can be included by MSBuild and
>calls that task.
>In the SharpDevelop source code, take a look at
>SharpDevelop\src\Libraries\ICSharpCode.Build.Tasks\Project\ILAsm.cs
>and SharpDevelop.Build.MSIL.targets
>However it is possible that the Visual Studio IronPython integration
>already comes with the MSBuild task and targets file; then you can
>just use that.
>
>Now the real start: Create a new SharpDevelop
AddIn project.
>The video at
>http://laputa.sharpdevelop.net/WritingASharpDevelopAddInTutorialVideo.aspx
>should help you understand the basics. Don't forget to look at the
>SharpDevelop\doc\technotes directory (in the SharpDevelop source
>code download).
>Then you should look at the ILAsmBinding source code (it's the
>simplest backend binding possible). When you look at
>ILAsmBinding.addin, you'll see the most important things to provide:
>1. FileFilter entry. Just copy it from ILAsmBinding and adjust to
>your needs.
>2. Templates: The XML entry tells SharpDevelop to look for a
>"Templates" directory inside the directory containing your AddIn
>assembly. Just create such a directory in the project browser and
>add a .xpt file to it, then set "Copy to output directory" for the
>.xpt file
to "Always".
>For writing the .xpt project template, just use the one from
>ILAsmBinding and adjust it to your needs. The important part is the
><LanguageName> property: this must match the language name used in
>the next step.
>3. Language Binding. Use the <LanguageBinding> codon to register
>your language binding with SharpDevelop. Try to use the file
>extension and GUID from the Visual Studio IronPython AddIn; or
>create your own GUID (Tools > Insert New GUID) and use a new file
>extension.
>For writing the LanguageBinding class: just adapt the
>ILAsmLanguageBinding to your needs. The "single file compilation" is
>not supported by SharpDevelop 2.0, it'll always use MSBuild. The
>important methods left are LoadProject and CreateProject. Both have
>to return a new instance of
your project class. The project class
>can be really simple (again, look at ILAsmProject) if you inherit
>from MSBuildProject. Just set the language name; don't forget to
>call base.Create(info) in the new project constructor /
>SetupProject(fileName) in the load project constructor. In the
>constructor creating a new project, you have to use "imports.Add()"
>to add a reference to your MSBuild target file. If you put your
>targets file in your AddIn's directory, you can create your own
>MSBuild property like this:
> static bool initialized = false;
> static void Init()
> {
> if (!initialized)
{
> initialized = true;
>
>MSBuildEngine.CompileTaskNames.Add("nameOfMyMSBuildCompilerTask");
>// makes SharpDevelop show the "Compiling ProjectName..."-line when
>compiling your projects
>
>MSBuildEngine.MSBuildProperties.Add("MyLanguageBinPath",
>Path.GetDirectoryName(typeof(MyProject).Assembly.Location));
> }
> }
>Make sure you call Init() in both constructors of your project
>class.
>
>4. ILAsmBinding.addin also contains the project options section. The
>dialog panels reference panels in the main SharpDevelop code that
>can be used for all (.NET) languages. If you use them, you need a
>"<Import assembly = ":ICSharpCode.SharpDevelop"/>" entry in your
><Runtime> section.
>
>5. Syntax mode for the text editor should be compiled as embedded
>resource and can be loaded using the <SyntaxMode> codon. You don't
>need this at the beginning.
>
>This is everything you need for very simple integration of a
>language.
>The next step after this is providing a parser for the language.
>That is a bit complicated (especially if you cannot use the parser
>from the IronPython compiler and have to write your own), but it
>will enable folding and the class browser (both the "Classes" pad
>and the combo boxes above the code
editor).
>
>If you run into any problems, you can ask me for help; or better,
>ask in the forums: http://community.sharpdevelop.net/forums/
>
>Daniel Grunwald
I did not saw any code he wrote, but here is the last mail from him:
I have indeed looked at it but truhfully haven't gotten too far.
What I have successfully done is to re-add the basic binding(?) and CPP
project options. (This was there before) You can now, in my version,
select basic windows, console or generic CPP project and it will use a
template to create them. Also regonizes and creates .h and .cpp files.
What needs to be done is to create/manage the cpp compile options
via the options component/interface and then compile based on those.
As you may know, MSBUILD (the compiler that both VS and #Dev use, does
not recognize nor compile cpp project. When it encounters a cpp
project it simply hands it off to the VCBUILD compiler which is itself
just an alias for cl.exe.....The cl compiler only ships with VC
(probably express as well) so there is a hard dependency there.
What has to be solved is:
1) What the structure of the vcproj file needs to be and hand to manage it via the options tabs within #Dev
2) How to hand off the project to MSBUILD via the build bindings.
This is where I've bogged down as I don't completely understand how the
various #Dev and .Net build bindings work together in order to create
the proper binding.
3) Also then need to understand what the allowable options are for
VCBUILD but I figure these could be sorted out by trial and error
(worst case)
Anyway, work responsibilities have sort of detracted from my ability
to continue with this for now. I'm happy to hand off what I've done so
far or even work with you to develop it further. We might be able to
share some of the above between us....
I think there's also a potential to add in something like the
digital MARS compiler or gcc with one of the open source windows
libs....to allow for the compilation of non-.Net CPP apps.
Thoughts?
Tim Brooks