Programmatically running EMF code generation - eclipse-emf

I have created an EMF model with extension .system which will generate the code for my work.
Now I can generate code using launch code generation action from Eclipse. But I want to generate the code by launching the code generation from a stand-alone program.
How do I achieve this?
Details: I have created a plugin from EMF model and have inlcluded in the Eclipse.
I will created .system files from out of my plugin and I can generate code from my plugins.
I have observed that when I click launch the code generation it is starting a LauchAction class from my plugin.
How do I start my LaunchAction class from a stand-alone Java program?
My aim is to run my created .system model and generate the code from a stand-alone Java program.
How do I achieve this?

You could call Eclipse from the command line. Something similar to this:
eclipse.exe -noSplash -data ${workspace_location} -model -edit -editor -tests -application org.eclipse.emf.codegen.ecore.Generator ${genmodel}
This command will start Eclipse silently and will generate mode code (-model), edit plug-in (-edit), editor plug-in (-editor), and the test plug-in (-tests). Leave out any of these parameters if they are not needed.

I don't know how to solve your problem, but I think it is doable. I think you have to look at the EMF source code to check how the code generation works.
Here are some starting points:
If you have PDE and the EMF tools, use use Import > Plug-ins and Fragments to get the EMF plugin into your Eclipse workspace.
Otherwise, clone and import the following Git repository:
https://git.eclipse.org/c/emf/org.eclipse.emf.git/
Have a look at the following file, maybe you can find what you need there:
plugins/org.eclipse.emf.codegen.ecore.ui/src/org/eclipse/emf/codegen/ecore/genmodel/handler/GenerateHandler.java
Otherwise, look in the org.eclipse.emf.codegen.ecore plugin.
Good luck! It's an interesting problem! Please report back here if you solve it!
EDIT: Ops, this question is 10 years old, I didn't notice!

Related

How to use the documentation of C++ code inside an IDE on linux?

Up to now i tried Eclipse, KDevelop and Code::Blocks.
Code::Blocks (12.11) seems not to be able to display documentation at all.
Eclipse (4.3.2) is able to display the documentation of at least the standard libraries during code completion and on hover, but it looks like there is no way to generate or add custom documentation. By now I was able to use DoxygenCPPInfo to convert the xml documentation to a "Java Serialization Data" file, which is useable by libhover. But the documentation is only visible on hover, but not on code completion.
KDevelop (4.7) does only show the comment, which normally contains the documentation, on hover and a heavily shortened version on code completion.
Is there another IDE or something else I could do to benefit from in code documentation while writing new code?
DoxygenCPPInfo can be compiled using the following files from eclipse-linuxtools:
ClassInfo.java
FunctionInfo.java
LibHoverInfo.java
MemberInfo.java
TypedefInfo.java
DoxygenCPPInfo.java
The xml documentation needs to be in one file to be used with DoxygenCPPInfo. This can be done by using xsltproc with combine.xslt and index.xml as input files. The final output of DoxygenCPPInfo can be placed in workspace/.metadata/.plugins/org.eclipse.linuxtools.cdt.libhover/CPP/ and will be loaded on next start of eclipse using that workspace. The documentation is only shown on hover and not on code completion.
You want to document a function in one file and use that function in another file. While using that function you want to reference the documentation written earlier in a tooltip without having to compile the first file. This can be done easily in kdevelop ide. There are not much IDEs I have come across that provide such ease of cross-referencing. Eclipse lib-hover plugin for C but it is clunky and I have had trouble working with that earlier. Here is the link to kdevelop-handbook .
Documenting in doxygen style in kdevelop

Run a script in eclipse before build

Simply put:
In eclipse how do I run a shell/batch script when I build? I have an external tool that can be run by hand but I want to trigger it when the project is built. Using build variables in the script would be an added bonus.
Why I want this:
I work on multi-platform games for mobile. The teams in the company I'm at use X-Code, Visual Studio, and Eclipse (Momentics) for our games. We want to be able to pick up a phone and see overlay on-top of it with information such as who built it, when it was built, what branch and revision it's from, and what library versions are being used. I've done this with X-Code by running a script on build that dumps some of that information to the resource directory of my game that I can then parse at runtime. It's really simple and I'm up for alternate suggestions if you have them; keeping in mind it must work for the three IDE's our developers use.
Bonus Sugar:
In X-Code we can use build variables which would be super nice to have for eclipse as well. I use them to change to the active cocos2d-x repository and get a git log to tell us when the last commit to that repository was made and by who. If that isn't possible in eclipse I can figure something out.
Thanks in advance!
Add a custom builder to your project: open Project properties from the popup menu, on the builders page add a new Program. That will open a "External tool configuration" page.
There you can define a script to run, and also add parameters, where you can add Eclipse variables, such as ${workspace}, etc.
Be careful though: this will run every time when the incremental project builder runs, and the configuration is shared through version control (so beware of absolute paths).

Reverse C++ source to UML Class Diagram

I would like to generate a C++ program to a Class Diagram using MacOS.
I've tried Doxygen (that many suggested in other topics in stackoverflow), but I don't seem to get how it works.
Could you suggest an easier solution? Which is the friendliest to the user program that offers an automated reverse to Class Diagram?
(For example something like what NetBeans 6.5.1 does for Java programs)
If you are using eclipse as an IDE, you could try the answers to this post.
You could possibly try to avoid the doxygen GUI. From terminal, enter your source folder then type
$ doxygen -g #that generates the doxygen config file "doxyfile"
$ doxygen
The latter generates two folders for the HTML and PDF versions of the UML.
the work is done!
you can edit doxyfile to change settings.
I usually use Understand for C++ to generate UML or to re-factor code:
http://www.scitools.com/index.php

Integrate code generation with eclipse c++ build

I am using Eclipse for C++ development on windows. I have also written a code generator that take an xml file and produces several C++ files. The project I am working on is currently setup to use the internal builder. What I would like to do is to run the code generator as part of the build process.
My problem is that I haven't been able to find a way to make Eclipse identify that the files are present (or have been updated) without 'Refeshing' the project. So although I can run the code generator as a pre-build step, the files generated aren't guaranteed to be included in the build.
Does anybody know whether there is a way to make Eclipse do a refresh after the pre-build step or something to that effect, using the internal builder?
Thanks
You can add a Builder to your project.
I'm not sure if this is possible using the internal builder of Eclipse. Refreshing has always been a problem there. But using external build tool, like Maven or Ant, works! I personally would switch to Visual Studio - there you never have such kind of problems
Although I have not tried this with CDT projects enabling the the Preferences->General->Workspace -> Refresh automatically helps me with Web & Java projects where code generation is involved.

standalone tool for generating makefile(s) from Eclipse's .cproject file?

Is there a standalone tool, that can be ran from a shell script, to generate a makefile from the .cproject? Actually, the same functionality as the CDT itself, but that can be non-interactive.
As is probably obvious, I want to be able to run a script that checkouts and builds the software, comprising from several C++ project. I am trying to avoid moving to a build system like maven, as it seems as like an overhead in this early stage of our project. thanks!
I know that there was discussions on the CDT-dev mailinglist a few months back about having a command-line tool for building CDT projects. Writing such a tool is really not very difficult (there was an example mentioned), it is simply a matter of defining your own Eclipse-application, load the project, and build it. Searching the CDT-dev list on "standalone build" should give you some relevant hits.