Search code examples
buildandroid-source

How to add conditional code in Android.bp


AOSP now has new build system, and file Android.bp has replaced Android.mk in many places.

Now I want to list source files conditionally depending on platform.

Say something like this:

if(atom)
{
   src: [
      .......list of files.......
   ],
   exclude_srcs: [
      .......list of files.......
   ]
} else
{
   src: [
      .......list of files.......
   ],
   exclude_srcs: [
      .......list of files.......
   ]
}

Any suggestions how to achieve this? Also, how can I achieve logical operations like NOT, OR etc in conditionals?

Thanks in advance.


Solution

  • Quote from documentation:

    By design, Android.bp files are very simple. There are no conditionals or control flow statements - any complexity is handled in build logic written in Go.

    You can read it here.