vlang / vab

V Android Bootstrapper
MIT License
307 stars 29 forks source link

compile: add support for `#flag /path/to/x.o` V code (better C dependency support) #289

Closed larpon closed 3 weeks ago

larpon commented 3 weeks ago

This PR adds support for compiling #flag /path/to/x.o entries (in V source code) with all supported Android compilers. This reduces the special-cases needed in vab for compiling C dependency object files. This basically means it is now possible to compile V code with your own C dependencies out of the box.

Since there's no way to pass a flag for a specific Android arch in V, there may still be cases where compiling for a specific arch may fail (see e.g. special-case for stbi_image_resize2.h that is preserved in this PR).

I have attached an example of an app running unmodified that uses my wren wrapper project (all is included in .zip) - this illustrates that vab (in this PR) is now compiling the module's #flag *.o entries without any hacks or special-cases needed. v_wren_and_json_on_android.zip

Since the function signature would otherwise change for the compile_v_imports_c_dependencies() function - I choose to deprecate it in favor of a new function compile_v_c_dependencies. The functions are very similar but would break userland code.

I have tested compiling and running of a few V examples that import's stbi (via gg) to ensure uninterrupted user experience.