No, this is intentionally not supported by Android.bp. All Android.bp files
are always loaded.

First, instead of changing variable.go / soong_config.mk, we do have
extension points for user-defined plugins:
https://android.googlesource.com/platform/build/soong/+/0fe7866897b177f2bf7ec934c5615a2b48e48a23

For what you're trying to do, we suggest compiling against one interface
(HAL) and choosing one at runtime (you can have PRODUCT_PACKAGES &
soong_namespaces only install one of the two. If you're unwilling to create
a HAL, you could duplicate all of your build definitions inside
soong_namespaces, so that you have one set of libraries/binaries defined
for PLATFORM_SAMSUNG and another defined for PLATFORM_QCOM. That gets
really messy, though you can clean a bunch of it up with defaults &
filegroups.

- Dan

On Fri, Nov 30, 2018 at 4:43 PM wjjsun <wjj...@gmail.com> wrote:

> I want to conditional compile one Android.bp module conditionally! if
> vendorA, use vendora.bp to compile, if vendorB, then use vendorb.bp to
> compile!
>
> Say I:
>
> ----1. define a marco in BoardConfig.mk:
>
> TARGET_PLATFORM_VENDOR := vendorA or vendorB etc.
>
> ----2. Then I change variable.go:
>
> type variableProperties struct {
>     ...
>     Platform_vendor struct {
>         Cflags []string
>     }
>     ...
> type productVariables struct {
>     Platform_vendor    *string `json:",omitempty"`
>
> ----3. And I change soong_config.mk:
> $(call add_json_str,  Platform_vendor,
> $(TARGET_PLATFORM_VENDOR))
>
> ----4. Change Android.bp (I guess):
>
> cc_defaults {
>     name: "my-defaults",
>     defaults: [
>     ],
>
>     product_variables: {
>         platform_vendor: {
>             vendora: {
>                 include vendorA.bp
>                 cflags: ["-DPLATFORM_SAMSUNG"],
>             },
>             vendorb: {
>                 include vendorB.bp
>                 cflags: ["-DPLATFORM_QCOM"],
>             }
>         }
>     }
> }
>
> I just write fake code here to include vendor.bp here! How can I write
> correct Android.bp to make it work?
>
>
> --
> --
> You received this message because you are subscribed to the "Android
> Building" mailing list.
> To post to this group, send email to android-building@googlegroups.com
> To unsubscribe from this group, send email to
> android-building+unsubscr...@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-building+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
You received this message because you are subscribed to the "Android Building" 
mailing list.
To post to this group, send email to android-building@googlegroups.com
To unsubscribe from this group, send email to
android-building+unsubscr...@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-building+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to