Bug 1677715 - Add a way of setting TK_CFLAGS in a gn generated moz.build file r=firefox-build-system-reviewers,mhentges,ng

This adds write_mozbuild_variables to the GnProjectData that can be used to
configure code generation of moz.build files. This is done to support adding
CONFIG["TK_CFLAGS"] to INCLUDES for gtk builds, which is necessary to support
pipewire.

There is likely a more elegant way of handling this, but since we plan to
remove code generation of moz.build files in the near future anyway, I'm not
sure it is worth investing more time than a minimal amount of time in this.

Differential Revision: https://phabricator.services.mozilla.com/D97427
This commit is contained in:
Dan Minor 2020-11-19 14:14:25 +00:00
parent b92c9ca167
commit c072d6f4d4
3 changed files with 19 additions and 1 deletions

View File

@ -2405,6 +2405,7 @@ VARIABLES = {
"non_unified_sources": StrictOrderingOnAppendList,
"mozilla_flags": list,
"gn_target": six.text_type,
"write_mozbuild_vars": dict,
}
),
list,
@ -2419,6 +2420,8 @@ VARIABLES = {
- mozilla_flags, a set of flags that if present in the gn config
will be mirrored to the resulting mozbuild configuration.
- gn_target, the name of the target to build.
- write_mozbuild_vars, a dictionary containing variables to control
code generation of moz.build files.
""",
),
"SPHINX_TREES": (

View File

@ -1437,3 +1437,4 @@ class GnProjectData(ContextDerived):
self.gn_sandbox_variables = gn_dir_attrs.sandbox_vars
self.mozilla_flags = gn_dir_attrs.mozilla_flags
self.gn_target = gn_dir_attrs.gn_target
self.write_mozbuild_variables = gn_dir_attrs.write_mozbuild_vars

View File

@ -434,7 +434,13 @@ def find_common_attrs(config_attributes):
def write_mozbuild(
config, srcdir, output, non_unified_sources, gn_config_files, mozilla_flags
config,
srcdir,
output,
non_unified_sources,
gn_config_files,
mozilla_flags,
write_mozbuild_variables,
):
all_mozbuild_results = []
@ -473,6 +479,13 @@ def write_mozbuild(
mb.write("\n")
mb.write(generated_header)
try:
if relsrcdir in write_mozbuild_variables["INCLUDE_TK_CFLAGS_DIRS"]:
mb.write('if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":\n')
mb.write(' CXXFLAGS += CONFIG["TK_CFLAGS"]\n')
except KeyError:
pass
all_args = [args for args, _ in configs]
# Start with attributes that will be a part of the mozconfig
@ -653,6 +666,7 @@ class GnMozbuildWriterBackend(BuildBackend):
obj.non_unified_sources,
gn_config_files,
obj.mozilla_flags,
obj.write_mozbuild_variables,
)
else:
print(