Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android NDK: custom pre-build step?

NDK 8b, Eclipse / Cygwin

I'm trying to add custom pre-build steps to Android.mk:

1) for every *.xyz file in the source tree, run a custom tool which generates corresponding .h and .cpp files

2) add the .cpp files to LOCAL_SRC_FILES

I've read this post and it's not quite what I'm looking for (it's only for one file)

like image 667
foo64 Avatar asked Sep 12 '26 21:09

foo64


1 Answers

According http://www.gnu.org/software/make/manual/make.html you can use old-fashioned suffix rules:

source_xyz_files = a.xyz b.xyz
.xyz.cpp: $(source_xyz_files)
    if test "`dirname $@`" != "."; then mkdir -p "`dirname $@`"; fi
    tool_to_create_cpp_and_h_from_xyz $< $@ $(patsubst %.cpp,%.h,$@)
LOCAL_SRC_FILES += $(patsubst %.xyz,%.cpp,$(source_xyz_files))

or patter rules:

generated_cpp_files = a.cpp b.cpp
$(generated_cpp_files) : %.cpp : %.xyz
    if test "`dirname $@`" != "."; then mkdir -p "`dirname $@`"; fi
    tool_to_create_cpp_and_h_from_xyz $< $@ $(patsubst %.cpp,%.h,$@)
LOCAL_SRC_FILES += $(generated_cpp_files)
like image 73
Andrey Starodubtsev Avatar answered Sep 15 '26 10:09

Andrey Starodubtsev