Strange wildcard problem in Android.mk

189 views
Skip to first unread message

Robin Degen

unread,
May 29, 2012, 6:41:58 PM5/29/12
to andro...@googlegroups.com
I integrated my android project with visual studio with the help of a makefile project, which runs the following command on build (greatly simplified to show the problem):

set CYGWIN_PATH=E:\android\cygwin\
set NDK_PATH=/home/robindegen/android-ndk/
set PROJECT_PATH=/home/robindegen/workspace/Dungeon/
%CYGWIN_PATH%\bin\bash.exe --login -c "%NDK_PATH%ndk-build NDK_PROJECT_PATH=%PROJECT_PATH%"

Now in my jni folder i have a bunch of cpp files in a subfolder called dungeon. So I used the following:
LOCAL_SRC_FILES := $(wildcard /dungeon/*.cpp)
This works fine if i run ndk-build from the cygwin commandline, but not if i run it with the commands as stated above. The strange thing however is, this works fine:
LOCAL_SRC_FILES := /dungeon/main.cpp 

And this:
LOCAL_PATH := $(call my-dir)
$(warning $(LOCAL_PATH))

returns /home/robindegen/workspace/Dungeon//jni/Android.mk:3: /home/robindegen/workspace/Dungeon//jni

Which is the right path. So.. what gives?

David Turner

unread,
May 30, 2012, 5:53:50 AM5/30/12
to andro...@googlegroups.com
Use $(info $(LOCAL_SRC_FILES)) to see what the $(wildcard ...) returned in both cases, that should give you a clue about the problem.

--
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/-/t0iANbcZ_MEJ.
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.

Robin Degen

unread,
May 30, 2012, 9:26:20 AM5/30/12
to andro...@googlegroups.com
Thanks for your answer. I already tried that though. If i use the wildcard, it's empty. Which is strange because it's ment to find the files. Manually adding them works just fine.

2012/5/30 David Turner <di...@android.com>

David Turner

unread,
May 30, 2012, 10:11:22 AM5/30/12
to andro...@googlegroups.com
Use NDK_LOG=1 in your ndk-build command line (both on Cygwin and with your script).
The differences in the output should also have some information.

I suspect that when started from the script, you may be really calling ndk-build.cmd or using prebuilt/windows/bin/make.exe which is not Cygwin compatible (and hence doesn't understand /dungeon/...)

Robin Degen

unread,
May 30, 2012, 10:23:18 AM5/30/12
to andro...@googlegroups.com
The only difference is this:
Commandline:
Android NDK: Found stable platform levels: 4 3 14 8 9 5
Android NDK: Found max platform level: 14
Android NDK: Looking for jni/Android.mk in /home/robindegen/workspace/Dungeon/jni
Android NDK: Looking for jni/Android.mk in /home/robindegen/workspace/Dungeon
Android NDK:     Found it !
Android NDK: Found project path: /home/robindegen/workspace/Dungeon
Android NDK: Ouput path: /home/robindegen/workspace/Dungeon/obj

Script:
Android NDK: Found stable platform levels: 4 3 14 8 9 5
Android NDK: Found max platform level: 14
Android NDK: Found project path: /home/robindegen/workspace/Dungeon/
Android NDK: Ouput path: /home/robindegen/workspace/Dungeon//obj

There is no mention of looking for Android.mk in the script. However, this makes sense because in the script, the path is already supplied as NDK_PROJECT_PATH so it doesn't need to be searched for.

For now i'm compiling it by manually adding the files. But the wildcard would be a lot more helpful

Robin Degen

unread,
May 30, 2012, 11:08:15 AM5/30/12
to andro...@googlegroups.com
Seems it was related to the execution path. Wildcard seems to ignore NDK_PROJECT_PATH somehow, and instead work relative to the execution path. I think this because this:

%CYGWIN_PATH%\bin\bash.exe --login -c "cd %PROJECT_PATH%jni/; %NDK_PATH%ndk-build NDK_PROJECT_PATH=%PROJECT_PATH%"

Works fine. I added the cd to the proper project path. Can anyone confirm or deny that this is a bug?

2012/5/30 Robin Degen <robin...@gmail.com>

David Turner

unread,
May 30, 2012, 11:16:24 AM5/30/12
to andro...@googlegroups.com
I see, there is an easier solution, which is to use the GNU Make -C <path> option, which will move (cd) to a given <path> before running, as in:

%CYGWIN_PATH%bin\bash.exe --login -c "%NDK_PATH%ndk-build -C %PROJECT_PATH%"

Hope this helps

Robin Degen

unread,
May 30, 2012, 11:20:09 AM5/30/12
to andro...@googlegroups.com
Thanks, that worked too. Make outputs that it entered the folder, and then wildcard picks it up fine. Do you think this is a path bug with wildcard? Or is this by design?

2012/5/30 David Turner <di...@android.com>

David Turner

unread,
May 30, 2012, 11:40:46 AM5/30/12
to andro...@googlegroups.com
On Wed, May 30, 2012 at 5:20 PM, Robin Degen <robin...@gmail.com> wrote:
Thanks, that worked too. Make outputs that it entered the folder, and then wildcard picks it up fine. Do you think this is a path bug with wildcard? Or is this by design?

I'm really not sure about this. It may be a Cygwin Make oddity. Who knows. 
Reply all
Reply to author
Forward
0 new messages