sdkbox / issues

The issue tracker for SDKBOX
MIT License
4 stars 0 forks source link

Make plugin's Android.mk also export parent directory as include #61

Open solodon4 opened 4 years ago

solodon4 commented 4 years ago

If you look at any of your plugins sdkbox-XXXX_v2.5.1.2.tar.gz and then look at extracted sdkbox-XXXX_v2.5.1.2/plugin/android/jni/PluginGoogleAnalytics/Android.mk you will see that all of them only export the same directory as Android.mk:

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)

The header file is indeed in that directory, however, all of your source files and respectively sources of all your users include those header files as #include <XXXX/XXXX.h> (primarily because they also have to work with frameworks on iOS) so that LOCAL_EXPORT_C_INCLUDES is of no use for me. This means that besides the usual:

$(call import-module, sdkbox/sdkbox-XXXX/plugin/android/jni/XXXX)

I also have to manually do:

LOCAL_C_INCLUDES += sdkbox/sdkbox-XXXX/plugin/android/jni

for the parent directory just to make those #include directives work.

Can you guys also export the parent directory from your plugins so that I don't have to list that directory manually in my source? If that is not possible for some unknown to me reason, can you restructure your plugin's folder in such a way where Android.mk is able to export both folders. Thank you!

hugohuang1111 commented 4 years ago

ndk can find #include <XXXX/XXXX.h>

tabke a look at https://github.com/sdkbox/sdkbox-sample-cpp317/tree/iap, we didn't include proj.android/app/jni in .mk file

solodon4 commented 4 years ago

Hmm, you are right: the sample builds indeed, i only get a warning:

/Classes/HelloWorldScene.cpp:28:10: warning: non-portable path to file '"pluginadmob/PluginAdMob.h"'; specified path differs in case from file name on disk [-Wnonportable-include-path]
#include "PluginAdMob/PluginAdMob.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
         "pluginadmob/PluginAdMob.h"

I wonder what's different with my case and why it doesn't work for me.

solodon4 commented 4 years ago

OK, the fact it works in sample's case is somehow related to the fact that your plugins are inside JNI folder, I guess that folder is added to search elsewhere. If i create a folder external in the root of the project (i.e. sdkbox-sample-cpp317/external) and move plugins there with correspondent modification in Android.mk:

$(call import-module, ./../../../external/sdkbox)
$(call import-module, ./../../../external/pluginsdkboxads)
$(call import-module, ./../../../external/pluginadmob)

I get the same error in your sample as I get in my own code:

sdkbox-sample-cpp317/proj.android/app/jni/../../../Classes/HelloWorldScene.cpp:28:10: fatal error: 'PluginAdMob/PluginAdMob.h' file not found
  #include "PluginAdMob/PluginAdMob.h"
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  1 error generated.
hugohuang1111 commented 4 years ago

you can add sdkbox-sample-cpp317/external to INCLUDES in proj.android/app/jni/Android.mk

solodon4 commented 4 years ago

That wouldn't quite work as I extract all SDKBOX plugins there: external/sdkbox-XXXX the way they are packed in your sdkbox-XXXX_v2.5.1.2.tar.gz. With that, for each plugin I have to add external/sdkbox-XXXX/plugin/android/jni to INCLUDES, which would have been unnecessary if only you guys also exported parent directory from your Android.mk for each SDKBOX plugin.

hugohuang1111 commented 4 years ago

you should copy sdkbox-XXXX/plugin/android/jni to external/sdkbox, and include external/sdkbox in proj.android/app/jni/Android.mk.

solodon4 commented 4 years ago

I understand how I can fix this on my side, i'm just suggesting a trivial improvement on SDKBOX' side for your users. I don't want to move subfolders around too much to avoid subtle differences on my own machine vs CI/CD runners. I simply unpack your plugins and point my Xcode project to iOS frameworks in your folder and my Android project to your Android ones.