fix and use mozmake

This commit is contained in:
2018-03-03 12:51:19 +08:00
parent 711009281e
commit 0145f46491
6 changed files with 107 additions and 48 deletions
+43
View File
@@ -11,7 +11,50 @@ import pymake.command, pymake.process
import gc
def find_executable(executable, path=None):
"""Find if 'executable' can be run. Looks for it in 'path'
(string that lists directories separated by 'os.pathsep';
defaults to os.environ['PATH']). Checks for all executable
extensions. Returns full path or None if no command is found.
"""
if path is None:
path = os.environ['PATH']
paths = path.split(os.pathsep)
extlist = ['']
if os.name == 'os2':
(base, ext) = os.path.splitext(executable)
# executable files on OS/2 can have an arbitrary extension, but
# .exe is automatically appended if no dot is present in the name
if not ext:
executable = executable + ".exe"
elif sys.platform == 'win32':
pathext = os.environ['PATHEXT'].lower().split(os.pathsep)
(base, ext) = os.path.splitext(executable)
if ext.lower() not in pathext:
extlist = pathext
for ext in extlist:
execname = executable + ext
if os.path.isfile(execname):
return execname
else:
for p in paths:
f = os.path.join(p, execname)
if os.path.isfile(f):
return f
else:
return None
if __name__ == '__main__':
# When building, execute mozmake instead. Until bug 978211, this is the easiest, albeit hackish, way to do this.
import subprocess
mozmake = find_executable('mozmake.exe')
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)
-7
View File
@@ -85,13 +85,6 @@ endif
# Windows checks.
ifneq (,$(findstring mingw,$(CONFIG_GUESS)))
# Require pymake (as opposed to GNU make).
ifndef .PYMAKE
$(error Pymake is required to build on Windows. Run |./mach build| to \
automatically use pymake. Or, invoke pymake directly via \
|python build/pymake/make.py|.)
endif
# check for CRLF line endings
ifneq (0,$(shell $(PERL) -e 'binmode(STDIN); while (<STDIN>) { if (/\r/) { print "1"; exit } } print "0"' < $(TOPSRCDIR)/client.mk))
$(error This source tree appears to have Windows-style line endings. To \
+19 -8
View File
@@ -11,15 +11,26 @@ DIST = $(DEPTH)/dist
_OBJ_SUFFIX := $(OBJ_SUFFIX)
OBJ_SUFFIX = $(error config/config.mk needs to be included before using OBJ_SUFFIX)
# We only want to do the pymake sanity on Windows, other os's can cope
ifeq ($(HOST_OS_ARCH),WINNT)
# Ensure invariants between GNU Make and pymake
# Checked here since we want the sane error in a file that
# actually can be found regardless of path-style.
ifeq (_:,$(.PYMAKE)_$(findstring :,$(srcdir)))
$(error Windows-style srcdir being used with GNU make. Did you mean to run $(topsrcdir)/build/pymake/make.py instead? [see-also: https://developer.mozilla.org/en/Gmake_vs._Pymake])
# We only support building with a non-msys gnu make version
# strictly above 4.0.
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
# 4.0- happens to be greater than 4.0, lower than the mozmake version,
# and lower than 4.0.1 or 4.1, whatever next version of gnu make will
# be released.
ifneq (4.0-,$(firstword $(sort 4.0- $(MAKE_VERSION))))
$(error Make version too old. Only versions strictly greater than 4.0 are supported.)
endif
ifdef INCLUDED_AUTOCONF_MK
ifeq (a,$(firstword a$(subst /, ,$(srcdir))))
$(error MSYS-style srcdir are not supported for Windows builds.)
endif
ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(srcdir))))
$(error MSYS-style srcdir being used with Pymake. Did you mean to run GNU Make instead? [see-also: https://developer.mozilla.org/ en/Gmake_vs._Pymake])
endif
endif # WINNT
+7 -8
View File
@@ -14,15 +14,14 @@ endif
_OBJ_SUFFIX := $(OBJ_SUFFIX)
OBJ_SUFFIX = $(error config/config.mk needs to be included before using OBJ_SUFFIX)
# We only want to do the pymake sanity on Windows, other os's can cope
ifeq ($(HOST_OS_ARCH),WINNT)
# Ensure invariants between GNU Make and pymake
# Checked here since we want the sane error in a file that
# actually can be found regardless of path-style.
ifeq (_:,$(.PYMAKE)_$(findstring :,$(srcdir)))
$(error Windows-style srcdir being used with GNU make. Did you mean to run $(topsrcdir)/build/pymake/make.py instead? [see-also: https://developer.mozilla.org/en/Gmake_vs._Pymake])
# We only support building with pymake or a specially built gnu make.
ifndef .PYMAKE
ifeq (,$(filter mozmake%,$(notdir $(MAKE))))
$(error Only building with pymake or mozmake is supported.)
endif
ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(srcdir))))
$(error MSYS-style srcdir being used with Pymake. Did you mean to run GNU Make instead? [see-also: https://developer.mozilla.org/ en/Gmake_vs._Pymake])
endif
ifeq (a,$(firstword a$(subst /, ,$(srcdir))))
$(error MSYS-style srcdir are not supported for Windows builds.)
endif
endif # WINNT
+4
View File
@@ -4259,6 +4259,7 @@ if test -n "$ENABLE_INTL_API" ; then
ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_REGULAR_EXPRESSIONS"
ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_BREAK_ITERATION"
ICU_SRCDIR=""
# Set OS dependent options for ICU
case "$OS_TARGET" in
Darwin)
@@ -4269,6 +4270,7 @@ if test -n "$ENABLE_INTL_API" ; then
;;
WINNT)
ICU_TARGET=MSYS/MSVC
ICU_SRCDIR="--srcdir=$(cd $srcdir/../../intl/icu/source; pwd -W)"
;;
esac
@@ -4294,6 +4296,8 @@ if test -n "$ENABLE_INTL_API" ; then
$ICU_BUILD_OPTS \
$ICU_TARGET \
$ICU_LINK_OPTS \
dnl Shell quoting is fun.
${ICU_SRCDIR+"$ICU_SRCDIR"} \
--enable-extras=no --enable-icuio=no --enable-layout=no \
--enable-tests=no --enable-samples=no || exit 1
) || exit 1
+34 -25
View File
@@ -128,7 +128,7 @@ endif
export MOZ_DEBUG_SYMBOLS
DEFAULT_GMAKE_FLAGS =
DEFAULT_GMAKE_FLAGS += CC="$(CC)"
DEFAULT_GMAKE_FLAGS += CC='$(CC)'
DEFAULT_GMAKE_FLAGS += SOURCE_MD_DIR=$(ABS_DIST)
DEFAULT_GMAKE_FLAGS += SOURCE_MDHEADERS_DIR=$(NSPR_INCLUDE_DIR)
DEFAULT_GMAKE_FLAGS += DIST=$(ABS_DIST)
@@ -137,12 +137,8 @@ DEFAULT_GMAKE_FLAGS += NSPR_LIB_DIR=$(NSPR_LIB_DIR)
DEFAULT_GMAKE_FLAGS += MOZILLA_CLIENT=1
DEFAULT_GMAKE_FLAGS += NO_MDUPDATE=1
DEFAULT_GMAKE_FLAGS += NSS_ENABLE_ECC=1
DEFAULT_GMAKE_FLAGS += NSINSTALL="$(NSINSTALL)"
ifeq ($(OS_ARCH),WINNT)
DEFAULT_GMAKE_FLAGS += INSTALL="$(NSINSTALL) -t"
endif
ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_1)
DEFAULT_GMAKE_FLAGS += OS_DLLFLAGS="-static-libgcc"
DEFAULT_GMAKE_FLAGS += OS_DLLFLAGS='-static-libgcc'
endif
ifndef MOZ_NATIVE_SQLITE
ifdef MOZ_FOLD_LIBS
@@ -157,12 +153,15 @@ DEFAULT_GMAKE_FLAGS += NSS_DISABLE_DBM=1
endif
ABS_topsrcdir := $(shell cd $(topsrcdir); pwd)
ifeq ($(HOST_OS_ARCH),WINNT)
ifdef .PYMAKE
#ifdef .PYMAKE
ABS_topsrcdir := $(shell cd $(topsrcdir); pwd -W)
endif
#endif
endif
# Hack to force NSS build system to use "normal" object directories
DEFAULT_GMAKE_FLAGS += BUILD='$(MOZ_BUILD_ROOT)/security/$$(subst $(ABS_topsrcdir)/security/,,$$(CURDIR))'
DEFAULT_GMAKE_FLAGS += ABS_topsrcdir='$(ABS_topsrcdir)'
# ABS_topsrcdir can't be expanded here because msys path mangling likes to break
# paths in that case.
DEFAULT_GMAKE_FLAGS += BUILD='$(MOZ_BUILD_ROOT)/security/$$(subst $$(ABS_topsrcdir)/security/,,$$(CURDIR))'
DEFAULT_GMAKE_FLAGS += BUILD_TREE='$$(BUILD)' OBJDIR='$$(BUILD)' DEPENDENCIES='$$(BUILD)/.deps' SINGLE_SHLIB_DIR='$$(BUILD)'
DEFAULT_GMAKE_FLAGS += SOURCE_XP_DIR=$(ABS_DIST)
ifndef MOZ_DEBUG
@@ -214,23 +213,23 @@ DEFAULT_GMAKE_FLAGS += CHECKLOC=
ifdef CROSS_COMPILE
DEFAULT_GMAKE_FLAGS += \
NATIVE_CC="$(HOST_CC)" \
CC="$(CC)" \
CCC="$(CXX)" \
LINK="$(LD)" \
AS="$(AS)" \
NATIVE_CC='$(HOST_CC)' \
CC='$(CC)' \
CCC='$(CXX)' \
LINK='$(LD)' \
AS='$(AS)' \
AR='$(AR) $(AR_FLAGS:$@=$$@)' \
RANLIB="$(RANLIB)" \
RC="$(RC) $(RCFLAGS)" \
OS_ARCH="$(OS_ARCH)" \
OS_TEST="$(OS_TEST)" \
CPU_ARCH="$(TARGET_CPU)" \
RANLIB='$(RANLIB)' \
RC='$(RC) $(RCFLAGS)' \
OS_ARCH='$(OS_ARCH)' \
OS_TEST='$(OS_TEST)' \
CPU_ARCH='$(TARGET_CPU)' \
$(NULL)
# Android has pthreads integrated into -lc, so OS_PTHREAD is set to nothing
ifeq ($(OS_TARGET), Android)
DEFAULT_GMAKE_FLAGS += \
OS_RELEASE="2.6" \
OS_RELEASE='2.6' \
OS_PTHREAD= \
STANDARDS_CFLAGS="-std=gnu89" \
$(NULL)
@@ -241,8 +240,8 @@ endif
ifdef WRAP_LDFLAGS
DEFAULT_GMAKE_FLAGS += \
LDFLAGS="$(LDFLAGS) $(WRAP_LDFLAGS)" \
DSO_LDOPTS="$(DSO_LDOPTS) $(LDFLAGS) $(WRAP_LDFLAGS)" \
LDFLAGS='$(LDFLAGS) $(WRAP_LDFLAGS)' \
DSO_LDOPTS='$(DSO_LDOPTS) $(LDFLAGS) $(WRAP_LDFLAGS)' \
$(NULL)
endif
@@ -255,8 +254,8 @@ ifdef MOZ_NO_WLZDEFS
DEFAULT_GMAKE_FLAGS += ZDEFS_FLAG=
endif
ifdef MOZ_CFLAGS_NSS
DEFAULT_GMAKE_FLAGS += XCFLAGS="$(CFLAGS)"
DEFAULT_GMAKE_FLAGS += DARWIN_DYLIB_VERSIONS="-compatibility_version 1 -current_version 1 $(LDFLAGS)"
DEFAULT_GMAKE_FLAGS += XCFLAGS='$(CFLAGS)'
DEFAULT_GMAKE_FLAGS += DARWIN_DYLIB_VERSIONS='-compatibility_version 1 -current_version 1 $(LDFLAGS)'
endif
DEFAULT_GMAKE_FLAGS += NSS_NO_PKCS11_BYPASS=1
@@ -327,7 +326,7 @@ ifdef MOZ_FOLD_LIBS
# TODO: The following can be replaced by something simpler when bug 844880
# is fixed.
# All static libraries required for nss, smime, ssl and nssutil.
NSS_STATIC_LIBS := $(shell $(MAKE) --no-print-directory -f $(srcdir)/nss.mk DEPTH="$(DEPTH)" topsrcdir="$(topsrcdir)" srcdir="$(srcdir)" echo-variable-libs)
NSS_STATIC_LIBS := $(shell $(MAKE) --no-print-directory -f $(srcdir)/nss.mk DEPTH='$(DEPTH)' topsrcdir='$(topsrcdir)' srcdir='$(srcdir)' echo-variable-libs)
# Corresponding build directories
NSS_STATIC_DIRS := $(foreach lib,$(NSS_STATIC_LIBS),$(patsubst %/,%,$(dir $(lib))))
NSS_DIRS += $(NSS_STATIC_DIRS)
@@ -452,6 +451,16 @@ libs-nss/lib/freebl: $(DIST)/lib/$(IMPORT_PREFIX)nssutil3$(IMPORT_SUFFIX) $(NSPR
$(addprefix libs-,$(NSS_STATIC_DIRS)): DEFAULT_GMAKE_FLAGS += SHARED_LIBRARY= IMPORT_LIBRARY=
endif # MOZ_FOLD_LIBS
ifeq ($(NSINSTALL_PY),$(NSINSTALL))
DEFAULT_GMAKE_FLAGS += PYTHON='$(PYTHON)'
DEFAULT_GMAKE_FLAGS += NSINSTALL_PY='$(call core_abspath,$(topsrcdir)/config/nsinstall.py)'
DEFAULT_GMAKE_FLAGS += NSINSTALL='$$(PYTHON) $$(NSINSTALL_PY)'
else
DEFAULT_GMAKE_FLAGS += NSINSTALL='$(NSINSTALL)'
endif
ifeq ($(OS_ARCH),WINNT)
DEFAULT_GMAKE_FLAGS += INSTALL='$$(NSINSTALL) -t'
endif
DEFAULT_GMAKE_FLAGS += $(EXTRA_GMAKE_FLAGS)
$(addprefix libs-,$(NSS_DIRS)): libs-%: