Skip to content

Commit

Permalink
Bug 1027890 - Reject builds with pymake. r=gps
Browse files Browse the repository at this point in the history
--HG--
extra : rebase_source : a662b896b5f431a37a1250ec19451324ebed3d14
  • Loading branch information
glandium committed Jun 24, 2014
1 parent 7ccb4eb commit c45c7ba
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 58 deletions.
2 changes: 2 additions & 0 deletions b2g/installer/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ GARBAGE += $(MOZ_PKG_MANIFEST)
endif

ifdef FXOS_SIMULATOR
export MAKE

.PHONY: simulator
simulator: make-package
@echo 'Building simulator addon...'
Expand Down
13 changes: 6 additions & 7 deletions build/pymake/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
import subprocess
mozmake = os.path.join(os.path.dirname(__file__), '..', '..',
'mozmake.exe')
if os.path.exists(mozmake):
cmd = [mozmake]
cmd.extend(sys.argv[1:])
shell = os.environ.get('SHELL')
if shell and not shell.lower().endswith('.exe'):
cmd += ['SHELL=%s.exe' % shell]
sys.exit(subprocess.call(cmd))
cmd = [mozmake]
cmd.extend(sys.argv[1:])
shell = os.environ.get('SHELL')
if shell and not shell.lower().endswith('.exe'):
cmd += ['SHELL=%s.exe' % shell]
sys.exit(subprocess.call(cmd))

sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)
Expand Down
13 changes: 6 additions & 7 deletions config/baseconfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ _OBJ_SUFFIX := $(OBJ_SUFFIX)
OBJ_SUFFIX = $(error config/config.mk needs to be included before using OBJ_SUFFIX)

ifeq ($(HOST_OS_ARCH),WINNT)
# We only support building with pymake or a non-msys gnu make version
# We only support building with a non-msys gnu make version
# strictly above 4.0.
ifndef .PYMAKE
ifdef .PYMAKE
$(error Pymake is no longer supported. Please upgrade to MozillaBuild 1.9 or newer and build with 'mach' or 'mozmake')
endif

ifeq (a,$(firstword a$(subst /, ,$(abspath .))))
$(error MSYS make is not supported)
endif
Expand All @@ -37,19 +40,15 @@ endif
ifneq (4.0-,$(firstword $(sort 4.0- $(MAKE_VERSION))))
$(error Make version too old. Only versions strictly greater than 4.0 are supported.)
endif
endif

ifdef INCLUDED_AUTOCONF_MK
ifeq (a,$(firstword a$(subst /, ,$(srcdir))))
$(error MSYS-style srcdir are not supported for Windows builds.)
endif
endif
endif # WINNT

ifdef .PYMAKE
include_deps = $(eval $(if $(2),,-)includedeps $(1))
else
include_deps = $(eval $(if $(2),,-)include $(1))
endif

ifndef INCLUDED_AUTOCONF_MK
default::
Expand Down
66 changes: 33 additions & 33 deletions python/mozbuild/mozbuild/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def _run_make(self, directory=None, filename=None, target=None, log=True,
srcdir=False, allow_parallel=True, line_handler=None,
append_env=None, explicit_env=None, ignore_errors=False,
ensure_exit_code=0, silent=True, print_directory=True,
pass_thru=False, num_jobs=0, force_pymake=False):
pass_thru=False, num_jobs=0):
"""Invoke make.
directory -- Relative directory to look for Makefile in.
Expand All @@ -408,11 +408,10 @@ def _run_make(self, directory=None, filename=None, target=None, log=True,
silent -- If True (the default), run make in silent mode.
print_directory -- If True (the default), have make print directories
while doing traversal.
force_pymake -- If True, pymake will be used instead of GNU make.
"""
self._ensure_objdir_exists()

args = self._make_path(force_pymake=force_pymake)
args = self._make_path()

if directory:
args.extend(['-C', directory.replace(os.sep, '/')])
Expand Down Expand Up @@ -475,44 +474,45 @@ def _run_make(self, directory=None, filename=None, target=None, log=True,

return fn(**params)

def _make_path(self, force_pymake=False):
if self._is_windows() and not force_pymake:
# Use gnumake if it's available and we can verify it's a working
# version.
baseconfig = os.path.join(self.topsrcdir, 'config', 'baseconfig.mk')
if os.path.exists(baseconfig):
def _make_path(self):
baseconfig = os.path.join(self.topsrcdir, 'config', 'baseconfig.mk')

def validate_make(make):
if os.path.exists(baseconfig) and os.path.exists(make):
cmd = [make, '-f', baseconfig]
if self._is_windows():
cmd.append('HOST_OS_ARCH=WINNT')
try:
make = which.which('gnumake')
subprocess.check_call([make, '-f', baseconfig, 'HOST_OS_ARCH=WINNT'],
stdout=open(os.devnull, 'wb'), stderr=subprocess.STDOUT)
return [make]
subprocess.check_call(cmd, stdout=open(os.devnull, 'wb'),
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError:
pass
except which.WhichError:
pass

# Use mozmake if it's available.
try:
return [which.which('mozmake')]
except which.WhichError:
pass
return False
return True
return False

if self._is_windows() or force_pymake:
make_py = os.path.join(self.topsrcdir, 'build', 'pymake',
'make.py').replace(os.sep, '/')
possible_makes = ['gmake', 'make', 'mozmake', 'gnumake']

# We might want to consider invoking with the virtualenv's Python
# some day. But, there is a chicken-and-egg problem w.r.t. when the
# virtualenv is created.
return [sys.executable, make_py]
if 'MAKE' in os.environ:
make = os.environ['MAKE']
if os.path.isabs(make):
if validate_make(make):
return [make]
else:
possible_makes.insert(0, make)

for test in ['gmake', 'make']:
for test in possible_makes:
try:
return [which.which(test)]
make = which.which(test)
except which.WhichError:
continue

raise Exception('Could not find a suitable make implementation.')
if validate_make(make):
return [make]

if self._is_windows():
raise Exception('Could not find a suitable make implementation.\n'
'Please use MozillaBuild 1.9 or newer')
else:
raise Exception('Could not find a suitable make implementation.')

def _run_command_in_srcdir(self, **args):
return self.run_process(cwd=self.topsrcdir, **args)
Expand Down
18 changes: 7 additions & 11 deletions python/mozbuild/mozbuild/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,13 @@ class Build(MachCommandBase):
@CommandArgument('--jobs', '-j', default='0', metavar='jobs', type=int,
help='Number of concurrent jobs to run. Default is the number of CPUs.')
@CommandArgument('what', default=None, nargs='*', help=BUILD_WHAT_HELP)
@CommandArgument('-p', '--pymake', action='store_true',
help='Force using pymake over GNU make.')
@CommandArgument('-X', '--disable-extra-make-dependencies',
default=False, action='store_true',
help='Do not add extra make dependencies.')
@CommandArgument('-v', '--verbose', action='store_true',
help='Verbose output for what commands the build is running.')
def build(self, what=None, pymake=False,
disable_extra_make_dependencies=None, jobs=0, verbose=False):
def build(self, what=None, disable_extra_make_dependencies=None, jobs=0,
verbose=False):
import which
from mozbuild.controller.building import BuildMonitor
from mozbuild.util import resolve_target_to_make
Expand Down Expand Up @@ -343,8 +341,8 @@ def build(self, what=None, pymake=False,
# comprehensive history lesson.
self._run_make(directory=self.topobjdir,
target='backend.RecursiveMakeBackend',
force_pymake=pymake, line_handler=output.on_line,
log=False, print_directory=False)
line_handler=output.on_line, log=False,
print_directory=False)

# Build target pairs.
for make_dir, make_target in target_pairs:
Expand All @@ -355,8 +353,7 @@ def build(self, what=None, pymake=False,
status = self._run_make(directory=make_dir, target=make_target,
line_handler=output.on_line, log=False, print_directory=False,
ensure_exit_code=False, num_jobs=jobs, silent=not verbose,
append_env={b'NO_BUILDSTATUS_MESSAGES': b'1'},
force_pymake=pymake)
append_env={b'NO_BUILDSTATUS_MESSAGES': b'1'})

if status != 0:
break
Expand All @@ -365,7 +362,7 @@ def build(self, what=None, pymake=False,
status = self._run_make(srcdir=True, filename='client.mk',
line_handler=output.on_line, log=False, print_directory=False,
allow_parallel=False, ensure_exit_code=False, num_jobs=jobs,
silent=not verbose, force_pymake=pymake)
silent=not verbose)

make_extra = self.mozconfig['make_extra'] or []
make_extra = dict(m.split('=', 1) for m in make_extra)
Expand All @@ -374,8 +371,7 @@ def build(self, what=None, pymake=False,
if moz_automation and status == 0:
status = self._run_make(target='automation/build',
line_handler=output.on_line, log=False, print_directory=False,
ensure_exit_code=False, num_jobs=jobs, silent=not verbose,
force_pymake=pymake)
ensure_exit_code=False, num_jobs=jobs, silent=not verbose)

self.log(logging.WARNING, 'warning_summary',
{'count': len(monitor.warnings_database)},
Expand Down

0 comments on commit c45c7ba

Please sign in to comment.