Skip to content

Commit

Permalink
android: consistant ML_API_COMMON macro
Browse files Browse the repository at this point in the history
ML_API_COMMON macro has been inconsistent for Android build,
where it is force-defined 1 in Android.mk while it may
become 0 or 1 depending on build system in meson.

Because android build uses meson and Android.mk simultaneously,
this must become consistent.

Signed-off-by: MyungJoo Ham <[email protected]>
  • Loading branch information
myungjoo committed Jun 13, 2024
1 parent 25b5117 commit 1fd82f2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
12 changes: 6 additions & 6 deletions jni/Android.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ LOCAL_C_INCLUDES := @MESON_NNTRAINER_INCS@ @MESON_ML_API_COMMON_ROOT@/include
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)

LOCAL_ARM_NEON := true
LOCAL_CFLAGS += -pthread -fexceptions -fopenmp -static-openmp @MESON_CFLAGS@ -DML_API_COMMON=1
LOCAL_CXXFLAGS += -std=c++17 -frtti -fexceptions -DML_API_COMMON=1 @MESON_CXXFLAGS@
LOCAL_CFLAGS += -pthread -fexceptions -fopenmp -static-openmp @MESON_CFLAGS@ @ML_API_COMMON@
LOCAL_CXXFLAGS += -std=c++17 -frtti -fexceptions @ML_API_COMMON@ @MESON_CXXFLAGS@
LOCAL_MODULE_TAGS := optional

LOCAL_LDLIBS := -llog -landroid -fopenmp -static-openmp
Expand All @@ -82,8 +82,8 @@ LOCAL_C_INCLUDES := @MESON_CCAPI_NNTRAINER_INCS@ @MESON_ML_API_COMMON_ROOT@/i
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)

LOCAL_ARM_NEON := true
LOCAL_CFLAGS += -pthread -fexceptions -fopenmp -static-openmp @MESON_CFLAGS@ -DML_API_COMMON=1
LOCAL_CXXFLAGS += -std=c++17 -frtti -fexceptions -DML_API_COMMON=1 -DVERSION_MAJOR=@VERSION_MAJOR@ -DVERSION_MINOR=@VERSION_MINOR@ -DVERSION_MICRO=@VERSION_MICRO@ @MESON_CXXFLAGS@
LOCAL_CFLAGS += -pthread -fexceptions -fopenmp -static-openmp @MESON_CFLAGS@ @ML_API_COMMON@
LOCAL_CXXFLAGS += -std=c++17 -frtti -fexceptions @ML_API_COMMON@ -DVERSION_MAJOR=@VERSION_MAJOR@ -DVERSION_MINOR=@VERSION_MINOR@ -DVERSION_MICRO=@VERSION_MICRO@ @MESON_CXXFLAGS@
LOCAL_MODULE_TAGS := optional

LOCAL_LDLIBS := -llog -landroid -fopenmp -static-openmp
Expand All @@ -100,8 +100,8 @@ LOCAL_C_INCLUDES := @MESON_CAPI_NNTRAINER_INCS@
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)

LOCAL_ARM_NEON := true
LOCAL_CFLAGS += -pthread -fexceptions -fopenmp -static-openmp @MESON_CFLAGS@ -DML_API_COMMON=1
LOCAL_CXXFLAGS += -std=c++17 -frtti -fexceptions -DML_API_COMMON=1 @MESON_CXXFLAGS@
LOCAL_CFLAGS += -pthread -fexceptions -fopenmp -static-openmp @MESON_CFLAGS@ @ML_API_COMMON@
LOCAL_CXXFLAGS += -std=c++17 -frtti -fexceptions @ML_API_COMMON@ @MESON_CXXFLAGS@
LOCAL_MODULE_TAGS := optional

LOCAL_LDLIBS := -llog -landroid -fopenmp -static-openmp
Expand Down
3 changes: 3 additions & 0 deletions jni/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ else
and_conf.set('MESON_HAS_TFLITE', 0)
endif

# -DML_API_COMMON=[01]
and_conf.set('ML_API_COMMON', ml_api_common_flag)

if blas_dep.found()
and_conf.set('MESON_BLAS_ROOT', blas_root)
else
Expand Down
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ nntrainer_conf.set('MEMORY_SWAP_PATH', nntrainer_swapdir)

dummy_dep = dependency('', required: false)
found_dummy_dep = declare_dependency() # dummy dep to use if found
ml_api_common_flag = '-DML_API_COMMON=0'

# if ml-api-support is disabled, enable dummy common api interfaces and disable related dependencies.
ml_api_common_dep = dependency(get_option('capi-ml-common-actual'), required : get_option('ml-api-support').enabled())
Expand All @@ -209,6 +210,7 @@ if (ml_api_common_dep.found())
if (nnstreamer_capi_dep.found())
nntrainer_conf.set('CAPI_ML_COMMON_DEP', get_option('capi-ml-common-actual'))
extra_defines += '-DML_API_COMMON=1'
ml_api_common_flag = '-DML_API_COMMON=1'
extra_defines += '-DNNSTREAMER_AVAILABLE=1'
# accessing this variable when dep_.not_found() remains hard error on purpose
supported_nnstreamer_capi = nnstreamer_capi_dep.version().version_compare('>=1.7.0')
Expand Down

0 comments on commit 1fd82f2

Please sign in to comment.