How to use build vars like PRODUCT_XXX in genrule cmd?

75 views
Skip to first unread message

DavidRobin

unread,
Jul 15, 2019, 12:31:58 PM7/15/19
to Android Building
I saw that in external/libmojo/Android.bp there is an example to generate header files for later build process.

genrule {
    name: "libmojo_mojom_headers",
    cmd: "$(location mojom_source_generator_sh)" +
    "    --mojom_bindings_generator=$(location mojom_bindings_generator)" +
    "    --package=external/libmojo" +
    "    --output_dir=$(genDir)" +
    "    --bytecode_path=$(genDir)" +
    "    --typemap=$(location gen/mojo/common/common_custom_types__type_mappings)" +
    "    --generators=c++" +
    "    --use_new_wrapper_types" +
    "    $(in)",

However, I cannot find how to use vars like $(PRODUCT_BRAND) $(PRODUCT_MANUFACTURER) etc in this cmd line.
Please help.
Thanks.

Dan Willemsen

unread,
Jul 15, 2019, 2:13:13 PM7/15/19
to Android Building
Those variables aren't exposed, partially because it becomes very difficult to understand which pieces of the system are then product-specific vs generic. Is there a reason why you wouldn't just read the runtime properties rather than trying to embed those values in code?

- Dan

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/48a06135-67f5-4381-a18c-5eed5a949601%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

DavidRobin

unread,
Jul 16, 2019, 11:13:22 AM7/16/19
to Android Building
Thanks for your reply.
Our purpose is to generate "License checking code" for specific product build.
So we have a shell script to generate the code based on the PRODUCT_XXX properties.

Are you implying that Android.bp should only be used in generic (product independent) modules?
And this kind of code should be put in device/product specific stuff and use Android.mk to achieve the goal?
(P.S. will Android.mk be kept or will Android.bp take over the whole build?)

On Tuesday, July 16, 2019 at 2:13:13 AM UTC+8, Dan Willemsen wrote:
Those variables aren't exposed, partially because it becomes very difficult to understand which pieces of the system are then product-specific vs generic. Is there a reason why you wouldn't just read the runtime properties rather than trying to embed those values in code?

- Dan

On Mon, Jul 15, 2019 at 9:31 AM DavidRobin <huangw...@gmail.com> wrote:
I saw that in external/libmojo/Android.bp there is an example to generate header files for later build process.

genrule {
    name: "libmojo_mojom_headers",
    cmd: "$(location mojom_source_generator_sh)" +
    "    --mojom_bindings_generator=$(location mojom_bindings_generator)" +
    "    --package=external/libmojo" +
    "    --output_dir=$(genDir)" +
    "    --bytecode_path=$(genDir)" +
    "    --typemap=$(location gen/mojo/common/common_custom_types__type_mappings)" +
    "    --generators=c++" +
    "    --use_new_wrapper_types" +
    "    $(in)",

However, I cannot find how to use vars like $(PRODUCT_BRAND) $(PRODUCT_MANUFACTURER) etc in this cmd line.
Please help.
Thanks.

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-...@googlegroups.com.

Chih-Wei Huang

unread,
Nov 22, 2019, 10:11:27 AM11/22/19
to Android Building
I have the same question.
I'd like to use product variables like TARGET_PRODUCT in Android.bp.
I searched the whole AOSP tree but still can't find a way to do that.
Sigh,,, Is it possible?

DavidRobin於 2019年7月16日星期二 UTC+8下午11時13分22秒寫道:

Dan Willemsen

unread,
Nov 22, 2019, 10:58:19 AM11/22/19
to Android Building
We've recently updated our documentation around conditionals (and most use of make variables fall into the same category):


tl;dr: we'd prefer you didn't use them, but if you need to, you can via a Go plugin. 

- Dan

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/6a64020b-1413-4723-aabe-3d6ce27f3ae9%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages