Page 1 of 2
How does Tailbite work ?
Posted: Wed Aug 06, 2008 7:39 am
by Progi1984
Hi all,
Working a little on Tailbite for Linux, and like Tailbite is very poor documented in code, i ask for developpers or advanced user or simple users how does tailbite transform PB Code in PB Userlib ?
What i understand :
-Tailbite uses Purebasic for transforming PB Code in ASM Code
-From this ASM Code, Tailbite extracts name of functions and arguments
-And after ?
I see a batch, obj files for each function, a desc file, LibraryMaker.exe... but don't know how that runs ?
Note :
Technology
-
http://www.purebasic.fr/english/viewtopic.php?t=29608
Linux version
-
http://home.arcor.de/x-linux/pure/tailbite_linux/
-
http://www.purebasic.fr/english/viewtop ... 970#147970
http://www.purebasic.fr/english/viewtopic.php?t=24327
Posted: Wed Aug 06, 2008 9:41 am
by Polo
Seeing this, I can't keep myself from asking why Purebasic compiler doesn't do that job natively (Blitzmax compiler does it...)
For sure that would be much faster to compile, and it would be supported on the 3 os.
Posted: Wed Aug 06, 2008 10:36 am
by srod
The process runs roughly along the following lines. It may do a couple of things in a different order than that given.
- PB compiler generates the ASM code
- Tailbite extracts lists of exported functions, internal functions, global variables, labels, imported libraries, user-libraries required by the source etc.
- Alters the names of all exported functions to match those given in the PB source (to be declared 'Public' in the relevant .asm file) and all references to these functions throughout the asm source are changed as appropriate.
- All global variables, labels etc. are renamed prior to being made 'Public' (so that they can be accessed by individual ASM files) and marked with 'Extern' in all external ASM files in which they are required.
- Individual ASM files created, one for each function (exported and internal) and one 'shared file' containing the data sections with global variables etc. An _Init function is also created (if not already present in the PB source).
- Each ASM file is passed in turn to Fasm for the creation of a COFF object file.
- The resulting set of object files are passed to POLIB (together with any external static libraries to be included in the resulting user library) and a .lib is created.
- Using information gathered during the above steps, Tailbite creates a .desc file for use by the library-maker tool.
- Tailbite passes the .desc file (together with the .lib file) to the library-maker tool which creates the final user library.
A simple affair in principle, not so easy to implement though!

My coffIT tool performed all of the above steps bar the last one (creating a PB include file instead of a .desc file) and it was quite a bit of work - and subsequent versions of PB break the program anyhow!
As for getting PB itself to create user-libraries. Well, the 'official' PB user-libraries differ from those created by Tailbite in one important regards (apart from being written in C / asm of course), namely they contain, where appropriate, ansi/unicode/threadsafe/threadsafe-unicode versions of individual functions. With Tailbite, you have to create 4 separate libraries instead. Now, (and without going into the details) getting Tailbite to perform this task automatically (without asking the programmer to explicitly declare which functions should have unicode/threadsafe counterparts) is far harder than many people realise, and I presume that PB would have the same problem. This is on top of the problem of dealing with optional parameters, although this would be somewhat easier than dealing with unicode etc.
My experience in creating user-libraries in which unicode and threadsafe versions of each affected function is placed within a single library is that it is best done, to some extent, by hand. Tailbite 4 versions of the source (ansi, unicode, threadsafe...), grab the resulting ASM files and pick and mix as appropriate, then create a .desc file...
There is also the problem of Tailbitten libraries frequently being 'broken' by updates to the PB compiler. This problem could also hinder user libraries created by PB itself should the facility ever be added to create user libraries etc.
Posted: Wed Aug 06, 2008 11:42 am
by PB
> I can't keep myself from asking why Purebasic compiler doesn't do that
It's been requested MANY times before. We still hold hope for it.

Posted: Wed Aug 06, 2008 11:52 am
by Polo
PB wrote:> I can't keep myself from asking why Purebasic compiler doesn't do that
It's been requested MANY times before. We still hold hope for it.

I know that, though it's not done yet
Seeing how easy it is to create a library with Blitzmax, I think we should have the same in Purebasic
(no, I dont want to use Blitmax

)
Posted: Wed Aug 06, 2008 2:14 pm
by Progi1984
Thank you srod for your technical answer.
I began to think at the creation of a new userlib creator, which will have as bases :
- the portability of application : Windows, Linux & MacOS.
- the multilingual
- the documentation of the application for easy changement and easy modification
- the control source via SVN. (May be GoogleCode)
Why that ?
Because Tailbite is so Windows thinking, that the migration to other systems will be so difficult.
Because Tailbite is not so enough documented.
Because Tailbite is principally developped by two principals developpers (which have done a very good work and very thank you to them for that).
Posted: Thu Aug 07, 2008 7:44 am
by Progi1984
What do you think of this idea ?
Posted: Thu Aug 07, 2008 10:30 am
by srod
Personally, and I think a few people feel the same way, I feel that closed user-libraries are more hassle than they are worth. I certainly no longer use them in my programs - heck I have applications which can only be compiled with PB 4.1 because of the dependence on user-libraries etc!
I prefer to ship either source code includes or dll's. The former have less chance of being broken than a user-lib when a new version of PB is released (the latter has no chance of being broken!)
I know this isn't exactly the feedback you are after, but knowing that some people are steering away from 3rd party user-libs is perhaps worth bearing in mind before you embark upon what will be a complex project. At least you have an idea of the 'larger picture'.
I am not saying that it is not a worthwhile project because a lot of people are happy to use user-libs etc. and will find your crossplatform version of Tailbite very useful indeed. It's just not something that I could justify spending time on given the way I feel about closed user-libraries.
Posted: Thu Aug 07, 2008 11:41 am
by Progi1984
Very thank you of your answer.
But atm, it's just a reflexion which could transform in projet.
I agree with you on the dependance on userlibs with version of PB. But source code and dll's wrappers are dependant too.
But Tailbite is actually very used for its simplification and privacy in comparison with an include.
About Tailbite, Where comes from this name ?
Posted: Thu Aug 07, 2008 12:36 pm
by srod
Well, dll's cannot be broken by changes to the PB compiler because they are completely linked etc.
The name 'Tailbite' is a reference to a dog spinning round and round chasing it's own tail, which is a great name and sums up the business of using user-libs perfectly. El-Choni chose the name well!

Posted: Thu Aug 07, 2008 12:59 pm
by Progi1984
I didn't say wrappers, but "dll's wrappers" which can not run with update of PB.
Thnak you for the explanation of the name.
Posted: Thu Aug 07, 2008 1:01 pm
by srod
Progi1984 wrote:I didn't say wrappers, but "dll's wrappers" which can not run with update of PB.
You did indeed, -my apologies. Although it is rare that a new version of PB would break a dll wrapper if using the import library etc.
Posted: Thu Aug 07, 2008 1:46 pm
by DarkDragon
Progi1984 wrote:Thank you srod for your technical answer.
I began to think at the creation of a new userlib creator, which will have as bases :
- the portability of application : Windows, Linux & MacOS.
- the multilingual
- the documentation of the application for easy changement and easy modification
- the control source via SVN. (May be GoogleCode)
Why that ?
Because Tailbite is so Windows thinking, that the migration to other systems will be so difficult.
Because Tailbite is not so enough documented.
Because Tailbite is principally developped by two principals developpers (which have done a very good work and very thank you to them for that).
Well the hardest thing would be the MacOS port, because who has a Mac with MacOS

and who knows how userlib creation works on MacOS except the PB team? I don't know anyone here who would help with a Mac.
Posted: Thu Aug 07, 2008 1:53 pm
by Progi1984
@srod
Indeed.
For coming back to the middle subject, i looked at the tailbite for windows & linux 's sourcecode. And it might be possible to do a good thing.
May be for having too a Mac version.
@Darkdragon :
If the used technology for creating userlibs on Windows & Linux is nearly the same, so we should have some luck.
Posted: Thu Aug 07, 2008 2:00 pm
by srod
Progi, do you have the Linux version working? That's great work if so.