BMK

BlitzMax Forums/BlitzMax Programming/BMK

AnthonyB(Posted 2010) [#1]
Hello guys,

Yesterday I realized how much I wanted a working preprocessor for BlitzMax, and I never got any of the ones that exist working. Then I found the BlitzPlus / Blitz3D preprocessor that you can find in the Toolbox here at blitzmax.com. It works by replacing blitzcc (the blitz compiler) and by changing the name of the original blitz compiler, so that the IDE calls the compiler, which is actually the preprocessor, and the preprocessor continues to call the compiler when it's done. I thought that was a very easy way to add new components to the language or to add new stages to the compilation process, like preprocessing.

I've written a few preprocessors myself, one for a language I'm developing (and I create the compiler etc all in blitzmax btw) for practice, and one for a different project, and I know I can pull it off rather easily (at least the most commong C preprocessor directives). So I decided to write my own, and use it the way the BlitzPlus / Blitz3D preprocessor does it.

However I have run into a slight problem. And this is where I need your help.

I don't call the BlitzMax compiler itself, because then I would have to replace BMK, which I think is very unnecessary. So I call BMK instead, and just name my preprocessor executable "bmk.exe", and rename the original BMK to "bmk1.exe", and then call "bmk1.exe" from the preprocessor. I save all the arguments that the IDE passes to the BMK (which is now my preprocessor), and then pass them on to the real BMK, which should make it compile just like normal, with whatever settings the programmer sets in his or her IDE. The only differense on the arguments passed from the IDE to my preprocessor, and from the arguments passed from my preprocessor to the BMK, is that the source name changed from "sourcename.bmx", to "sourcename.i.bmx", which is the file that the preprocessor generates when it's finished (and it doesn't call the real bmx if any errors where detected). The only downside with doing it this way is that you can only use the preprocessor with the first file you compile. I will fix this problem later by integrating this into the real bmk, by making the bmk first call my preprocessor, and then go on with it's regular business. But I wanted to get the process working with one file first, so that I know that it works in practice, and not just in theory.

I get this working, and it compiles, but for some reason, when the program is compiled, and then executed, nothing happens, and a program that should be about 80 kb in size becomes like... 1300 kb in size. I know other people have done bmk utilities or ever rewritten bmk, so I was wondering, did any of you bump into this problem, and do you know what I am doing wrong and thus how to fix it?

I haven't written the actual precompiler yet, so no harm done if this method doesn't work, but shouldn't this work?

I would be greatful to ANY help at all.

Regards,
Anthony

EDIT: I just realized I could rename BCC instead, since it will be called from BMK, thus making the BMK call my preprocessor instead, without changing it's code, thus making what Make tool one uses totally independent of my preprocessor. Then I could just pass the arguments passed from BMK to my precompiler over to BCC, and get the preprocessor working on all files that are compiled, without the user actually noticing anything except a slightly slower compile time. But this doesn't solve the problem I came here for. So I still need your help, hehe.


markcw(Posted 2010) [#2]
Michael Reitzenstein might be able to help you as he is the author of the BBP but I don't think he visits here much any more so you'll probably need to email him.

Then again there are probably a few guys around the forums here who could answer this, like Matthew Smith or ziggy.


AnthonyB(Posted 2010) [#3]
@marksw: Okay, I'll do that, but since BlitzMax and Blitz3D/BlitzPlus have different compilers, he might not know what is going on. I think someone that is familiar with the compiler is probably a better help.


markcw(Posted 2010) [#4]
There also a similar project here.
http://code.google.com/p/bb-bmax-precompiler/


AnthonyB(Posted 2010) [#5]
Thanks! But there's no documentation?

I will proceed with my own preprocessor though, since I would like to be able to add whatever feature I like, hehe.

BTW, I solved my problem. It was too simple to mention. But I will anyway, since it was so freakin weird. I forgot to close the preprocessed file after saving it to disc. I can swear that I could see in my code that I closed it, but after looking again after a few days of not programming, I noticed that I actually didn't close it. :)


markcw(Posted 2010) [#6]
Well no but you can get the python source from here if it's any help:
http://bb-bmax-precompiler.googlecode.com/svn/trunk/src/

Glad you fixed it and good luck with the project. It would be a great addition to Bmx.

Also if you haven't noticed yet there's another guy with the same project here:
http://www.blitzmax.com/Community/posts.php?topic=91193