How to avoid MPS delete my class files during generation

Hi, I have built a language to generate bytecode. Now, I have post-process scripts which output class files in the class_gen directory. It used to work but now MPS has decided to delete my class files: the files are created during generation but some step of the generation process throw them away for some reason. Do you have any idea how can I prevent that from happening?

3 comments

Federico, could you please elaborate which MPS versions you've been using and the overall generate/make process (e.g. where your bytecodes were generated, how they end up in classes_gen, whether you utilize custom make facets. Are you talking about IDE experience or command-line build)? Generally, MPS does not expect anything user-valuable inside classes_gen.

0

I am using 3.3.4.

I have a language (MpsBytecode) that is translated to bytecode so I have a make facet that take those models and write class files in classes_gen. That worked fine.
Then I created a language which is translated to MpsBytecode. In that case the class files get deleted. My adding logs in my make facet I see they are created at a certain point just to be deleted later.
Given I am generating class files I thought it made sense to add them in classes_gen. In this way the user could write an application in the base language which use libraries written in my other language. When running the base-language application it would have found the class files produced by my language by looking in the classes_gen directory.

0

Federico: 

MPS manages the files created while running make in classes_gen folder,  so "uknown" files get deleted. Generally one should avoid writing directly to this folder, because integrating with the mechanism that watches it and deletes stale files can be tricky. But not impossible. 

Take a look at the make facet "Binaries" in the solution "j.m.lang.resources". Its purpose is simply to copy the resources (binary files in the source directory) to the current output folder (classes_gen for baselanguage). The key point is that it should be run before "reconcile" target in Make facet and output a sequence of "DResource" objects, which are really tuples wrapping the list of "deltas". These deltas tell the "reconciler" that the files were actually written for a purpose and should not be cleaned. 

 

0

Please sign in to leave a comment.