Issues encountered with GN in Chromium with my project to enable ARC everywhere

27 views
Skip to first unread message

Avi Drissman

unread,
May 12, 2023, 2:39:08 PM5/12/23
to gn-dev
ARC is a mode that you can compile Objective-C files in; in the Chromium GN setup, it lives in //build/config/compiler:enable_arc, which can be added as a config on a GN target/source_set/whatever.

While new features in Chromium tend to have their own targets, so that I can convert them to ARC by dealing with just that target, the older code tends to be in huge monolithic targets (//base, //chrome/browser, //chrome/browser/ui), and that’s a problem, because I can’t do conversions of these targets all at once.

In trying to do a split of a few files off of //chrome/browser/ui, I’m hitting a problem. The CL is https://crrev.com/c/4517437, but in summary:

//chrome/browser depends on //chrome/browser/ui. In splitting a few files from //chrome/browser/ui into //chrome/browser/ui/cocoa/applescript, the files in /chrome/browser/ui/cocoa/applescript have #includes into //chrome/browser files.

The GN dependency is //chrome/browser → //chrome/browser/ui → //chrome/browser/ui/cocoa/applescript so I can’t add a dependency back, as that would be adding a build cycle. I can’t add an “allow circular dependencies” into //chrome/browser as it doesn’t directly depend on //chrome/browser/ui/cocoa/applescript.

Should I add a new dependency of //chrome/browser → //chrome/browser/ui/cocoa/applescript for the sole purpose of being able to add an “allow circular dependency”?

In general, is there a better way to apply build configurations to just a few files within a target, so that I don’t have to deal with splitting targets and then wrestling with deps?

Thanks,

Avi



Dirk Pranke

unread,
May 12, 2023, 5:27:01 PM5/12/23
to Avi Drissman, gn-dev
If you can't refactor the files in //chrome/browser that you need into a new target that both //chrome/browser and //chrome/browser/ui/cocoa/applescript depend on, then, yeah, I think you have to create a fake dependency from browser on applescript.

There is not a way to add flags to just a few files in a target: targets are the level of granularity you get. In GN you would split the target into two if they need two different sets of flags. This makes it easier to think about which things have one set of flags and which have another. 

If you could do that inside a target, then I think you'd end up recreating source_sets() as a concept.

-- Dirk

--
To unsubscribe from this group and stop receiving emails from it, send an email to gn-dev+un...@chromium.org.
Reply all
Reply to author
Forward
0 new messages