writing a gyp build script for building lib on android

487 Views Asked by At

I want to build my code (a native lib) using a gyp build enviroment. How to start. How to add support for executing a gyp scipts. A small working example will be helpful to refer.

i m trying to build "icu4c" i got the gyp file for that(opensource) but I donot know to execute this build the lib I am building it for andorid enviroment.

2

There are 2 best solutions below

2
On

I dont know about icu4c but the basic commands I use for my project is

ANDROID_BUILD_TOP=`pwd` GYP_GENERATORS=android gyp gypfilename.gyp --depth=. --toplevel-dir=.

and you add defines needed in the gyp files with -D

Android project is different in that it cannot specify an output directory, so after you run the gyp commands, android mk files will be generated besides your gyp file. So you will need to run ndk-build in the root folder to generate your lib files

You will need a Application.mk file to run ndk-build

0
On

It's possible to use ninja generator to build shared library. Right clang version and build flags can be found in NDK/build/tools/make_standalone_toolchain.py. Ready example can be found here.