From d80a683c1486d1b6e7a8595b82ccab16bc9f6016 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Thu, 18 Aug 2016 17:20:33 -0700 Subject: [PATCH] add support to mozbuild for specifying GYP includes --- positron/moz.build | 14 ++++++++++++++ python/mozbuild/mozbuild/frontend/context.py | 2 ++ python/mozbuild/mozbuild/frontend/gyp_reader.py | 4 +++- python/mozbuild/mozbuild/frontend/reader.py | 6 +++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/positron/moz.build b/positron/moz.build index 6f8effb4c071..b15582af2055 100644 --- a/positron/moz.build +++ b/positron/moz.build @@ -92,3 +92,17 @@ EXTRA_JS_MODULES.renderer['web-view'] += [ 'electron/lib/renderer/web-view/web-view-constants.js', 'electron/lib/renderer/web-view/web-view.js', ] + +include('/build/gyp.mozbuild') +GYP_DIRS += ['spidernode'] +GYP_DIRS['spidernode'].input = 'spidernode/node.gyp' +GYP_DIRS['spidernode'].variables = gyp_vars + +# The current incarnation of mozbuild's GYP support resolves include paths +# relative to $topsrcdir/media/webrtc/trunk/build, which is why we need +# to prepend ../../../../ to get to $topsrcdir in them. +# TODO: make mozbuild resolve include paths relative to the moz.build file. +GYP_DIRS['spidernode'].includes += [ + '../../../../positron/spidernode/common.gypi', + '../../../../positron/spidernode/config.gypi', +] diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index ff1b8f980bc7..75366b773d32 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -1618,6 +1618,7 @@ def aggregate(files): 'GYP_DIRS': (StrictOrderingOnAppendListWithFlagsFactory({ 'variables': dict, + 'includes': StrictOrderingOnAppendList, 'input': unicode, 'sandbox_vars': dict, 'non_unified_sources': StrictOrderingOnAppendList, @@ -1632,6 +1633,7 @@ def aggregate(files): object directory. - variables, a dictionary containing variables and values to pass to the gyp processor. + - includes, a list of GYP include files (usually .gypi) to include. - sandbox_vars, a dictionary containing variables and values to pass to the mozbuild processor on top of those derived from gyp configuration. diff --git a/python/mozbuild/mozbuild/frontend/gyp_reader.py b/python/mozbuild/mozbuild/frontend/gyp_reader.py index 816fe526725a..43732da8fd04 100644 --- a/python/mozbuild/mozbuild/frontend/gyp_reader.py +++ b/python/mozbuild/mozbuild/frontend/gyp_reader.py @@ -74,7 +74,8 @@ def encode(value): return value -def read_from_gyp(config, path, output, vars, non_unified_sources = set()): +def read_from_gyp(config, path, output, vars, non_unified_sources = set(), + incs = set()): """Read a gyp configuration and emits GypContexts for the backend to process. @@ -100,6 +101,7 @@ def read_from_gyp(config, path, output, vars, non_unified_sources = set()): finder = FileFinder(chrome_src, find_executables=False) includes.extend(encode(mozpath.join(chrome_src, name)) for name, _ in finder.find('*/supplement.gypi')) + includes.extend(encode(mozpath.join(script_dir, inc)) for inc in incs) # Read the given gyp file and its dependencies. generator, flat_list, targets, data = \ diff --git a/python/mozbuild/mozbuild/frontend/reader.py b/python/mozbuild/mozbuild/frontend/reader.py index 8192b1ec6e64..7414af42b524 100644 --- a/python/mozbuild/mozbuild/frontend/reader.py +++ b/python/mozbuild/mozbuild/frontend/reader.py @@ -1158,12 +1158,16 @@ def _read_mozbuild(self, path, config, descend, metadata): context) non_unified_sources.add(source) time_start = time.time() + incs = set() + for s in getattr(gyp_dir, 'includes', ()): + incs.add(s) for gyp_context in read_from_gyp(context.config, mozpath.join(curdir, gyp_dir.input), mozpath.join(context.objdir, target_dir), gyp_dir.variables, - non_unified_sources = non_unified_sources): + non_unified_sources = non_unified_sources, + incs = incs): gyp_context.update(gyp_dir.sandbox_vars) gyp_contexts.append(gyp_context) self._file_count += len(gyp_context.all_paths)