How to ensure that the flag enabled in the intermediate .mk files is updated and visible to Soong

304 views
Skip to first unread message

Priyanka Bose

unread,
Dec 21, 2017, 3:22:11 PM12/21/17
to Android Building
Hi,

I need to add a conditional flag based on which I need to include my srcs and libs when they are enabled.
As  some suggestions in the other posts, I have added a  struct variable under productvariable in the variables.go.
Then included the same in the soong_config.mk file.
Made the changes in my .bp file to include that productvariable struct.
In my .go file , I have checked for the condition variable ( which I am enabling in one of the .mk files) and based on that updating the flag.

The problem is regardless of whether I enable or disable the flag in my .mk file, all files get compiled .
The compilation is success but when I checked the /out/soong/soong.variables file generated after my build, I see that the new product variable is present
 in the variable.go but that is null , hence not updated.

Can you tell me how to  ensure that my specific soong variable is updated based on the flags I set in the mk files.
And also accordingly the set of srcs are compiled 

Best Regards
Priyanka

Colin Cross

unread,
Dec 21, 2017, 3:43:50 PM12/21/17
to android-...@googlegroups.com
soong_config.mk is parsed very early, before any of the Android.mk files and many of the files in build/make/core.  You probably need to set your variable in your product's BoardConfig.mk file.

--
--
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+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Priyanka Bose

unread,
Dec 22, 2017, 12:28:13 PM12/22/17
to Android Building
Hi Colin,

Thanks for the reply !
Ok but then it might not be possible to update this flag so early in the build.
The flag can only be set in my development code and that is enabled in its Android.mk file.

So do you have any other suggestions then as to how can I add srcs and libs  as a part of conditional flag in  my Android.bp 
based on whether that flag is enabled/disabled in it's Android.mk file.

Thanks in advance !

Best Regards
Priyanka 

On Friday, December 22, 2017 at 2:13:50 AM UTC+5:30, Colin Cross wrote:
soong_config.mk is parsed very early, before any of the Android.mk files and many of the files in build/make/core.  You probably need to set your variable in your product's BoardConfig.mk file.
On Thu, Dec 21, 2017 at 12:07 PM, Priyanka Bose <dolab...@gmail.com> wrote:
Hi,

I need to add a conditional flag based on which I need to include my srcs and libs when they are enabled.
As  some suggestions in the other posts, I have added a  struct variable under productvariable in the variables.go.
Then included the same in the soong_config.mk file.
Made the changes in my .bp file to include that productvariable struct.
In my .go file , I have checked for the condition variable ( which I am enabling in one of the .mk files) and based on that updating the flag.

The problem is regardless of whether I enable or disable the flag in my .mk file, all files get compiled .
The compilation is success but when I checked the /out/soong/soong.variables file generated after my build, I see that the new product variable is present
 in the variable.go but that is null , hence not updated.

Can you tell me how to  ensure that my specific soong variable is updated based on the flags I set in the mk files.
And also accordingly the set of srcs are compiled 

Best Regards
Priyanka

--
--
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.

Colin Cross

unread,
Dec 22, 2017, 1:11:56 PM12/22/17
to android-...@googlegroups.com
No, that is not possible.  Even without soong it's not possible to do reliably - Android.mk files for a directory are sometimes parsed without the rest of the tree, so one module may or may not see flags that were set in another module.

To post to this group, send email to android-building@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-building+unsubscribe@googlegroups.com.

Priyanka Bose

unread,
Dec 22, 2017, 6:13:41 PM12/22/17
to Android Building
Actually my requirement is something like below:
I have for eg : a directory named as Dummy with an Android.bp. Android.mk and Dummy.go  file. All the files are included during the build. 

I need to update this .bp to include some set of srcs and libs only if the Environment
Variable is set and this ENV_TEST is set in the same module via the Android.mk file (existing in the same dir Dummy )

1.   So  for  including  the srcs , I added the Env_struct { Srcs []string } to varaibleProperties in build/soong/variable.go

2.   Env_struct  *string `json:",omitempty to productVariables in build/soong/variable.go 

3.  Passed ENV_VARIABLE to Env_struct in build/make/core/soong_config.mk

      => echo '    "Env_struct": "$(ENV_TEST)",'

4. Now within the Dummy Dir, I have set the ENV_TEST  as true/false in its Android.mk file.

The problem comes here :

5) In the Dummy.go file , when I check if the flag of ENV_TEST is enabled or not , it always reads null.  

I have checked with fmt.Println(" Env value:",$(ENV_TEST));, so it looks like the flag is never updated


6) Secondly  the srcs which I had included  in the Android.bp as  below is always compiled regardless whether the ENV_TEST is true or false :

    product_variables: {
       env_struct : {
                   srcs: []
        }
   }

Any suggestions or any other ways on how to ensure to compile the  required srcs based on the ENV_TEST flag.

Best Regards
Priyanka
Reply all
Reply to author
Forward
0 new messages