How To Run Custom Rule In Android.mk Before Compilation?
Solution 1:
I would suggest the following:
include$(CLEAR_VARS)
LOCAL_SRC_FILES += callmanager_wrap.cpp
MY_JNI_WRAP := $(LOCAL_PATH)/callmanager_wrap.cpp
$(MY_JNI_WRAP):
echo "in myjni target"
swig -c++ -java -package com.package.my -o $(MY_JNI_WRAP) callmanager.i
cat jnistuff.txt >> $(MY_JNI_WRAP).PHONY: $(MY_JNI_WRAP)include$(BUILD_SHARED_LIBRARY)
That's it.
I probably owe you some explanations. So here we go:
$(LOCAL_SRC_FILES)
is a list of file names relative to$(LOCAL_PATH)
, so to address a file from outside the standard NDK actions, you need the full path for your file, which is$(LOCAL_PATH)/callmanager_wrap.cpp
.We specify the file as
.PHONY
to guarantee that the custom action is executed every time you run ndk-build. But if you know which are actual dependencies ofcallmanager_wrap.cpp
, you can specify them instead, like$(MY_JNI_WRAP): callmanager.i jnistuff.txt $(LOCAL_PATH)/../src/com/package/my/Something.java
In this case, you will not need the
.PHONY
line.If you want your source directory to remain clean, you can declare the wrapper file as
.INTERMEDIATE
like this:.INTERMEDIATE: $(MY_JNI_WRAP)
Now make will delete the wrapper file after build, if it did not exist before the build.
Solution 2:
I have done it this way: let's say I need to create .s file from .ll file
# custom build
source_ll_files := $(wildcard *.ll)%.s:
llc -o $@$(patsubst %.s,%.ll,$@)
LOCAL_SRC_FILES += $(patsubst %.ll,%.s,$(source_ll_files))# end
Post a Comment for "How To Run Custom Rule In Android.mk Before Compilation?"