“configs” is undefined?

Skip to first unread message

Avi Drissman

Jun 4, 2023, 4:11:51 PMJun 4
to gn-dev
I’m still trying to ARC.

In remoting/host/installer/mac/BUILD.gn I add:

    configs += [ "//build/config/compiler:enable_arc" ]

and get the error:

ERROR at //remoting/host/installer/mac/BUILD.gn:134:3: Undefined identifier.
  configs += [ "//build/config/compiler:enable_arc" ]

But if I change to:

  configs = [ "//build/config/compiler:enable_arc" ]

then I get:

../../remoting/host/installer/mac/uninstaller/remoting_uninstaller.mm:5:10: fatal error: 'remoting/host/installer/mac/uninstaller/remoting_uninstaller.h' file not found
#include "remoting/host/installer/mac/uninstaller/remoting_uninstaller.h"

where it can’t find files that are there, so there’s an issue with include paths. So splatting “configs” is bad, but then why doesn’t += work?

Does anyone have suggestions? Thanks.


Sylvain Defresne

Jun 4, 2023, 4:18:36 PMJun 4
to Avi Drissman, gn-dev
This is probably due to a template not using `set_defaults()` but setting `configs`.

To make it short, it is possible to set default values for any template or target type via `set_defaults("template_name")`. This is used to set the default value for `configs` for `source_set` (and many other templates) in chromium. This is why you have to use `configs += [ ... ]` when adding config to a target.

Here, it is probable that the template does not use set_defaults() but instead unconditionally set `configs = [ ... ]` in its expansion while still forwarding the value from the invoker. This causes the template itself to try to overwrite the value that is passed in the template expansion.

My recommendation is to find which template is behaving like this, and to move the configs value from the template expansion to a set_defaults("template_name") just after the template definition. You can see how this is done in chromium by searching for set_defaults, one such example is here for ios_app_bundle template. You can get some information from gn by using `gn help set_defaults`.

Hope this helps,
-- Sylvain

Sylvain Defresne

Jun 4, 2023, 4:22:14 PMJun 4
to Avi Drissman, gn-dev
Followup, this is likely due to the `mac_app_bundle` template.

The template probably predates the change in gn allowing the use of `set_defaults` in any BUILD.gn file, and thus exposes `add_configs` and `remove_configs` parameters instead of using `set_defaults`. So you may want to replace `configs = [ ... ]` by `add_configs = [ ... ]` in your CL (and maybe file a bug to ask to convert `map_app_bundle` to instead use `set_defaults` to make it more idiomatic to use).

-- Sylvain

Avi Drissman

Jun 5, 2023, 6:24:07 PMJun 5
to gn-dev, Sylvain Defresne, gn-dev, Avi Drissman
Reply all
Reply to author
0 new messages