Skip to content

Commit 920c132

Browse files
bnoordhuisBridgeAR
authored andcommitted
tools: teach gyp to write an 'all deps' rule
Make GYP write a .deps file in the top-level directory that we can use in the Makefile to get a proper dependency chain for the `node` target. Preparatory work for getting rid of recursive make invocations. PR-URL: #17407 Reviewed-By: Richard Lau <[email protected]>
1 parent de4600e commit 920c132

File tree

1 file changed

+14
-0
lines changed
  • tools/gyp/pylib/gyp/generator

1 file changed

+14
-0
lines changed

tools/gyp/pylib/gyp/generator/make.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,6 +2136,7 @@ def CalculateMakefilePath(build_file, base_name):
21362136
for target in gyp.common.AllTargets(target_list, target_dicts, build_file):
21372137
needed_targets.add(target)
21382138

2139+
all_deps = set()
21392140
build_files = set()
21402141
include_list = set()
21412142
for qualified_target in target_list:
@@ -2184,6 +2185,12 @@ def CalculateMakefilePath(build_file, base_name):
21842185
os.path.dirname(makefile_path))
21852186
include_list.add(mkfile_rel_path)
21862187

2188+
if 'actions' in spec:
2189+
for action in spec['actions']:
2190+
all_deps.update(map(writer.Absolutify, action['inputs']))
2191+
if 'sources' in spec:
2192+
all_deps.update(map(writer.Absolutify, spec['sources']))
2193+
21872194
# Write out per-gyp (sub-project) Makefiles.
21882195
depth_rel_path = gyp.common.RelativePath(options.depth, os.getcwd())
21892196
for build_file in build_files:
@@ -2227,3 +2234,10 @@ def CalculateMakefilePath(build_file, base_name):
22272234
root_makefile.write(SHARED_FOOTER)
22282235

22292236
root_makefile.close()
2237+
2238+
# Hack to get rid of $(obj)/path/to/foo.o deps that node.gyp adds manually.
2239+
all_deps = [s for s in all_deps if not '$' in s]
2240+
all_deps_path = os.path.join(options.toplevel_dir, '.deps')
2241+
with open(all_deps_path, 'w') as f:
2242+
f.write('ALL_DEPS := \\\n\t')
2243+
f.write(' \\\n\t'.join(sorted(all_deps)))

0 commit comments

Comments
 (0)