priitj / whitedb

WhiteDB memory database
http://whitedb.org/
GNU General Public License v3.0
608 stars 78 forks source link

Add unite.sh which can create an amalgamation of header and source files. #18

Closed necrophcodr closed 10 years ago

necrophcodr commented 10 years ago

This commit effectively increases the possible productivity with whitedb, as well as making the environment as readily available as SQLite3 (somewhat).

By combining the headers into one file, and source files into one file, third party developers can effectively copy these files into their code base, and easily use the entire library. Obviously comforming to the license of both YAJL and WhiteDB is a requirement of doing so, but this enables future open source GPL licensed software to benefit vastly from WhiteDB, even if (some) performance hit can be taken [citation_needed].

(I did not notice any performance hit when compiling Examples/speed/speed10.c with a modified whitedb.h inclusion, as opposed to the latest "master" (4555d5a0c77929ff926c2a0fdf7802d2a2ef9b03 as of the time of writing), however this still needs testing).

priitj commented 10 years ago

This looks nice, thanks!

Could you also add the usage instructions, just a few sentences with an example compilation command line? The relevant sections are the "Not building anything" in the installation manual Doc/install.txt and "Compiling with database source files" in Doc/Manual.txt.

necrophcodr commented 10 years ago

Does that work?

I would add some compilation examples or demos, but I am in no position to edit m4s or autotool Makefile.am's at the moment.

priitj commented 10 years ago

Yep, this is what I meant, thanks again.

Before I merge this, just one last thing. I'm curious as to why did you choose to include the header using

#include <whitedb.h>

and not

#include "whitedb.h"
necrophcodr commented 10 years ago

The include thing is because most systems base their development on having libraries installed in an include path, and most projects put their directories in their include paths anyway.

Doing so allows the amalgamation to be installed both locally (say, in .local/include), in-project, and system-wide, with the same results.

Using "whitedb.h" nullifies this, and allows ONLY whitedb.h to be included, if it is in a path that "whitedb.h" encompasses, which can be either in-project, or in-exact-source-dir. It is also possible that certain compilers allow "whitedb.h" to mean , however this is implementation defined, and not standard (to my knowledge, if anyone can cite a standard spec that goes against this, i'd be willing to change my mind. GNU C extensions don't count)

For instance, picture being able to do the following:

gcc -I. whitedb.c -o wgdb.o -std=c99 -D_C_POSIX_SOURCE=200899L -D_XOPEN_SOURCE=600
ar rcu libwgdb.a wgdb.o
gcc -I. test.c libwgdb.a -o test -std=c99 -D_C_POSIX_SOURCE=200899L -D_XOPEN_SOURCE=600

In your project, and done. You're good. One could even replace the "." with any directory, and whitedb would work great.

(The appended -std=c99 -D_C_POSIX_SOURCE=200899L -D_XOPEN_SOURCE=600 is to comform with the C99 standard, as well as POSIX and XDG standards, instead of using GNU C extensions. Compiling without, when using gcc, works just fine though).