3

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)

Community
  • 1
  • 1
foo64
  • 2,075
  • 3
  • 18
  • 25
  • Similar to http://stackoverflow.com/questions/7651608/simplifying-an-android-mk-file-which-build-multiple-executables. I think you could adapt the answer to that question to solve your problem. – acj Nov 10 '12 at 04:24

1 Answers1

1

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)
Andrey Starodubtsev
  • 5,139
  • 3
  • 32
  • 46