symisc / unqlite

An Embedded NoSQL, Transactional Database Engine
https://unqlite.symisc.net
Other
2.11k stars 164 forks source link

Fix/crosscompile #57

Closed gjrtimmer closed 6 years ago

gjrtimmer commented 6 years ago

A lot of automatic build tools, Travis CI, GitLab CI etc. are using docker containers to build software. Unqlite can be cross-compiled for Windows from Linux. This requires the Mingw-64 Cross Compiler.

However, within the source code there is an include for <Windows.h> this is correct for Windows platforms but does not work when cross compiling.

In order to build a Windows binary of Unqlite from a Linux host, the include header has to be changed to <windows.h> (Windows requires uppercase, Linux cross-compile with Ming2-64 requires lower case).

In order to preserve cross-platform source code, this commit fixes this issues to allow both successful compilation from Windows targets as well as cross-compiling from a Linux host.

This fix allows Unqlite to be build by CI environments.

gjrtimmer commented 6 years ago

Additional Information

The mingw pre-processor defines both __MINGW32__ and __MINGW64__ for this fix I've chosen to only use __MINGW32__ because the 64-Bit (mingw-64-*) compilers defines both.

Therefore using the __MINGW32__ does not break 32-bit compilation. Because while the 64 bit mingw-64 defines both; the 32-bit only defines __MINGW32__.

gjrtimmer commented 6 years ago

Updated CHANGELOG.

Change log was added as seperate PR from fix/repository.

fix/repository already merged within fix/crosscompile.

gjrtimmer commented 6 years ago

fix/repository (Add CHANGELOG) PR #58 should be merged into master before #57

gjrtimmer commented 6 years ago

@symisc Ready to merge.

Fix: Travis CI Fix: Gitlab CI Add: Windows Cross-Compilation jobs Add: 32Bit Compilation jobs for Linux and Windows

gjrtimmer commented 6 years ago

@symisc Do you require squashed commits for this PR ?

symisc commented 6 years ago

The MINGW compiler fix should be removed. Under windows, users have to rely on the Microsoft compilers only or Clang.

gjrtimmer commented 6 years ago

@symisc Fix, will not break Microsoft compilers or CLang, it only adds the support for Cross Compiling from Linux. Most build platforms use Docker containers, like travis and GitLab, this fix allows compiling a Windows UnQLite from a Linux Host.

Can you provide more information while it should be removed while it is fully compatible with Microsoft and CLang compilers ?

The fix just adds more compiler support.

symisc commented 6 years ago

Yes, unqlite.h and unqlite.c should not be modified and the library version upgraded for a simple uppercase letter that does not affect the engine in any case. However your build scripts are very welcomed.

gjrtimmer commented 6 years ago

Are you willing to include the the fix in the non-amalgamation and push it upstream to this repo? Without this Fix you will loose the cross-compile Windows build checks.

Fix for non-amalgamation code:

Replace

#include <Windows.h>

With

#ifdef __MINGW32__
#include <windows.h>
#elif
#include <Windows.h>
#endif

If you can include this in the original source and push a new amalgamation code then I can update this PR.

Without this fix, this PR has no point because then this repo does not support Cross-Compilation by automatic build servers. I think that it is very important to the endusers that a repo does not force which compiler an end-user has to use.

I understand that the modification to the amalgamation what I have done is something you do not want. However the code in src is not equal in terms of version and according to a previous closed issue being kept for code profiling.

Will the source which builds the amalgamation and amalgamation build script also be pushed to this repo ?

If all of the above is not an option then this PR has no point and cross-compiling both directions

This is a great project by the way.

Last but no least; I would like to know how do you intend to receive PR's on the source of UnQLite without the non-amalgamation code. Please advice.

symisc commented 6 years ago

I would like to know how do you intend to receive PR's on the source of UnQLite without the non-amalgamation code. Please advice. Yes, PR's are more than welcome especially from motivated developers like you. The amalgamation is the last thing automatically generated whenever a new version of UnQLite is pushed.