How to build my GText generated c++?

As some may have noticed from my earlier posts I'm making a self-contained language that generates to cxx using GText.

I'm getting to the point where I'd like to set up the build system for it so I can see if all the code I'm generating actually compiles w/o manually copying things around or whatever.

I did a bit of looking around and see the buildLanguage and read the user guide section on it, and I think it will work for me though I'm not entirely sure how.

The user guide talks about how to make a stand-alone buildLanguage thing that echoes "Hello World", but I'm not sure how I should set it up to build a solution that uses my new language. Do I make a generator somewhere that goes from a model in my language and generates a buildLanguage project and somehow make it go? I'm just not really sure where to start here. If I get pointed in the right general direction I can probably figure out the details.

Also: I think I should file a bug on this, but as long as I'm posting here: I followed along with the buildLanguage user guide and created a simple "echo Hello World" task (BuildTest.zip (12KB)), but I get "Buildfile: build.xml does not exist!" when I try to run it. Am I doing something wrong or should I file a bug?

If I can't get this to work from w/in MPS I see you can generate from w/in an ant script so I might make an ant script outside of MPS that does the building, but that wouldn't demo as well :).

Thanks!
7 comments
There are two different tasks:
1. Allow developer to make/run cxx code in MPS IDE.
2. Allow creating "makefile" to build redistributable package.

buildLanguage is about the later one. It generates ANT script, which may not be the best choice for non-java language. You can use it though. I would create a separate "makefile"-like language.

If you need to participate in MPS make process (i.e. when you press Ctrl-F9), you should create a so-called facet in plugin aspect of your language. Facets is a general way to plug-in more steps into make. Default facets are Generate, TextGen and Make (`the end of make marker`). In your case you probably want to add a Compile step. Look at 'JavaCompile' facet, declared in baseLanguage as an example.

1. create facet CxxCompile, Required facets: TextGen, Make
2. add target "compile", which will be executed "after textGen", but "before make"
3. start external process to compile/store files; report progress
4. report created files (make deletes all unreported files at the end)
0
Cool, thanks for the quick response! I'll chew on that for awhile and see what I can figure out.
0
I've been studying the code and am starting to get the hang of things. There's one thing that's holding me up currently. I'm getting an error "type resource is not comparable with jetbrains.mps.smodel.resources.TResource" when I try to cast an input element to (module, delta). Normally these sorts of things mean I need to add something to one of the dependency lists somewhere, but I'm actually getting that error even inside JavaCompile so it makes me think it could be a bug?
0
It is definitely a bug. Just ignore it. See MPS-14075
0
D'oh, should have searched the bug db. I couldn't ignore it 'cause it was failing the build, but I found a workaround and documented it in the bug.

Thanks!

edit: I was actually completely ignoring the ignore button in the build errors dialog, had honestly never realized it was there, of course I could have used the ignore button :)
0
Just thought I'd update this. I fiddled around quite awhile and wasn't getting very far. I finally realized I was being too stubborn trying to generate to c++ and it really wasn't a hard requirement for my project so I've switched to doing it the "MPS way" and generate to Java and things are going quite a bit smoother so far.
0
btw I would rather create a simple C++ implementation in MPS (structure, editor and textgen) than take a generic gtext language. Higher level language definition takes more time at the beginning, but allows you to create statically typed generators, understand intermediate models and always generate correct code.
0

Please sign in to leave a comment.