Building app from external directory

403 views
Skip to first unread message

Steve

unread,
Oct 5, 2009, 6:57:59 PM10/5/09
to android-ndk
Hi there,

I have managed to build some of my own custom code situation in a
directory:

/path/to/ndk/root/eg/android-ndk-1.6_r1/apps/NAME_OF_PROJECT

However, I have a cross platform project that lives somewhere
completely different that I'd like to build, but I am struggling to
work out how to do this. The other project lives in a directory
structure something like:

/path/to/other/project/Game/Android/Application.mak
/path/to/other/project/Game/Android/projects/jni/Android.mak

With source files living in places like:

/path/to/other/project/Game/main.cpp
/path/to/other/project/Game/stuff.cpp

and

/path/to/other/project/Engine/Engine.cpp
/path/to/other/project/Engine/bla.cpp

Is there any sensible way to achieve this, or for the time being is
the only clean and easy way to copy all my source files in to my ndk/
apps/NAME_OF_PROJECT directory, and work from there?

Steve

Rockthesmurf

unread,
Oct 6, 2009, 4:24:28 AM10/6/09
to android-ndk
I haven't found a nice solution to this yet, but for the time being I
have made a symbolic link to:

/path/to/other/project

In:

/path/to/ndk/eg/android-ndk-1.6_r1/apps/myproject

Then in the root of that folder setup the application makefile, which
points to Android/jni/Android makefile. Then in the makefile I have
got it to pick up the files it needs to, it is a bit messy but just
about works (managed to get my project to link). I had to do some
slightly odd things to specify the pathing to the files, and the
include folder, and also had to manually specify the system library
folder/include folder (otherwise it didn't see the GL header/library)
- I guess this is a side effect from not having the files in the
default place.

Still - if anyone has a better solution I'd love to know about it!!

Steve

David Turner

unread,
Oct 6, 2009, 11:45:27 AM10/6/09
to andro...@googlegroups.com
What about defining the following in your Android.mk:

LOCAL_PATH := $(call my-dir)/../../..

?

Steve

unread,
Oct 10, 2009, 5:59:56 AM10/10/09
to android-ndk
I have it setup pretty much like that, one slight problem I have is
the directory I want to build in it no where near the directory my NDK
is installed in to, and (from my limited understanding) the best way
to build JNI code is to CD in to the root of the NDK dir, then do
something along the lines of 'make APP=myapplication' - it will then
look for a directory in apps called 'myapplication'. What I have done
is created a symbolic link of 'myapplication' in the apps folder that
points at this other location - the problem is I have to point it at
the root of the project directory (instead of game/android), as if I
point it directly at the 'game/android' folder, I am then unable to
bring in any source files from the folder above (as looking in the
folder above just follows the symbolic link backwards). It looked to
make as if there should be a way to resolve the symbolic link to a
real path, at which point going up a directory would work - I guess
this is more of a cygwin/make question now, but if anyone has any
ideas that'd be great!

Steve

On Oct 6, 4:45 pm, David Turner <di...@android.com> wrote:
> What about defining the following in your Android.mk:
> LOCAL_PATH := $(call my-dir)/../../..
> ?
>

Jack Palevich

unread,
Oct 10, 2009, 11:21:03 AM10/10/09
to andro...@googlegroups.com
The way I avoided the problem you've encountered is to use a relative path in the $NDK/app/myapp/Application.mk file.

That is, from your description it sounds like you're doing:

$NDK/app/yourapp/Application.mk:
APP_MODULES      := yourapp
APP_PROJECT_PATH := $(call my-dir)/project

And then you've got a symbolic link from $NDK/app/yourapp/project to your real project. directory

What I did was:

$NDK/app/myapp/Application.mk:
APP_MODULES      := myapp
APP_PROJECT_PATH := $(call my-dir)/../../../my-real-project-dir

Where the ../../../my-real-project-dir was the relative path from $NDK/app/myapp to where my project sources were kept.

It seemed to work. Maybe you could do that as well. (I only tried this on Linux and OSX, I don't have a cygwin installation handy.)

Steve

unread,
Oct 11, 2009, 8:58:24 AM10/11/09
to android-ndk
Just reading through my posts, it isn't soo clear what I am doing is
it! :o)

/path/to/top/level/projects/directory/Application.mak
APP_MODULES := pigame
APP_PROJECT_PATH := $(call my-dir)/PiGame/Android

/path/to/top/level/projects/directory/PiGame/Android/jni/Android.mk
LOCAL_PATH := $(call my-dir)
ENGINE_PATH := ../../../PiEngine
GAME_PATH := ../../../PiGame
THIRDPARTY_PATH := ../../../ThirdParty
include $(CLEAR_VARS)
STLPORT_BASE := $(NDK_WRAPPERS_BASE)/stlport
LOCAL_MODULE := pigame
LOCAL_CFLAGS += -I$(STLPORT_BASE)/stlport \
-I$(LOCAL_PATH)/../../../PiEngine/Base \
-I$(LOCAL_PATH)/SharedEngine \
-D__NEW__ \
-D__SGI_STL_INTERNAL_PAIR_H \
-DANDROID \
-D_ANDROID \
-DOS_ANDROID \
-DANDROID_NDK \
-DDISABLE_IMPORTGL \
-DTCHAR=char \
-I$(NDK_DIR)/build/platforms/android-4/arch-arm/usr/include

...and so on! And in my Android NDK folder, inside apps I have a
symlink called 'PiGame' that goes to:

/path/to/top/level/projects/directory

It isn't ideal, as it means I can only build one project from the
projects directory. I will have another play with it with your ideas
below and see if I can get any better. I think the essential problem I
have, is I tried to symlink my actual android directory (with the
source code a couple of directories higher), and then in the makefile
I used $(realpath .) to get the real path of the symlinked directory,
from there I was able to include all my source files, but the android
makefile system tried to include my real paths concatenated to the
android app directory - oops!

As I said, I will have another play!

Steve


On Oct 10, 4:21 pm, Jack Palevich <jack...@google.com> wrote:
> The way I avoided the problem you've encountered is to use a relative path
> in the $NDK/app/myapp/Application.mk file.
>
> That is, from your description it sounds like you're doing:
>
> $NDK/app/yourapp/Application.mk:
> APP_MODULES      := yourapp
> APP_PROJECT_PATH := $(call my-dir)/project
>
> And then you've got a symbolic link from $NDK/app/yourapp/project to your
> real project. directory
>
> What I did was:
>
> $NDK/app/myapp/Application.mk:
> APP_MODULES      := myapp
> APP_PROJECT_PATH := $(call my-dir)/../../../my-real-project-dir
>
> Where the ../../../my-real-project-dir was the relative path from
> $NDK/app/myapp to where my project sources were kept.
>
> It seemed to work. Maybe you could do that as well. (I only tried this on
> Linux and OSX, I don't have a cygwin installation handy.)
>
Reply all
Reply to author
Forward
0 new messages