I have a simple Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
$(shell ($(LOCAL_PATH)/echo_test.sh))
LOCAL_MODULE := libecho_test
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
The interesting thing that it does is to call the 'echo_test.sh' bash script. In the case when the contents of the script are
#!/bin/bash
echo 'echo is working' >&2
or
#!/bin/bash
echo 'echo is working' >/dev/null
everything is OK.
Things go wrong when the bash script is
#!/bin/bash
echo 'echo is working'
or
#!/bin/bash
echo 'echo is working' >&1
Then the returned error is
Android.mk:4: *** missing separator. Stop.
This happens both with Android NDK 7 and when you include this module during the build of Android Ice Cream Sandwich 4.0.3.
I really can't understand what's the deal with the standard output and the Android build system. Does anyone have an explanation?
The Android NDK build system is actually GNU Make. All of the code in the Android.mk file has to be valid make
.
When you run $(shell) and don't store the value in a variable, then it is as if you copied the standard output of the script into your Android.mk file. i.e. it is as if your file contained the following:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
echo is working
LOCAL_MODULE := libecho_test
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
.. which is not valid make syntax. Redirecting to >&2 in your script works because the output goes to the error output and is then shown on the console.
As Vishrut mentions, use $(info) or $(warning) to print messages. Or if you really want to run a script during the build, store its output in a variable:
ECHO_RESULT := $(shell ($(LOCAL_PATH)/echo_test.sh))
Here you won't see the echo output of the script, it goes into the variable.
Try $(info $(shell ($(LOCAL_PATH)/echo_test.sh)))
, it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With