NG BCC Compiler and Native Support

BlitzMax Forums/MiniB3D Module/NG BCC Compiler and Native Support

RustyKristi(Posted 2016) [#1]
Reading this somewhere, I think bmx-ng.com..

BlitzMax-NG, a Monkey-originated bcc parser for BlitzMax.



I hope I'm not speculating and this is related to my previous question pertaining to mixing java or any other code. I'm seeing this structure being implemented in Monkey via the "Native" Folder.

So my question is how do you get to use and add other sources, something like this:

https://github.com/MikeHart66/fantomX/tree/master/native

Only got this idea with the pre.make and post.make.

I hope this makes sense. I just can't find any doc or tutorial where you could achieve something like this, even basic stuff.


xlsior(Posted 2016) [#2]
Not sure what you're asking here, but:

The standard blitzmax BCC creates x86 assembly code, which then get compiled to an x86 executable (under Windows it uses FASM for that last step). This means that although stock blitzmax can compile for Windows, OS X and Linux, it will only work on x86 -- even though it can compile for Linux, it won't work on an ARM-chip based Linux install.

Blitzmax-NG's BCC instead translates the Blitzmax code to standard C, which can then be compiled by a C compiler on the destination platform -- this is what allows Brucey's version to also compile for iOS and Raspberry Pi, Android tablets, etc. which are NOT running on x86 chips.

Monkey does the same thing (creates C code, which then gets translated/compiled to other languages.) I don't think it would really help you with mixing in Java, unless you can somehow translate the generated C code into Java and go from there.


RustyKristi(Posted 2016) [#3]
Yes, that's why I indicated NG in my title post, vanilla bmx is out of the question here.

I completely understand the underlying architecture (I'm not a beginner in OS and C++ programming ;-) ) and what is needed I was talking more about the process.

If NG and Monkey are doing the same thing, and Monkey has this Native java code (see fantom X code I posted again) and other etc which NG does not support yet, would that translate to how NG would work as well? at least added with some effort which I was the topic per se.

Maybe I'm talking more about how NG operates in preparing a module for android build (java code, c sources)


skidracer(Posted 2016) [#4]
Monkey outputs high level languages like c++. NG as I understand it uses completely different low level C output so not the same animal at all.


Brucey(Posted 2016) [#5]
Monkey outputs high level languages like c++

... as well as Java, JavaScript, and possibly C#...

All depending on the particular target platform.
For example, for Android, it spits out Java source.


BlitzMax NG was designed to be closely compatible with the standard BlitzMax base structures - which are a kind of object-oriented C structs.

If NG and Monkey are doing the same thing...

They are doing similar things - generating source for a target language from another language.
It's just that Monkey can generate different target languages. NG generates C regardless of the platform.

and Monkey has this Native java code

Java is not really "native". It's just what Android happens to use for a lot of its software stack.
Android's actual "native" is machine-code compiled libraries and binaries using the same tools as you would build apps on the desktop.
This is what NG compiles to.

If you want to integrate with Java, you need to go through JNI (Java Native Interface).
This requires writing (or generating) the appropriate glue code to convert Java stuff to BlitzMax stuff, and vice versa.

There is a ton of information online about JNI - examples, tutorials, etc.

For example, to access the information specifically mentioned in the fantomX source, I found this :

http://stackoverflow.com/questions/7183627/retrieve-android-os-build-system-properties-via-purely-native-android-app

which indicates stuff is accessible via sys/system_properties.h


RustyKristi(Posted 2016) [#6]
Thanks Brucey. That made things clear.

Another question is how do you set bmk/bcc to see android ndk C/C++ headers instead of the standard C/C++ libs?