What file does ndk-build look for - android-ndk

When you use make the idea is you have a Makefile that you start the building off with. With ndk-build it according to the docs just runs $GNUMAKE -f <ndk>/build/core/build-local.mk but like is there a file in my project I need to have or what files is is looking for.

Yes, typically it expects to find your project makefile as jni/Android.mk, but you have lots of freedom if you need.

Related

What are these commands used in the following section when using the libxl library?

It's from the readme section on how to use libxl when I downloaded it and started using it in mingw-w64
What is the use of -I in this command?
What is the use of -L in this command?
What is the use of -lxl in this command?
I can't figure out what they mean and what they do; can anyone help me?
This is an example taken from the library libxl readme section.
This is a command to invoke Gnu's C++ compiler on the 'generate.cpp' source code file to create an executable named generate.exe.
-I../../../include.cpp says to look 3 directories above the current one for an Include file named include.cpp.
-lxl says to search the "xl" library when the linking loader runs and -L../../../bin says you might find the "xl" library in the bin folder three levels above the current directory

How to make debug build of specific module under AOSP tree?

I built eng flavor of AOSP tree and installed on a device. I like to step through code of a module (say libinput.so). I want to build this module with "-O0 -g" passed as part of CFLAGS. BUT I don't want to change the Android.mk file of this module.
Lets say this module is at aosppath/frameworks/base/service/input.
I cd to this folder after sourcing build/envsetup.sh.
I tried "mm -B LOCAL_STRIP_MODULE=false". When I was stepping through eclipse gdb, I see the execution order going zig zag.
Then I tried "mm -B LOCAL_STRIP_MODULE=false LOCAL_CFLAGS="-O0 -g""
Now gdb was able to step through fine. But this doesn't seem to work in other projects. I have a module that uses skia and opengl. The build is failing when I pass LOCAL_CFLAGS on command line.
What is the suggested way to make debug flavor of specific .so or exe under AOSP tree?
Thanks
So since the main reason you don't want to make changes to Android.mk is so you don't have to check it in, an alternative here is to use the .repo/local_manifests folder to change a module that is owned by android to be owned by you.
Here is a sample my_manifest.xml file which can do this for you:
<manifest>
<remote name="origin"
fetch="ssh://git#github.com/YourRepoHere/" />
<remove-project name="platform/frameworks/base"/>
<project path="frameworks/base" remote="origin" name="frameworks-base" revision="your-branch-name"/>
</manifest>
This will remove frameworks/base from the android manifest tree, and replace it with your own manifest tree (which you need to fork into your own repository).
After that, you can then use a conditional inside of your Android.mk file like so:
ifeq ($(TARGET_BUILD_VARIANT),userdebug)
CONDITIONAL_CHANGES_HERE
endif
Again, I realize that you didn't want to modify the Android.mk file but since you also asked for the suggested way of making a module that is conditional on the build variant, I am going to include this answer anyway in case nothing better comes your way. This is really the suggested way of doing what you want to do, as your project will now be maintained by the repo tool.

CMake, build options

I can't seem to find much about this, so maybe it isn't possible... or I am searching with the wrong keywords.
Anyway, I have a directory of source. Let's say that there is a folder within Source called Tests and another called Products. I have the usual hierarchy of CMakeLists.txt files so that I can build all the source in each directory and subdirectory, etc... What I want to know is if it is possible to pass a command line argument with cmake so that it will only build the tests folder or the source folder.
e.g. something like cmake TEST ..
Thanks
Of course you can use flags.
if(TEST)
include needed folders
else()
do something else
endif()
And call cmake like this:
cmake -DTEST=1 ..
You can create them as different targets. CMake will configure all of them, but then you can run make test or make product. An example would be:
project(myProject)
add_subdirectory(tests)
add_subdirectory(products)
add_executable(test EXCLUDE_FROM_ALL ${TEST_SRC_FILES})
add_executable(product EXCLUDE_FROM_ALL ${PRODUCT_SRC_FILES})
In each subdirectory you would have a CMakeLists.txt that builds the source file variables. The EXCLUDE_FROM_ALL means that just typing make won't build either tests or products, but you can decide if you want that to happen or not.
To build, you can do make test or make product and it will build only that target (and any dependencies).

How to prevent Android native project full rebuild after changing Android.mk?

I'm editing Android.mk of my project to fine-tune some compiler options. Every time the build process is started from scratch. I don't want to do a full rebuild after each and every change. Is there a way to do so?
GNU make has the option -o (http://unixhelp.ed.ac.uk/CGI/man-cgi?make) to do not remake the file file even if it is older than its dependencies, and do not remake anything on account of changes in file. Essentially the file is treated as very old and its rules are ignored.
This code does the trick:
ndk-build -o jni/Android.mk

scons: foiling an IDE when using alternate build directories

So I have scons working with an alternate build location (build/ for my output files, src/ for my input files) and it works great. Except for one thing.
I'm using an IDE (TI Code Composer 4) to debug my program. I point the IDE at the output executable to run it, and what it uses for the source files for debugging is the build/ directory. I don't really care, except when I go to edit the file in the IDE, for example main.cpp, the file is really build/main.cpp which gets clobbered as soon as I run scons again. I have to remember to edit src/main.cpp instead. I am aware of this issue and yet I make the same mistake often.
Is there a way to have scons make the source files it copies into the build path read-only? (I'd ask how to get TI CCS4 to use the right source files when it is debugging an executable, but I doubt I'd get any answers.)
This page has information about wrapping InstallTargets with a chmod call.
FYI, the scons user list is quite active with many knowledgeable people and you can get answers pretty quickly.
You could always tell scons not to duplicate source files in the build directory:
SConscript('src/SConscript', variant_dir='build', duplicate=0)

Resources