From eb8660f21f59af34a1a4b3de71b02013513e5e2a Mon Sep 17 00:00:00 2001 From: Chris Manchester Date: Fri, 2 Dec 2016 10:05:57 -0800 Subject: [PATCH] Bug 1317778 - Emit a depfile with python configure dependencies so Make will know when to re-run configure. r=glandium MozReview-Commit-ID: AuTHadY7KqO --- client.mk | 4 ++++ configure.py | 17 ++++++++++++++++- moz.configure | 8 +++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/client.mk b/client.mk index 42133d2eb383..f2c606f2e6f2 100644 --- a/client.mk +++ b/client.mk @@ -329,6 +329,10 @@ CONFIG_STATUS_DEPS := \ $(OBJDIR)/.mozconfig.json \ $(NULL) +# Include a dep file emitted by configure to track Python files that +# may influence the result of configure. +-include $(OBJDIR)/configure.d + CONFIGURE_ENV_ARGS += \ MAKE='$(MAKE)' \ $(NULL) diff --git a/configure.py b/configure.py index f7392d0ffa5c..75470fb542b6 100644 --- a/configure.py +++ b/configure.py @@ -5,6 +5,7 @@ from __future__ import print_function, unicode_literals import codecs +import itertools import os import subprocess import sys @@ -14,6 +15,8 @@ import textwrap base_dir = os.path.abspath(os.path.dirname(__file__)) sys.path.insert(0, os.path.join(base_dir, 'python', 'mozbuild')) from mozbuild.configure import ConfigureSandbox +from mozbuild.makeutil import Makefile +from mozbuild.pythonutil import iter_modules_in_path from mozbuild.util import ( indented_repr, encode, @@ -46,7 +49,8 @@ def config_status(config): sanitized_config = {} sanitized_config['substs'] = { k: sanitized_bools(v) for k, v in config.iteritems() - if k not in ('DEFINES', 'non_global_defines', 'TOPSRCDIR', 'TOPOBJDIR') + if k not in ('DEFINES', 'non_global_defines', 'TOPSRCDIR', 'TOPOBJDIR', + 'ALL_CONFIGURE_PATHS') } sanitized_config['defines'] = { k: sanitized_bools(v) for k, v in config['DEFINES'].iteritems() @@ -84,6 +88,17 @@ def config_status(config): config_status(**args) ''')) + # Write out a depfile so Make knows to re-run configure when relevant Python + # changes. + mk = Makefile() + rule = mk.create_rule() + rule.add_targets(["$(OBJDIR)/config.status"]) + rule.add_dependencies(itertools.chain(config['ALL_CONFIGURE_PATHS'], + iter_modules_in_path(config['TOPOBJDIR'], + config['TOPSRCDIR']))) + with open('configure.d', 'w') as fh: + mk.dump(fh) + # Other things than us are going to run this file, so we need to give it # executable permissions. os.chmod('config.status', 0o755) diff --git a/moz.configure b/moz.configure index ec90697f5d76..17fa353199f4 100644 --- a/moz.configure +++ b/moz.configure @@ -338,4 +338,10 @@ def nsis_binary_type(nsis): # Fallthrough to autoconf-based configure include('build/moz.configure/old.configure') -# Please do not add anything after the include of old.configure. + +@imports('__sandbox__') +def all_paths(): + return __sandbox__._all_paths + +set_config('ALL_CONFIGURE_PATHS', all_paths()) +# Please do not add anything after setting ALL_CONFIGURE_PATHS.