You can specify which target your module should be built for: Android, Host, or Both.
Host means GNU/Linux if that is what you build the AOSP in.
Android
This is the typical binary module to be built for the device architecture.
cc_binary {
name: "my-binary",
srcs: [ "main.cpp" ],
shared_libs: [ "libcutils" ]
}
Host
There are multiple _host
module types (e.g. cc_binary_host
, cc_test_host
, java_binary_host
) that will create host binaries.
cc_binary_host {
name: "my-binary-host",
srcs: [ "main.cpp" ],
shared_libs: [ "libcutils" ]
}
Both
If you want to build both, a device binary and a host binary, you can use host_supported: true
.
cc_binary {
name: "my-binary",
srcs: [ "main.cpp" ],
shared_libs: [ "libcutils" ],
host_supported: true
}
You might want to specify additional flags, defines, sources, etc. for android
or host
. You can do that with the target
property:
cc_binary {
name: "my-binary",
srcs: [ "main.cpp" ],
shared_libs: [ "libcutils" ],
host_supported: true,
target: {
android: {
// android specific properties
},
host: {
// host-side specific properties
}
}
}
A note on module dependencies
Every module another module depends on needs to be supported for the same target.
Example: a cc_binary_host
cannot depend on a cc_library
with host_supported: false
.