I'm trying to convert a makefile to a .bp file for Android Q and I'm facing some issues.
I'm not sure how to define a release version. Previously in makefile i would just write something along the lines of:
MY_RELEASE_VERSION := $(shell cd $(LOCAL_PATH); git describe --always --dirty) DSW_VERSION= \"$(MY_RELEASE_VERSION)\"
Which would be defined as a string like for example: DSW_VERSION="project_specific_3_0"
Now I am able to use a cppflag in .bp with the DSW_VERSION , but I found no way to make the value of it to be taken like in the makefile. Something like:
MY_RELEASE_VERSION = ["__builtin_func:shell cd <'LOCAL_PATH' unset>; git describe --always --dirty"]
CPPFLAGS = [
"DSW_VERSION = "\"MY_RELEASE_VERSION"\",
]
Does not work.
Secondly I'm facing issues in defining a config variant, which in turn would define a variable from the source code. Something like this in .mk files:
LOCAL_CPPFLAGS +=$(TARGET_CONFIG)
With a ifdefined
in the code that looks like this:
#if defined (TARGET_ONE)
static const VAR = 1;
#elif defined (TARGET_TWO)
static const VAR = 2;
I tried in .bp appending to the cppflags, something like :
cppflags: MY_CPPFLAGS + TARGET_CONFIG
,
where MY_CPPFLAGS is a variable defined with all the flags needed and it doesn't work
Anyone can help me with those?
You can use genrule
to generate code at build time (e.g. a header file containing the repository version). Check out the Wayland Android.bp as an example on how a genrule
looks like.
To answer your second question: You can use cflags
to add defines:
<some-module> {
[...]
cflags: ["-DTARGET_CONFIG"],
}