Cameron Martin Cameron Martin - 1 year ago 125
Android Question

In an AOSP file, how do I execute a command and fail the build if the command fails?

In an file, I have the following line which executes a bash script:

$(info $(shell ($(LOCAL_PATH)/

However, if the command fails the build continues rather than quitting.

How do I make the whole build fail in this situation?

Answer Source

Dump stdout, test the exit status, and error out on failure:

ifneq (0,$(shell >/dev/null command doesnotexist ; echo $$?))
  $(error "not good")

Here's what failure looks like:

[user@host]$ make 
/bin/sh: doesnotexist: command not found
Makefile:6: *** not good.  Stop.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download