Question about user modules

BlitzMax Forums/BlitzMax Programming/Question about user modules

QuickSilva(Posted 2009) [#1]
If you make your own module and place it in with the BRL ones (instead of keeping it seperate from them) will it automatically be included when you compile your program or do you still have to manually import it at the top of your code?

I know that this will add to the size of your .exe but I would just like to know as I do not currently have mingw on my machine to test it myself.

Thanks,

Jason.


GfK(Posted 2009) [#2]
No idea but you should create a folder called, say, QuickSilva.mod, then a QuickSilvasFirstModLiekEver.mod within, and have your module there.

It is senseless to NOT use Framework/Import, since using them will cut your executable size down dramatically, as only the modules you need will be included.

Use Jim Brown's Framework Assistant to determine which modules you need.


plash(Posted 2009) [#3]
...will it automatically be included when you compile your program or do you still have to manually import it at the top of your code?
No it will not. Only a few BRL modules get imported to any source code automatically (when Framework is not used).

It is senseless to NOT use Framework/Import, since using them will cut your executable size down dramatically, as only the modules you need will be included.
100% agree.


Brucey(Posted 2009) [#4]
No it will not.

I was under the impression all BRL and Pub modules are included when you don't use Framework.


<EDIT>
I just tested it out, and it certainly appears to be true.


QuickSilva(Posted 2009) [#5]
Thanks for trying it. I was just curious really. I can certainly see the benefits of having user modules in there own folder but I thought that it would be intersting to see if it worked.

Jason.


plash(Posted 2009) [#6]
I just tested it out, and it certainly appears to be true.
Interesting..


klepto2(Posted 2009) [#7]
yes brl and pub modules get fully included if you're not using framework.

But writing user modules and give them brl or pub scope is a bad idea.

1. It is blowing your app size and compilation time.
2. brl and pub folders will completely update with each bmax update. So you have to manually copy your mods each time a new update was installed.

In my opinion user modules should never be placed in brl or pub folder. I remember dreamotion which was/is build in pub scope and every small app which was build later was trying to load the dll needed for dreamotion, if you didn't use framework. And to be honest thats a no go if you just want to test small things.


QuickSilva(Posted 2009) [#8]
Could be handy if you want to include some features to existing BMax mods though without actually changing them, ones that you always want to be present.

Jason.


Brucey(Posted 2009) [#9]
ones that you always want to be present.

If you use Framework, you are only guaranteed to have BRL.Blitz and Pub.Stdc. (By default also BRL.AppStub - but you can override that).
The rest, you would of course Import - although, since there are other dependencies, importing one module will likely get you a bunch of others as required.

There's no reason not to use Framework. :-)


Brucey(Posted 2009) [#10]
Just for fun, here's the BlitzMax import tree (for BRL and Pub) :


(as generated by BaH.Graphviz no less :-p )

Without using Framework, you get ALL of these!! Yay!


GfK(Posted 2009) [#11]
I fancy some spag-bol for dinner. Dunno why...


TaskMaster(Posted 2009) [#12]
Do you have to use Framework when building a module as well?


Brucey(Posted 2009) [#13]
No. Framework is implied - so you need to import everything you need.


byo(Posted 2009) [#14]
To add to this discussion:

Can I use Framework twice in the same code?

It seems that the IDE shows me an error and I haven't quite understood if I can use it multiple times or if I should use Import for other modules.

If I have something like:

Framework maxgui.Drivers
Framework bah.DBSQLite


the IDE won't let me proceed.

Am I doing it the wrong way? :/


Gabriel(Posted 2009) [#15]
Am I doing it the wrong way? :/

Yes. When you have Framework, you're essentially saying "I don't need anything else except this". So saying it a second time makes no sense. Any modules you need above and beyond what you define with Framework need to be Import'ed.

' JUST ONE FRAMEWORK
Framework maxgui.Drivers
' THEN IMPORTS
Import bah.DBSQLite
' MORE IMPORTS IF YOU NEED THEM
' |
' |
' |



byo(Posted 2009) [#16]
Thanks for the explanation, Gabriel.

I guess what still confuses me is that Framework is supposed to let the user manually choose what to import. But what about the brl modules? Aren't some of them necessary?

The idea I have of Framework is that when you use it you have to import everything you need manually. My application worked with only this:

Framework maxgui.drivers


Shouldn't some basic system modules be included manually?


Gabriel(Posted 2009) [#17]
I don't have a recent copy of MaxGUI downloaded, and I guess SVN is up the chute at the moment, so I can't download it to test. I rather suspect, however, that if you open the module, you'll find that it imports a number of other modules itself.

In other words, if the module you import needs other modules itself, those will be imported too. MaxGUI is a pretty big one, so it probably needs lots of stuff.


plash(Posted 2009) [#18]
The only Module that is necessary for any program is brl.blitz (and it is always imported regardless of framework).

I prefer to do
Framework brl.blitz
' Imports..

for anything I write.


byo(Posted 2009) [#19]
Thank you guys.
So summing up the lessons learnt here:

In a game: brl.blitz is the minimum framework I can use.

In a GUI application: I could use the maxgui framework because it imports mostly everything that's necessary.

With that, my executable size dropped considerably. :)


Russell(Posted 2009) [#20]
Personally, I'd like to see something like Framework Assistant incorporated into the compiler so code is automagically made as small and efficient as possible. And throw in auto-UPX for good measure...

Russell


xlsior(Posted 2009) [#21]
Personally, I'd like to see something like Framework Assistant incorporated into the compiler so code is automagically made as small and efficient as possible. And throw in auto-UPX for good measure...


Apparently the biggest hurdle was determining whether or not you need things like jpgloader, bmploader, oggloader, etc. because it's not always possible to determine ahead of time which data formats the program would be dealing with... But you'd think that the compiler should be able to rule out at least some of the modules automatically...