Android local module based on custom target

Android has makefile macros for creating local modules  written in C, C++ and Java. A module declaration can look something like this.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := mymodule
LOCAL_SRC_FILES := a.cpp b.cpp
LOCAL_LDLIBS := -lGLESv3 -llog
LOCAL_CXXFLAGS := -std=c++14
include $(BUILD_SHARED_LIBRARY)

The syntax is simple, but not very flexible.

Today I needed to create a custom target in an Android makefile. At first I thought that it would be as simple as creating a standard Makefile target, but in my particular situation I found that it had to be structured as a local module. I finally found a solution by invoking the BUILD_PHONY_PACKAGE module template.

custom_myfile_target: 
        echo Run custom code here
include $(CLEAR_VARS)
LOCAL_MODULE := mymodule
LOCAL_ADDITIONAL_DEPENDENCIES := custom_myfile_target
include $(BUILD_PHONY_PACKAGE)
custom_myfile_target is a regular GNU makefile target which can be extended as such.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s