Extending Monkey hugely with a custom target?

Monkey Forums/Monkey Programming/Extending Monkey hugely with a custom target?

Raptisoft(Posted 2011) [#1]
Hi guys,
Really enjoying Monkey so far. You've made it so extendable that I've gotten around every little problem I've had so far.

The only issue I'm having is handling on-the-fly resolution changes for PC/Mac games... a feature I'd really like to include for my customers. I respect that Monkey can't do this because of the Flash/HTML5/Hard OS Resolutions of some of the targets.

Is there any way to extend Monkey with a new target? I see the code templates... for PC and Mac, I'd like to be able to add my own target-- have Mojo redirect to my own DirectX functions (for Win) and that kind of thing, even for initializing the graphics system, while defaulting to Monkey standard for Flash, etc.

Is there any way this would be possible by adding stuff to the targets folder or whatnot, is or half of this baked into the compiler itself?


Canardian(Posted 2011) [#2]
I wrote a tutorial how to add a GLFWMINGW target, but the same idea works for other targets too:
http://www.monkeytools.net/articles/Adding_a_GLFWMINGW_target
And today I'll start to write an automated Target Installer, which could be also expanded to work with custom targets, so new targets could be added with some config files for the installer.


Raptisoft(Posted 2011) [#3]
Ah, thank you very much! (And quick response, too!)


Raptisoft(Posted 2011) [#4]
Lumooja, when I try to rebuild trans.monkey, I get this:

TRANS monkey compiler V1.01
Parsing...
Semanting...
Translating...
Building...
TRANS monkey compiler V1.01
Failed to open config file
TRANS Failed to execute '"C:/Users/Raptisoft/Desktop/MonkeyPro29/bin/trans.build/stdcpp/main_winnt"', return code=-1

Any idea what's going on there? Do I have to rename the config.winnt.txt file or something?


Xaron(Posted 2011) [#5]
First you should get the latest build which is V31. ;)


Perturbatio(Posted 2011) [#6]
(By clicking on your account link at the top and click product updates)


Raptisoft(Posted 2011) [#7]
Just did that... get the same error. There must be a step I'm not doing... what is this config file? I can't even rebuild monkey.trans out of the box without changes.

Is there some extra MINGW component I need to add? I just went and got MINGW and installed everything.


Xaron(Posted 2011) [#8]
Hmm... I never tried that stdcpp target as it's for standard console stuff at the moment only. I always use GLFW for Windows/Mac...


Raptisoft(Posted 2011) [#9]
Tried it with GLFW, got 103 compile errors from Visual Studio... so let me roll back to the previous version and see if the same happens...

(Edit) Yeah, same thing... 103 errors, looks like they all stem from int bb_trans_Html5Target::bbMakeTarget() having some screwed up formatting with the return type and end target.

Are you able to simply rebuild it, without having to do anything special?


Canardian(Posted 2011) [#10]
You need to compile trans.monkey with STDCPP target.


Raptisoft(Posted 2011) [#11]
When I do that, I get the error I listed above, with the config file missing... any idea what config file that is, or what I do to get around it?


Canardian(Posted 2011) [#12]
Use F7 to build it only, don't try to run it.


Raptisoft(Posted 2011) [#13]
I could have sworn I tried that (since that's what it says to do on the web page) but evidently I didn't... thanks, that's got it working.


Raptisoft(Posted 2011) [#14]
I hate to keep bothering on this topic, but this is somewhat important for me to get working...

When I do all the steps, and replace the trans_winnt.exe in the bin folder, now on Monkey startup I get this error:

The program can't start because libgcc_s_dw2-1.dll is missing from your computer. Try reinstalling the program to fix this problem.

I have snagged that DLL from MINGW, and I've put it in system32, and I've put it in the Monkey folder... but still I get this error. When I try to regsvr32 it, Windows tells me that it might not be compatible. Is anyone working on Win7 or Vista, and got this to work? Can you tell me how to get rid of this error?


Canardian(Posted 2011) [#15]
I have mingw normally installed, and c:\mingw\bin is in the system path. It's the same mingw which is needed for BlitzMax.


Raptisoft(Posted 2011) [#16]
Thanks! Looks like I'm up and running. Haven't had to play around with system files and things like this in years.


Canardian(Posted 2011) [#17]
You don't need to play around with system files. You just install mingw the normal way, it will automatically add c:\mingw\bin to the PATH variable.


Raptisoft(Posted 2011) [#18]
It didn't... not sure if it's a Win7 security issue or what. I had to add it to path manually.


Canardian(Posted 2011) [#19]
That's part of the normal installation of mingw :)


Brucey(Posted 2011) [#20]
I had to add it to path manually.

I always add it myself... and recently the MinGW installer tends to miss out whole chunks of stuff... which is a bit of a pain.

Is there any way to extend Monkey with a new target?

I am writing a "qt" target for Mac/Linux/Win32 (so far). Kind of interesting, and rather complex in places...

For example, I've been working on getting a Class constructor to auto-generate the super constructor for matching parameters.
Class CodeEditor Extends QPlainTextEdit


	Method New(parent:QWidget)
	End Method

End


Since QPlainTextEdit already has a matching constructor, ideally, the generated C++ should call it as part of its invocation on the child. (Like in Java, when you do super.method(xxx) in the constructor)
And this is what I've been able to generate :
bbCodeEditor::bbCodeEditor(QWidget* bbparent)
: MaxQPlainTextEdit( bbparent)
{

which is kinda groovy :-)

So, yes, it's extendible if you don't mind getting your hands (really) dirty!