Android Build System: How to add prebuilt event?

321 views
Skip to first unread message

pps

unread,
Jan 10, 2013, 1:45:25 AM1/10/13
to andro...@googlegroups.com
How can I add "pre-build" event for compilation of any file in android build system?

In regular makefile, I'd do something like this:

.PHONY pre-build
%.cpp: pre-build
pre-build:
    PrebuildRule.sh


all: pre-build ...
...


this way, no matter what, pre-build step will be executed, but I can't find a way how to do such thing with android build system.
Can anybody suggest appropriate workaround?
thanks.

David Turner

unread,
Jan 11, 2013, 10:58:02 AM1/11/13
to andro...@googlegroups.com
On Thu, Jan 10, 2013 at 7:45 AM, pps <pavlov...@gmail.com> wrote:
How can I add "pre-build" event for compilation of any file in android build system?

You can't, instead write a wrapper that runs your prebuilt script, then invokes ndk-build.

 
In regular makefile, I'd do something like this:

.PHONY pre-build
%.cpp: pre-build
pre-build:
    PrebuildRule.sh


all: pre-build ...
...


this way, no matter what, pre-build step will be executed, but I can't find a way how to do such thing with android build system.
Can anybody suggest appropriate workaround?
thanks.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/c949bXj7iNwJ.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

pps

unread,
Jan 14, 2013, 9:21:04 AM1/14/13
to andro...@googlegroups.com
On Friday, January 11, 2013 10:58:02 AM UTC-5, Digit wrote:

How can I add "pre-build" event for compilation of any file in android build system?

You can't, instead write a wrapper that runs your prebuilt script, then invokes ndk-build.

 
In regular makefile, I'd do something like this:

.PHONY pre-build
%.cpp: pre-build
pre-build:
    PrebuildRule.sh


all: pre-build ...
...


this way, no matter what, pre-build step will be executed, but I can't find a way how to do such thing with android build system.
Can anybody suggest appropriate workaround?
thanks.


I would really prefer to avoid adding stuff, since I want to make as simple as possible for the other programmers that use my stuff.
So, I added something like this at the beginning of my Android.mk file:

$(PrebuildResult) := $(shell prebuild.sh)

LOCAL_SRC_FILES := ....

And, then, I also manually added dependency on the prebuild.sh script (which generates the Prebuit.h header):
Prebuilt.h: prebuild.sh
 
So far everything works fine, except that it might fails on first clean built with -j8, because some parallel jobs try to compile files that depend on prebuilt.h which wasn't yet generated by the prebuilt.sh. That's why I was trying to find a way how add dependency or a prebuilt step in android. Perhaps, android/ndk devs could add that as a todo for the build system. Knowing internals it of the system it's easy to add something like that.
Reply all
Reply to author
Forward
0 new messages