Bug 656049 - teach comm-central client.mk to invoke client.py. r=Standard8
- Adds a new make co|checkout target to run client.py
- Adds support for:
mk_add_options CLIENT_PY_ARGS="--verbose --skip-venkman"
in .mozconfig to control what arguments to pass to client.py
- Adds support for:
mk_add_options ALWAYS_RUN_CLIENT_PY=1
in .mozconfig to control if client.py should pretty much always be invoked during
make invocations, or limit itself to being invoked explicitely via make checkout
new file mode 100755
--- /dev/null
+++ b/build/print_mk_add_options.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+ac_add_options() {
+ return
+}
+
+mk_add_options() {
+ echo "mk_add_options:" "$@"
+}
+
+MOZCONFIG=${MOZCONFIG:-./.mozconfig}
+topsrcdir=${topsrcdir:-$PWD}
+
+source $MOZCONFIG
new file mode 100644
--- /dev/null
+++ b/build/run_client.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+
+import sys
+import os.path
+import re
+from subprocess import Popen, PIPE
+import shlex
+
+topsrcdir = sys.argv[1]
+
+run = False
+
+if len(sys.argv) >= 3:
+ run = True
+
+client_py_args = []
+
+options_re = re.compile('^mk_add_options:\s+CLIENT_PY_ARGS\s*=\s*(.*)$')
+always_run_re = re.compile('^mk_add_options:\s+ALWAYS_RUN_CLIENT_PY\s*=\s*(.*)$')
+
+process = Popen(['build/print_mk_add_options.sh'], stdout=PIPE, stderr=sys.stderr)
+output, unused_err = process.communicate()
+
+for line in output.splitlines():
+ found_opt = options_re.match(line)
+ if found_opt:
+ client_py_args = found_opt.group(1)
+
+ found_always = always_run_re.match(line)
+ if found_always:
+ val = found_always.group(1)
+ if val != "0":
+ run = True
+
+if run:
+ if not client_py_args:
+ print >> sys.stderr, "Can't run client.py without some CLIENT_PY_ARGS in mozconfig"
+ sys.exit(1)
+ cmd = [sys.executable, 'client.py' ] + shlex.split(client_py_args)
+ print >> sys.stderr, "Running: %s" % cmd
+ # Run the command and redirect output to stderr so make will display it
+ p = Popen(cmd,
+ stdout=sys.stderr,
+ stderr=sys.stderr,
+ )
+ p.wait()
+ print >> sys.stderr, "%s returned %s" % (cmd, p.returncode)
+ sys.exit(p.returncode)
--- a/client.mk
+++ b/client.mk
@@ -131,16 +131,27 @@ endif
# Load mozconfig Options
# See build pages, http://www.mozilla.org/build/ for how to set up mozconfig.
MOZCONFIG_LOADER := mozilla/build/autoconf/mozconfig2client-mk
MOZCONFIG_FINDER := mozilla/build/autoconf/mozconfig-find
MOZCONFIG_MODULES := mozilla/build/unix/uniq.pl
+# We need to give client.py an early chance to run, since we don't necessarely
+# have a mozilla/ checkout yet
+run_for_side_effects := \
+ @if test ! -f .client.run; then \
+ $(shell $(PYTHON) $(TOPSRCDIR)/build/run_client.py $(TOPSRCDIR) > .client.out ); \
+ touch .client.run \
+ else \
+ rm -f .client.run; \
+ true; \
+ fi
+
run_for_side_effects := \
$(shell $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) $(TOPSRCDIR)/.mozconfig.mk > $(TOPSRCDIR)/.mozconfig.out)
include $(TOPSRCDIR)/.mozconfig.mk
ifndef MOZ_OBJDIR
MOZ_OBJDIR = obj-$(CONFIG_GUESS)
endif
@@ -399,17 +410,21 @@ cleansrcdir:
else \
echo "Removing object files from srcdir..."; \
rm -fr `find . -type d \( -name .deps -print -o -name CVS \
-o -exec test ! -d {}/CVS \; \) -prune \
-o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
build/autoconf/clean-config.sh; \
fi;
+checkout co:
+ @$(PYTHON) $(TOPSRCDIR)/build/run_client.py $(TOPSRCDIR) force
+
+
echo-variable-%:
@echo $($*)
# This makefile doesn't support parallel execution. It does pass
# MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute
# in parallel.
.NOTPARALLEL:
-.PHONY: checkout real_checkout depend build profiledbuild maybe_clobber_profiledbuild export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure preflight_all preflight postflight postflight_all
+.PHONY: checkout co real_checkout depend build profiledbuild maybe_clobber_profiledbuild export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure preflight_all preflight postflight postflight_all