Android.mk wrong path using wildcard

2,203 views
Skip to first unread message

Aristarh Smertin

unread,
Feb 27, 2012, 3:14:51 AM2/27/12
to android-ndk
Problem:

http://stackoverflow.com/questions/9456762/android-mk-wilcard-extra-jni-in-path

Summary:
Wilcard function adds a extra 'jni' in source path, so make can't find
a source

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := AbyssEngine
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.c)

make: No rule to make target jni/jni/abyss_engine.c (extra jni, but
source just in jni root folder where is no subfolders at all) like:

jni/abyss_engine.c
jni/asset_manager.c
etc

LOCAL_SRC_FILES abyss_engine.c asset_manager.c works fine

P.S. I don't always clones a stack overflow questions, but then i do,
i put plus on every comment or answer

a1

unread,
Feb 27, 2012, 1:44:48 PM2/27/12
to andro...@googlegroups.com
Problem:

http://stackoverflow.com/questions/9456762/android-mk-wilcard-extra-jni-in-path

Summary:
Wilcard function adds a extra 'jni' in source path, so make can't find
a source
 
Nothing was added you have used jni/*.c wildcard which was expanded into jni/file1.c jni/file2/.c use notdir function to strip directory part, that is:
LOCAL_SRC_FILES=$(notdir $(wildcard $(LOCAL_PATH)/*.c))

If you would like to create recursive list of source files you may use following functions:

# -----------------------------------------------------------------------------
# Creates subdirs list from given root (root is included) and append given
# suffix to each element 
#
# Function : make-subdirs-list-with-suffix
# Returns  : list of subdirs with suffix appended
# Usage    : $(call make-subdirs-wildcards,<DIR>,<SUFFIX>)
# -----------------------------------------------------------------------------
make-subdirs-list-with-suffix = $(addsuffix $2, $(sort $(dir $(wildcard $1/**/))))

# -----------------------------------------------------------------------------
# List all files with given extension(s) from given directory and all of subdirs.
# Returned list is root relative (that is contains files in form: ./subdir/file.ext) 
#
# Function : list-all
# Returns  : list of files relative to root
# Usage    : $(call list-all,<DIR>,<EXTENSIONS-LIST>)
# -----------------------------------------------------------------------------
list-all = $(subst $1, ., $(wildcard $(foreach ext,$2,$(call make-subdirs-list-with-suffix,$1,$(ext))))) 

David Turner

unread,
Feb 28, 2012, 5:43:25 PM2/28/12
to andro...@googlegroups.com
It's not a problem. As stated by the documentation, the files listed through LOCAL_SRC_FILES must be relative to LOCAL_PATH.
The result of $(wildcard $(LOCAL_PATH)/*.c) will return $(LOCAL_PATH)/foo.c, $(LOCAL_PATH)/bar.c, etc..

So the build system will try to find $(LOCAL_PATH)/$(LOCAL_PATH)/foo.c, etc...

The solution is to remove the $(LOCAL_PATH) prefix from the results of $(wildcard ...)


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
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.


Reply all
Reply to author
Forward
0 new messages