Parameters to ndk-build with spaces don't work

822 views
Skip to first unread message

Adrian Taylor

unread,
Jul 13, 2010, 10:53:00 AM7/13/10
to android-ndk
Hi all,

I'm running into a minor problem with the ndk-build script.

I want to build a project passing in some C #defines from an external
source. So, in my Android.mk I have:

LOCAL_CFLAGS := -DSOME_FLAG $(EXTERNAL_CFLAGS)

I then want to build the project like this:

ndk-build EXTERNAL_CFLAGS="-DHELLO -DGOODBYE"

Note that I'm passing multiple #defines within that variable and
therefore it contains a space.

Unfortunately that results in a problem:
make: invalid option -- 'D'
make: invalid option -- 'G'
make: invalid option -- 'O'
make: invalid option -- 'O'
make: invalid option -- 'D'
make: invalid option -- 'Y'
make: invalid option -- 'E'

It does work fine if I do this:

make -f $NDK_PATH/build/core/build-local.mk EXTERNAL_CFLAGS="-DHELLO -
DGOODBYE"

The problem therefore seems to come down to the ndk-build script
itself. Its last line is:

$GNUMAKE -f $PROGDIR/build/core/build-local.mk $@

It seems that the problem disappears if I change it to:

$GNUMAKE -f $PROGDIR/build/core/build-local.mk "$@"

"man bash" explains this effect:
"When the expansion occurs within double quotes, each parameter
expands to a separate word. That is, "$@" is equivalent to "$1"
"$2" ..."

That seems like it explains why it solves the problem, and sounds like
it would be a good thing to do. I can't see that this would negatively
impact anyone, but then again I'm far from an expert on shell scripts!

Would it be possible to put this tweak into future revisions of the
NDK?

Thanks very much for any suggestions.

Adrian

David Turner

unread,
Jul 13, 2010, 1:32:22 PM7/13/10
to andro...@googlegroups.com
Yes, good idea, will include the fix. Feel free to modify your ndk-build in the meantime.


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


Doug Schaefer

unread,
Jul 13, 2010, 1:41:05 PM7/13/10
to andro...@googlegroups.com
Hey David, is there a way to submit patches to the NDK via the AOSP?

David Turner

unread,
Jul 13, 2010, 2:15:43 PM7/13/10
to andro...@googlegroups.com
Hello Doug,

As always, r.android.com is the preferred way to send patches. Even if the AOSP stuff is *really* far far away from the
internal branch right now, this allows me to integrate the corresponding changes to the internal tree asap (and makes lawyers happy too).

We're working on open-sourcing NDK development though, but this will require moving the platform headers to a different directory
and some restructuring of a few scripts.

Regards

Adrian Taylor

unread,
Jul 14, 2010, 6:47:50 AM7/14/10
to andro...@googlegroups.com
Hi David, Doug,

On Tue, Jul 13, 2010 at 7:53 AM, Adrian Taylor

<adrian...@realvnc.com <mailto:adrian...@realvnc.com>>


> I'm running into a minor problem with the ndk-build script.

On Tue, Jul 13, 2010 at 10:41 AM, Doug Schaefer <cdt...@gmail.com
<mailto:cdt...@gmail.com>> wrote:
> Hey David, is there a way to submit patches to the NDK via the AOSP?

Good thinking to submit it via r.android.com. Here we go:

https://review.source.android.com/15795

Two whole bytes needing review :-)

Regards

Adrian

Reply all
Reply to author
Forward
0 new messages