How to print a var using echo o print in a NDK-build Android.mk file to debug compilation?

DebuggingMakefileAndroid Ndk

Debugging Problem Overview


I'm trying to print some extra info when in compile a library using ndk-build.

For example:

LOCAL_PATH := $(call my-dir)
all:;echo $(LOCAL_PATH)
echo: $(LOCAL_PATH)
print:echo "i'm not working"

When i do ndk-build, just compile all the Android.mk, but i don't get the console echo. I have readed the GNU make info (ndk-build is just a tiny GNU make), and some post whom said echo must work using a $(VAR) but it's not working on my case.

Some idea?

Debugging Solutions


Solution 1 - Debugging

Use

LOCAL_PATH := $(call my-dir)
$(warning $(LOCAL_PATH))

Solution 2 - Debugging

The more correct function to call is "$(info ...)" :

LOCAL_PATH := $(call my-dir)
$(info $(LOCAL_PATH))

Solution 3 - Debugging

The following displays are available in Android.mk:

  • error: debug print + stop the build
  • info: basic debug print
  • warning: same as info but displays the line number where it's been inserted

Here below some samples:

$(error this is the error message that will stop the build process)
$(warning this the warning msg)
$(info this the info msg)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionvgonisanzView Question on Stackoverflow
Solution 1 - DebuggingAndrey KamaevView Answer on Stackoverflow
Solution 2 - DebuggingnelluteView Answer on Stackoverflow
Solution 3 - DebuggingPedroSw7View Answer on Stackoverflow