Compile a DSL developed in Xtext and Xpand on command line - dsl

It seems like a DSL (Domain-specific Language) developed in Xtext and Xpand is very much bound with Eclipse. Is there any way I can compile my DSL on command line, just like compiling Java code?

If you have a mwe workflow to execute your generator with, it can be executed from the command line as well. Look for the Mwe2Launcher class (http://git.eclipse.org/c/emf/org.eclipse.mwe.git/tree/plugins/org.eclipse.emf.mwe2.launch/src/org/eclipse/emf/mwe2/launch/runtime/Mwe2Launcher.java) for details.
If you already execute your Xpand generator from Java, then you have to simply wrap its call into an executable command line application.
In both case, you can either create an Eclipse application with all the dependencies by defining an Eclipse product that contains Xtext, Xpand, your plug-ins (and mwe if needed).

Related

Purescript inside Haskell code

I want to use a PureScript in the program code to generate text of JavaScript from it. For example, I use Julius (from Yesod) to directly insert a javascript. I want to use the same PureScript .Maybe there are such solutions or libraries?
Thank you!
When I have done something similar, I've kept the Purescript source in separate files, and combined the Haskell & Purescript parts later (during the build or at runtime). I think this is the easiest way, and you can keep using existing Purescript tools.
I had my web server read the JS output from purs at runtime. Another option would be to use file-embed to include the JS text when compiling the Haskell code. One reason to prefer file-embed is if you need to have a single executable file to deploy.
Finally, I have a Makefile that builds the Purescript code, then the Haskell code.

is there a command to apply hlint suggestions in emacs?

I'm using flycheck and haskell-hlint in emacs when I write Haskell codes
and I think it will be great if I can apply those hlint suggestions by invoking some emacs procedures instead of modifying the code manually.
If there isn't one available and in case I have to write this procedure for myself:
Is it guaranteed that hlint output is always of the following form:
Found:
{Text1}
Why not:
{Text2}
where {Text?} can always be parsed as a Haskell abstract syntax tree?
HLint comes with an Emacs script hs-lint.el that does the replacement you are after, details are in the README. The script isn't officially supported by the HLint developer, but some people have had some success with it.
Separately, there are plans to provide a proper replacement feature in HLint, which if provided would be easy to integrate with Emacs. While it's always been on the back-burner, there are now people working on the necessary whitespace-aware-syntax-replacement libraries that HLint requires.
There is an HLint Refactor Mode building on the apply-refact tool that provides HLint replacements in Emacs.

Formatting build.gradle automatically

Does a nice API exist to format gradle files with specific configuration (tabs, indentation,...) ?
I had a look over org.hibernate.tools java formatter, but there is no mean to handle files except java sources.
You'll need a tool that can handle Groovy sources, such as IntelliJ or Eclipse (with Groovy plugin). I'm not aware of a command line tool or API for formatting Groovy sources, but perhaps a web search will turn up something.

How to extract compilation args for each compilation unit in a vcxproj?

I'm trying to get the compilation args for each compilation unit so I can create the "compilation_commands.json" for my vcxproj that can be used with clang's libTooling.
The libTooling tutorial suggests using a CompilationDatabase to provide the compilation args for all the cpp files in a project. The tutorial shows that CMake can generate the compilation_commands.json for CMake based projects.
Since clang can be put into "MSVC mode" via clang.exe --driver-mode=cl or clang-cl.exe my thought was if I could get the compilation args for each cpp file in my VS2012 project I can create the compilation_commands.json for a vcxproj.
However I'm having trouble finding APIs in the VS2012 SDK that walks a vcxproj and retrieves the compilation args for each compilation unit. Can someone point me towards the right APIs?
I know this is really old, but the question is still relevant, so for those still looking for an answer, I managed to finally do this recently using this little VS extension.
Just install it and a new 'Sourcetrail' menu will appear, with a 'Create Compilation Database' entry (I found Intellisense needs to be enabled for it to be clickable). That will let you customize what to include and generate a compile_commands.json that you can use with other clang-based tools, etc.
It is a DIY job. The VS IDE projects have properties for each .cpp file. By selecting a .cpp, then right-click -> Properties -> Config properties -> C/C++ -> Command-Line you have the options required to compile that specific file. The 64 dollar question is how to do it for every file in the project / solution. The answer is not trivial, but it is doable. At least I did it on VS 2010 and I'm pretty sure it works on VS 2012/3
The secret lies with what is called VCEngine. It is a tool that evaluates all the properties or the files in the project. So the real problem is how to evaluate the property "Command Line" for each file. You need to iterate through all the .cpp files and call VCProject's Evaluate method for the "Command Line" property.
The simplest way I think you can do it is to write a plugin for the VS IDE and thus gain access to the VCEngine instance. There are plenty of examples of how to do that. Be aware that the VCEngine is version dependent.
Anywhay, for projects/solutions with thousands of .cpp files, you need to automate the compilation database creation.
When I'll have time I will put the solution on github
You may be interested in reading this
compile_commands.json for Windows/MSVC
You can try to parse the CL.command.* files in the intermediate directories.
https://gist.github.com/Trass3r/f3fbe6807d28106e917368c33abf45d4

How to run an ant script from VC++

Assume a Visual C++ solution that outputs several executables. These executables are meant to be run in a certain order and with certain parameters -- and for this purpose there already is an ant build.xml script.
What would be a decent approach to integrating this ant script with VC++, such that the ant script will point against the recently output executables (.\Debug and .\Release folders) and ideally could be run directly from VC++, and dare I say with remote debugging.
I was thinking of using build post-events that populate a build.properties file with the output location of each executable, and let the ant script use this .properties file.
Any help on the matter would be great.
I'm not sure if there is a good answer for this. Perhaps you are not asking the right questions. From C++ you can launch anything, including scripts. I'm not sure what you mean by VC++ integration.
The generic answer would be:
save the output locations somewhere, doesn't matter where (file, registry, environment variables etc.)
retrieve them in the script before use
But depending on what you need, you could also try:
Output the same executables in the same folder structure. This way you can use relative paths.
Use a post-build event which copies the script in the output folder and make it use the relative path.
Instead of a script you can also try handling everything from the first EXE. Instead of an ANT script it could use a configuration file which specifies execution order and parameters.

Resources