How to speed up mm in module making of AOSP - android

I am working on the contacts app from android open source project. My android version is 2.3.5_r1. And using mm to make the module, but the making speed is quite slow, so i doubt if there is a method to speed up the making.
PS:Actually if i compile this module in eclipse, i will speed up a litter because the auto build feature of eclipse. But i don't like work with eclipse so give it up.

For instance, I use the following command from the root folder of your Android project:
mmm frameworks/base snod -j4
And I think that this is the best choice. Try it but substitute frameworks/base with your project name (relative path where Android.mk is stored).

In order of least cost to you:
Don't make clean so much. Allow the makefile to determine what to rebuild.
Use CCACHE export USE_CCACHE=1. You're only likely to see the effects of CCACHE upon having rebuilt multiple times. If your project is large set a higher CCACHE size e.g. 10GB ${ANDROID_DIR}/prebuilt/linux-x86/ccache/ccache -M 10G
Get a better processor and run with higher -j parameter

1. Build module + dependencies
mmma is slower than mmm, as the former make sure all dependencies are met for the module, and if they are not it compiles them as well. So, initially instead of a full make command, build the dependencies concerning the module you are interested in using the following:
mmma -j4 adir/yourmoduledir
2. Build module
Now that dependencies have met, keep recompiling just the module you are interested in. Skipping check for dependencies saves precious time. The directory you are using though, might contain more than one compilation target. To compile a single target, use something like:
mmm -j4 adir/yourmoduledir:moduletargetname
Example
Build libart
Build library and all of its dependencies once:
mmma -j4 art/runtime
Modify libart's code and quickly build it:
mmm -j4 art/runtime:libart
You will get half compilation time in comparison to Yury's approach as for example the debugging flavor of libart (libartd) will be omitted altogether.
Further speedup?
You should of course enable caching as suggested by aultbot.
Also, depending on the modules you are interested, there might be compilation targets you might want to disable by digging up in the makefiles. For example libart is compiled for both the host and the target. If you modify a variable in the makefiles can force compilation just for one of the 2, saving you half of the time.
Additional info:
Checkout out the outdated build guide in aosp:
build/core/build-system.html.
N-Preview google is switching to a new build system that aims to speed up incremental builds. I hope the documentation gets updated as well.

I found that when I use my laptop ssh to my desktop computer and build module, I can build it very very fast. I don't know why.

Related

How to quickly build module in Android Project?

Suppose I have an Android Project, and already compiled.
If I add an printk in kernel, and recompile make bootimage, it should be done quickly.
But Android Build System will still read bunch of makefiles, is there any way to skip this and just start compiling?
You can try using the same hack as here:
https://github.com/realdmitchell/condor-vendor-cm/blob/master/bootimage/Android.mk
This should allow you to use mmm make <path to bootimage dir> without parse all the makefiles in the tree

ndk-build installs libraries even if no change. Can this be changed?

I'm using the Native Development Kit (NDK) in a project of mine, and I'm trying to automate the whole app build procedure with Python.
Whenever ndk-build is called, it copies the prebuilt shared libraries to libs/<abi>/, even if there's no changes in them or they already exist there. This causes problem when I call ant later on, as it detects changed files (the library timestamps are newer) and so rebuilds the apk without any need.
Is there a way to change the ndk-build behaviour so it checks for existing libraries in the libs/<abi>/ folder and if they need updating or some are missing, it will call ndk-build, otherwise, just proceed to the next build step?
I've tried using filecmp in Python, but as the timestamps are different between the prebuilt shared libraries and the installed ones, it doesn't work.
The OP probably doesn't need this any more, but I had the exact same problem, trying to set up a Makefile to build a project, so maybe this will be helpful to someone else in the future as well.
ndk-build is a wrapper around gnu make, that invokes a bunch of Makefiles in build/core directory of the ndk, so, while it's not universally applicable*, for your personal project you can modify those Makefiles to do whatever you want. I found a clean-installed-binaries target that a couple of build/install targets depended on, removing those dependencies fixed the issue with perpetual installs.
In whichever cases that clean target is necessary you can invoke it manually with:
ndk-build clean-installed-binaries.
*Given the time to come up with a clean opt-in solution you can submit a patch to ndk project, and if accepted it will eventually become universally applicable.

Using OpenCv contrib modules for android

Is there a way to use opencv contrib modules in android ? I am specifically using text module. Is there a android lib for these modules. I have my code working on desktop and i m trying to migrate my codes to android. Any insight would be gr8.
I was having issues figuring out solutions to these problems as well. I thought I would find a relevant question out there and put a response in for the community in case others are also looking for solutions to a problem similar to this one and mine. Compilation was done on a Macbook Retina 13".
The instructions provided are somewhat incomplete and there are additional steps that will be needed to get to a final product.
At the start you will follow the standard procedure as outlined online
$ cd <opecv_directory>
$ mkdir build
$ cd <opencv_build_directory>
$ cmake -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory>
$ make -j5
$ make install
In addition to this, you may run across an error or two. I needed to install some missing components in order to get past things that were missing but this may differ for you (I researched errors and understood that I needed additional components)
brew install ninja
brew install oxygen
brew install ant
I also ran into an error with one module requesting the need for the following declared in the source code (or with compiler flags):
#define SOLARIS_64BIT_ENABLED
Another thing you can do is remove other modules in the contrib folder you may not be interested in during compilation. Just include the modules you want and hopefully those ones are good. I did this simply by removing one or two from the /modules folder and then reran the python script.
A final python script was needed to run the build. I created a directory alongside the main source tree and contrib folder.
OpenCVSource
-> opencv
-> opencv_contrib
-> android_opencv_build
The call below was made from the directory where I want the build to be taking place from, so I changed to the directory The call was the following:
python ../opencv/platforms/android/build_sdk.py --extra_modules_path ../opencv_contrib/modules --ndk_path <your-path-to-ndk-top-level-folder> --sdk_path <your-path-to-sdk-top-level-folder> ./ ../opencv
This only builds the .so files that are necessary for using the library, but it doesn't build the .jar file that you will need to use the new binaries. In order to do that navigate to your build folder (mine as seen is in android_opencv_build/OpenCV-android-sdk)
Load this project into Eclipse in the standard manner with the import existing Android project into workspace. You really only need the /sdk project but feel free to load samples as well if desired. Then build the project. You may need to alter the target build to support the new Camera APIs for a successful build; in my case changing the target to API level 21.
You will then find the .jar file in the /bin directory of the project. The .jar and the .so files found in android_opencv_build/OpenCV-android-sdk/sdk/native/jni/ contain the necessary .so files that you will need to include in your projects /lib folder alongside this jar.
Now you should have everything that you need. Since we are working with contrib modules (or not if you are building it for other reasons), it is possible that you will run across other errors in the build process that are not quite stable and will need some attention. This cannot be helped but people can feel free to add comments to other peoples solutions and this post to aide them in resolving them if they have found a solution.

How do I build just the LatinIME package from AOSP?

I'm trying to test some changes that I made to the LatinIME package in AOSP. The problem is, that the documentation only shows how to build the entire thing.
What I really need to know is how to build a single package (in this case, LatinIME), from the command line
edit: What isn't made clear (at least to me), is that in the repo root directory, you can type make PACKAGE (e.g. `make LatinIME'), and it will build that. I haven't tested it thoroughly, but it does appear to build all the prerequisites of the required package as well.
I think you want the mm or mmm command. See this documentation
Building only an individual program or module
If you use build/envsetup.sh, you can use some of the defined functions to build only a part of the tree. Use the 'mm' or 'mmm' commands to do this.
The 'mm' command makes stuff in the current directory (and sub-directories, I believe). With the 'mmm' command, you specify a directory or list of directories, and it builds those.
To install your changes, do 'make snod' from the top of tree. 'make snod' builds a new system image from current binaries.

ndk-build keeps rebuilding all sources

I have set up Eclipse to build my C/C++ files. I created a builder and set it to point at
the ndk-build executable in the ndk install tree. Each time I run this it keeps rebuilding all sources. I am not passing any arguments so why would it do this?
It doesn't look like it's possible to currently perform incremental builds using stock android-ndk. You could, however, do it manually. It's quite an involved process because you'll have to redo the makefiles and such. See this answer for a description of what this involves.

Categories

Resources