merge mozilla-inbound to mozilla-central a=merge

This commit is contained in:
Carsten "Tomcat" Book 2016-01-26 11:53:21 +01:00
commit e5db360177
116 changed files with 3732 additions and 1904 deletions

View File

@ -22,5 +22,6 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.
Bug 1241975 - port B2G branding Makefiles to moz.build;
Bug 1241974 - remove testing/mochitest/manifests/Makefile.in;
Merge day clobber

View File

@ -0,0 +1,24 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@template
def B2GBranding():
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
BRANDING_FILES += [
'app.ico',
]
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
BRANDING_FILES += [
'app.icns',
'background.png',
'disk.icns',
'dsstore',
]
if CONFIG['MOZ_WIDGET_GTK']:
BRANDING_FILES += [
'default.png',
]

View File

@ -1,30 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
include $(topsrcdir)/config/config.mk
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
BRANDING_FILES := \
app.ico \
$(NULL)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
BRANDING_FILES := \
app.icns \
background.png \
disk.icns \
dsstore \
$(NULL)
endif
ifdef MOZ_WIDGET_GTK
BRANDING_FILES := \
default.png \
$(NULL)
endif
BRANDING_DEST := $(DIST)/branding
BRANDING_TARGET := export
INSTALL_TARGETS += BRANDING

View File

@ -5,3 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += ['content', 'locales']
include('../branding-common.mozbuild')
B2GBranding()

View File

@ -1,30 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
include $(topsrcdir)/config/config.mk
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
BRANDING_FILES := \
app.ico \
$(NULL)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
BRANDING_FILES := \
app.icns \
background.png \
disk.icns \
dsstore \
$(NULL)
endif
ifdef MOZ_WIDGET_GTK
BRANDING_FILES := \
default.png \
$(NULL)
endif
BRANDING_DEST := $(DIST)/branding
BRANDING_TARGET := export
INSTALL_TARGETS += BRANDING

View File

@ -5,3 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += ['content', 'locales']
include('../branding-common.mozbuild')
B2GBranding()

View File

@ -1,30 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
include $(topsrcdir)/config/config.mk
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
BRANDING_FILES := \
app.ico \
$(NULL)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
BRANDING_FILES := \
app.icns \
background.png \
disk.icns \
dsstore \
$(NULL)
endif
ifdef MOZ_WIDGET_GTK
BRANDING_FILES := \
default.png \
$(NULL)
endif
BRANDING_DEST := $(DIST)/branding
BRANDING_TARGET := export
INSTALL_TARGETS += BRANDING

View File

@ -5,3 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += ['content', 'locales']
include('../branding-common.mozbuild')
B2GBranding()

View File

@ -1,30 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
include $(topsrcdir)/config/config.mk
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
BRANDING_FILES := \
app.ico \
$(NULL)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
BRANDING_FILES := \
app.icns \
background.png \
disk.icns \
dsstore \
$(NULL)
endif
ifdef MOZ_WIDGET_GTK
BRANDING_FILES := \
default.png \
$(NULL)
endif
BRANDING_DEST := $(DIST)/branding
BRANDING_TARGET := export
INSTALL_TARGETS += BRANDING

View File

@ -5,3 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += ['content', 'locales']
include('../branding-common.mozbuild')
B2GBranding()

View File

@ -33,7 +33,7 @@ MOZ_ARG_WITH_STRING(nspr-libs,
ifdef([CONFIGURING_JS],[
MOZ_ARG_ENABLE_BOOL(nspr-build,
[ --enable-nspr-build Configure and build NSPR from source tree],
[ --enable-nspr-build Build NSPR from source tree],
MOZ_BUILD_NSPR=1,
MOZ_BUILD_NSPR=)
])
@ -187,72 +187,3 @@ AC_SUBST(NSPR_PKGCONF_CHECK)
fi # _IS_OUTER_CONFIGURE
])
AC_DEFUN([MOZ_SUBCONFIGURE_NSPR], [
if test -z "$MOZ_NATIVE_NSPR"; then
ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla"
if test -n "$MOZ_USING_CCACHE"; then
# Avoid double prepending ccache by omitting --with-ccache in building NSPR.
ac_configure_args="`echo $ac_configure_args | sed -e 's/--with-ccache[[^ ]]*//'`"
fi
if test -z "$MOZ_DEBUG"; then
ac_configure_args="$ac_configure_args --disable-debug"
else
ac_configure_args="$ac_configure_args --enable-debug"
if test -n "$MOZ_NO_DEBUG_RTL"; then
ac_configure_args="$ac_configure_args --disable-debug-rtl"
fi
fi
if test "$MOZ_OPTIMIZE" = "1"; then
ac_configure_args="$ac_configure_args --enable-optimize"
elif test -z "$MOZ_OPTIMIZE"; then
ac_configure_args="$ac_configure_args --disable-optimize"
fi
if test -n "$HAVE_64BIT_BUILD"; then
ac_configure_args="$ac_configure_args --enable-64bit"
fi
if test -n "$USE_ARM_KUSER"; then
ac_configure_args="$ac_configure_args --with-arm-kuser"
fi
# A configure script generated by autoconf 2.68 does not allow the cached
# values of "precious" variables such as CFLAGS and LDFLAGS to differ from
# the values passed to the configure script. Since we modify CFLAGS and
# LDFLAGS before passing them to NSPR's configure script, we cannot share
# config.cache with NSPR. As a result, we cannot pass AS, CC, CXX, etc. to
# NSPR via a shared config.cache file and must pass them to NSPR on the
# configure command line.
for var in AS CC CXX CPP LD AR RANLIB STRIP; do
ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
done
# A configure script generated by autoconf 2.68 warns if --host is
# specified but --build isn't. So we always pass --build to NSPR's
# configure script.
ac_configure_args="$ac_configure_args --build=$build"
ac_configure_args="$ac_configure_args $NSPR_CONFIGURE_ARGS"
# Save these, so we can mess with them for the subconfigure ..
_SAVE_CFLAGS="$CFLAGS"
_SAVE_CPPFLAGS="$CPPFLAGS"
_SAVE_LDFLAGS="$LDFLAGS"
if test -n "$MOZ_LINKER" -a "$ac_cv_func_dladdr" = no ; then
# dladdr is supported by the new linker, even when the system linker doesn't
# support it. Trick nspr into using dladdr when it's not supported.
export CPPFLAGS="-include $_topsrcdir/mozglue/linker/dladdr.h $CPPFLAGS"
fi
export LDFLAGS="$LDFLAGS $NSPR_LDFLAGS"
export CFLAGS="$CFLAGS $MOZ_FRAMEPTR_FLAGS $MOZ_FOLD_LIBS_FLAGS"
AC_OUTPUT_SUBDIRS(nsprpub)
# .. and restore them
CFLAGS="$_SAVE_CFLAGS"
CPPFLAGS="$_SAVE_CPPFLAGS"
LDFLAGS="$_SAVE_LDFLAGS"
ac_configure_args="$_SUBDIR_CONFIG_ARGS"
fi
])

View File

@ -1,56 +0,0 @@
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
include $(topsrcdir)/config/rules.mk
ifdef MOZ_BUILD_NSPR
# Copy NSPR to the SDK
ifdef MOZ_FOLD_LIBS
# Trick the nspr build system into not building shared libraries.
# bug #851869.
EXTRA_MAKE_FLAGS := SHARED_LIBRARY= IMPORT_LIBRARY= SHARED_LIB_PDB=
# Work around libVersionPoint conflict between all three libraries.
# See bug #838566.
EXTRA_MAKE_FLAGS += XP_DEFINE=-DlibVersionPoint='libVersionPoint$$(LIBRARY_NAME)'
else
# nspr's make export compiles and links everything, but linking can't happen
# during export on platforms where nspr is linked against mozcrt/mozglue.
export:: EXTRA_MAKE_FLAGS += SHARED_LIBRARY= IMPORT_LIBRARY= SHARED_LIB_PDB=
endif
MOZ_BUILDID := $(shell cat $(DEPTH)/config/buildid)
# The NSPR build system uses build-time generated dates for public API
# exposed data structures. Use the buildid as forced date, to avoid
# having to deal with what changing NSPR itself might mean.
# SH_DATE is a date with the format "%Y-%m-%d %T"
EXTRA_MAKE_FLAGS += SH_DATE="$(shell $(PYTHON) -c 'd = "$(MOZ_BUILDID)"; print d[0:4]+"-"+d[4:6]+"-"+d[6:8]+" "+d[8:10]+":"+d[10:12]+":"+d[12:14]')"
# SH_NOW is a date as a unix timestamp in µseconds
EXTRA_MAKE_FLAGS += SH_NOW="$(shell $(PYTHON) -c 'import time, calendar; print calendar.timegm(time.strptime("$(MOZ_BUILDID)", "%Y%m%d%H%M%S"))')000000"
clean distclean export::
$(MAKE) -C $(DEPTH)/nsprpub $@ $(EXTRA_MAKE_FLAGS)
target::
# nspr's libs and install rule re-export headers, and that can race with other
# compilations, so use a separate directory here. The headers are exported
# during export anyways.
$(MAKE) -C $(DEPTH)/nsprpub libs $(EXTRA_MAKE_FLAGS) dist_includedir=$(ABS_DIST)/nspr-include
$(MAKE) -C $(DEPTH)/nsprpub install prefix=$(ABS_DIST)/sdk exec_prefix=$(ABS_DIST)/sdk bindir=$(ABS_DIST)/sdk/dummy includedir=$(ABS_DIST)/nspr-include libdir=$(ABS_DIST)/sdk/lib datadir=$(ABS_DIST)/sdk/dummy DESTDIR= $(EXTRA_MAKE_FLAGS)
$(INSTALL) $(DEPTH)/nsprpub/config/nspr-config $(DIST)/sdk/bin
$(RM) -rf $(DIST)/sdk/dummy
ifneq (,$(filter WINNT,$(OS_ARCH))) # {
$(RM) -f $(DIST)/sdk/lib/$(DLL_PREFIX)nspr4$(DLL_SUFFIX) $(DIST)/sdk/lib/$(DLL_PREFIX)plc4$(DLL_SUFFIX) $(DIST)/sdk/lib/$(DLL_PREFIX)plds4$(DLL_SUFFIX)
$(RM) -f $(DIST)/sdk/lib/$(LIB_PREFIX)nspr4_s.$(LIB_SUFFIX) $(DIST)/sdk/lib/$(LIB_PREFIX)plc4_s.$(LIB_SUFFIX) $(DIST)/sdk/lib/$(LIB_PREFIX)plds4_s.$(LIB_SUFFIX)
else # } {
$(RM) -f $(DIST)/sdk/lib/$(LIB_PREFIX)nspr4.$(LIB_SUFFIX) $(DIST)/sdk/lib/$(LIB_PREFIX)plc4.$(LIB_SUFFIX) $(DIST)/sdk/lib/$(LIB_PREFIX)plds4.$(LIB_SUFFIX)
endif # }
endif

6
config/external/nspr/_pl_bld.h vendored Normal file
View File

@ -0,0 +1,6 @@
/*
* This file was previously generated at build time to set some preprocessor
* macros for use by plvrsion.c, but that file will set the values to (empty)
* defaults if they're not set, so this is just a stub to avoid having to
* generate another header file at build time.
*/

6
config/external/nspr/_pr_bld.h vendored Normal file
View File

@ -0,0 +1,6 @@
/*
* This file was previously generated at build time to set some preprocessor
* macros for use by prvrsion.c, but that file will set the values to (empty)
* defaults if they're not set, so this is just a stub to avoid having to
* generate another header file at build time.
*/

34
config/external/nspr/ds/moz.build vendored Normal file
View File

@ -0,0 +1,34 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
if CONFIG['MOZ_FOLD_LIBS']:
Library('plds4')
else:
SharedLibrary('plds4')
SOURCES += ['/nsprpub/lib/ds/plvrsion.c']
USE_LIBS += ['nspr4']
# We allow warnings for third-party code that can be updated from upstream.
# TODO: fix NSPR warnings and remove this
ALLOW_COMPILER_WARNINGS = True
DEFINES['_NSPR_BUILD_'] = True
LOCAL_INCLUDES += [
'/config/external/nspr',
'/nsprpub/pr/include',
]
EXPORTS.nspr += [
'/nsprpub/lib/ds/plarena.h',
'/nsprpub/lib/ds/plarenas.h',
'/nsprpub/lib/ds/plhash.h',
]
SOURCES += [
'/nsprpub/lib/ds/plarena.c',
'/nsprpub/lib/ds/plhash.c',
]

45
config/external/nspr/libc/moz.build vendored Normal file
View File

@ -0,0 +1,45 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
if CONFIG['MOZ_FOLD_LIBS']:
Library('plc4')
else:
SharedLibrary('plc4')
SOURCES += ['/nsprpub/lib/libc/src/plvrsion.c']
USE_LIBS += ['nspr4']
# We allow warnings for third-party code that can be updated from upstream.
# TODO: fix NSPR warnings and remove this
ALLOW_COMPILER_WARNINGS = True
DEFINES['_NSPR_BUILD_'] = True
LOCAL_INCLUDES += [
'/config/external/nspr',
]
EXPORTS.nspr += [
'/nsprpub/lib/libc/include/plbase64.h',
'/nsprpub/lib/libc/include/plerror.h',
'/nsprpub/lib/libc/include/plgetopt.h',
'/nsprpub/lib/libc/include/plstr.h',
]
SOURCES += [
'/nsprpub/lib/libc/src/base64.c',
'/nsprpub/lib/libc/src/plerror.c',
'/nsprpub/lib/libc/src/plgetopt.c',
'/nsprpub/lib/libc/src/strcase.c',
'/nsprpub/lib/libc/src/strcat.c',
'/nsprpub/lib/libc/src/strchr.c',
'/nsprpub/lib/libc/src/strcmp.c',
'/nsprpub/lib/libc/src/strcpy.c',
'/nsprpub/lib/libc/src/strdup.c',
'/nsprpub/lib/libc/src/strlen.c',
'/nsprpub/lib/libc/src/strpbrk.c',
'/nsprpub/lib/libc/src/strstr.c',
'/nsprpub/lib/libc/src/strtok.c',
]

View File

@ -6,16 +6,23 @@
Library('nspr')
if CONFIG['MOZ_FOLD_LIBS']:
# When folding libraries, nspr is actually in the nss library.
USE_LIBS += [
'nss',
]
elif CONFIG['MOZ_BUILD_NSPR']:
USE_LIBS += [
'/nsprpub/lib/ds/plds4',
'/nsprpub/lib/libc/src/plc4',
'/nsprpub/pr/src/nspr4',
if CONFIG['MOZ_BUILD_NSPR']:
DIRS += [
'pr',
'ds',
'libc',
]
if CONFIG['MOZ_FOLD_LIBS']:
# When folding libraries, nspr is actually in the nss library.
USE_LIBS += [
'nss',
]
else:
USE_LIBS += [
'nspr4',
'plc4',
'plds4',
]
EXPORTS.nspr += ['prcpucfg.h']
else:
OS_LIBS += CONFIG['NSPR_LIBS']

221
config/external/nspr/pr/moz.build vendored Normal file
View File

@ -0,0 +1,221 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
if CONFIG['MOZ_FOLD_LIBS']:
Library('nspr4')
else:
SharedLibrary('nspr4')
# We allow warnings for third-party code that can be updated from upstream.
# TODO: fix NSPR warnings and remove this
ALLOW_COMPILER_WARNINGS = True
DEFINES['_NSPR_BUILD_'] = True
if CONFIG['OS_ARCH'] == 'Linux':
OS_LIBS += CONFIG['REALTIME_LIBS']
DEFINES.update(
LINUX=True,
HAVE_FCNTL_FILE_LOCKING=True,
_GNU_SOURCE=True,
)
SOURCES += ['/nsprpub/pr/src/md/unix/linux.c']
if CONFIG['CPU_ARCH'] == 'x86_64':
SOURCES += ['/nsprpub/pr/src/md/unix/os_Linux_x86_64.s']
elif CONFIG['CPU_ARCH'] == 'x86':
DEFINES['i386'] = True
SOURCES += ['/nsprpub/pr/src/md/unix/os_Linux_x86.s']
elif CONFIG['CPU_ARCH'] == 'ppc':
SOURCES += ['/nsprpub/pr/src/md/unix/os_Linux_ppc.s']
elif CONFIG['OS_TARGET'] == 'Darwin':
DEFINES.update(
DARWIN=True,
HAVE_BSD_FLOCK=True,
HAVE_SOCKLEN_T=True,
)
SOURCES += [
'/nsprpub/pr/src/md/unix/darwin.c',
'/nsprpub/pr/src/md/unix/os_Darwin.s',
]
if not CONFIG['MOZ_IOS']:
DEFINES['HAVE_CRT_EXTERNS_H'] = True
elif CONFIG['OS_TARGET'] == 'WINNT':
OS_LIBS += [
'advapi32',
'ws2_32',
'mswsock',
'winmm',
]
DEFINES.update(
XP_PC=True,
WIN32=True,
# For historical reasons we use the WIN95 NSPR target instead of
# WINNT.
WIN95=True,
WINNT=False,
_PR_GLOBAL_THREADS_ONLY=True,
)
if CONFIG['CPU_ARCH'] == 'x86_64':
DEFINES['_AMD64_'] = True
else:
DEFINES['_X86_'] = True
else:
error('Not a supported OS_TARGET for NSPR in moz.build: "%s". Use --with-system-nspr' % CONFIG['OS_TARGET'])
LOCAL_INCLUDES += [
'/config/external/nspr',
'/nsprpub/pr/include',
'/nsprpub/pr/include/private',
]
SOURCES += [
'/nsprpub/pr/src/io/prfdcach.c',
'/nsprpub/pr/src/io/priometh.c',
'/nsprpub/pr/src/io/pripv6.c',
'/nsprpub/pr/src/io/prlayer.c',
'/nsprpub/pr/src/io/prlog.c',
'/nsprpub/pr/src/io/prmapopt.c',
'/nsprpub/pr/src/io/prmmap.c',
'/nsprpub/pr/src/io/prmwait.c',
'/nsprpub/pr/src/io/prpolevt.c',
'/nsprpub/pr/src/io/prprf.c',
'/nsprpub/pr/src/io/prscanf.c',
'/nsprpub/pr/src/io/prstdio.c',
'/nsprpub/pr/src/linking/prlink.c',
'/nsprpub/pr/src/malloc/prmalloc.c',
'/nsprpub/pr/src/malloc/prmem.c',
'/nsprpub/pr/src/md/prosdep.c',
'/nsprpub/pr/src/memory/prseg.c',
'/nsprpub/pr/src/memory/prshm.c',
'/nsprpub/pr/src/memory/prshma.c',
'/nsprpub/pr/src/misc/pralarm.c',
'/nsprpub/pr/src/misc/pratom.c',
'/nsprpub/pr/src/misc/praton.c',
'/nsprpub/pr/src/misc/prcountr.c',
'/nsprpub/pr/src/misc/prdtoa.c',
'/nsprpub/pr/src/misc/prenv.c',
'/nsprpub/pr/src/misc/prerr.c',
'/nsprpub/pr/src/misc/prerror.c',
'/nsprpub/pr/src/misc/prerrortable.c',
'/nsprpub/pr/src/misc/prinit.c',
'/nsprpub/pr/src/misc/prinrval.c',
'/nsprpub/pr/src/misc/pripc.c',
'/nsprpub/pr/src/misc/prlog2.c',
'/nsprpub/pr/src/misc/prlong.c',
'/nsprpub/pr/src/misc/prnetdb.c',
'/nsprpub/pr/src/misc/prolock.c',
'/nsprpub/pr/src/misc/prrng.c',
'/nsprpub/pr/src/misc/prsystem.c',
'/nsprpub/pr/src/misc/prthinfo.c',
'/nsprpub/pr/src/misc/prtime.c',
'/nsprpub/pr/src/misc/prtpool.c',
'/nsprpub/pr/src/misc/prtrace.c',
'/nsprpub/pr/src/threads/prcmon.c',
'/nsprpub/pr/src/threads/prrwlock.c',
'/nsprpub/pr/src/threads/prtpd.c',
]
if CONFIG['OS_TARGET'] != 'WINNT':
DEFINES['_PR_PTHREADS'] = True
SOURCES += [
'/nsprpub/pr/src/md/unix/unix.c',
'/nsprpub/pr/src/md/unix/unix_errors.c',
'/nsprpub/pr/src/md/unix/uxproces.c',
'/nsprpub/pr/src/md/unix/uxrng.c',
'/nsprpub/pr/src/md/unix/uxshm.c',
'/nsprpub/pr/src/md/unix/uxwrap.c',
'/nsprpub/pr/src/pthreads/ptio.c',
'/nsprpub/pr/src/pthreads/ptmisc.c',
'/nsprpub/pr/src/pthreads/ptsynch.c',
'/nsprpub/pr/src/pthreads/ptthread.c',
]
else:
SOURCES += [
'/nsprpub/pr/src/io/prdir.c',
'/nsprpub/pr/src/io/prfile.c',
'/nsprpub/pr/src/io/prio.c',
'/nsprpub/pr/src/io/prsocket.c',
'/nsprpub/pr/src/md/windows/ntgc.c',
'/nsprpub/pr/src/md/windows/ntinrval.c',
'/nsprpub/pr/src/md/windows/ntmisc.c',
'/nsprpub/pr/src/md/windows/ntsec.c',
'/nsprpub/pr/src/md/windows/ntsem.c',
'/nsprpub/pr/src/md/windows/w32ipcsem.c',
'/nsprpub/pr/src/md/windows/w32poll.c',
'/nsprpub/pr/src/md/windows/w32rng.c',
'/nsprpub/pr/src/md/windows/w32shm.c',
'/nsprpub/pr/src/md/windows/w95cv.c',
'/nsprpub/pr/src/md/windows/w95dllmain.c',
'/nsprpub/pr/src/md/windows/w95io.c',
'/nsprpub/pr/src/md/windows/w95sock.c',
'/nsprpub/pr/src/md/windows/w95thred.c',
'/nsprpub/pr/src/md/windows/win32_errors.c',
'/nsprpub/pr/src/misc/pripcsem.c',
'/nsprpub/pr/src/threads/combined/prucpu.c',
'/nsprpub/pr/src/threads/combined/prucv.c',
'/nsprpub/pr/src/threads/combined/prulock.c',
'/nsprpub/pr/src/threads/combined/prustack.c',
'/nsprpub/pr/src/threads/combined/pruthr.c',
'/nsprpub/pr/src/threads/prcthr.c',
'/nsprpub/pr/src/threads/prdump.c',
'/nsprpub/pr/src/threads/prmon.c',
'/nsprpub/pr/src/threads/prsem.c',
]
EXPORTS.nspr += [
'/nsprpub/pr/include/nspr.h',
'/nsprpub/pr/include/pratom.h',
'/nsprpub/pr/include/prbit.h',
'/nsprpub/pr/include/prclist.h',
'/nsprpub/pr/include/prcmon.h',
'/nsprpub/pr/include/prcountr.h',
'/nsprpub/pr/include/prcvar.h',
'/nsprpub/pr/include/prdtoa.h',
'/nsprpub/pr/include/prenv.h',
'/nsprpub/pr/include/prerr.h',
'/nsprpub/pr/include/prerror.h',
'/nsprpub/pr/include/prinet.h',
'/nsprpub/pr/include/prinit.h',
'/nsprpub/pr/include/prinrval.h',
'/nsprpub/pr/include/prio.h',
'/nsprpub/pr/include/pripcsem.h',
'/nsprpub/pr/include/prlink.h',
'/nsprpub/pr/include/prlock.h',
'/nsprpub/pr/include/prlog.h',
'/nsprpub/pr/include/prlong.h',
'/nsprpub/pr/include/prmem.h',
'/nsprpub/pr/include/prmon.h',
'/nsprpub/pr/include/prmwait.h',
'/nsprpub/pr/include/prnetdb.h',
'/nsprpub/pr/include/prolock.h',
'/nsprpub/pr/include/prpdce.h',
'/nsprpub/pr/include/prprf.h',
'/nsprpub/pr/include/prproces.h',
'/nsprpub/pr/include/prrng.h',
'/nsprpub/pr/include/prrwlock.h',
'/nsprpub/pr/include/prshm.h',
'/nsprpub/pr/include/prshma.h',
'/nsprpub/pr/include/prsystem.h',
'/nsprpub/pr/include/prthread.h',
'/nsprpub/pr/include/prtime.h',
'/nsprpub/pr/include/prtpool.h',
'/nsprpub/pr/include/prtrace.h',
'/nsprpub/pr/include/prtypes.h',
'/nsprpub/pr/include/prvrsion.h',
'/nsprpub/pr/include/prwin16.h',
]
EXPORTS.nspr.md += [
'/nsprpub/pr/include/md/_darwin.cfg',
'/nsprpub/pr/include/md/_linux.cfg',
'/nsprpub/pr/include/md/_win95.cfg',
]
EXPORTS.nspr.private += [
'/nsprpub/pr/include/private/pprio.h',
'/nsprpub/pr/include/private/pprthred.h',
'/nsprpub/pr/include/private/prpriv.h',
]

23
config/external/nspr/prcpucfg.h vendored Normal file
View File

@ -0,0 +1,23 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef NSPR_PRCPUCFG_H_
#define NSPR_PRCPUCFG_H_
/*
* Need to support conditionals that are defined in both the top-level build
* system as well as NSS' build system for now.
*/
#if defined(XP_DARWIN) || defined(DARWIN)
#include "md/_darwin.cfg"
#elif defined(XP_WIN) || defined(_WINDOWS)
#include "md/_win95.cfg"
#elif defined(__linux__)
#include "md/_linux.cfg"
#else
#error "Unsupported platform!"
#endif
#endif /* NSPR_PRCPUCFG_H_ */

View File

@ -257,6 +257,10 @@ DEFAULT_GMAKE_FLAGS += MAKE_OBJDIR='$$(INSTALL) -D $$(OBJDIR)'
# it, creating race conditions. See bug #836220
DEFAULT_GMAKE_FLAGS += TARGETS='$$(LIBRARY) $$(SHARED_LIBRARY) $$(PROGRAM)'
ifeq ($(MOZ_FOLD_LIBS),1)
MOZ_FOLD_LIBS_FLAGS += -D_NSPR_BUILD_=1
endif
ifdef MOZ_FOLD_LIBS_FLAGS
DEFAULT_GMAKE_FLAGS += XCFLAGS='$(MOZ_FOLD_LIBS_FLAGS)'
endif

View File

@ -16,17 +16,10 @@ elif CONFIG['MOZ_FOLD_LIBS']:
SDK_LIBRARY = True
# Normally, there should be /something/ to ensure nspr is built
# before this directory, but since nspr is built during "export",
# it actually doesn't matter.
if CONFIG['OS_TARGET'] == 'WINNT':
suffix = '_s'
else:
suffix = ''
USE_LIBS += [
'static:/nsprpub/lib/ds/plds4%s' % suffix,
'static:/nsprpub/lib/libc/src/plc4%s' % suffix,
'static:/nsprpub/pr/src/nspr4%s' % suffix,
'nspr4',
'plc4',
'plds4',
]
OS_LIBS += CONFIG['REALTIME_LIBS']

View File

@ -944,7 +944,6 @@ OBJ_SUFFIX=o
LIB_SUFFIX=a
ASM_SUFFIX=s
IMPORT_LIB_SUFFIX=
TARGET_MD_ARCH=unix
DIRENT_INO=d_ino
MOZ_USER_DIR=".mozilla"
@ -1843,7 +1842,6 @@ case "$host" in
HOST_CFLAGS="$HOST_CFLAGS -mwindows"
fi
HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
HOST_NSPR_MDCPUCFG='"md/_winnt.cfg"'
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
HOST_BIN_SUFFIX=.exe
case "$host" in
@ -1869,13 +1867,11 @@ case "$host" in
*-darwin*)
HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
HOST_NSPR_MDCPUCFG='"md/_darwin.cfg"'
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
;;
*-linux*|*-kfreebsd*-gnu|*-gnu*)
HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
HOST_NSPR_MDCPUCFG='"md/_linux.cfg"'
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
;;
@ -2012,7 +2008,6 @@ case "$target" in
# builds.
MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
fi
TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
if test "x$lto_is_enabled" = "xyes"; then
echo "Skipping -dead_strip because lto is enabled."
@ -2105,7 +2100,6 @@ ia64*-hpux*)
MOZ_LINKER=1
fi
fi
TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
MOZ_GFX_OPTIMIZE_MOBILE=1
MOZ_OPTIMIZE_FLAGS="-Os -fno-reorder-functions"
@ -2129,8 +2123,6 @@ ia64*-hpux*)
fi
fi
TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
MOZ_MEMORY=1
case "${target_cpu}" in
@ -2226,10 +2218,8 @@ ia64*-hpux*)
_DEFINES_CXXFLAGS='-FI $(topobjdir)/mozilla-config.h -DMOZILLA_CLIENT'
CFLAGS="$CFLAGS -W3 -Gy"
CXXFLAGS="$CXXFLAGS -W3 -Gy"
if test "$CPU_ARCH" = "x86" -a -z "$CLANG_CL"; then
if test "$CPU_ARCH" = "x86"; then
dnl VS2012+ defaults to -arch:SSE2.
dnl Clang-cl gets confused by -arch:IA32, so don't add it.
dnl (See https://llvm.org/bugs/show_bug.cgi?id=24335)
CFLAGS="$CFLAGS -arch:IA32"
CXXFLAGS="$CXXFLAGS -arch:IA32"
fi
@ -2326,13 +2316,9 @@ ia64*-hpux*)
MOZ_OPTIMIZE_FLAGS='-O1 -Oi'
MOZ_FIX_LINK_PATHS=
MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
# Disable these flags on clang-cl since it doesn't ignore unknown arguments by default, and
# autoconf insists on passing $LDFLAGS to the compiler.
if test -z "$CLANG_CL"; then
LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
if test -z "$DEVELOPER_OPTIONS"; then
LDFLAGS="$LDFLAGS -RELEASE"
fi
LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
if test -z "$DEVELOPER_OPTIONS"; then
LDFLAGS="$LDFLAGS -RELEASE"
fi
dnl For profile-guided optimization
PROFILE_GEN_CFLAGS="-GL"
@ -2373,14 +2359,10 @@ ia64*-hpux*)
AC_DEFINE(WIN32_LEAN_AND_MEAN)
dnl See http://support.microsoft.com/kb/143208 to use STL
AC_DEFINE(NOMINMAX)
TARGET_MD_ARCH=win32
_PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
BIN_SUFFIX='.exe'
MOZ_USER_DIR="Mozilla"
dnl Hardcode to win95 for now - cls
TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
dnl set NO_X11 defines here as the general check is skipped on win32
no_x=yes
AC_DEFINE(NO_X11)
@ -2411,11 +2393,7 @@ ia64*-hpux*)
LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup -Wl,--large-address-aware"
else
DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
# Disable this flag on clang-cl since it doesn't ignore unknown arguments by default, and
# autoconf insists on passing $LDFLAGS to the compiler.
if test -z "$CLANG_CL"; then
LDFLAGS="$LDFLAGS -SAFESEH"
fi
LDFLAGS="$LDFLAGS -SAFESEH"
fi
AC_DEFINE(_X86_)
@ -2477,7 +2455,6 @@ ia64*-hpux*)
*-solaris*)
AC_DEFINE(SOLARIS)
TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
MOZ_FIX_LINK_PATHS=
# $ORIGIN/.. is for shared libraries under components/ to locate shared
# libraries one level up (e.g. libnspr4.so)
@ -3006,7 +2983,7 @@ dnl Checks for library functions.
dnl ========================================================
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo)
AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo gettid lchown setpriority strerror syscall)
dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
@ -8860,15 +8837,12 @@ AC_SUBST(HOST_AR)
AC_SUBST(HOST_AR_FLAGS)
AC_SUBST(HOST_LD)
AC_SUBST(HOST_RANLIB)
AC_SUBST(HOST_NSPR_MDCPUCFG)
AC_SUBST(HOST_BIN_SUFFIX)
AC_SUBST(HOST_OS_ARCH)
AC_SUBST(TARGET_CPU)
AC_SUBST(TARGET_VENDOR)
AC_SUBST(TARGET_OS)
AC_SUBST(TARGET_NSPR_MDCPUCFG)
AC_SUBST(TARGET_MD_ARCH)
AC_SUBST(TARGET_XPCOM_ABI)
AC_SUBST(OS_TARGET)
AC_SUBST(OS_ARCH)
@ -9172,8 +9146,6 @@ if test "$COMPILE_ENVIRONMENT"; then
export WRAP_LDFLAGS
MOZ_SUBCONFIGURE_NSPR()
dnl ========================================================
dnl = Setup a nice relatively clean build environment for
dnl = sub-configures.

View File

@ -2732,8 +2732,8 @@ nsDOMWindowUtils::IsPartOfOpaqueLayer(nsIDOMElement* aElement, bool* aResult)
return NS_ERROR_FAILURE;
}
Layer* layer = FrameLayerBuilder::GetDebugSingleOldLayerForFrame(frame);
if (!layer || !layer->AsPaintedLayer()) {
PaintedLayer* layer = FrameLayerBuilder::GetDebugSingleOldPaintedLayerForFrame(frame);
if (!layer) {
return NS_ERROR_FAILURE;
}
@ -2761,12 +2761,12 @@ nsDOMWindowUtils::NumberOfAssignedPaintedLayers(nsIDOMElement** aElements,
return NS_ERROR_FAILURE;
}
Layer* layer = FrameLayerBuilder::GetDebugSingleOldLayerForFrame(frame);
if (!layer || !layer->AsPaintedLayer()) {
PaintedLayer* layer = FrameLayerBuilder::GetDebugSingleOldPaintedLayerForFrame(frame);
if (!layer) {
return NS_ERROR_FAILURE;
}
layers.PutEntry(layer->AsPaintedLayer());
layers.PutEntry(layer);
}
*aResult = layers.Count();

View File

@ -1527,6 +1527,7 @@ nsObjectLoadingContent::ShouldRewriteYoutubeEmbed(nsIURI* aURI)
nsAutoCString uri;
aURI->GetSpec(uri);
if (uri.Find("enablejsapi=1", true, 0, -1) != kNotFound) {
Telemetry::Accumulate(Telemetry::YOUTUBE_NONREWRITABLE_EMBED_SEEN, 1);
return false;
}

View File

@ -151,7 +151,7 @@ TestArray.addTest(
);
// -----------------------------------------------------------------------------
/*TestArray.addTest(
TestArray.addTest(
"Import raw PBKDF2 key and derive bits using HMAC-SHA-256",
function() {
var that = this;
@ -173,11 +173,11 @@ TestArray.addTest(
}
function fail(x) { console.log("failing"); error(that)(x); }
crypto.subtle.importKey("raw", key, alg, false, ["deriveKey"])
crypto.subtle.importKey("raw", key, alg, false, ["deriveBits"])
.then( doDerive, fail )
.then( memcmp_complete(that, tv.pbkdf2_sha256.derived), fail );
}
);*/
);
/*]]>*/</script>
</head>

View File

@ -790,6 +790,7 @@ void HTMLMediaElement::NoSupportedMediaSourceError()
ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE);
DispatchAsyncEvent(NS_LITERAL_STRING("error"));
ChangeDelayLoadStatus(false);
UpdateAudioChannelPlayingState();
}
typedef void (HTMLMediaElement::*SyncSectionFn)();
@ -3516,6 +3517,7 @@ void HTMLMediaElement::Error(uint16_t aErrorCode)
ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_IDLE);
}
ChangeDelayLoadStatus(false);
UpdateAudioChannelPlayingState();
}
void HTMLMediaElement::PlaybackEnded()
@ -4730,6 +4732,11 @@ HTMLMediaElement::IsPlayingThroughTheAudioChannel() const
return false;
}
// If we have an error, we are not playing.
if (mError) {
return false;
}
// If this element doesn't have any audio tracks.
if (!HasAudio()) {
return false;

View File

@ -2383,6 +2383,7 @@ ContentParent::InitializeMembers()
mShutdownPending = false;
mIPCOpen = true;
mHangMonitorActor = nullptr;
mHasGamepadListener = false;
}
bool
@ -2426,7 +2427,6 @@ ContentParent::ContentParent(mozIApplication* aApp,
, mOpener(aOpener)
, mIsForBrowser(aIsForBrowser)
, mIsNuwaProcess(aIsNuwaProcess)
, mHasGamepadListener(false)
{
InitializeMembers(); // Perform common initialization.

View File

@ -131,7 +131,7 @@ PushNotifier::NotifyPushWorkers(const nsACString& aScope,
// Otherwise, we're in the parent and e10s is enabled. Broadcast the event
// to all content processes.
bool ok = false;
bool ok = true;
nsTArray<ContentParent*> contentActors;
ContentParent::GetAll(contentActors);
for (uint32_t i = 0; i < contentActors.Length(); ++i) {
@ -169,7 +169,7 @@ PushNotifier::NotifySubscriptionChangeWorkers(const nsACString& aScope,
}
// Parent process, e10s enabled.
bool ok = false;
bool ok = true;
nsTArray<ContentParent*> contentActors;
ContentParent::GetAll(contentActors);
for (uint32_t i = 0; i < contentActors.Length(); ++i) {

556
js/src/asmjs/Wasm.cpp Normal file
View File

@ -0,0 +1,556 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
*
* Copyright 2015 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "asmjs/Wasm.h"
#include "asmjs/WasmGenerator.h"
#include "asmjs/WasmText.h"
using namespace js;
using namespace js::wasm;
typedef Handle<WasmModuleObject*> HandleWasmModule;
typedef MutableHandle<WasmModuleObject*> MutableHandleWasmModule;
/*****************************************************************************/
// reporting
static bool
Fail(JSContext* cx, const char* str)
{
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_FAIL, str);
return false;
}
static bool
Fail(JSContext* cx, Decoder& d, const char* str)
{
uint32_t offset = d.currentOffset();
char offsetStr[sizeof "4294967295"];
JS_snprintf(offsetStr, sizeof offsetStr, "%" PRIu32, offset);
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_DECODE_FAIL, offsetStr, str);
return false;
}
/*****************************************************************************/
// wasm function body validation
class FunctionDecoder
{
JSContext* cx_;
Decoder& d_;
ModuleGenerator& mg_;
FunctionGenerator& fg_;
uint32_t funcIndex_;
public:
FunctionDecoder(JSContext* cx, Decoder& d, ModuleGenerator& mg, FunctionGenerator& fg,
uint32_t funcIndex)
: cx_(cx), d_(d), mg_(mg), fg_(fg), funcIndex_(funcIndex)
{}
JSContext* cx() const { return cx_; }
Decoder& d() const { return d_; }
ModuleGenerator& mg() const { return mg_; }
FunctionGenerator& fg() const { return fg_; }
uint32_t funcIndex() const { return funcIndex_; }
ExprType ret() const { return mg_.funcSig(funcIndex_).ret(); }
bool fail(const char* str) {
return Fail(cx_, d_, str);
}
};
static bool
CheckType(FunctionDecoder& f, ExprType actual, ExprType expected)
{
if (actual == expected || expected == ExprType::Void)
return true;
return f.fail("type mismatch");
}
static bool
DecodeExpr(FunctionDecoder& f, ExprType expected)
{
Expr expr;
if (!f.d().readExpr(&expr))
return f.fail("unable to read expression");
switch (expr) {
case Expr::Nop:
return CheckType(f, ExprType::Void, expected);
case Expr::I32Const:
if (!f.d().readVarU32())
return f.fail("unable to read i32.const immediate");
return CheckType(f, ExprType::I32, expected);
default:
break;
}
return f.fail("bad expression code");
}
static bool
DecodeFuncBody(JSContext* cx, Decoder& d, ModuleGenerator& mg, FunctionGenerator& fg,
uint32_t funcIndex)
{
const uint8_t* bodyBegin = d.currentPosition();
FunctionDecoder f(cx, d, mg, fg, funcIndex);
if (!DecodeExpr(f, f.ret()))
return false;
const uint8_t* bodyEnd = d.currentPosition();
uintptr_t bodyLength = bodyEnd - bodyBegin;
if (!fg.bytecode().resize(bodyLength))
return false;
PodCopy(fg.bytecode().begin(), bodyBegin, bodyLength);
return true;
}
/*****************************************************************************/
// wasm decoding and generation
static bool
DecodeSignatureSection(JSContext* cx, Decoder& d, ModuleGeneratorData* init)
{
if (!d.readCStringIf(SigSection))
return true;
uint32_t sectionStart;
if (!d.startSection(&sectionStart))
return Fail(cx, d, "expected decl section byte size");
uint32_t numSigs;
if (!d.readVarU32(&numSigs))
return Fail(cx, d, "expected number of declarations");
if (!init->sigs.resize(numSigs))
return false;
for (uint32_t sigIndex = 0; sigIndex < numSigs; sigIndex++) {
uint32_t numArgs;
if (!d.readVarU32(&numArgs))
return Fail(cx, d, "bad number of signature args");
ExprType result;
if (!d.readExprType(&result))
return Fail(cx, d, "bad result type");
ValTypeVector args;
if (!args.resize(numArgs))
return false;
for (uint32_t i = 0; i < numArgs; i++) {
if (!d.readValType(&args[i]))
return Fail(cx, d, "bad arg type");
}
init->sigs[sigIndex] = Sig(Move(args), result);
}
if (!d.finishSection(sectionStart))
return Fail(cx, d, "decls section byte size mismatch");
return true;
}
static bool
DecodeDeclarationSection(JSContext* cx, Decoder& d, ModuleGeneratorData* init)
{
if (!d.readCStringIf(DeclSection))
return true;
uint32_t sectionStart;
if (!d.startSection(&sectionStart))
return Fail(cx, d, "expected decl section byte size");
uint32_t numDecls;
if (!d.readVarU32(&numDecls))
return Fail(cx, d, "expected number of declarations");
if (!init->funcSigs.resize(numDecls))
return false;
for (uint32_t i = 0; i < numDecls; i++) {
uint32_t sigIndex;
if (!d.readVarU32(&sigIndex))
return Fail(cx, d, "expected declaration signature index");
if (sigIndex > init->sigs.length())
return Fail(cx, d, "declaration signature index out of range");
init->funcSigs[i] = &init->sigs[sigIndex];
}
if (!d.finishSection(sectionStart))
return Fail(cx, d, "decls section byte size mismatch");
return true;
}
static bool
DecodeExport(JSContext* cx, Decoder& d, ModuleGenerator& mg, ExportMap* exportMap)
{
if (!d.readCStringIf(FuncSubsection))
return Fail(cx, d, "expected 'func' tag");
uint32_t funcIndex;
if (!d.readVarU32(&funcIndex))
return Fail(cx, d, "expected export internal index");
if (funcIndex >= mg.numFuncSigs())
return Fail(cx, d, "export function index out of range");
uint32_t exportIndex;
if (!mg.declareExport(funcIndex, &exportIndex))
return false;
MOZ_ASSERT(exportIndex <= exportMap->exportNames.length());
if (exportIndex == exportMap->exportNames.length()) {
UniqueChars funcName(JS_smprintf("%u", unsigned(funcIndex)));
if (!funcName || !exportMap->exportNames.emplaceBack(Move(funcName)))
return false;
}
if (!exportMap->fieldsToExports.append(exportIndex))
return false;
const char* chars;
if (!d.readCString(&chars))
return Fail(cx, d, "expected export external name string");
return exportMap->fieldNames.emplaceBack(DuplicateString(chars));
}
typedef HashSet<const char*, CStringHasher> CStringSet;
static bool
DecodeExportsSection(JSContext* cx, Decoder& d, ModuleGenerator& mg, ExportMap* exportMap)
{
if (!d.readCStringIf(ExportSection))
return true;
uint32_t sectionStart;
if (!d.startSection(&sectionStart))
return Fail(cx, d, "expected export section byte size");
uint32_t numExports;
if (!d.readVarU32(&numExports))
return Fail(cx, d, "expected number of exports");
for (uint32_t i = 0; i < numExports; i++) {
if (!DecodeExport(cx, d, mg, exportMap))
return false;
}
if (!d.finishSection(sectionStart))
return Fail(cx, d, "export section byte size mismatch");
CStringSet dupSet(cx);
if (!dupSet.init())
return false;
for (const UniqueChars& prevName : exportMap->fieldNames) {
CStringSet::AddPtr p = dupSet.lookupForAdd(prevName.get());
if (p)
return Fail(cx, d, "duplicate export");
if (!dupSet.add(p, prevName.get()))
return false;
}
return true;
}
static bool
DecodeFunc(JSContext* cx, Decoder& d, ModuleGenerator& mg, uint32_t funcIndex)
{
int64_t before = PRMJ_Now();
FunctionGenerator fg;
if (!mg.startFuncDef(d.currentOffset(), &fg))
return false;
if (!d.readCStringIf(FuncSubsection))
return Fail(cx, d, "expected 'func' tag");
uint32_t sectionStart;
if (!d.startSection(&sectionStart))
return Fail(cx, d, "expected func section byte size");
if (!DecodeFuncBody(cx, d, mg, fg, funcIndex))
return false;
if (!d.finishSection(sectionStart))
return Fail(cx, d, "func section byte size mismatch");
int64_t after = PRMJ_Now();
unsigned generateTime = (after - before) / PRMJ_USEC_PER_MSEC;
return mg.finishFuncDef(funcIndex, generateTime, &fg);
}
static bool
DecodeCodeSection(JSContext* cx, Decoder& d, ModuleGenerator& mg)
{
if (!mg.startFuncDefs())
return false;
uint32_t funcIndex = 0;
while (d.readCStringIf(CodeSection)) {
uint32_t sectionStart;
if (!d.startSection(&sectionStart))
return Fail(cx, d, "expected code section byte size");
uint32_t numFuncs;
if (!d.readVarU32(&numFuncs))
return Fail(cx, d, "expected number of functions");
if (funcIndex + numFuncs > mg.numFuncSigs())
return Fail(cx, d, "more function definitions than declarations");
for (uint32_t i = 0; i < numFuncs; i++) {
if (!DecodeFunc(cx, d, mg, funcIndex++))
return false;
}
if (!d.finishSection(sectionStart))
return Fail(cx, d, "code section byte size mismatch");
}
if (!mg.finishFuncDefs())
return false;
return true;
}
static bool
DecodeUnknownSection(JSContext* cx, Decoder& d)
{
const char* unused;
if (!d.readCString(&unused))
return Fail(cx, d, "failed to read section name");
if (!d.skipSection())
return Fail(cx, d, "unable to skip unknown section");
return true;
}
static bool
DecodeModule(JSContext* cx, UniqueChars filename, const uint8_t* bytes, uint32_t length,
MutableHandle<WasmModuleObject*> moduleObj, ExportMap* exportMap)
{
Decoder d(bytes, bytes + length);
uint32_t u32;
if (!d.readU32(&u32) || u32 != MagicNumber)
return Fail(cx, d, "failed to match magic number");
if (!d.readU32(&u32) || u32 != EncodingVersion)
return Fail(cx, d, "failed to match binary version");
UniqueModuleGeneratorData init = MakeUnique<ModuleGeneratorData>();
if (!init)
return false;
if (!DecodeSignatureSection(cx, d, init.get()))
return false;
if (!DecodeDeclarationSection(cx, d, init.get()))
return false;
ModuleGenerator mg(cx);
if (!mg.init(Move(init)))
return false;
if (!DecodeExportsSection(cx, d, mg, exportMap))
return false;
HeapUsage heapUsage = HeapUsage::None;
if (!DecodeCodeSection(cx, d, mg))
return false;
CacheableCharsVector funcNames;
while (!d.readCStringIf(EndSection)) {
if (!DecodeUnknownSection(cx, d))
return false;
}
if (!d.done())
return Fail(cx, d, "failed to consume all bytes of module");
UniqueModuleData module;
UniqueStaticLinkData link;
SlowFunctionVector slowFuncs(cx);
if (!mg.finish(heapUsage, Move(filename), Move(funcNames), &module, &link, &slowFuncs))
return false;
moduleObj.set(WasmModuleObject::create(cx));
if (!moduleObj)
return false;
if (!moduleObj->init(cx->new_<Module>(Move(module))))
return false;
return moduleObj->module().staticallyLink(cx, *link);
}
/*****************************************************************************/
// JS entry poitns
static bool
WasmEval(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject callee(cx, &args.callee());
if (args.length() < 1 || args.length() > 2) {
ReportUsageError(cx, callee, "Wrong number of arguments");
return false;
}
if (!args[0].isObject() || !args[0].toObject().is<ArrayBufferObject>()) {
ReportUsageError(cx, callee, "First argument must be an ArrayBuffer");
return false;
}
if (!args.get(1).isUndefined() && !args.get(1).isObject()) {
ReportUsageError(cx, callee, "Second argument, if present, must be an Object");
return false;
}
UniqueChars filename;
if (!DescribeScriptedCaller(cx, &filename))
return false;
Rooted<ArrayBufferObject*> code(cx, &args[0].toObject().as<ArrayBufferObject>());
const uint8_t* bytes = code->dataPointer();
uint32_t length = code->byteLength();
Vector<uint8_t> copy(cx);
if (code->hasInlineData()) {
if (!copy.append(bytes, length))
return false;
bytes = copy.begin();
}
Rooted<WasmModuleObject*> moduleObj(cx);
ExportMap exportMap;
if (!DecodeModule(cx, Move(filename), bytes, length, &moduleObj, &exportMap)) {
if (!cx->isExceptionPending())
ReportOutOfMemory(cx);
return false;
}
Module& module = moduleObj->module();
Rooted<ArrayBufferObject*> heap(cx);
if (module.usesHeap())
return Fail(cx, "Heap not implemented yet");
Rooted<FunctionVector> imports(cx, FunctionVector(cx));
if (module.imports().length() > 0)
return Fail(cx, "Imports not implemented yet");
if (!module.dynamicallyLink(cx, heap, imports))
return false;
RootedObject exportObj(cx);
if (!module.createExportObject(cx, moduleObj, exportMap, &exportObj))
return false;
args.rval().setObject(*exportObj);
return true;
}
static bool
WasmTextToBinary(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject callee(cx, &args.callee());
if (args.length() != 1) {
ReportUsageError(cx, callee, "Wrong number of arguments");
return false;
}
if (!args[0].isString()) {
ReportUsageError(cx, callee, "First argument must be a String");
return false;
}
AutoStableStringChars twoByteChars(cx);
if (!twoByteChars.initTwoByte(cx, args[0].toString()))
return false;
UniqueChars error;
wasm::UniqueBytecode bytes = wasm::TextToBinary(twoByteChars.twoByteChars(), &error);
if (!bytes) {
JS_ReportError(cx, error.get() ? error.get() : "out of memory");
return false;
}
Rooted<ArrayBufferObject*> buffer(cx, ArrayBufferObject::create(cx, bytes->length()));
if (!buffer)
return false;
memcpy(buffer->dataPointer(), bytes->begin(), bytes->length());
args.rval().setObject(*buffer);
return true;
}
static const JSFunctionSpecWithHelp WasmTestingFunctions[] = {
JS_FN_HELP("wasmEval", WasmEval, 2, 0,
"wasmEval(buffer, imports)",
" Compiles the given binary wasm module given by 'buffer' (which must be an ArrayBuffer)\n"
" and links the module's imports with the given 'imports' object."),
JS_FN_HELP("wasmTextToBinary", WasmTextToBinary, 1, 0,
"wasmTextToBinary(str)",
" Translates the given text wasm module into its binary encoding."),
JS_FS_HELP_END
};
static bool
SupportsWasm(JSContext* cx)
{
#if defined(JS_CODEGEN_NONE) || defined(JS_CODEGEN_ARM64)
return false;
#endif
if (!cx->jitSupportsFloatingPoint())
return false;
if (cx->gcSystemPageSize() != AsmJSPageSize)
return false;
return true;
}
bool
wasm::DefineTestingFunctions(JSContext* cx, HandleObject globalObj)
{
if (SupportsWasm(cx))
return JS_DefineFunctionsWithHelp(cx, globalObj, WasmTestingFunctions);
return true;
}

34
js/src/asmjs/Wasm.h Normal file
View File

@ -0,0 +1,34 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
*
* Copyright 2015 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef wasm_h
#define wasm_h
#include "gc/Rooting.h"
namespace js {
namespace wasm {
// Add wasm testing JS functions to the given JS global object.
bool
DefineTestingFunctions(JSContext* cx, HandleObject globalObj);
} // namespace wasm
} // namespace js
#endif // namespace wasm_h

View File

@ -27,6 +27,20 @@ class PropertyName;
namespace wasm {
// Module header constants
static const uint32_t MagicNumber = 0x6d736100; // "\0asm"
static const uint32_t EncodingVersion = -1; // experimental
// Module section names:
static const char SigSection[] = "sig";
static const char DeclSection[] = "decl";
static const char ExportSection[] = "export";
static const char CodeSection[] = "code";
static const char EndSection[] = "";
// Subsection names:
static const char FuncSubsection[] = "func";
enum class Expr : uint8_t
{
// Control opcodes
@ -331,6 +345,15 @@ class Encoder
bytecode_[pc] = uint8_t(v);
}
template <class T>
static const T load(const uint8_t* p) {
T t;
memcpy(&t, p, sizeof(T));
return t;
}
static const uint32_t BadSectionLength = uint32_t(-1);
public:
explicit Encoder(Bytecode& bytecode)
: bytecode_(bytecode)
@ -355,9 +378,11 @@ class Encoder
}
MOZ_WARN_UNUSED_RESULT bool
writeExpr(Expr expr, size_t* offset = nullptr) {
return writeEnum(expr, offset);
}
writeExpr(Expr expr, size_t* offset = nullptr) { return writeEnum(expr, offset); }
MOZ_WARN_UNUSED_RESULT bool
writeValType(ValType type, size_t* offset = nullptr) { return writeEnum(type, offset); }
MOZ_WARN_UNUSED_RESULT bool
writeExprType(ExprType type, size_t* offset = nullptr) { return writeEnum(type, offset); }
MOZ_WARN_UNUSED_RESULT bool
writeU8(uint8_t i, size_t* offset = nullptr) { return write<uint8_t>(i, offset); }
@ -391,6 +416,25 @@ class Encoder
return true;
}
MOZ_WARN_UNUSED_RESULT bool writeCString(const char* cstr) {
MOZ_ASSERT(cstr);
return bytecode_.append(reinterpret_cast<const uint8_t*>(cstr), strlen(cstr) + 1);
}
MOZ_WARN_UNUSED_RESULT bool startSection(size_t* offset) {
if (!writeU32(BadSectionLength))
return false;
*offset = bytecode_.length();
return true;
}
void finishSection(size_t offset) {
uint8_t* patchAt = bytecode_.begin() + offset - sizeof(uint32_t);
MOZ_ASSERT(patchAt <= bytecode_.end() - sizeof(uint32_t));
MOZ_ASSERT(load<uint32_t>(patchAt) == BadSectionLength);
uint32_t numBytes = bytecode_.length() - offset;
memcpy(patchAt, &numBytes, sizeof(uint32_t));
}
#ifdef DEBUG
bool pcIsPatchable(size_t pc, unsigned size) const {
bool patchable = true;
@ -427,7 +471,8 @@ class Decoder
read(T* out) {
if (uintptr_t(end_ - cur_) < sizeof(T))
return false;
memcpy((void*)out, cur_, sizeof(T));
if (out)
memcpy((void*)out, cur_, sizeof(T));
cur_ += sizeof(T);
return true;
}
@ -440,7 +485,8 @@ class Decoder
uint8_t u8;
if (!read(&u8))
return false;
*out = T(u8);
if (out)
*out = T(u8);
return true;
}
@ -474,6 +520,13 @@ class Decoder
}
public:
Decoder(const uint8_t* begin, const uint8_t* end)
: beg_(begin),
end_(end),
cur_(begin)
{
MOZ_ASSERT(begin <= end);
}
explicit Decoder(const Bytecode& bytecode)
: beg_(bytecode.begin()),
end_(bytecode.end()),
@ -485,59 +538,121 @@ class Decoder
return cur_ == end_;
}
const uint8_t* currentPosition() const {
return cur_;
}
size_t currentOffset() const {
return cur_ - beg_;
}
void assertCurrentIs(const DebugOnly<size_t> offset) const {
MOZ_ASSERT(size_t(cur_ - beg_) == offset);
MOZ_ASSERT(currentOffset() == offset);
}
// The fallible unpacking API should be used when we're not assuming
// anything about the bytecode, in particular if it is well-formed.
MOZ_WARN_UNUSED_RESULT bool readU8 (uint8_t* i) { return read(i); }
MOZ_WARN_UNUSED_RESULT bool readI32(int32_t* i) { return read(i); }
MOZ_WARN_UNUSED_RESULT bool readF32(float* f) { return read(f); }
MOZ_WARN_UNUSED_RESULT bool readU32(uint32_t* u) { return read(u); }
MOZ_WARN_UNUSED_RESULT bool readF64(double* d) { return read(d); }
MOZ_WARN_UNUSED_RESULT bool readU8 (uint8_t* i = nullptr) { return read(i); }
MOZ_WARN_UNUSED_RESULT bool readI32(int32_t* i = nullptr) { return read(i); }
MOZ_WARN_UNUSED_RESULT bool readF32(float* f = nullptr) { return read(f); }
MOZ_WARN_UNUSED_RESULT bool readU32(uint32_t* u = nullptr) { return read(u); }
MOZ_WARN_UNUSED_RESULT bool readF64(double* d = nullptr) { return read(d); }
MOZ_WARN_UNUSED_RESULT bool readI32X4(jit::SimdConstant* c) {
MOZ_WARN_UNUSED_RESULT bool readI32X4(jit::SimdConstant* c = nullptr) {
int32_t v[4] = { 0, 0, 0, 0 };
for (size_t i = 0; i < 4; i++) {
if (!readI32(&v[i]))
return false;
}
*c = jit::SimdConstant::CreateX4(v[0], v[1], v[2], v[3]);
if (c)
*c = jit::SimdConstant::CreateX4(v[0], v[1], v[2], v[3]);
return true;
}
MOZ_WARN_UNUSED_RESULT bool readF32X4(jit::SimdConstant* c) {
MOZ_WARN_UNUSED_RESULT bool readF32X4(jit::SimdConstant* c = nullptr) {
float v[4] = { 0., 0., 0., 0. };
for (size_t i = 0; i < 4; i++) {
if (!readF32(&v[i]))
return false;
}
*c = jit::SimdConstant::CreateX4(v[0], v[1], v[2], v[3]);
if (c)
*c = jit::SimdConstant::CreateX4(v[0], v[1], v[2], v[3]);
return true;
}
MOZ_WARN_UNUSED_RESULT bool readVarU32(uint32_t* decoded) {
*decoded = 0;
MOZ_WARN_UNUSED_RESULT bool readVarU32(uint32_t* out = nullptr) {
uint32_t u32 = 0;
uint8_t byte;
uint32_t shift = 0;
do {
if (!readU8(&byte))
return false;
if (!(byte & 0x80)) {
*decoded |= uint32_t(byte & 0x7F) << shift;
if (out)
*out = u32 | uint32_t(byte & 0x7F) << shift;
return true;
}
*decoded |= uint32_t(byte & 0x7F) << shift;
u32 |= uint32_t(byte & 0x7F) << shift;
shift += 7;
} while (shift != 28);
if (!readU8(&byte) || (byte & 0xF0))
return false;
*decoded |= uint32_t(byte) << 28;
if (out)
*out = u32 | uint32_t(byte) << 28;
return true;
}
MOZ_WARN_UNUSED_RESULT bool readExpr(Expr* expr) {
MOZ_WARN_UNUSED_RESULT bool readExpr(Expr* expr = nullptr) {
return readEnum(expr);
}
MOZ_WARN_UNUSED_RESULT bool readValType(ValType* type = nullptr) {
return readEnum(type);
}
MOZ_WARN_UNUSED_RESULT bool readExprType(ExprType* type = nullptr) {
return readEnum(type);
}
MOZ_WARN_UNUSED_RESULT bool readCString(const char** cstr = nullptr) {
if (cstr)
*cstr = reinterpret_cast<const char*>(cur_);
for (; cur_ != end_; cur_++) {
if (!*cur_) {
cur_++;
return true;
}
}
return false;
}
MOZ_WARN_UNUSED_RESULT bool readCStringIf(const char* tag) {
for (const uint8_t* p = cur_; p != end_; p++, tag++) {
if (*p != *tag)
return false;
if (!*p) {
cur_ = p + 1;
return true;
}
}
return false;
}
MOZ_WARN_UNUSED_RESULT bool startSection(uint32_t* offset) {
uint32_t unused;
if (!readU32(&unused))
return false;
*offset = currentOffset();
return true;
}
MOZ_WARN_UNUSED_RESULT bool finishSection(uint32_t offset) {
const uint8_t* start = beg_ + offset;
uint32_t numBytes;
memcpy(&numBytes, start - sizeof(uint32_t), sizeof(uint32_t));
return numBytes == uintptr_t(cur_ - start);
}
MOZ_WARN_UNUSED_RESULT bool skipSection() {
uint32_t numBytes;
if (!readU32(&numBytes))
return false;
if (uintptr_t(end_ - cur_) < numBytes)
return false;
cur_ += numBytes;
return true;
}
// The infallible unpacking API should be used when we are sure that the
// bytecode is well-formed.

View File

@ -105,6 +105,9 @@ ParallelCompilationEnabled(ExclusiveContext* cx)
bool
ModuleGenerator::init(UniqueModuleGeneratorData shared, ModuleKind kind)
{
if (!funcIndexToExport_.init())
return false;
module_ = MakeUnique<ModuleData>();
if (!module_)
return false;
@ -385,9 +388,6 @@ ModuleGenerator::startFuncDefs()
if (!threadView_)
return false;
if (!funcIndexToExport_.init())
return false;
uint32_t numTasks;
if (ParallelCompilationEnabled(cx_) &&
HelperThreadState().wasmCompilationInProgress.compareExchange(false, true))

957
js/src/asmjs/WasmText.cpp Normal file
View File

@ -0,0 +1,957 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
*
* Copyright 2015 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "asmjs/WasmText.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/Maybe.h"
#include "jsnum.h"
#include "jsprf.h"
#include "asmjs/WasmBinary.h"
#include "ds/LifoAlloc.h"
#include "js/CharacterEncoding.h"
#include "js/HashTable.h"
using namespace js;
using namespace js::wasm;
using mozilla::CheckedInt;
using mozilla::Maybe;
using mozilla::Range;
static const unsigned AST_LIFO_DEFAULT_CHUNK_SIZE = 4096;
/*****************************************************************************/
// wasm AST
template <class T>
using WasmAstVector = mozilla::Vector<T, 0, LifoAllocPolicy<Fallible>>;
template <class K, class V, class HP>
using WasmAstHashMap = HashMap<K, V, HP, LifoAllocPolicy<Fallible>>;
typedef WasmAstVector<ValType> WasmAstValTypeVector;
struct WasmAstBase
{
void* operator new(size_t numBytes, LifoAlloc& astLifo) throw() {
return astLifo.alloc(numBytes);
}
};
class WasmAstSig : public WasmAstBase
{
WasmAstValTypeVector args_;
ExprType ret_;
public:
WasmAstSig(WasmAstValTypeVector&& args, ExprType ret)
: args_(Move(args)),
ret_(ret)
{}
WasmAstSig(WasmAstSig&& rhs)
: args_(Move(rhs.args_)),
ret_(rhs.ret_)
{}
const WasmAstValTypeVector& args() const {
return args_;
}
ExprType ret() const {
return ret_;
}
typedef const WasmAstSig& Lookup;
static HashNumber hash(Lookup sig) {
return AddContainerToHash(sig.args(), HashNumber(sig.ret()));
}
static bool match(const WasmAstSig* lhs, Lookup rhs) {
return lhs->ret() == rhs.ret() && EqualContainers(lhs->args(), rhs.args());
}
};
enum class WasmAstKind
{
Nop,
Const,
Func,
Export,
Module
};
class WasmAstNode : public WasmAstBase
{
const WasmAstKind kind_;
public:
explicit WasmAstNode(WasmAstKind kind)
: kind_(kind)
{}
WasmAstKind kind() const { return kind_; }
};
class WasmAstExpr : public WasmAstNode
{
protected:
explicit WasmAstExpr(WasmAstKind kind)
: WasmAstNode(kind)
{}
public:
template <class T>
T& as() {
MOZ_ASSERT(kind() == T::Kind);
return static_cast<T&>(*this);
}
};
struct WasmAstNop : WasmAstExpr
{
WasmAstNop()
: WasmAstExpr(WasmAstKind::Nop)
{}
};
class WasmAstConst : public WasmAstExpr
{
const Val val_;
public:
static const WasmAstKind Kind = WasmAstKind::Const;
explicit WasmAstConst(Val val)
: WasmAstExpr(Kind),
val_(val)
{}
Val val() const { return val_; }
};
class WasmAstFunc : public WasmAstNode
{
const uint32_t sigIndex_;
WasmAstExpr* const maybeBody_;
public:
WasmAstFunc(uint32_t sigIndex, WasmAstExpr* maybeBody)
: WasmAstNode(WasmAstKind::Func),
sigIndex_(sigIndex),
maybeBody_(maybeBody)
{}
uint32_t sigIndex() const { return sigIndex_; }
WasmAstExpr* maybeBody() const { return maybeBody_; }
};
class WasmAstExport : public WasmAstNode
{
const char16_t* const externalName_;
const size_t externalNameLength_;
uint32_t internalIndex_;
public:
WasmAstExport(const char16_t* externalNameBegin,
const char16_t* externalNameEnd)
: WasmAstNode(WasmAstKind::Export),
externalName_(externalNameBegin),
externalNameLength_(externalNameEnd - externalNameBegin),
internalIndex_(UINT32_MAX)
{
MOZ_ASSERT(externalNameBegin <= externalNameEnd);
}
const char16_t* externalName() const { return externalName_; }
size_t externalNameLength() const { return externalNameLength_; }
void initInternalIndex(uint32_t internalIndex) {
MOZ_ASSERT(internalIndex_ == UINT32_MAX);
internalIndex_ = internalIndex;
}
size_t internalIndex() const {
MOZ_ASSERT(internalIndex_ != UINT32_MAX);
return internalIndex_;
}
};
class WasmAstModule : public WasmAstNode
{
typedef WasmAstVector<WasmAstFunc*> FuncVector;
typedef WasmAstVector<WasmAstExport*> ExportVector;
typedef WasmAstVector<WasmAstSig*> SigVector;
typedef WasmAstHashMap<WasmAstSig*, uint32_t, WasmAstSig> SigMap;
LifoAlloc& lifo_;
FuncVector funcs_;
ExportVector exports_;
SigVector sigs_;
SigMap sigMap_;
public:
explicit WasmAstModule(LifoAlloc& lifo)
: WasmAstNode(WasmAstKind::Module),
lifo_(lifo),
funcs_(lifo),
exports_(lifo),
sigs_(lifo),
sigMap_(lifo)
{}
bool init() {
return sigMap_.init();
}
bool declare(WasmAstSig&& sig, uint32_t* sigIndex) {
SigMap::AddPtr p = sigMap_.lookupForAdd(sig);
if (p) {
*sigIndex = p->value();
return true;
}
*sigIndex = sigs_.length();
return sigs_.append(new (lifo_) WasmAstSig(Move(sig))) &&
sigMap_.add(p, sigs_.back(), *sigIndex);
}
const SigVector& sigs() const {
return sigs_;
}
bool append(WasmAstFunc* func) {
return funcs_.append(func);
}
const FuncVector& funcs() const {
return funcs_;
}
bool append(WasmAstExport* exp) {
return exports_.append(exp);
}
const ExportVector& exports() const {
return exports_;
}
};
/*****************************************************************************/
// wasm text token stream
class WasmToken
{
public:
enum Kind
{
OpenParen,
CloseParen,
Name,
Text,
Integer,
ValueType,
Const,
Module,
Func,
Param,
Result,
Export,
Nop,
EndOfFile,
Error
};
private:
Kind kind_;
const char16_t* begin_;
const char16_t* end_;
union {
uint32_t integer_;
ValType valueType_;
} u;
public:
explicit WasmToken() = default;
WasmToken(Kind kind, const char16_t* begin, const char16_t* end)
: kind_(kind),
begin_(begin),
end_(end)
{
MOZ_ASSERT(kind_ != Error);
MOZ_ASSERT((kind == EndOfFile) == (begin == end));
}
explicit WasmToken(uint32_t integer, const char16_t* begin, const char16_t* end)
: kind_(Integer),
begin_(begin),
end_(end)
{
MOZ_ASSERT(begin != end);
u.integer_ = integer;
}
explicit WasmToken(Kind kind, ValType valueType, const char16_t* begin, const char16_t* end)
: kind_(kind),
begin_(begin),
end_(end)
{
MOZ_ASSERT(begin != end);
MOZ_ASSERT(kind_ == ValueType || kind_ == Const);
u.valueType_ = valueType;
}
explicit WasmToken(const char16_t* begin)
: kind_(Error),
begin_(begin),
end_(begin)
{}
Kind kind() const {
return kind_;
}
const char16_t* begin() const {
return begin_;
}
const char16_t* end() const {
return end_;
}
const char16_t* textBegin() const {
MOZ_ASSERT(kind_ == Text);
MOZ_ASSERT(begin_[0] == '"');
return begin_ + 1;
}
const char16_t* textEnd() const {
MOZ_ASSERT(kind_ == Text);
MOZ_ASSERT(end_[-1] == '"');
return end_ - 1;
}
uint32_t integer() const {
MOZ_ASSERT(kind_ == Integer);
return u.integer_;
}
ValType valueType() const {
MOZ_ASSERT(kind_ == ValueType || kind_ == Const);
return u.valueType_;
}
};
static bool
IsWasmNewLine(char16_t c)
{
return c == '\n';
}
static bool
IsWasmSpace(char16_t c)
{
switch (c) {
case ' ':
case '\n':
case '\r':
case '\t':
case '\v':
case '\f':
return true;
default:
return false;
}
}
static bool
IsWasmDigit(char16_t c)
{
return c >= '0' && c <= '9';
}
static bool
IsWasmLetter(char16_t c)
{
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
static bool
IsNameAfterDollar(char16_t c)
{
return c == '_' || IsWasmDigit(c) || IsWasmLetter(c);
}
class WasmTokenStream
{
static const uint32_t LookaheadSize = 2;
const char16_t* cur_;
const char16_t* const end_;
const char16_t* lineStart_;
unsigned line_;
uint32_t lookaheadIndex_;
uint32_t lookaheadDepth_;
WasmToken lookahead_[LookaheadSize];
bool consume(const char16_t* end, const char16_t* match) {
const char16_t* p = cur_;
for (; *match; p++, match++) {
if (p == end || *p != *match)
return false;
}
cur_ = p;
return true;
}
WasmToken fail(const char16_t* begin) const {
return WasmToken(begin);
}
WasmToken next() {
while (cur_ != end_ && IsWasmSpace(*cur_)) {
if (IsWasmNewLine(*cur_++)) {
lineStart_ = cur_;
line_++;
}
}
if (cur_ == end_)
return WasmToken(WasmToken::EndOfFile, cur_, cur_);
const char16_t* begin = cur_++;
switch (*begin) {
case '"':
while (cur_ != end_ && *cur_ != '"')
cur_++;
return WasmToken(WasmToken::Text, begin, ++cur_);
case '$':
while (cur_ != end_ && IsNameAfterDollar(*cur_))
cur_++;
return WasmToken(WasmToken::Name, begin, cur_);
case '(':
return WasmToken(WasmToken::OpenParen, begin, cur_);
case ')':
return WasmToken(WasmToken::CloseParen, begin, cur_);
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9': {
CheckedInt<uint32_t> u32 = *begin - '0';
while (cur_ != end_ && IsWasmDigit(*cur_)) {
u32 *= 10;
u32 += *cur_ - '0';
if (!u32.isValid())
return fail(begin);
cur_++;
}
return WasmToken(u32.value(), begin, cur_);
}
case 'e':
if (consume(end_, MOZ_UTF16("xport")))
return WasmToken(WasmToken::Export, begin, cur_);
break;
case 'f':
if (consume(end_, MOZ_UTF16("unc")))
return WasmToken(WasmToken::Func, begin, cur_);
if (consume(end_, MOZ_UTF16("32"))) {
if (consume(end_, MOZ_UTF16(".const")))
return WasmToken(WasmToken::Const, ValType::F32, begin, cur_);
else
return WasmToken(WasmToken::ValueType, ValType::F32, begin, cur_);
}
if (consume(end_, MOZ_UTF16("64"))) {
if (consume(end_, MOZ_UTF16(".const")))
return WasmToken(WasmToken::Const, ValType::F64, begin, cur_);
else
return WasmToken(WasmToken::ValueType, ValType::F64, begin, cur_);
}
break;
case 'i':
if (consume(end_, MOZ_UTF16("32"))) {
if (consume(end_, MOZ_UTF16(".const")))
return WasmToken(WasmToken::Const, ValType::I32, begin, cur_);
else
return WasmToken(WasmToken::ValueType, ValType::I32, begin, cur_);
}
if (consume(end_, MOZ_UTF16("64"))) {
if (consume(end_, MOZ_UTF16(".const")))
return WasmToken(WasmToken::Const, ValType::I64, begin, cur_);
else
return WasmToken(WasmToken::ValueType, ValType::I64, begin, cur_);
}
break;
case 'p':
if (consume(end_, MOZ_UTF16("aram")))
return WasmToken(WasmToken::Param, begin, cur_);
break;
case 'm':
if (consume(end_, MOZ_UTF16("odule")))
return WasmToken(WasmToken::Module, begin, cur_);
break;
case 'n':
if (consume(end_, MOZ_UTF16("op")))
return WasmToken(WasmToken::Nop, begin, cur_);
break;
case 'r':
if (consume(end_, MOZ_UTF16("esult")))
return WasmToken(WasmToken::Result, begin, cur_);
break;
default:
break;
}
return fail(begin);
}
public:
WasmTokenStream(const char16_t* text, UniqueChars* error)
: cur_(text),
end_(text + js_strlen(text)),
lineStart_(text),
line_(0),
lookaheadIndex_(0),
lookaheadDepth_(0)
{}
void generateError(WasmToken token, UniqueChars* error) {
unsigned column = token.begin() - lineStart_ + 1;
error->reset(JS_smprintf("parsing wasm text at at %u:%u", line_, column));
}
WasmToken peek() {
if (!lookaheadDepth_) {
lookahead_[lookaheadIndex_] = next();
lookaheadDepth_ = 1;
}
return lookahead_[lookaheadIndex_];
}
WasmToken get() {
static_assert(LookaheadSize == 2, "can just flip");
if (lookaheadDepth_) {
lookaheadDepth_--;
WasmToken ret = lookahead_[lookaheadIndex_];
lookaheadIndex_ ^= 1;
return ret;
}
return next();
}
void unget(WasmToken token) {
static_assert(LookaheadSize == 2, "can just flip");
lookaheadDepth_++;
lookaheadIndex_ ^= 1;
lookahead_[lookaheadIndex_] = token;
}
// Helpers:
bool getIf(WasmToken::Kind kind) {
if (peek().kind() == kind) {
get();
return true;
}
return false;
}
bool match(WasmToken::Kind expect, WasmToken* token, UniqueChars* error) {
*token = get();
if (token->kind() == expect)
return true;
generateError(*token, error);
return false;
}
bool match(WasmToken::Kind expect, UniqueChars* error) {
WasmToken token;
return match(expect, &token, error);
}
};
/*****************************************************************************/
// wasm text format parser
struct WasmParseContext
{
WasmTokenStream ts;
LifoAlloc& lifo;
UniqueChars* error;
WasmParseContext(const char16_t* text, LifoAlloc& lifo, UniqueChars* error)
: ts(text, error),
lifo(lifo),
error(error)
{}
};
static WasmAstConst*
ParseConst(WasmParseContext& c, WasmToken constToken)
{
switch (constToken.valueType()) {
case ValType::I32: {
WasmToken val;
if (!c.ts.match(WasmToken::Integer, &val, c.error))
return nullptr;
return new(c.lifo) WasmAstConst(Val(val.integer()));
}
default:
c.ts.generateError(constToken, c.error);
return nullptr;
}
}
static WasmAstExpr*
ParseExpr(WasmParseContext& c)
{
WasmToken expr = c.ts.get();
switch (expr.kind()) {
case WasmToken::Nop:
return new(c.lifo) WasmAstNop;
case WasmToken::Const:
return ParseConst(c, expr);
default:
c.ts.generateError(expr, c.error);
return nullptr;
}
}
static WasmAstFunc*
ParseFunc(WasmParseContext& c, WasmAstModule* module)
{
WasmAstValTypeVector args(c.lifo);
ExprType result = ExprType::Void;
WasmAstExpr* maybeBody = nullptr;
while (c.ts.getIf(WasmToken::OpenParen) && !maybeBody) {
WasmToken field = c.ts.get();
switch (field.kind()) {
case WasmToken::Param: {
WasmToken valueType;
if (!c.ts.match(WasmToken::ValueType, &valueType, c.error))
return nullptr;
if (!args.append(valueType.valueType()))
return nullptr;
break;
}
case WasmToken::Result: {
if (result != ExprType::Void) {
c.ts.generateError(field, c.error);
return nullptr;
}
WasmToken valueType;
if (!c.ts.match(WasmToken::ValueType, &valueType, c.error))
return nullptr;
result = ToExprType(valueType.valueType());
break;
}
default:
c.ts.unget(field);
maybeBody = ParseExpr(c);
if (!maybeBody)
return nullptr;
break;
}
if (!c.ts.match(WasmToken::CloseParen, c.error))
return nullptr;
}
uint32_t sigIndex;
if (!module->declare(WasmAstSig(Move(args), result), &sigIndex))
return nullptr;
return new(c.lifo) WasmAstFunc(sigIndex, maybeBody);
}
static WasmAstExport*
ParseExport(WasmParseContext& c)
{
WasmToken externalName;
if (!c.ts.match(WasmToken::Text, &externalName, c.error))
return nullptr;
auto exp = new(c.lifo) WasmAstExport(externalName.textBegin(), externalName.textEnd());
if (!exp)
return nullptr;
WasmToken internalName = c.ts.get();
switch (internalName.kind()) {
case WasmToken::Integer:
exp->initInternalIndex(internalName.integer());
break;
default:
c.ts.generateError(internalName, c.error);
return nullptr;
}
return exp;
}
static WasmAstModule*
TextToAst(const char16_t* text, LifoAlloc& lifo, UniqueChars* error)
{
WasmParseContext c(text, lifo, error);
if (!c.ts.match(WasmToken::OpenParen, c.error))
return nullptr;
if (!c.ts.match(WasmToken::Module, c.error))
return nullptr;
auto module = new(c.lifo) WasmAstModule(c.lifo);
if (!module || !module->init())
return nullptr;
while (c.ts.getIf(WasmToken::OpenParen)) {
WasmToken section = c.ts.get();
switch (section.kind()) {
case WasmToken::Export: {
WasmAstExport* exp = ParseExport(c);
if (!exp || !module->append(exp))
return nullptr;
break;
}
case WasmToken::Func: {
WasmAstFunc* func = ParseFunc(c, module);
if (!func || !module->append(func))
return nullptr;
break;
}
default:
c.ts.generateError(section, c.error);
return nullptr;
}
if (!c.ts.match(WasmToken::CloseParen, c.error))
return nullptr;
}
if (!c.ts.match(WasmToken::CloseParen, c.error))
return nullptr;
if (!c.ts.match(WasmToken::EndOfFile, c.error))
return nullptr;
return module;
}
/*****************************************************************************/
// wasm function body serialization
static bool
EncodeConst(Encoder& e, WasmAstConst& c)
{
switch (c.val().type()) {
case ValType::I32:
return e.writeExpr(Expr::I32Const) &&
e.writeVarU32(c.val().i32());
default:
break;
}
MOZ_CRASH("Bad value type");
}
static bool
EncodeExpr(Encoder& e, WasmAstExpr& expr)
{
switch (expr.kind()) {
case WasmAstKind::Nop:
return e.writeExpr(Expr::Nop);
case WasmAstKind::Const:
return EncodeConst(e, expr.as<WasmAstConst>());
default:;
}
MOZ_CRASH("Bad expr kind");
}
/*****************************************************************************/
// wasm AST binary serialization
static bool
EncodeSignatureSection(Encoder& e, WasmAstModule& module)
{
if (module.funcs().empty())
return true;
if (!e.writeCString(SigSection))
return false;
size_t offset;
if (!e.startSection(&offset))
return false;
if (!e.writeVarU32(module.sigs().length()))
return false;
for (WasmAstSig* sig : module.sigs()) {
if (!e.writeVarU32(sig->args().length()))
return false;
if (!e.writeExprType(sig->ret()))
return false;
for (ValType t : sig->args()) {
if (!e.writeValType(t))
return false;
}
}
e.finishSection(offset);
return true;
}
static bool
EncodeDeclarationSection(Encoder& e, WasmAstModule& module)
{
if (module.funcs().empty())
return true;
if (!e.writeCString(DeclSection))
return false;
size_t offset;
if (!e.startSection(&offset))
return false;
if (!e.writeVarU32(module.funcs().length()))
return false;
for (WasmAstFunc* func : module.funcs()) {
if (!e.writeVarU32(func->sigIndex()))
return false;
}
e.finishSection(offset);
return true;
}
static bool
EncodeExport(Encoder& e, WasmAstExport& exp)
{
if (!e.writeCString(FuncSubsection))
return false;
if (!e.writeVarU32(exp.internalIndex()))
return false;
Range<const char16_t> twoByte(exp.externalName(), exp.externalNameLength());
UniqueChars utf8(JS::CharsToNewUTF8CharsZ(nullptr, twoByte).c_str());
if (!utf8)
return false;
if (!e.writeCString(utf8.get()))
return false;
return true;
}
static bool
EncodeExportSection(Encoder& e, WasmAstModule& module)
{
if (module.exports().empty())
return true;
if (!e.writeCString(ExportSection))
return false;
size_t offset;
if (!e.startSection(&offset))
return false;
if (!e.writeVarU32(module.exports().length()))
return false;
for (WasmAstExport* exp : module.exports()) {
if (!EncodeExport(e, *exp))
return false;
}
e.finishSection(offset);
return true;
}
static bool
EncodeFunc(Encoder& e, WasmAstFunc& func)
{
if (!e.writeCString(FuncSubsection))
return false;
size_t offset;
if (!e.startSection(&offset))
return false;
if (func.maybeBody()) {
if (!EncodeExpr(e, *func.maybeBody()))
return false;
} else {
if (!e.writeExpr(Expr::Nop))
return false;
}
e.finishSection(offset);
return true;
}
static bool
EncodeCodeSection(Encoder& e, WasmAstModule& module)
{
if (module.funcs().empty())
return true;
if (!e.writeCString(CodeSection))
return false;
size_t offset;
if (!e.startSection(&offset))
return false;
if (!e.writeVarU32(module.funcs().length()))
return false;
for (WasmAstFunc* func : module.funcs()) {
if (!EncodeFunc(e, *func))
return false;
}
e.finishSection(offset);
return true;
}
static UniqueBytecode
AstToBinary(WasmAstModule& module)
{
UniqueBytecode bytecode = MakeUnique<Bytecode>();
if (!bytecode)
return nullptr;
Encoder e(*bytecode);
if (!e.writeU32(MagicNumber))
return nullptr;
if (!e.writeU32(EncodingVersion))
return nullptr;
if (!EncodeSignatureSection(e, module))
return nullptr;
if (!EncodeDeclarationSection(e, module))
return nullptr;
if (!EncodeExportSection(e, module))
return nullptr;
if (!EncodeCodeSection(e, module))
return nullptr;
if (!e.writeCString(EndSection))
return nullptr;
return Move(bytecode);
}
/*****************************************************************************/
UniqueBytecode
wasm::TextToBinary(const char16_t* text, UniqueChars* error)
{
LifoAlloc lifo(AST_LIFO_DEFAULT_CHUNK_SIZE);
WasmAstModule* module = TextToAst(text, lifo, error);
if (!module)
return nullptr;
return AstToBinary(*module);
}

38
js/src/asmjs/WasmText.h Normal file
View File

@ -0,0 +1,38 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
*
* Copyright 2015 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef wasm_text_h
#define wasm_text_h
#include "asmjs/WasmBinary.h"
#include "js/Utility.h"
namespace js {
namespace wasm {
// Translate the textual representation of a wasm module (given by a
// null-terminated char16_t array) into a Bytecode object. If there is an error
// other than out-of-memory an error message string will be stored in 'error'.
extern UniqueBytecode
TextToBinary(const char16_t* text, UniqueChars* error);
} // namespace wasm
} // namespace js
#endif // wasm_text_h

View File

@ -226,21 +226,10 @@ class Sig
const ExprType& ret() const { return ret_; }
HashNumber hash() const {
HashNumber hn = HashNumber(ret_);
for (unsigned i = 0; i < args_.length(); i++)
hn = mozilla::AddToHash(hn, HashNumber(args_[i]));
return hn;
return AddContainerToHash(args_, HashNumber(ret_));
}
bool operator==(const Sig& rhs) const {
if (ret() != rhs.ret())
return false;
if (args().length() != rhs.args().length())
return false;
for (unsigned i = 0; i < args().length(); i++) {
if (arg(i) != rhs.arg(i))
return false;
}
return true;
return ret() == rhs.ret() && EqualContainers(args(), rhs.args());
}
bool operator!=(const Sig& rhs) const {
return !(*this == rhs);

View File

@ -19,6 +19,7 @@
#include "jswrapper.h"
#include "asmjs/AsmJS.h"
#include "asmjs/Wasm.h"
#include "jit/InlinableNatives.h"
#include "jit/JitFrameIterator.h"
#include "js/Debug.h"
@ -3672,6 +3673,9 @@ js::DefineTestingFunctions(JSContext* cx, HandleObject obj, bool fuzzingSafe_,
disableOOMFunctions = disableOOMFunctions_;
if (!wasm::DefineTestingFunctions(cx, obj))
return false;
if (!JS_DefineProperties(cx, obj, TestingProperties))
return false;

View File

@ -760,7 +760,6 @@ OBJ_SUFFIX=o
LIB_SUFFIX=a
ASM_SUFFIX=s
IMPORT_LIB_SUFFIX=
TARGET_MD_ARCH=unix
DIRENT_INO=d_ino
MOZ_USER_DIR=".mozilla"
@ -1498,7 +1497,6 @@ case "$target" in
DSO_LDOPTS=''
STRIP="$STRIP -x -S"
_PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
LDFLAGS="$LDFLAGS -lobjc"
# The ExceptionHandling framework is needed for Objective-C exception
# logging code in nsObjCExceptions.h. Currently we only use that in debug
@ -1580,7 +1578,6 @@ ia64*-hpux*)
AC_DEFINE(NO_PW_GECOS)
no_x=yes
_PLATFORM_DEFAULT_TOOLKIT=cairo-android
TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
MOZ_GFX_OPTIMIZE_MOBILE=1
MOZ_OPTIMIZE_FLAGS="-O3 -fno-reorder-functions"
@ -1606,8 +1603,6 @@ ia64*-hpux*)
fi
fi
TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
case "${target_cpu}" in
alpha*)
CFLAGS="$CFLAGS -mieee"
@ -1691,10 +1686,8 @@ ia64*-hpux*)
_DEFINES_CXXFLAGS='-FI $(topobjdir)/js/src/js-confdefs.h -DMOZILLA_CLIENT'
CFLAGS="$CFLAGS -W3 -Gy"
CXXFLAGS="$CXXFLAGS -W3 -Gy"
if test "$CPU_ARCH" = "x86" -a -z "$CLANG_CL"; then
if test "$CPU_ARCH" = "x86"; then
dnl VS2012+ defaults to -arch:SSE2.
dnl Clang-cl gets confused by -arch:IA32, so don't add it.
dnl (See https://llvm.org/bugs/show_bug.cgi?id=24335)
CFLAGS="$CFLAGS -arch:IA32"
CXXFLAGS="$CXXFLAGS -arch:IA32"
fi
@ -1782,13 +1775,9 @@ ia64*-hpux*)
WARNINGS_AS_ERRORS='-WX'
MOZ_OPTIMIZE_FLAGS="-O2"
MOZ_FIX_LINK_PATHS=
# Disable these flags on clang-cl since it doesn't ignore unknown arguments by default, and
# autoconf insists on passing $LDFLAGS to the compiler.
if test -z "$CLANG_CL"; then
LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
if test -z "$DEVELOPER_OPTIONS"; then
LDFLAGS="$LDFLAGS -RELEASE"
fi
LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
if test -z "$DEVELOPER_OPTIONS"; then
LDFLAGS="$LDFLAGS -RELEASE"
fi
dnl For profile-guided optimization
PROFILE_GEN_CFLAGS="-GL"
@ -1816,14 +1805,10 @@ ia64*-hpux*)
AC_DEFINE(HW_THREADS)
AC_DEFINE(STDC_HEADERS)
AC_DEFINE(WIN32_LEAN_AND_MEAN)
TARGET_MD_ARCH=win32
_PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
BIN_SUFFIX='.exe'
MOZ_USER_DIR="Mozilla"
dnl Hardcode to win95 for now - cls
TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
dnl set NO_X11 defines here as the general check is skipped on win32
no_x=yes
AC_DEFINE(NO_X11)
@ -1846,11 +1831,7 @@ ia64*-hpux*)
LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
else
DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
# Disable this flag on clang-cl since it doesn't ignore unknown arguments by default, and
# autoconf insists on passing $LDFLAGS to the compiler.
if test -z "$CLANG_CL"; then
LDFLAGS="$LDFLAGS -SAFESEH"
fi
LDFLAGS="$LDFLAGS -SAFESEH"
fi
AC_DEFINE(_X86_)
@ -1901,7 +1882,6 @@ ia64*-hpux*)
*-solaris*)
AC_DEFINE(SOLARIS)
TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
if test -z "$CROSS_COMPILE" && pkginfo -q SUNWpr && pkginfo -q SUNWprd; then
NO_NSPR_CONFIG_SYSTEM_LDFLAGS="-L/usr/lib/mps -R/usr/lib/mps -lnspr4"
NO_NSPR_CONFIG_SYSTEM_CFLAGS="-I/usr/include/mps"
@ -3712,8 +3692,6 @@ AC_SUBST(HOST_OS_ARCH)
AC_SUBST(TARGET_CPU)
AC_SUBST(TARGET_VENDOR)
AC_SUBST(TARGET_OS)
AC_SUBST(TARGET_NSPR_MDCPUCFG)
AC_SUBST(TARGET_MD_ARCH)
AC_SUBST(TARGET_XPCOM_ABI)
AC_SUBST(OS_TARGET)
AC_SUBST(OS_ARCH)
@ -3832,9 +3810,6 @@ AC_SUBST(JS_LIBRARY_NAME)
AC_SUBST(JS_CONFIG_MOZ_JS_LIBS)
AC_SUBST(JS_CONFIG_LIBS)
if test -n "$MOZ_BUILD_NSPR"; then
MOZ_SUBCONFIGURE_NSPR()
fi
MOZ_SUBCONFIGURE_FFI()
MOZ_SUBCONFIGURE_JEMALLOC()

View File

@ -75,10 +75,10 @@ if (typeof assertErrorMessage === 'undefined') {
throw new Error("Assertion failed: expected exception " + ctor.name + ", got " + e);
if (typeof test == "string") {
if (test != e.message)
throw new Error("Assertion failed: expeceted " + test + ", got " + e.message);
throw new Error("Assertion failed: expected " + test + ", got " + e.message);
} else {
if (!test.test(e.message))
throw new Error("Assertion failed: expeceted " + test.toString() + ", got " + e.message);
throw new Error("Assertion failed: expected " + test.toString() + ", got " + e.message);
}
return;
}

View File

@ -0,0 +1,5 @@
load(libdir + "asserts.js");
function wasmEvalText(str, imports) {
return wasmEval(wasmTextToBinary(str), imports);
}

View File

@ -1,5 +1,5 @@
if (typeof SIMD !== 'object')
exit(0);
quit(0);
function test() {
return SIMD.Float32x4().toSource();

View File

@ -0,0 +1,91 @@
load(libdir + "wasm.js");
if (!this.wasmEval)
quit();
function mismatchError(expect, actual) {
return /type mismatch/;
}
// ----------------------------------------------------------------------------
// exports
var o = wasmEvalText('(module)');
assertEq(Object.getOwnPropertyNames(o).length, 0);
var o = wasmEvalText('(module (func))');
assertEq(Object.getOwnPropertyNames(o).length, 0);
var o = wasmEvalText('(module (func) (export "" 0))');
assertEq(typeof o, "function");
assertEq(o.name, "0");
assertEq(o.length, 0);
assertEq(o(), undefined);
var o = wasmEvalText('(module (func) (export "a" 0))');
var names = Object.getOwnPropertyNames(o);
assertEq(names.length, 1);
assertEq(names[0], 'a');
var desc = Object.getOwnPropertyDescriptor(o, 'a');
assertEq(typeof desc.value, "function");
assertEq(desc.value.name, "0");
assertEq(desc.value.length, 0);
assertEq(desc.value(), undefined);
assertEq(desc.writable, true);
assertEq(desc.enumerable, true);
assertEq(desc.configurable, true);
assertEq(desc.value(), undefined);
var o = wasmEvalText('(module (func) (func) (export "" 0) (export "a" 1))');
assertEq(typeof o, "function");
assertEq(o.name, "0");
assertEq(o.length, 0);
assertEq(o(), undefined);
var desc = Object.getOwnPropertyDescriptor(o, 'a');
assertEq(typeof desc.value, "function");
assertEq(desc.value.name, "1");
assertEq(desc.value.length, 0);
assertEq(desc.value(), undefined);
assertEq(desc.writable, true);
assertEq(desc.enumerable, true);
assertEq(desc.configurable, true);
assertEq(desc.value(), undefined);
wasmEvalText('(module (func) (func) (export "a" 0))');
wasmEvalText('(module (func) (func) (export "a" 1))');
assertErrorMessage(() => wasmEvalText('(module (func) (export "a" 1))'), Error, /export function index out of range/);
assertErrorMessage(() => wasmEvalText('(module (func) (func) (export "a" 2))'), Error, /export function index out of range/);
var o = wasmEvalText('(module (func) (export "a" 0) (export "b" 0))');
assertEq(Object.getOwnPropertyNames(o).sort().toString(), "a,b");
assertEq(o.a.name, "0");
assertEq(o.b.name, "0");
assertEq(o.a === o.b, true);
var o = wasmEvalText('(module (func) (func) (export "a" 0) (export "b" 1))');
assertEq(Object.getOwnPropertyNames(o).sort().toString(), "a,b");
assertEq(o.a.name, "0");
assertEq(o.b.name, "1");
assertEq(o.a === o.b, false);
var o = wasmEvalText('(module (func (result i32) (i32.const 1)) (func (result i32) (i32.const 2)) (export "a" 0) (export "b" 1))');
assertEq(o.a(), 1);
assertEq(o.b(), 2);
var o = wasmEvalText('(module (func (result i32) (i32.const 1)) (func (result i32) (i32.const 2)) (export "a" 1) (export "b" 0))');
assertEq(o.a(), 2);
assertEq(o.b(), 1);
assertErrorMessage(() => wasmEvalText('(module (func) (export "a" 0) (export "a" 0))'), Error, /duplicate export/);
assertErrorMessage(() => wasmEvalText('(module (func) (func) (export "a" 0) (export "a" 1))'), Error, /duplicate export/);
// ----------------------------------------------------------------------------
// signatures
assertErrorMessage(() => wasmEvalText('(module (func (result i32)))'), Error, mismatchError("i32", "void"));
assertErrorMessage(() => wasmEvalText('(module (func (result i32) (nop)))'), Error, mismatchError("i32", "void"));
wasmEvalText('(module (func (nop)))');
wasmEvalText('(module (func (result i32) (i32.const 42)))');
wasmEvalText('(module (func (param i32)))');
wasmEvalText('(module (func (param i32) (result i32) (i32.const 42)))');
wasmEvalText('(module (func (result i32) (param i32) (i32.const 42)))');

View File

@ -0,0 +1,33 @@
load(libdir + "wasm.js");
if (!this.wasmEval)
quit();
// MagicNumber = 0x4d534100
var magic0 = 0;
var magic1 = 97; // 'a'
var magic2 = 115; // 's'
var magic3 = 109; // 'm'
// EncodingVersion = -1
var ver0 = 0xff;
var ver1 = 0xff;
var ver2 = 0xff;
var ver3 = 0xff;
var magicError = /failed to match magic number/;
var versionError = /failed to match binary version/;
var extraError = /failed to consume all bytes of module/;
assertErrorMessage(() => wasmEval(Uint8Array.of().buffer), Error, magicError);
assertErrorMessage(() => wasmEval(Uint8Array.of(42).buffer), Error, magicError);
assertErrorMessage(() => wasmEval(Uint8Array.of(magic0, magic1, magic2).buffer), Error, magicError);
assertErrorMessage(() => wasmEval(Uint8Array.of(1,2,3,4).buffer), Error, magicError);
assertErrorMessage(() => wasmEval(Uint8Array.of(magic0, magic1, magic2, magic3).buffer), Error, versionError);
assertErrorMessage(() => wasmEval(Uint8Array.of(magic0, magic1, magic2, magic3, 1).buffer), Error, versionError);
assertErrorMessage(() => wasmEval(Uint8Array.of(magic0, magic1, magic2, magic3, ver0).buffer), Error, versionError);
assertErrorMessage(() => wasmEval(Uint8Array.of(magic0, magic1, magic2, magic3, ver0, ver1, ver2).buffer), Error, versionError);
assertErrorMessage(() => wasmEval(Uint8Array.of(magic0, magic1, magic2, magic3, ver0, ver1, ver2, ver3, 0, 1).buffer), Error, extraError);
var o = wasmEval(Uint8Array.of(magic0, magic1, magic2, magic3, ver0, ver1, ver2, ver3, 0).buffer);
assertEq(Object.getOwnPropertyNames(o).length, 0);

View File

@ -0,0 +1,15 @@
load(libdir + "wasm.js");
if (!this.wasmEval)
quit();
var parsingError = /parsing wasm text at/;
assertErrorMessage(() => wasmEvalText(""), Error, parsingError);
assertErrorMessage(() => wasmEvalText("("), Error, parsingError);
assertErrorMessage(() => wasmEvalText("(m"), Error, parsingError);
assertErrorMessage(() => wasmEvalText("(module"), Error, parsingError);
assertErrorMessage(() => wasmEvalText("(moduler"), Error, parsingError);
// Note: the s-expression text format is temporary, this file is mostly just to
// hold basic error smoke tests.

View File

@ -360,6 +360,10 @@ MSG_DEF(JSMSG_USE_ASM_TYPE_FAIL, 1, JSEXN_TYPEERR, "asm.js type error: {0}
MSG_DEF(JSMSG_USE_ASM_LINK_FAIL, 1, JSEXN_TYPEERR, "asm.js link error: {0}")
MSG_DEF(JSMSG_USE_ASM_TYPE_OK, 1, JSEXN_NONE, "Successfully compiled asm.js code ({0})")
// wasm
MSG_DEF(JSMSG_WASM_FAIL, 1, JSEXN_TYPEERR, "wasm error: {0}")
MSG_DEF(JSMSG_WASM_DECODE_FAIL, 2, JSEXN_TYPEERR, "wasm validation error at offset {0}: {1}")
// Proxy
MSG_DEF(JSMSG_BAD_TRAP_RETURN_VALUE, 2, JSEXN_TYPEERR,"trap {1} for {0} returned a primitive value")
MSG_DEF(JSMSG_CANT_CHANGE_EXTENSIBILITY, 0, JSEXN_TYPEERR, "can't change object's extensibility")

View File

@ -14,6 +14,7 @@
#include "mozilla/Assertions.h"
#include "mozilla/Compiler.h"
#include "mozilla/GuardObjects.h"
#include "mozilla/HashFunctions.h"
#include "mozilla/PodOperations.h"
#include <limits.h>
@ -134,6 +135,28 @@ ForEach(InputIterT begin, InputIterT end, CallableT f)
f(*begin);
}
template <class Container1, class Container2>
static inline bool
EqualContainers(const Container1& lhs, const Container2& rhs)
{
if (lhs.length() != rhs.length())
return false;
for (size_t i = 0, n = lhs.length(); i < n; i++) {
if (lhs[i] != rhs[i])
return false;
}
return true;
}
template <class Container>
static inline HashNumber
AddContainerToHash(const Container& c, HashNumber hn = 0)
{
for (size_t i = 0; i < c.length(); i++)
hn = mozilla::AddToHash(hn, HashNumber(c[i]));
return hn;
}
template <class T>
static inline T
Min(T t1, T t2)

View File

@ -144,12 +144,14 @@ EXPORTS.js += [
UNIFIED_SOURCES += [
'asmjs/AsmJS.cpp',
'asmjs/Wasm.cpp',
'asmjs/WasmFrameIterator.cpp',
'asmjs/WasmGenerator.cpp',
'asmjs/WasmIonCompile.cpp',
'asmjs/WasmModule.cpp',
'asmjs/WasmSignalHandlers.cpp',
'asmjs/WasmStubs.cpp',
'asmjs/WasmText.cpp',
'asmjs/WasmTypes.cpp',
'builtin/AtomicsObject.cpp',
'builtin/Eval.cpp',

View File

@ -273,12 +273,6 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared
void setNewOwnedData(FreeOp* fop, BufferContents newContents);
void changeContents(JSContext* cx, BufferContents newContents);
/*
* Ensure data is not stored inline in the object. Used when handing back a
* GC-safe pointer.
*/
static bool ensureNonInline(JSContext* cx, Handle<ArrayBufferObject*> buffer);
/* Neuter this buffer and all its views. */
static MOZ_WARN_UNUSED_RESULT bool
neuter(JSContext* cx, Handle<ArrayBufferObject*> buffer, BufferContents newContents);

View File

@ -33,7 +33,7 @@ static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 342;
static const uint32_t XDR_BYTECODE_VERSION =
uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND);
static_assert(JSErr_Limit == 438,
static_assert(JSErr_Limit == 440,
"GREETINGS, POTENTIAL SUBTRAHEND INCREMENTER! If you added or "
"removed MSG_DEFs from js.msg, you should increment "
"XDR_BYTECODE_VERSION_SUBTRAHEND and update this assertion's "

View File

@ -177,8 +177,11 @@ FrameLayerBuilder::DisplayItemData::EndUpdate(nsAutoPtr<nsDisplayItemGeometry> a
{
MOZ_RELEASE_ASSERT(mLayer);
MOZ_ASSERT(mItem);
MOZ_ASSERT(mGeometry || aGeometry);
mGeometry = aGeometry;
if (aGeometry) {
mGeometry = aGeometry;
}
mClip = mItem->GetClip();
mFrameListChanges.Clear();
@ -409,7 +412,6 @@ public:
PaintedLayerData() :
mAnimatedGeometryRoot(nullptr),
mScrollClip(nullptr),
mFixedPosFrameForLayerData(nullptr),
mReferenceFrame(nullptr),
mLayer(nullptr),
mSolidColor(NS_RGBA(0, 0, 0, 0)),
@ -554,7 +556,6 @@ public:
* metadata for this layer. This can be a position:fixed frame or a viewport
* frame; the latter case is used for background-attachment:fixed content.
*/
const nsIFrame* mFixedPosFrameForLayerData;
const nsIFrame* mReferenceFrame;
PaintedLayer* mLayer;
/**
@ -671,7 +672,6 @@ struct NewLayerEntry {
NewLayerEntry()
: mAnimatedGeometryRoot(nullptr)
, mScrollClip(nullptr)
, mFixedPosFrameForLayerData(nullptr)
, mLayerContentsVisibleRect(0, 0, -1, -1)
, mLayerState(LAYER_INACTIVE)
, mHideAllLayersBelow(false)
@ -686,7 +686,6 @@ struct NewLayerEntry {
RefPtr<Layer> mLayer;
AnimatedGeometryRoot* mAnimatedGeometryRoot;
const DisplayItemScrollClip* mScrollClip;
const nsIFrame* mFixedPosFrameForLayerData;
// If non-null, this FrameMetrics is set to the be the first FrameMetrics
// on the layer.
UniquePtr<FrameMetrics> mBaseFrameMetrics;
@ -1078,10 +1077,6 @@ public:
MOZ_ASSERT(!mBuilder->IsPaintingToWindow() ||
nsLayoutUtils::IsAncestorFrameCrossDoc(mBuilder->RootReferenceFrame(),
*mContainerAnimatedGeometryRoot));
NS_ASSERTION(!aContainerItem || !aContainerItem->ShouldFixToViewport(mBuilder),
"Container items never return true for ShouldFixToViewport");
mContainerFixedPosFrame =
FindFixedPosFrameForLayerData(mContainerAnimatedGeometryRoot, false);
// When AllowResidualTranslation is false, display items will be drawn
// scaled with a translation by integer pixels, so we know how the snapping
// will work.
@ -1281,24 +1276,6 @@ protected:
*/
void InvalidateForLayerChange(nsDisplayItem* aItem,
PaintedLayer* aNewLayer);
/**
* Find the fixed-pos frame, if any, containing (or equal to)
* aAnimatedGeometryRoot. Only return a fixed-pos frame if its viewport
* has a displayport.
* aDisplayItemFixedToViewport is true if the layer contains a single display
* item which returned true for ShouldFixToViewport.
* This can return the actual viewport frame for layers whose display items
* are directly on the viewport (e.g. background-attachment:fixed backgrounds).
*/
const nsIFrame* FindFixedPosFrameForLayerData(AnimatedGeometryRoot* aAnimatedGeometryRoot,
bool aDisplayItemFixedToViewport);
/**
* Set fixed-pos layer metadata on aLayer according to the data for aFixedPosFrame.
*/
void SetFixedPositionLayerData(Layer* aLayer,
const nsIFrame* aFixedPosFrame,
bool aIsClipFixed);
/**
* Returns true if aItem's opaque area (in aOpaque) covers the entire
* scrollable area of its presshell.
@ -1331,7 +1308,6 @@ protected:
*/
nsIntRegion ComputeOpaqueRect(nsDisplayItem* aItem,
AnimatedGeometryRoot* aAnimatedGeometryRoot,
const nsIFrame* aFixedPosFrame,
const DisplayItemClip& aClip,
nsDisplayList* aList,
bool* aHideAllLayersBelow,
@ -1386,7 +1362,6 @@ protected:
nsIFrame* mContainerFrame;
nsIFrame* mContainerReferenceFrame;
AnimatedGeometryRoot* mContainerAnimatedGeometryRoot;
const nsIFrame* mContainerFixedPosFrame;
ContainerLayer* mContainerLayer;
nsRect mContainerBounds;
const DisplayItemScrollClip* mContainerScrollClip;
@ -1977,8 +1952,8 @@ FrameLayerBuilder::GetDebugOldLayerFor(nsIFrame* aFrame, uint32_t aDisplayItemKe
return nullptr;
}
/* static */ Layer*
FrameLayerBuilder::GetDebugSingleOldLayerForFrame(nsIFrame* aFrame)
/* static */ PaintedLayer*
FrameLayerBuilder::GetDebugSingleOldPaintedLayerForFrame(nsIFrame* aFrame)
{
const nsTArray<DisplayItemData*>* array =
static_cast<nsTArray<DisplayItemData*>*>(aFrame->Properties().Get(LayerManagerDataProperty()));
@ -1990,13 +1965,16 @@ FrameLayerBuilder::GetDebugSingleOldLayerForFrame(nsIFrame* aFrame)
Layer* layer = nullptr;
for (DisplayItemData* data : *array) {
AssertDisplayItemData(data);
if (!data->mLayer->AsPaintedLayer()) {
continue;
}
if (layer && layer != data->mLayer) {
// More than one layer assigned, bail.
return nullptr;
}
layer = data->mLayer;
}
return layer;
return layer->AsPaintedLayer();
}
already_AddRefed<ColorLayer>
@ -2983,77 +2961,6 @@ PaintedLayerDataTree::FindNodeForAncestorAnimatedGeometryRoot(AnimatedGeometryRo
return FindNodeForAncestorAnimatedGeometryRoot(aAnimatedGeometryRoot->mParentAGR, aOutAncestorChild);
}
const nsIFrame*
ContainerState::FindFixedPosFrameForLayerData(AnimatedGeometryRoot* aAnimatedGeometryRoot,
bool aDisplayItemFixedToViewport)
{
if (!mManager->IsWidgetLayerManager()) {
// Never attach any fixed-pos metadata to inactive layers, it's pointless!
return nullptr;
}
nsPresContext* presContext = mContainerFrame->PresContext();
nsIFrame* viewport = presContext->PresShell()->GetRootFrame();
if (viewport == *aAnimatedGeometryRoot && aDisplayItemFixedToViewport &&
nsLayoutUtils::ViewportHasDisplayPort(presContext)) {
// Probably a background-attachment:fixed item
return viewport;
}
// Viewports with no fixed-pos frames are not relevant.
if (!viewport->GetChildList(nsIFrame::kFixedList).FirstChild()) {
return nullptr;
}
for (const nsIFrame* f = *aAnimatedGeometryRoot; f; f = f->GetParent()) {
if (nsLayoutUtils::IsFixedPosFrameInDisplayPort(f)) {
return f;
}
if (f == mContainerReferenceFrame) {
// The metadata will go on an ancestor layer if necessary.
return nullptr;
}
}
return nullptr;
}
void
ContainerState::SetFixedPositionLayerData(Layer* aLayer,
const nsIFrame* aFixedPosFrame,
bool aIsClipFixed)
{
aLayer->SetIsFixedPosition(aFixedPosFrame != nullptr);
if (!aFixedPosFrame) {
return;
}
nsPresContext* presContext = aFixedPosFrame->PresContext();
const nsIFrame* viewportFrame = aFixedPosFrame->GetParent();
// anchorRect will be in the container's coordinate system (aLayer's parent layer).
// This is the same as the display items' reference frame.
nsRect anchorRect;
if (viewportFrame) {
// Fixed position frames are reflowed into the scroll-port size if one has
// been set.
if (presContext->PresShell()->IsScrollPositionClampingScrollPortSizeSet()) {
anchorRect.SizeTo(presContext->PresShell()->GetScrollPositionClampingScrollPortSize());
} else {
anchorRect.SizeTo(viewportFrame->GetSize());
}
} else {
// A display item directly attached to the viewport.
// For background-attachment:fixed items, the anchor point is always the
// top-left of the viewport currently.
viewportFrame = aFixedPosFrame;
}
// The anchorRect top-left is always the viewport top-left.
anchorRect.MoveTo(viewportFrame->GetOffsetToCrossDoc(mContainerReferenceFrame));
nsLayoutUtils::SetFixedPositionLayerData(aLayer,
viewportFrame, anchorRect, aFixedPosFrame, presContext, mParameters,
aIsClipFixed);
}
static bool
CanOptimizeAwayPaintedLayer(PaintedLayerData* aData,
FrameLayerBuilder* aLayerBuilder)
@ -3207,7 +3114,6 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB
newLayerEntry->mLayer = layer;
newLayerEntry->mAnimatedGeometryRoot = data->mAnimatedGeometryRoot;
newLayerEntry->mScrollClip = data->mScrollClip;
newLayerEntry->mFixedPosFrameForLayerData = data->mFixedPosFrameForLayerData;
newLayerEntry->mIsCaret = data->mIsCaret;
// Hide the PaintedLayer. We leave it in the layer tree so that we
@ -3346,9 +3252,6 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB
}
layer->SetContentFlags(flags);
SetFixedPositionLayerData(layer, data->mFixedPosFrameForLayerData,
!data->mSingleItemFixedToViewport);
PaintedLayerData* containingPaintedLayerData =
mLayerBuilder->GetContainingPaintedLayerData();
if (containingPaintedLayerData) {
@ -3620,8 +3523,6 @@ ContainerState::NewPaintedLayerData(nsDisplayItem* aItem,
data.mAnimatedGeometryRoot = aAnimatedGeometryRoot;
data.mScrollClip = aScrollClip;
data.mAnimatedGeometryRootOffset = aTopLeft;
data.mFixedPosFrameForLayerData =
FindFixedPosFrameForLayerData(aAnimatedGeometryRoot, aShouldFixToViewport);
data.mReferenceFrame = aItem->ReferenceFrame();
data.mSingleItemFixedToViewport = aShouldFixToViewport;
data.mBackfaceHidden = aItem->Frame()->BackfaceIsHidden();
@ -3631,7 +3532,6 @@ ContainerState::NewPaintedLayerData(nsDisplayItem* aItem,
NewLayerEntry* newLayerEntry = mNewChildLayers.AppendElement();
newLayerEntry->mAnimatedGeometryRoot = aAnimatedGeometryRoot;
newLayerEntry->mScrollClip = aScrollClip;
newLayerEntry->mFixedPosFrameForLayerData = data.mFixedPosFrameForLayerData;
newLayerEntry->mIsCaret = data.mIsCaret;
// newLayerEntry->mOpaqueRegion is filled in later from
// paintedLayerData->mOpaqueRegion, if necessary.
@ -3743,7 +3643,6 @@ ContainerState::ChooseAnimatedGeometryRoot(const nsDisplayList& aList,
nsIntRegion
ContainerState::ComputeOpaqueRect(nsDisplayItem* aItem,
AnimatedGeometryRoot* aAnimatedGeometryRoot,
const nsIFrame* aFixedPosFrame,
const DisplayItemClip& aClip,
nsDisplayList* aList,
bool* aHideAllLayersBelow,
@ -3759,7 +3658,6 @@ ContainerState::ComputeOpaqueRect(nsDisplayItem* aItem,
opaqueClipped.Or(opaqueClipped, aClip.ApproximateIntersectInward(*r));
}
if (aAnimatedGeometryRoot == mContainerAnimatedGeometryRoot &&
aFixedPosFrame == mContainerFixedPosFrame &&
opaqueClipped.Contains(mContainerBounds)) {
*aHideAllLayersBelow = true;
aList->SetIsOpaque();
@ -4130,10 +4028,6 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
~Layer::CONTENT_BACKFACE_HIDDEN);
}
const nsIFrame* fixedPosFrame =
FindFixedPosFrameForLayerData(animatedGeometryRoot, shouldFixToViewport);
SetFixedPositionLayerData(ownLayer, fixedPosFrame, !shouldFixToViewport);
nsRect invalid;
if (item->IsInvalid(invalid)) {
ownLayer->SetInvalidRectToVisibleRegion();
@ -4177,7 +4071,6 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
newLayerEntry->mLayer = ownLayer;
newLayerEntry->mAnimatedGeometryRoot = animatedGeometryRoot;
newLayerEntry->mScrollClip = agrScrollClip;
newLayerEntry->mFixedPosFrameForLayerData = fixedPosFrame;
newLayerEntry->mLayerState = layerState;
if (itemType == nsDisplayItem::TYPE_PERSPECTIVE) {
newLayerEntry->mIsPerspectiveItem = true;
@ -4212,7 +4105,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
newLayerEntry->mVisibleRegion = itemVisibleRect;
}
newLayerEntry->mOpaqueRegion = ComputeOpaqueRect(item,
animatedGeometryRoot, fixedPosFrame, layerClip, aList,
animatedGeometryRoot, layerClip, aList,
&newLayerEntry->mHideAllLayersBelow,
&newLayerEntry->mOpaqueForAnimatedGeometryRootParent);
} else {
@ -4247,11 +4140,10 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
*/
mLayerBuilder->AddLayerDisplayItem(ownLayer, item, layerState, nullptr);
} else {
bool forceOwnLayer = shouldFixToViewport;
bool avoidCreatingLayer = (maxLayers != -1 && layerCount >= maxLayers);
PaintedLayerData* paintedLayerData =
mPaintedLayerDataTree.FindPaintedLayerFor(animatedGeometryRoot, agrScrollClip,
itemVisibleRect, forceOwnLayer,
itemVisibleRect, false,
item->Frame()->BackfaceIsHidden(),
avoidCreatingLayer,
[&]() {
@ -4271,8 +4163,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
paintedLayerData->UpdateCommonClipCount(itemClip);
}
nsIntRegion opaquePixels = ComputeOpaqueRect(item,
animatedGeometryRoot, paintedLayerData->mFixedPosFrameForLayerData,
itemClip, aList,
animatedGeometryRoot, itemClip, aList,
&paintedLayerData->mHideAllLayersBelow,
&paintedLayerData->mOpaqueForAnimatedGeometryRootParent);
MOZ_ASSERT(nsIntRegion(itemDrawRect).Contains(opaquePixels));
@ -4356,7 +4247,7 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData)
PaintedLayerItemsEntry* entry = mPaintedLayerItems.GetEntry(paintedLayer);
nsAutoPtr<nsDisplayItemGeometry> geometry(item->AllocateGeometry(mDisplayListBuilder));
nsAutoPtr<nsDisplayItemGeometry> geometry;
PaintedDisplayItemLayerUserData* layerData =
static_cast<PaintedDisplayItemLayerUserData*>(aData->mLayer->GetUserData(&gPaintedDisplayItemLayerUserData));
@ -4364,7 +4255,7 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData)
const DisplayItemClip& clip = item->GetClip();
// If the frame is marked as invalidated, and didn't specify a rect to invalidate then we want to
// If the frame is marked as invalidated, and didn't specify a rect to invalidate then we want to
// invalidate both the old and new bounds, otherwise we only want to invalidate the changed areas.
// If we do get an invalid rect, then we want to add this on top of the change areas.
nsRect invalid;
@ -4372,7 +4263,7 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData)
bool notifyRenderingChanged = true;
if (!aData->mGeometry) {
// This item is being added for the first time, invalidate its entire area.
//TODO: We call GetGeometry again in AddPaintedDisplayItem, we should reuse this.
geometry = item->AllocateGeometry(mDisplayListBuilder);
combined = clip.ApplyNonRoundedIntersection(geometry->ComputeInvalidationRegion());
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
@ -4380,7 +4271,8 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData)
}
#endif
} else if (aData->mIsInvalid || (item->IsInvalid(invalid) && invalid.IsEmpty())) {
// Either layout marked item as needing repainting, invalidate the entire old and new areas.
// Layout marked item/frame as needing repainting (without an explicit rect), invalidate the entire old and new areas.
geometry = item->AllocateGeometry(mDisplayListBuilder);
combined = aData->mClip.ApplyNonRoundedIntersection(aData->mGeometry->ComputeInvalidationRegion());
combined.MoveBy(shift);
combined.Or(combined, clip.ApplyNonRoundedIntersection(geometry->ComputeInvalidationRegion()));
@ -4394,8 +4286,10 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData)
// repainted.
const nsTArray<nsIFrame*>& changedFrames = aData->GetFrameListChanges();
aData->mGeometry->MoveBy(shift);
item->ComputeInvalidationRegion(mDisplayListBuilder, aData->mGeometry, &combined);
// We have an optimization to cache the drawing background-attachment: fixed canvas
// We have an optimization to cache the drawing of background-attachment: fixed canvas
// background images so we can scroll and just blit them when they are flattened into
// the same layer as scrolling content. NotifyRenderingChanged is only used to tell
// the canvas bg image item to purge this cache. We want to be careful not to accidentally
@ -4404,16 +4298,16 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData)
// AddOffsetAndComputeDifference is the only thing that will invalidate we skip the
// NotifyRenderingChanged call (ComputeInvalidationRegion for background images also calls
// NotifyRenderingChanged if anything changes).
if (aData->mGeometry->ComputeInvalidationRegion() == geometry->ComputeInvalidationRegion() &&
aData->mClip == clip && invalid.IsEmpty() && changedFrames.Length() == 0) {
if (!combined.IsEmpty()) {
geometry = item->AllocateGeometry(mDisplayListBuilder);
} else if (aData->mClip == clip && invalid.IsEmpty() && changedFrames.Length() == 0) {
notifyRenderingChanged = false;
}
aData->mGeometry->MoveBy(shift);
item->ComputeInvalidationRegion(mDisplayListBuilder, aData->mGeometry, &combined);
aData->mClip.AddOffsetAndComputeDifference(entry->mCommonClipCount,
shift, aData->mGeometry->ComputeInvalidationRegion(),
clip, entry->mLastCommonClipCount, geometry->ComputeInvalidationRegion(),
clip, entry->mLastCommonClipCount,
geometry ? geometry->ComputeInvalidationRegion() :
aData->mGeometry->ComputeInvalidationRegion(),
&combined);
// Add in any rect that the frame specified
@ -4748,19 +4642,16 @@ ContainerState::CollectOldLayers()
struct OpaqueRegionEntry {
AnimatedGeometryRoot* mAnimatedGeometryRoot;
const nsIFrame* mFixedPosFrameForLayerData;
nsIntRegion mOpaqueRegion;
};
static OpaqueRegionEntry*
FindOpaqueRegionEntry(nsTArray<OpaqueRegionEntry>& aEntries,
AnimatedGeometryRoot* aAnimatedGeometryRoot,
const nsIFrame* aFixedPosFrameForLayerData)
AnimatedGeometryRoot* aAnimatedGeometryRoot)
{
for (uint32_t i = 0; i < aEntries.Length(); ++i) {
OpaqueRegionEntry* d = &aEntries[i];
if (d->mAnimatedGeometryRoot == aAnimatedGeometryRoot &&
d->mFixedPosFrameForLayerData == aFixedPosFrameForLayerData) {
if (d->mAnimatedGeometryRoot == aAnimatedGeometryRoot) {
return d;
}
}
@ -4898,8 +4789,7 @@ ContainerState::PostprocessRetainedLayers(nsIntRegion* aOpaqueRegionForContainer
// entry, the entry for mContainerAnimatedGeometryRoot.
AnimatedGeometryRoot* animatedGeometryRootForOpaqueness =
mFlattenToSingleLayer ? mContainerAnimatedGeometryRoot : e->mAnimatedGeometryRoot;
OpaqueRegionEntry* data = FindOpaqueRegionEntry(opaqueRegions,
animatedGeometryRootForOpaqueness, e->mFixedPosFrameForLayerData);
OpaqueRegionEntry* data = FindOpaqueRegionEntry(opaqueRegions, animatedGeometryRootForOpaqueness);
SetupScrollingMetadata(e);
@ -4930,19 +4820,16 @@ ContainerState::PostprocessRetainedLayers(nsIntRegion* aOpaqueRegionForContainer
if (e->mOpaqueForAnimatedGeometryRootParent &&
e->mAnimatedGeometryRoot->mParentAGR == mContainerAnimatedGeometryRoot) {
animatedGeometryRootToCover = mContainerAnimatedGeometryRoot;
data = FindOpaqueRegionEntry(opaqueRegions,
animatedGeometryRootToCover, e->mFixedPosFrameForLayerData);
data = FindOpaqueRegionEntry(opaqueRegions, animatedGeometryRootToCover);
}
if (!data) {
if (animatedGeometryRootToCover == mContainerAnimatedGeometryRoot &&
e->mFixedPosFrameForLayerData == mContainerFixedPosFrame) {
if (animatedGeometryRootToCover == mContainerAnimatedGeometryRoot) {
NS_ASSERTION(opaqueRegionForContainer == -1, "Already found it?");
opaqueRegionForContainer = opaqueRegions.Length();
}
data = opaqueRegions.AppendElement();
data->mAnimatedGeometryRoot = animatedGeometryRootToCover;
data->mFixedPosFrameForLayerData = e->mFixedPosFrameForLayerData;
}
nsIntRegion clippedOpaque = e->mOpaqueRegion;

View File

@ -358,7 +358,7 @@ public:
* frame's display items (i.e. zero, or more than one).
* This function is for testing purposes and not performance sensitive.
*/
static Layer* GetDebugSingleOldLayerForFrame(nsIFrame* aFrame);
static PaintedLayer* GetDebugSingleOldPaintedLayerForFrame(nsIFrame* aFrame);
/**
* Destroy any stored LayerManagerDataProperty and the associated data for

View File

@ -48,6 +48,9 @@ ZoomConstraintsClient::~ZoomConstraintsClient()
static nsIWidget*
GetWidget(nsIPresShell* aShell)
{
if (!aShell) {
return nullptr;
}
if (nsIFrame* rootFrame = aShell->GetRootFrame()) {
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_UIKIT)
return rootFrame->GetNearestWidget();

View File

@ -25,6 +25,7 @@ DECLARE_DISPLAY_ITEM_TYPE(COMBOBOX_FOCUS)
DECLARE_DISPLAY_ITEM_TYPE(EVENT_RECEIVER)
DECLARE_DISPLAY_ITEM_TYPE(LAYER_EVENT_REGIONS)
DECLARE_DISPLAY_ITEM_TYPE(FIELDSET_BORDER_BACKGROUND)
DECLARE_DISPLAY_ITEM_TYPE(FIXED_POSITION)
DECLARE_DISPLAY_ITEM_TYPE(STICKY_POSITION)
DECLARE_DISPLAY_ITEM_TYPE(FRAMESET_BORDER)
DECLARE_DISPLAY_ITEM_TYPE(FRAMESET_BLANK)

View File

@ -2245,7 +2245,6 @@ nsDisplayBackgroundImage::nsDisplayBackgroundImage(nsDisplayListBuilder* aBuilde
const nsStyleBackground* aBackgroundStyle)
: nsDisplayImageContainer(aBuilder, aFrame)
, mBackgroundStyle(aBackgroundStyle)
, mAnimatedGeometryRootForScrollMetadata(mAnimatedGeometryRoot)
, mLayer(aLayer)
{
MOZ_COUNT_CTOR(nsDisplayBackgroundImage);
@ -2432,7 +2431,13 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
nsDisplayBackgroundImage* bgItem =
new (aBuilder) nsDisplayBackgroundImage(aBuilder, aFrame, i, bg);
bgItemList.AppendNewToTop(bgItem);
if (bgItem->ShouldFixToViewport(aBuilder)) {
bgItemList.AppendNewToTop(
nsDisplayFixedPosition::CreateForFixedBackground(aBuilder, aFrame, bgItem, i));
} else {
bgItemList.AppendNewToTop(bgItem);
}
}
if (needBlendContainer) {
@ -2996,6 +3001,13 @@ nsDisplayBackgroundImage::GetPerFrameKey()
nsDisplayItem::GetPerFrameKey();
}
void
nsDisplayBackgroundImage::MarkBoundsAsVisible(nsDisplayListBuilder* aBuilder)
{
bool snap;
mVisibleRect = GetBounds(aBuilder, &snap);
}
nsDisplayThemedBackground::nsDisplayThemedBackground(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame)
: nsDisplayItem(aBuilder, aFrame)
@ -4624,6 +4636,117 @@ nsDisplayResolution::BuildLayer(nsDisplayListBuilder* aBuilder,
return layer.forget();
}
nsDisplayFixedPosition::nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
nsDisplayList* aList)
: nsDisplayOwnLayer(aBuilder, aFrame, aList)
, mIndex(0)
, mIsFixedBackground(false)
{
MOZ_COUNT_CTOR(nsDisplayFixedPosition);
Init(aBuilder);
}
nsDisplayFixedPosition::nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
nsDisplayList* aList,
uint32_t aIndex)
: nsDisplayOwnLayer(aBuilder, aFrame, aList)
, mIndex(aIndex)
, mIsFixedBackground(true)
{
MOZ_COUNT_CTOR(nsDisplayFixedPosition);
Init(aBuilder);
}
void
nsDisplayFixedPosition::Init(nsDisplayListBuilder* aBuilder)
{
bool snap;
mVisibleRect = GetBounds(aBuilder, &snap);
mAnimatedGeometryRootForScrollMetadata = mAnimatedGeometryRoot;
if (ShouldFixToViewport(aBuilder)) {
mAnimatedGeometryRoot = aBuilder->FindAnimatedGeometryRootFor(this);
}
}
/* static */ nsDisplayFixedPosition*
nsDisplayFixedPosition::CreateForFixedBackground(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
nsDisplayBackgroundImage* aImage,
uint32_t aIndex)
{
// Clear clipping on the child item, since we will apply it to the
// fixed position item as well.
aImage->SetClip(aBuilder, DisplayItemClip());
aImage->SetScrollClip(nullptr);
aImage->MarkBoundsAsVisible(aBuilder);
nsDisplayList temp;
temp.AppendToTop(aImage);
return new (aBuilder) nsDisplayFixedPosition(aBuilder, aFrame, &temp, aIndex + 1);
}
#ifdef NS_BUILD_REFCNT_LOGGING
nsDisplayFixedPosition::~nsDisplayFixedPosition() {
MOZ_COUNT_DTOR(nsDisplayFixedPosition);
}
#endif
already_AddRefed<Layer>
nsDisplayFixedPosition::BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerLayerParameters& aContainerParameters) {
RefPtr<Layer> layer =
nsDisplayOwnLayer::BuildLayer(aBuilder, aManager, aContainerParameters);
layer->SetIsFixedPosition(true);
nsPresContext* presContext = Frame()->PresContext();
nsIFrame* fixedFrame = mIsFixedBackground ? presContext->PresShell()->GetRootFrame() : Frame();
const nsIFrame* viewportFrame = fixedFrame->GetParent();
// anchorRect will be in the container's coordinate system (aLayer's parent layer).
// This is the same as the display items' reference frame.
nsRect anchorRect;
if (viewportFrame) {
// Fixed position frames are reflowed into the scroll-port size if one has
// been set.
if (presContext->PresShell()->IsScrollPositionClampingScrollPortSizeSet()) {
anchorRect.SizeTo(presContext->PresShell()->GetScrollPositionClampingScrollPortSize());
} else {
anchorRect.SizeTo(viewportFrame->GetSize());
}
} else {
// A display item directly attached to the viewport.
// For background-attachment:fixed items, the anchor point is always the
// top-left of the viewport currently.
viewportFrame = fixedFrame;
}
// The anchorRect top-left is always the viewport top-left.
anchorRect.MoveTo(viewportFrame->GetOffsetToCrossDoc(ReferenceFrame()));
nsLayoutUtils::SetFixedPositionLayerData(layer,
viewportFrame, anchorRect, fixedFrame, presContext, aContainerParameters, !mIsFixedBackground);
return layer.forget();
}
bool nsDisplayFixedPosition::TryMerge(nsDisplayItem* aItem) {
if (aItem->GetType() != TYPE_FIXED_POSITION)
return false;
// Items with the same fixed position frame can be merged.
nsDisplayFixedPosition* other = static_cast<nsDisplayFixedPosition*>(aItem);
if (other->mFrame != mFrame)
return false;
if (aItem->GetClip() != GetClip())
return false;
MergeFromTrackingMergedFrames(other);
return true;
}
nsDisplayStickyPosition::nsDisplayStickyPosition(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
nsDisplayList* aList)

View File

@ -1154,6 +1154,7 @@ private:
friend class nsDisplayCanvasBackgroundImage;
friend class nsDisplayBackgroundImage;
friend class nsDisplayFixedPosition;
AnimatedGeometryRoot* FindAnimatedGeometryRootFor(nsDisplayItem* aItem);
AnimatedGeometryRoot* WrapAGRForFrame(nsIFrame* aAnimatedGeometryRoot,
@ -2747,9 +2748,7 @@ public:
virtual bool ShouldFixToViewport(nsDisplayListBuilder* aBuilder) override;
AnimatedGeometryRoot* AnimatedGeometryRootForScrollMetadata() const override {
return mAnimatedGeometryRootForScrollMetadata;
}
void MarkBoundsAsVisible(nsDisplayListBuilder* aBuilder);
protected:
typedef class mozilla::layers::ImageContainer ImageContainer;
@ -2782,7 +2781,6 @@ protected:
nsCOMPtr<imgIContainer> mImage;
RefPtr<ImageContainer> mImageContainer;
LayoutDeviceRect mImageLayerDestRect;
AnimatedGeometryRoot* mAnimatedGeometryRootForScrollMetadata;
/* Bounds of this display item */
nsRect mBounds;
nsRect mDestArea;
@ -3619,6 +3617,52 @@ public:
virtual bool TryMerge(nsDisplayItem* aItem) override;
};
class nsDisplayFixedPosition : public nsDisplayOwnLayer {
public:
nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
nsDisplayList* aList);
static nsDisplayFixedPosition* CreateForFixedBackground(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
nsDisplayBackgroundImage* aImage,
uint32_t aIndex);
#ifdef NS_BUILD_REFCNT_LOGGING
virtual ~nsDisplayFixedPosition();
#endif
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerLayerParameters& aContainerParameters) override;
NS_DISPLAY_DECL_NAME("FixedPosition", TYPE_FIXED_POSITION)
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerLayerParameters& aParameters) override
{
return mozilla::LAYER_ACTIVE;
}
virtual bool TryMerge(nsDisplayItem* aItem) override;
virtual bool ShouldFixToViewport(nsDisplayListBuilder* aBuilder) override { return mIsFixedBackground; }
virtual uint32_t GetPerFrameKey() override { return (mIndex << nsDisplayItem::TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); }
AnimatedGeometryRoot* AnimatedGeometryRootForScrollMetadata() const override {
return mAnimatedGeometryRootForScrollMetadata;
}
private:
// For background-attachment:fixed
nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
nsDisplayList* aList, uint32_t aIndex);
void Init(nsDisplayListBuilder* aBuilder);
AnimatedGeometryRoot* mAnimatedGeometryRootForScrollMetadata;
uint32_t mIndex;
bool mIsFixedBackground;
};
/**
* This creates an empty scrollable layer. It has no child layers.
* It is used to record the existence of a scrollable frame in the layer

View File

@ -167,10 +167,6 @@ PrintDisplayItemTo(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
aStream << nsPrintfCString(" (opaque %d,%d,%d,%d)", r->x, r->y, r->width, r->height);
}
if (aItem->ShouldFixToViewport(aBuilder)) {
aStream << " fixed";
}
if (aItem->Frame()->StyleDisplay()->mWillChange.Length() > 0) {
aStream << " (will-change=";
for (size_t i = 0; i < aItem->Frame()->StyleDisplay()->mWillChange.Length(); i++) {

View File

@ -417,8 +417,14 @@ nsCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
if (bg->mLayers[i].mBlendMode != NS_STYLE_BLEND_NORMAL) {
needBlendContainer = true;
}
aLists.BorderBackground()->AppendNewToTop(
new (aBuilder) nsDisplayCanvasBackgroundImage(aBuilder, this, i, bg));
nsDisplayCanvasBackgroundImage* bgItem =
new (aBuilder) nsDisplayCanvasBackgroundImage(aBuilder, this, i, bg);
if (bgItem->ShouldFixToViewport(aBuilder)) {
aLists.BorderBackground()->AppendNewToTop(
nsDisplayFixedPosition::CreateForFixedBackground(aBuilder, this, bgItem, i));
} else {
aLists.BorderBackground()->AppendNewToTop(bgItem);
}
}
if (needBlendContainer) {

View File

@ -2043,6 +2043,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
nsLayoutUtils::GetNearestScrollableFrame(GetParent(),
nsLayoutUtils::SCROLLABLE_SAME_DOC |
nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN));
bool useFixedPosition = nsLayoutUtils::IsFixedPosFrameInDisplayPort(this);
nsDisplayListBuilder::AutoBuildingDisplayList
buildingDisplayList(aBuilder, this, dirtyRect, true);
@ -2056,7 +2057,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
nsDisplayListBuilder::AutoSaveRestorePerspectiveIndex perspectiveIndex(aBuilder, this);
if (isTransformed || useBlendMode || usingSVGEffects || useStickyPosition) {
if (isTransformed || useBlendMode || usingSVGEffects || useFixedPosition || useStickyPosition) {
// We don't need to pass ancestor clipping down to our children;
// everything goes inside a display item's child list, and the display
// item itself will be clipped.
@ -2273,7 +2274,10 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
/* If we have sticky positioning, wrap it in a sticky position item.
*/
if (useStickyPosition) {
if (useFixedPosition) {
resultList.AppendNewToTop(
new (aBuilder) nsDisplayFixedPosition(aBuilder, this, &resultList));
} else if (useStickyPosition) {
resultList.AppendNewToTop(
new (aBuilder) nsDisplayStickyPosition(aBuilder, this, &resultList));
}

View File

@ -57,7 +57,7 @@ RESOURCE_FILES.fonts += [
'mathfontUnicode.properties',
]
if CONFIG['TARGET_MD_ARCH'] == 'win32':
if CONFIG['OS_TARGET'] == 'WINNT':
RESOURCE_FILES.fonts += [
'mathfontSymbol.properties',
]

View File

@ -1,7 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<input type="text" disabled>
<input type="text" disabled
style="-moz-appearance: none"><!-- Workaround for bug 1223198 -->
<!-- div to cover spin box area -->
<div style="display:block; position:absolute; background-color:black; width:200px; height:100px; top:0px; left:100px;">
</body>

View File

@ -1,7 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<input type="number" disabled>
<input type="number" disabled
style="-moz-appearance: none"><!-- Workaround for bug 1223198 -->
<!-- div to cover spin box area -->
<div style="display:block; position:absolute; background-color:black; width:200px; height:100px; top:0px; left:100px;">
</body>

View File

@ -112,7 +112,7 @@ MP4Metadata::~MP4Metadata()
#ifdef MOZ_RUST_MP4PARSE
// Helper to test the rust parser on a data source.
static bool try_rust(const UniquePtr<mp4parse_state, FreeMP4ParseState>& aRustState, RefPtr<Stream> aSource)
static int32_t try_rust(const UniquePtr<mp4parse_state, FreeMP4ParseState>& aRustState, RefPtr<Stream> aSource)
{
static LazyLogModule sLog("MP4Metadata");
int64_t length;

View File

@ -124,7 +124,7 @@ pub unsafe extern "C" fn mp4parse_read(context: *mut MediaContext, buffer: *cons
// result in an Ok(..) otherwise, meaning we could see
// Ok(Err(Error::..)) here. So map thread failures back
// to an mp4parse::Error before converting to a C return value.
match task.join().or(Err(Error::AssertCaught)) {
match task.join().unwrap_or(Err(Error::AssertCaught)) {
Ok(_) => MP4PARSE_OK,
Err(Error::InvalidData) => MP4PARSE_ERROR_INVALID,
Err(Error::Unsupported) => MP4PARSE_ERROR_UNSUPPORTED,

View File

@ -59,6 +59,3 @@ if CONFIG['HOST_OS_ARCH'] == 'WINNT':
]
HOST_DEFINES['NO_SIGN_VERIFY'] = True
if CONFIG['CROSS_COMPILE'] and CONFIG['HOST_NSPR_MDCPUCFG']:
HOST_DEFINES['MDCPUCFG'] = CONFIG['HOST_NSPR_MDCPUCFG']

View File

@ -473,7 +473,11 @@ nsSocketInputStream::AsyncWait(nsIInputStreamCallback *callback,
bool hasError = false;
{
MutexAutoLock lock(mTransport->mLock);
if (mTransport->mState != nsSocketTransport::STATE_TRANSFERRING && NS_FAILED(mCondition)) {
SOCKET_LOG(("nsSocketInputStream::AsyncWait [this=%p] "
"Not Transferring %X.\n", mTransport, mCondition));
return NS_OK;
}
if (callback && target) {
//
// build event proxy
@ -707,7 +711,12 @@ nsSocketOutputStream::AsyncWait(nsIOutputStreamCallback *callback,
{
MutexAutoLock lock(mTransport->mLock);
if (mTransport->mState != nsSocketTransport::STATE_TRANSFERRING && NS_FAILED(mCondition)) {
// do not take the callback reference if we will not call onOutputReady
SOCKET_LOG(("nsSocketOutputStream::AsyncWait [this=%p] mTransport=%p "
"Not Transferring %X.\n",this, mTransport, mCondition));
return NS_OK;
}
if (callback && target) {
//
// build event proxy

View File

@ -187,7 +187,6 @@ private:
enum {
STATE_CLOSED,
STATE_IDLE,
STATE_RESOLVING,
STATE_CONNECTING,
STATE_TRANSFERRING

View File

@ -96,11 +96,11 @@ struct PLArenaPool {
/* These definitions are usually provided through the
* sanitizer/asan_interface.h header installed by ASan.
* See https://code.google.com/p/address-sanitizer/wiki/ManualPoisoning
* See https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning
*/
void __asan_poison_memory_region(void const volatile *addr, size_t size);
void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
PR_IMPORT(void) __asan_poison_memory_region(void const volatile *addr, size_t size);
PR_IMPORT(void) __asan_unpoison_memory_region(void const volatile *addr, size_t size);
#define PL_MAKE_MEM_NOACCESS(addr, size) \
__asan_poison_memory_region((addr), (size))

View File

@ -2715,7 +2715,7 @@ static void* _MD_Unix_mmap64(
/* Android <= 19 doesn't have mmap64. */
#if defined(ANDROID) && __ANDROID_API__ <= 19
extern void *__mmap2(void *, size_t, int, int, int, size_t);
PR_IMPORT(void) *__mmap2(void *, size_t, int, int, int, size_t);
#define ANDROID_PAGE_SIZE 4096

View File

@ -8,6 +8,10 @@
*
*/
/* Mozilla's build system defines this globally. */
#ifdef WIN32_LEAN_AND_MEAN
#undef WIN32_LEAN_AND_MEAN
#endif
#include "primpl.h"
#ifdef WINCE

View File

@ -168,7 +168,6 @@ class CppEclipseBackend(CommonBackend):
settings = settings.replace('@IPDL_INCLUDE_PATH@', os.path.join(self.environment.topobjdir, 'ipc/ipdl/_ipdlheaders'))
settings = settings.replace('@PREINCLUDE_FILE_PATH@', os.path.join(self.environment.topobjdir, 'dist/include/mozilla-config.h'))
settings = settings.replace('@DEFINE_MOZILLA_INTERNAL_API@', self._define_entry('MOZILLA_INTERNAL_API', '1'))
settings = settings.replace('@DEFINE_MDCPUCFG@', self._define_entry('MDCPUCFG', self.environment.substs['TARGET_NSPR_MDCPUCFG']))
settings = settings.replace("@COMPILER_FLAGS@", self._cxx + " " + self._cppflags);
fh.write(settings)
@ -428,7 +427,6 @@ LANGUAGE_SETTINGS_TEMPLATE = """<?xml version="1.0" encoding="UTF-8" standalone=
MOZILLA_EXTERNAL_API code will suffer.
-->
@DEFINE_MOZILLA_INTERNAL_API@
@DEFINE_MDCPUCFG@
</resource>
</language>
</provider>

View File

@ -55,4 +55,4 @@ class Introspection(MachCommandBase):
return
print(' '.join(shell_quote(arg)
for arg in shell_split(build_vars[name])))
for arg in util.sanitize_cflags(shell_split(build_vars[name]))))

View File

@ -110,7 +110,7 @@ class CompileDBBackend(CommonBackend):
if name not in build_vars:
continue
build_vars[name] = shell_split(build_vars[name])
build_vars[name] = util.sanitize_cflags(shell_split(build_vars[name]))
self._flags[directory] = build_vars
return self._flags[directory]

View File

@ -33,3 +33,22 @@ def get_build_vars(directory, cmd):
cmd.log_manager.replace_terminal_handler(old_logger)
return build_vars
def sanitize_cflags(flags):
# We filter out -Xclang arguments as clang based tools typically choke on
# passing these flags down to the clang driver. -Xclang tells the clang
# driver driver to pass whatever comes after it down to clang cc1, which is
# why we skip -Xclang and the argument immediately after it. Here is an
# example: the following two invocations pass |-foo -bar -baz| to cc1:
# clang -cc1 -foo -bar -baz
# clang -Xclang -foo -Xclang -bar -Xclang -baz
sanitized = []
saw_xclang = False
for flag in flags:
if flag == '-Xclang':
saw_xclang = True
elif saw_xclang:
saw_xclang = False
else:
sanitized.append(flag)
return sanitized

View File

@ -128,6 +128,11 @@ class Context(KeyedDefaultDict):
if path not in self._all_paths:
self._all_paths.insert(0, path)
@property
def error_is_fatal(self):
"""Returns True if the error function should be fatal."""
return self.config and getattr(self.config, 'error_is_fatal', True)
@property
def all_paths(self):
"""Returns all paths ever added to the context."""

View File

@ -134,6 +134,7 @@ class EmptyConfig(object):
self.substs_unicode = self.PopulateOnGetDict(EmptyValue, udict)
self.defines = self.substs
self.external_source_dir = None
self.error_is_fatal = False
def is_read_allowed(path, config):
@ -325,7 +326,10 @@ class MozbuildSandbox(Sandbox):
print('WARNING: %s' % message, file=sys.stderr)
def _error(self, message):
raise SandboxCalledError(self._context.source_stack, message)
if self._context.error_is_fatal:
raise SandboxCalledError(self._context.source_stack, message)
else:
self._warning(message)
def _template_decorator(self, func):
"""Registers a template function."""

View File

@ -18,7 +18,11 @@ log_manager.add_terminal_logging()
# mozconfig is not a reusable type (it's actually a module) so, we
# have to mock it.
class MockConfig(object):
def __init__(self, topsrcdir='/path/to/topsrcdir', extra_substs={}):
def __init__(self,
topsrcdir='/path/to/topsrcdir',
extra_substs={},
error_is_fatal=True,
):
self.topsrcdir = mozpath.abspath(topsrcdir)
self.topobjdir = mozpath.abspath('/path/to/topobjdir')
@ -41,3 +45,4 @@ class MockConfig(object):
self.import_suffix = '.so'
self.dll_prefix = 'lib'
self.dll_suffix = '.so'
self.error_is_fatal = error_is_fatal

View File

@ -42,11 +42,13 @@ class TestBuildReader(unittest.TestCase):
return MockConfig(path, **kwargs)
def reader(self, name, enable_tests=False, **kwargs):
def reader(self, name, enable_tests=False, error_is_fatal=True, **kwargs):
extra = {}
if enable_tests:
extra['ENABLE_TESTS'] = '1'
config = self.config(name, extra_substs=extra)
config = self.config(name,
extra_substs=extra,
error_is_fatal=error_is_fatal)
return BuildReader(config, **kwargs)
@ -239,6 +241,11 @@ class TestBuildReader(unittest.TestCase):
self.assertIn('A moz.build file called the error() function.', str(e))
self.assertIn(' Some error.', str(e))
def test_error_error_func_ok(self):
reader = self.reader('reader-error-error-func', error_is_fatal=False)
contexts = list(reader.read_topsrcdir())
def test_inheriting_variables(self):
reader = self.reader('inheriting-variables')

View File

@ -1,6 +1,6 @@
Copyright (c) 2007 Ian Bicking and Contributors
Copyright (c) 2009 Ian Bicking, The Open Planning Project
Copyright (c) 2011-2014 The virtualenv developers
Copyright (c) 2011-2015 The virtualenv developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@ -1,11 +1,12 @@
recursive-include bin *
recursive-include docs *
recursive-include scripts *
recursive-include tests *.py *.sh *.expected
recursive-include virtualenv_support *.whl
recursive-include virtualenv_embedded *
recursive-exclude docs/_templates *
recursive-exclude docs/_build *
include virtualenv_support/__init__.py
include bin/*
include scripts/*
include *.py
include AUTHORS.txt
include LICENSE.txt

View File

@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: virtualenv
Version: 12.0.5
Version: 14.0.1
Summary: Virtual Python Environment builder
Home-page: https://virtualenv.pypa.io/
Author: Jannis Leidel, Carl Meyer and Brian Rosner
@ -47,785 +47,57 @@ Description: Virtualenv
Release History
===============
12.0.5 (2015-01-03)
~~~~~~~~~~~~~~~~~~~
14.0.1 (2016-01-21)
-------------------
* Upgrade pip to 6.0.6
* Upgrade from pip 8.0.0 to 8.0.2.
* Upgrade setuptools to 11.0
* Fix the default of ``--(no-)download`` to default to downloading.
12.0.4 (2014-22-23)
~~~~~~~~~~~~~~~~~~~
14.0.0 (2016-01-19)
-------------------
* Revert the fix to ``-p`` on Debian based pythons as it was broken in other
situations.
* **BACKWARDS INCOMPATIBLE** Drop support for Python 3.2.
* Revert several sys.path changes new in 12.0 which were breaking virtualenv.
* Upgrade setuptools to 19.4
12.0.3 (2014-22-23)
~~~~~~~~~~~~~~~~~~~
* Upgrade wheel to 0.26.0
* Fix an issue where Debian based Pythons would fail when using -p with the
host Python.
* Upgrade pip to 8.0.0
* Upgrade pip to 6.0.3
* Upgrade argparse to 1.4.0
12.0.2 (2014-12-23)
~~~~~~~~~~~~~~~~~~~
* Added support for ``python-config`` script (PR #798)
* Upgraded pip to 6.0.2
* Updated activate.fish (PR #589) (PR #799)
12.0.1 (2014-12-22)
~~~~~~~~~~~~~~~~~~~
* Account for a ``site.pyo`` correctly in some python implementations (PR #759)
* Upgraded pip to 6.0.1
* Properly restore an empty PS1 (#407)
12.0 (2014-12-22)
~~~~~~~~~~~~~~~~~
* Properly remove ``pydoc`` when deactivating
* **PROCESS** Version numbers are now simply ``X.Y`` where the leading ``1``
has been dropped.
* Split up documentation into structured pages
* Now using pytest framework
* Correct sys.path ordering for debian, issue #461
* Correctly throws error on older Pythons, issue #619
* Allow for empty $PATH, pull #601
* Don't set prompt if $env:VIRTUAL_ENV_DISABLE_PROMPT is set for Powershell
* Updated setuptools to 7.0
* Remove workaround for very old Mageia / Mandriva linuxes (PR #472)
1.11.6 (2014-05-16)
~~~~~~~~~~~~~~~~~~~
* Added a space after virtualenv name in the prompt: ``(env) $PS1``
* Updated setuptools to 3.6
* Updated pip to 1.5.6
* Make sure not to run a --user install when creating the virtualenv (PR #803)
1.11.5 (2014-05-03)
~~~~~~~~~~~~~~~~~~~
* Remove virtualenv file's path from directory when executing with a new
python. Fixes issue #779, #763 (PR #805)
* Updated setuptools to 3.4.4
* Updated documentation to use https://virtualenv.pypa.io/
* Updated pip to 1.5.5
* Remove use of () in .bat files so ``Program Files (x86)`` works #35
1.11.4 (2014-02-21)
~~~~~~~~~~~~~~~~~~~
* Download new releases of the preinstalled software from PyPI when there are
new releases available. This behavior can be disabled using
``--no-download``.
* Updated pip to 1.5.4
* Make ``--no-setuptools``, ``--no-pip``, and ``--no-wheel`` independent of
each other.
1.11.3 (2014-02-20)
~~~~~~~~~~~~~~~~~~~
* Updated setuptools to 2.2
* Updated pip to 1.5.3
1.11.2 (2014-01-26)
~~~~~~~~~~~~~~~~~~~
* Fixed easy_install installed virtualenvs by updated pip to 1.5.2
1.11.1 (2014-01-20)
~~~~~~~~~~~~~~~~~~~
* Fixed an issue where pip and setuptools were not getting installed when using
the ``--system-site-packages`` flag.
* Updated setuptools to fix an issue when installed with easy_install
* Fixed an issue with Python 3.4 and sys.stdout encoding being set to ascii
* Upgraded pip to v1.5.1
* Upgraded setuptools to v2.1
1.11 (2014-01-02)
~~~~~~~~~~~~~~~~~
* **BACKWARDS INCOMPATIBLE** Switched to using wheels for the bundled copies of
setuptools and pip. Using sdists is no longer supported - users supplying
their own versions of pip/setuptools will need to provide wheels.
* **BACKWARDS INCOMPATIBLE** Modified the handling of ``--extra-search-dirs``.
This option now works like pip's ``--find-links`` option, in that it adds
extra directories to search for compatible wheels for pip and setuptools.
The actual wheel selected is chosen based on version and compatibility, using
the same algorithm as ``pip install setuptools``.
* Fixed #495, --always-copy was failing (#PR 511)
* Upgraded pip to v1.5
* Upgraded setuptools to v1.4
1.10.1 (2013-08-07)
~~~~~~~~~~~~~~~~~~~
* **New Signing Key** Release 1.10.1 is using a different key than normal with
fingerprint: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA
* Upgraded pip to v1.4.1
* Upgraded setuptools to v0.9.8
1.10 (2013-07-23)
~~~~~~~~~~~~~~~~~
* **BACKWARDS INCOMPATIBLE** Dropped support for Python 2.5. The minimum
supported Python version is now Python 2.6.
* **BACKWARDS INCOMPATIBLE** Using ``virtualenv.py`` as an isolated script
(i.e. without an associated ``virtualenv_support`` directory) is no longer
supported for security reasons and will fail with an error.
Along with this, ``--never-download`` is now always pinned to ``True``, and
is only being maintained in the short term for backward compatibility
(Pull #412).
* **IMPORTANT** Switched to the new setuptools (v0.9.7) which has been merged
with Distribute_ again and works for Python 2 and 3 with one codebase.
The ``--distribute`` and ``--setuptools`` options are now no-op.
* Updated to pip 1.4.
* Added support for PyPy3k
* Added the option to use a version number with the ``-p`` option to get the
system copy of that Python version (Windows only)
* Removed embedded ``ez_setup.py``, ``distribute_setup.py`` and
``distribute_from_egg.py`` files as part of switching to merged setuptools.
* Fixed ``--relocatable`` to work better on Windows.
* Fixed issue with readline on Windows.
.. _Distribute: https://pypi.python.org/pypi/distribute
1.9.1 (2013-03-08)
~~~~~~~~~~~~~~~~~~
* Updated to pip 1.3.1 that fixed a major backward incompatible change of
parsing URLs to externally hosted packages that got accidentily included
in pip 1.3.
1.9 (2013-03-07)
~~~~~~~~~~~~~~~~
* Unset VIRTUAL_ENV environment variable in deactivate.bat (Pull #364)
* Upgraded distribute to 0.6.34.
* Added ``--no-setuptools`` and ``--no-pip`` options (Pull #336).
* Fixed Issue #373. virtualenv-1.8.4 was failing in cygwin (Pull #382).
* Fixed Issue #378. virtualenv is now "multiarch" aware on debian/ubuntu (Pull #379).
* Fixed issue with readline module path on pypy and OSX (Pull #374).
* Made 64bit detection compatible with Python 2.5 (Pull #393).
1.8.4 (2012-11-25)
~~~~~~~~~~~~~~~~~~
* Updated distribute to 0.6.31. This fixes #359 (numpy install regression) on
UTF-8 platforms, and provides a workaround on other platforms:
``PYTHONIOENCODING=utf8 pip install numpy``.
* When installing virtualenv via curl, don't forget to filter out arguments
the distribute setup script won't understand. Fixes #358.
* Added some more integration tests.
* Removed the unsupported embedded setuptools egg for Python 2.4 to reduce
file size.
1.8.3 (2012-11-21)
~~~~~~~~~~~~~~~~~~
* Fixed readline on OS X. Thanks minrk
* Updated distribute to 0.6.30 (improves our error reporting, plus new
distribute features and fixes). Thanks Gabriel (g2p)
* Added compatibility with multiarch Python (Python 3.3 for example). Added an
integration test. Thanks Gabriel (g2p)
* Added ability to install distribute from a user-provided egg, rather than the
bundled sdist, for better speed. Thanks Paul Moore.
* Make the creation of lib64 symlink smarter about already-existing symlink,
and more explicit about full paths. Fixes #334 and #330. Thanks Jeremy Orem.
* Give lib64 site-dir preference over lib on 64-bit systems, to avoid wrong
32-bit compiles in the venv. Fixes #328. Thanks Damien Nozay.
* Fix a bug with prompt-handling in ``activate.csh`` in non-interactive csh
shells. Fixes #332. Thanks Benjamin Root for report and patch.
* Make it possible to create a virtualenv from within a Python
3.3. pyvenv. Thanks Chris McDonough for the report.
* Add optional --setuptools option to be able to switch to it in case
distribute is the default (like in Debian).
1.8.2 (2012-09-06)
~~~~~~~~~~~~~~~~~~
* Updated the included pip version to 1.2.1 to fix regressions introduced
there in 1.2.
1.8.1 (2012-09-03)
~~~~~~~~~~~~~~~~~~
* Fixed distribute version used with `--never-download`. Thanks michr for
report and patch.
* Fix creating Python 3.3 based virtualenvs by unsetting the
``__PYVENV_LAUNCHER__`` environment variable in subprocesses.
1.8 (2012-09-01)
~~~~~~~~~~~~~~~~
* **Dropped support for Python 2.4** The minimum supported Python version is
now Python 2.5.
* Fix `--relocatable` on systems that use lib64. Fixes #78. Thanks Branden
Rolston.
* Symlink some additional modules under Python 3. Fixes #194. Thanks Vinay
Sajip, Ian Clelland, and Stefan Holek for the report.
* Fix ``--relocatable`` when a script uses ``__future__`` imports. Thanks
Branden Rolston.
* Fix a bug in the config option parser that prevented setting negative
options with environment variables. Thanks Ralf Schmitt.
* Allow setting ``--no-site-packages`` from the config file.
* Use ``/usr/bin/multiarch-platform`` if available to figure out the include
directory. Thanks for the patch, Mika Laitio.
* Fix ``install_name_tool`` replacement to work on Python 3.X.
* Handle paths of users' site-packages on Mac OS X correctly when changing
the prefix.
* Updated the embedded version of distribute to 0.6.28 and pip to 1.2.
1.7.2 (2012-06-22)
~~~~~~~~~~~~~~~~~~
* Updated to distribute 0.6.27.
* Fix activate.fish on OS X. Fixes #8. Thanks David Schoonover.
* Create a virtualenv-x.x script with the Python version when installing, so
virtualenv for multiple Python versions can be installed to the same
script location. Thanks Miki Tebeka.
* Restored ability to create a virtualenv with a path longer than 78
characters, without breaking creation of virtualenvs with non-ASCII paths.
Thanks, Bradley Ayers.
* Added ability to create virtualenvs without having installed Apple's
developers tools (using an own implementation of ``install_name_tool``).
Thanks Mike Hommey.
* Fixed PyPy and Jython support on Windows. Thanks Konstantin Zemlyak.
* Added pydoc script to ease use. Thanks Marc Abramowitz. Fixes #149.
* Fixed creating a bootstrap script on Python 3. Thanks Raul Leal. Fixes #280.
* Fixed inconsistency when having set the ``PYTHONDONTWRITEBYTECODE`` env var
with the --distribute option or the ``VIRTUALENV_USE_DISTRIBUTE`` env var.
``VIRTUALENV_USE_DISTRIBUTE`` is now considered again as a legacy alias.
1.7.1.2 (2012-02-17)
~~~~~~~~~~~~~~~~~~~~
* Fixed minor issue in `--relocatable`. Thanks, Cap Petschulat.
1.7.1.1 (2012-02-16)
~~~~~~~~~~~~~~~~~~~~
* Bumped the version string in ``virtualenv.py`` up, too.
* Fixed rST rendering bug of long description.
1.7.1 (2012-02-16)
~~~~~~~~~~~~~~~~~~
* Update embedded pip to version 1.1.
* Fix `--relocatable` under Python 3. Thanks Doug Hellmann.
* Added environ PATH modification to activate_this.py. Thanks Doug
Napoleone. Fixes #14.
* Support creating virtualenvs directly from a Python build directory on
Windows. Thanks CBWhiz. Fixes #139.
* Use non-recursive symlinks to fix things up for posix_local install
scheme. Thanks michr.
* Made activate script available for use with msys and cygwin on Windows.
Thanks Greg Haskins, Cliff Xuan, Jonathan Griffin and Doug Napoleone.
Fixes #176.
* Fixed creation of virtualenvs on Windows when Python is not installed for
all users. Thanks Anatoly Techtonik for report and patch and Doug
Napoleone for testing and confirmation. Fixes #87.
* Fixed creation of virtualenvs using -p in installs where some modules
that ought to be in the standard library (e.g. `readline`) are actually
installed in `site-packages` next to `virtualenv.py`. Thanks Greg Haskins
for report and fix. Fixes #167.
* Added activation script for Powershell (signed by Jannis Leidel). Many
thanks to Jason R. Coombs.
1.7 (2011-11-30)
~~~~~~~~~~~~~~~~
* Gave user-provided ``--extra-search-dir`` priority over default dirs for
finding setuptools/distribute (it already had priority for finding pip).
Thanks Ethan Jucovy.
* Updated embedded Distribute release to 0.6.24. Thanks Alex Gronholm.
* Made ``--no-site-packages`` behavior the default behavior. The
``--no-site-packages`` flag is still permitted, but displays a warning when
used. Thanks Chris McDonough.
* New flag: ``--system-site-packages``; this flag should be passed to get the
previous default global-site-package-including behavior back.
* Added ability to set command options as environment variables and options
in a ``virtualenv.ini`` file.
* Fixed various encoding related issues with paths. Thanks Gunnlaugur Thor Briem.
* Made ``virtualenv.py`` script executable.
1.6.4 (2011-07-21)
~~~~~~~~~~~~~~~~~~
* Restored ability to run on Python 2.4, too.
1.6.3 (2011-07-16)
~~~~~~~~~~~~~~~~~~
* Restored ability to run on Python < 2.7.
1.6.2 (2011-07-16)
~~~~~~~~~~~~~~~~~~
* Updated embedded distribute release to 0.6.19.
* Updated embedded pip release to 1.0.2.
* Fixed #141 - Be smarter about finding pkg_resources when using the
non-default Python interpreter (by using the ``-p`` option).
* Fixed #112 - Fixed path in docs.
* Fixed #109 - Corrected doctests of a Logger method.
* Fixed #118 - Fixed creating virtualenvs on platforms that use the
"posix_local" install scheme, such as Ubuntu with Python 2.7.
* Add missing library to Python 3 virtualenvs (``_dummy_thread``).
1.6.1 (2011-04-30)
~~~~~~~~~~~~~~~~~~
* Start to use git-flow.
* Added support for PyPy 1.5
* Fixed #121 -- added sanity-checking of the -p argument. Thanks Paul Nasrat.
* Added progress meter for pip installation as well as setuptools. Thanks Ethan
Jucovy.
* Added --never-download and --search-dir options. Thanks Ethan Jucovy.
1.6
~~~
* Added Python 3 support! Huge thanks to Vinay Sajip and Vitaly Babiy.
* Fixed creation of virtualenvs on Mac OS X when standard library modules
(readline) are installed outside the standard library.
* Updated bundled pip to 1.0.
1.5.2
~~~~~
* Moved main repository to Github: https://github.com/pypa/virtualenv
* Transferred primary maintenance from Ian to Jannis Leidel, Carl Meyer and Brian Rosner
* Fixed a few more pypy related bugs.
* Updated bundled pip to 0.8.2.
* Handed project over to new team of maintainers.
* Moved virtualenv to Github at https://github.com/pypa/virtualenv
1.5.1
~~~~~
* Added ``_weakrefset`` requirement for Python 2.7.1.
* Fixed Windows regression in 1.5
1.5
~~~
* Include pip 0.8.1.
* Add support for PyPy.
* Uses a proper temporary dir when installing environment requirements.
* Add ``--prompt`` option to be able to override the default prompt prefix.
* Fix an issue with ``--relocatable`` on Windows.
* Fix issue with installing the wrong version of distribute.
* Add fish and csh activate scripts.
1.4.9
~~~~~
* Include pip 0.7.2
1.4.8
~~~~~
* Fix for Mac OS X Framework builds that use
``--universal-archs=intel``
* Fix ``activate_this.py`` on Windows.
* Allow ``$PYTHONHOME`` to be set, so long as you use ``source
bin/activate`` it will get unset; if you leave it set and do not
activate the environment it will still break the environment.
* Include pip 0.7.1
1.4.7
~~~~~
* Include pip 0.7
1.4.6
~~~~~
* Allow ``activate.sh`` to skip updating the prompt (by setting
``$VIRTUAL_ENV_DISABLE_PROMPT``).
1.4.5
~~~~~
* Include pip 0.6.3
* Fix ``activate.bat`` and ``deactivate.bat`` under Windows when
``PATH`` contained a parenthesis
1.4.4
~~~~~
* Include pip 0.6.2 and Distribute 0.6.10
* Create the ``virtualenv`` script even when Setuptools isn't
installed
* Fix problem with ``virtualenv --relocate`` when ``bin/`` has
subdirectories (e.g., ``bin/.svn/``); from Alan Franzoni.
* If you set ``$VIRTUALENV_DISTRIBUTE`` then virtualenv will use
Distribute by default (so you don't have to remember to use
``--distribute``).
1.4.3
~~~~~
* Include pip 0.6.1
1.4.2
~~~~~
* Fix pip installation on Windows
* Fix use of stand-alone ``virtualenv.py`` (and boot scripts)
* Exclude ~/.local (user site-packages) from environments when using
``--no-site-packages``
1.4.1
~~~~~
* Include pip 0.6
1.4
~~~
* Updated setuptools to 0.6c11
* Added the --distribute option
* Fixed packaging problem of support-files
1.3.4
~~~~~
* Virtualenv now copies the actual embedded Python binary on
Mac OS X to fix a hang on Snow Leopard (10.6).
* Fail more gracefully on Windows when ``win32api`` is not installed.
* Fix site-packages taking precedent over Jython's ``__classpath__``
and also specially handle the new ``__pyclasspath__`` entry in
``sys.path``.
* Now copies Jython's ``registry`` file to the virtualenv if it exists.
* Better find libraries when compiling extensions on Windows.
* Create ``Scripts\pythonw.exe`` on Windows.
* Added support for the Debian/Ubuntu
``/usr/lib/pythonX.Y/dist-packages`` directory.
* Set ``distutils.sysconfig.get_config_vars()['LIBDIR']`` (based on
``sys.real_prefix``) which is reported to help building on Windows.
* Make ``deactivate`` work on ksh
* Fixes for ``--python``: make it work with ``--relocatable`` and the
symlink created to the exact Python version.
1.3.3
~~~~~
* Use Windows newlines in ``activate.bat``, which has been reported to help
when using non-ASCII directory names.
* Fixed compatibility with Jython 2.5b1.
* Added a function ``virtualenv.install_python`` for more fine-grained
access to what ``virtualenv.create_environment`` does.
* Fix `a problem <https://bugs.launchpad.net/virtualenv/+bug/241581>`_
with Windows and paths that contain spaces.
* If ``/path/to/env/.pydistutils.cfg`` exists (or
``/path/to/env/pydistutils.cfg`` on Windows systems) then ignore
``~/.pydistutils.cfg`` and use that other file instead.
* Fix ` a problem
<https://bugs.launchpad.net/virtualenv/+bug/340050>`_ picking up
some ``.so`` libraries in ``/usr/local``.
1.3.2
~~~~~
* Remove the ``[install] prefix = ...`` setting from the virtualenv
``distutils.cfg`` -- this has been causing problems for a lot of
people, in rather obscure ways.
* If you use a boot script it will attempt to import ``virtualenv``
and find a pre-downloaded Setuptools egg using that.
* Added platform-specific paths, like ``/usr/lib/pythonX.Y/plat-linux2``
1.3.1
~~~~~
* Real Python 2.6 compatibility. Backported the Python 2.6 updates to
``site.py``, including `user directories
<http://docs.python.org/dev/whatsnew/2.6.html#pep-370-per-user-site-packages-directory>`_
(this means older versions of Python will support user directories,
whether intended or not).
* Always set ``[install] prefix`` in ``distutils.cfg`` -- previously
on some platforms where a system-wide ``distutils.cfg`` was present
with a ``prefix`` setting, packages would be installed globally
(usually in ``/usr/local/lib/pythonX.Y/site-packages``).
* Sometimes Cygwin seems to leave ``.exe`` off ``sys.executable``; a
workaround is added.
* Fix ``--python`` option.
* Fixed handling of Jython environments that use a
jython-complete.jar.
1.3
~~~
* Update to Setuptools 0.6c9
* Added an option ``virtualenv --relocatable EXISTING_ENV``, which
will make an existing environment "relocatable" -- the paths will
not be absolute in scripts, ``.egg-info`` and ``.pth`` files. This
may assist in building environments that can be moved and copied.
You have to run this *after* any new packages installed.
* Added ``bin/activate_this.py``, a file you can use like
``execfile("path_to/activate_this.py",
dict(__file__="path_to/activate_this.py"))`` -- this will activate
the environment in place, similar to what `the mod_wsgi example
does <http://code.google.com/p/modwsgi/wiki/VirtualEnvironments>`_.
* For Mac framework builds of Python, the site-packages directory
``/Library/Python/X.Y/site-packages`` is added to ``sys.path``, from
Andrea Rech.
* Some platform-specific modules in Macs are added to the path now
(``plat-darwin/``, ``plat-mac/``, ``plat-mac/lib-scriptpackages``),
from Andrea Rech.
* Fixed a small Bashism in the ``bin/activate`` shell script.
* Added ``__future__`` to the list of required modules, for Python
2.3. You'll still need to backport your own ``subprocess`` module.
* Fixed the ``__classpath__`` entry in Jython's ``sys.path`` taking
precedent over virtualenv's libs.
1.2
~~~
* Added a ``--python`` option to select the Python interpreter.
* Add ``warnings`` to the modules copied over, for Python 2.6 support.
* Add ``sets`` to the module copied over for Python 2.3 (though Python
2.3 still probably doesn't work).
1.1.1
~~~~~
* Added support for Jython 2.5.
1.1
~~~
* Added support for Python 2.6.
* Fix a problem with missing ``DLLs/zlib.pyd`` on Windows. Create
* ``bin/python`` (or ``bin/python.exe``) even when you run virtualenv
with an interpreter named, e.g., ``python2.4``
* Fix MacPorts Python
* Added --unzip-setuptools option
* Update to Setuptools 0.6c8
* If the current directory is not writable, run ez_setup.py in ``/tmp``
* Copy or symlink over the ``include`` directory so that packages will
more consistently compile.
1.0
~~~
* Fix build on systems that use ``/usr/lib64``, distinct from
``/usr/lib`` (specifically CentOS x64).
* Fixed bug in ``--clear``.
* Fixed typos in ``deactivate.bat``.
* Preserve ``$PYTHONPATH`` when calling subprocesses.
0.9.2
~~~~~
* Fix include dir copying on Windows (makes compiling possible).
* Include the main ``lib-tk`` in the path.
* Patch ``distutils.sysconfig``: ``get_python_inc`` and
``get_python_lib`` to point to the global locations.
* Install ``distutils.cfg`` before Setuptools, so that system
customizations of ``distutils.cfg`` won't effect the installation.
* Add ``bin/pythonX.Y`` to the virtualenv (in addition to
``bin/python``).
* Fixed an issue with Mac Framework Python builds, and absolute paths
(from Ronald Oussoren).
0.9.1
~~~~~
* Improve ability to create a virtualenv from inside a virtualenv.
* Fix a little bug in ``bin/activate``.
* Actually get ``distutils.cfg`` to work reliably.
0.9
~~~
* Added ``lib-dynload`` and ``config`` to things that need to be
copied over in an environment.
* Copy over or symlink the ``include`` directory, so that you can
build packages that need the C headers.
* Include a ``distutils`` package, so you can locally update
``distutils.cfg`` (in ``lib/pythonX.Y/distutils/distutils.cfg``).
* Better avoid downloading Setuptools, and hitting PyPI on environment
creation.
* Fix a problem creating a ``lib64/`` directory.
* Should work on MacOSX Framework builds (the default Python
installations on Mac). Thanks to Ronald Oussoren.
0.8.4
~~~~~
* Windows installs would sometimes give errors about ``sys.prefix`` that
were inaccurate.
* Slightly prettier output.
0.8.3
~~~~~
* Added support for Windows.
0.8.2
~~~~~
* Give a better warning if you are on an unsupported platform (Mac
Framework Pythons, and Windows).
* Give error about running while inside a workingenv.
* Give better error message about Python 2.3.
0.8.1
~~~~~
Fixed packaging of the library.
0.8
~~~
Initial release. Everything is changed and new!
`Full Changelog <https://virtualenv.pypa.io/en/latest/changes.html>`_.
Keywords: setuptools deployment installation distutils
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
@ -837,3 +109,5 @@ Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4

View File

@ -1,10 +1,20 @@
virtualenv
==========
.. image:: https://pypip.in/v/virtualenv/badge.png
.. image:: https://img.shields.io/pypi/v/virtualenv.svg
:target: https://pypi.python.org/pypi/virtualenv
.. image:: https://secure.travis-ci.org/pypa/virtualenv.png?branch=develop
.. image:: https://img.shields.io/travis/pypa/virtualenv/develop.svg
:target: http://travis-ci.org/pypa/virtualenv
For documentation, see https://virtualenv.pypa.io/
Code of Conduct
---------------
Everyone interacting in the virtualenv project's codebases, issue trackers,
chat rooms, and mailing lists is expected to follow the
`PyPA Code of Conduct`_.
.. _PyPA Code of Conduct: https://www.pypa.io/en/latest/code-of-conduct/

View File

@ -2,70 +2,72 @@
"""
Helper script to rebuild virtualenv.py from virtualenv_support
"""
from __future__ import print_function
import re
import os
import sys
import re
import codecs
from zlib import crc32
here = os.path.dirname(__file__)
script = os.path.join(here, '..', 'virtualenv.py')
file_regex = re.compile(
r'##file (.*?)\n([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*convert\("""(.*?)"""\)',
re.S)
file_template = '##file %(filename)s\n%(varname)s = convert("""\n%(data)s""")'
gzip = codecs.lookup('zlib')
b64 = codecs.lookup('base64')
def rebuild():
f = open(script, 'rb')
content = f.read()
f.close()
file_regex = re.compile(
br'##file (.*?)\n([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*convert\("""\n(.*?)"""\)',
re.S)
file_template = b'##file %(filename)s\n%(varname)s = convert("""\n%(data)s""")'
def rebuild(script_path):
with open(script_path, 'rb') as f:
script_content = f.read()
parts = []
last_pos = 0
match = None
for match in file_regex.finditer(content):
parts.append(content[last_pos:match.start()])
for match in file_regex.finditer(script_content):
parts += [script_content[last_pos:match.start()]]
last_pos = match.end()
filename = match.group(1)
filename, fn_decoded = match.group(1), match.group(1).decode()
varname = match.group(2)
data = match.group(3)
print('Found reference to file %s' % filename)
pathname = os.path.join(here, '..', 'virtualenv_embedded', filename)
f = open(pathname, 'rb')
c = f.read()
f.close()
new_data = c.encode('zlib').encode('base64')
print('Found file %s' % fn_decoded)
pathname = os.path.join(here, '..', 'virtualenv_embedded', fn_decoded)
with open(pathname, 'rb') as f:
embedded = f.read()
new_crc = crc32(embedded)
new_data = b64.encode(gzip.encode(embedded)[0])[0]
if new_data == data:
print(' Reference up to date (%s bytes)' % len(c))
parts.append(match.group(0))
print(' File up to date (crc: %s)' % new_crc)
parts += [match.group(0)]
continue
print(' Content changed (%s bytes -> %s bytes)' % (
zipped_len(data), len(c)))
new_match = file_template % dict(
filename=filename,
varname=varname,
data=new_data)
parts.append(new_match)
parts.append(content[last_pos:])
new_content = ''.join(parts)
if new_content != content:
sys.stdout.write('Content updated; overwriting... ')
f = open(script, 'wb')
f.write(new_content)
f.close()
# Else: content has changed
crc = crc32(gzip.decode(b64.decode(data)[0])[0])
print(' Content changed (crc: %s -> %s)' %
(crc, new_crc))
new_match = file_template % {
b'filename': filename,
b'varname': varname,
b'data': new_data
}
parts += [new_match]
parts += [script_content[last_pos:]]
new_content = b''.join(parts)
if new_content != script_content:
print('Content updated; overwriting... ', end='')
with open(script_path, 'wb') as f:
f.write(new_content)
print('done.')
else:
print('No changes in content')
if match is None:
print('No variables were matched/found')
def zipped_len(data):
if not data:
return 'no data'
try:
return len(data.decode('base64').decode('zlib'))
except:
return 'unknown'
if __name__ == '__main__':
rebuild()
rebuild(script)

View File

@ -1,24 +1,158 @@
Release History
===============
14.0.1 (2016-01-21)
-------------------
* Upgrade from pip 8.0.0 to 8.0.2.
* Fix the default of ``--(no-)download`` to default to downloading.
14.0.0 (2016-01-19)
-------------------
* **BACKWARDS INCOMPATIBLE** Drop support for Python 3.2.
* Upgrade setuptools to 19.4
* Upgrade wheel to 0.26.0
* Upgrade pip to 8.0.0
* Upgrade argparse to 1.4.0
* Added support for ``python-config`` script (:pull:`798`)
* Updated activate.fish (:pull:`589`) (:pull:`799`)
* Account for a ``site.pyo`` correctly in some python implementations (:pull:`759`)
* Properly restore an empty PS1 (:issue:`407`)
* Properly remove ``pydoc`` when deactivating
* Remove workaround for very old Mageia / Mandriva linuxes (:pull:`472`)
* Added a space after virtualenv name in the prompt: ``(env) $PS1``
* Make sure not to run a --user install when creating the virtualenv (:pull:`803`)
* Remove virtualenv file's path from directory when executing with a new
python. Fixes issue :issue:`779`, :issue:`763` (:pull:`805`)
* Remove use of () in .bat files so ``Program Files (x86)`` works :issue:`35`
* Download new releases of the preinstalled software from PyPI when there are
new releases available. This behavior can be disabled using
``--no-download``.
* Make ``--no-setuptools``, ``--no-pip``, and ``--no-wheel`` independent of
each other.
13.1.2 (2015-08-23)
-------------------
* Upgrade pip to 7.1.2.
13.1.1 (2015-08-20)
-------------------
* Upgrade pip to 7.1.1.
* Upgrade setuptools to 18.2.
* Make the activate script safe to use when bash is running with ``-u``.
13.1.0 (2015-06-30)
-------------------
* Upgrade pip to 7.1.0
* Upgrade setuptools to 18.0.1
13.0.3 (2015-06-01)
-------------------
* Upgrade pip to 7.0.3
13.0.2 (2015-06-01)
-------------------
* Upgrade pip to 7.0.2
* Upgrade setuptools to 17.0
13.0.1 (2015-05-22)
-------------------
* Upgrade pip to 7.0.1
13.0.0 (2015-05-21)
-------------------
* Automatically install wheel when creating a new virutalenv. This can be
disabled by using the ``--no-wheel`` option.
* Don't trust the current directory as a location to discover files to install
packages from.
* Upgrade setuptools to 16.0.
* Upgrade pip to 7.0.0.
12.1.1 (2015-04-07)
-------------------
* Upgrade pip to 6.1.1
12.1.0 (2015-04-07)
-------------------
* Upgrade setuptools to 15.0
* Upgrade pip to 6.1.0
12.0.7 (2015-02-04)
-------------------
* Upgrade pip to 6.0.8
12.0.6 (2015-01-28)
-------------------
* Upgrade pip to 6.0.7
* Upgrade setuptools to 12.0.5
12.0.5 (2015-01-03)
~~~~~~~~~~~~~~~~~~~
-------------------
* Upgrade pip to 6.0.6
* Upgrade setuptools to 11.0
12.0.4 (2014-22-23)
~~~~~~~~~~~~~~~~~~~
12.0.4 (2014-12-23)
-------------------
* Revert the fix to ``-p`` on Debian based pythons as it was broken in other
situations.
* Revert several sys.path changes new in 12.0 which were breaking virtualenv.
12.0.3 (2014-22-23)
~~~~~~~~~~~~~~~~~~~
12.0.3 (2014-12-23)
-------------------
* Fix an issue where Debian based Pythons would fail when using -p with the
host Python.
@ -26,17 +160,18 @@ Release History
* Upgrade pip to 6.0.3
12.0.2 (2014-12-23)
~~~~~~~~~~~~~~~~~~~
-------------------
* Upgraded pip to 6.0.2
12.0.1 (2014-12-22)
~~~~~~~~~~~~~~~~~~~
-------------------
* Upgraded pip to 6.0.1
12.0 (2014-12-22)
~~~~~~~~~~~~~~~~~
-----------------
* **PROCESS** Version numbers are now simply ``X.Y`` where the leading ``1``
has been dropped.
@ -49,38 +184,38 @@ Release History
* Updated setuptools to 7.0
1.11.6 (2014-05-16)
~~~~~~~~~~~~~~~~~~~
-------------------
* Updated setuptools to 3.6
* Updated pip to 1.5.6
1.11.5 (2014-05-03)
~~~~~~~~~~~~~~~~~~~
-------------------
* Updated setuptools to 3.4.4
* Updated documentation to use https://virtualenv.pypa.io/
* Updated pip to 1.5.5
1.11.4 (2014-02-21)
~~~~~~~~~~~~~~~~~~~
-------------------
* Updated pip to 1.5.4
1.11.3 (2014-02-20)
~~~~~~~~~~~~~~~~~~~
-------------------
* Updated setuptools to 2.2
* Updated pip to 1.5.3
1.11.2 (2014-01-26)
~~~~~~~~~~~~~~~~~~~
-------------------
* Fixed easy_install installed virtualenvs by updated pip to 1.5.2
1.11.1 (2014-01-20)
~~~~~~~~~~~~~~~~~~~
-------------------
* Fixed an issue where pip and setuptools were not getting installed when using
the ``--system-site-packages`` flag.
@ -90,7 +225,7 @@ Release History
* Upgraded setuptools to v2.1
1.11 (2014-01-02)
~~~~~~~~~~~~~~~~~
-----------------
* **BACKWARDS INCOMPATIBLE** Switched to using wheels for the bundled copies of
setuptools and pip. Using sdists is no longer supported - users supplying
@ -105,7 +240,7 @@ Release History
* Upgraded setuptools to v1.4
1.10.1 (2013-08-07)
~~~~~~~~~~~~~~~~~~~
-------------------
* **New Signing Key** Release 1.10.1 is using a different key than normal with
fingerprint: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA
@ -114,7 +249,7 @@ Release History
1.10 (2013-07-23)
~~~~~~~~~~~~~~~~~
-----------------
* **BACKWARDS INCOMPATIBLE** Dropped support for Python 2.5. The minimum
supported Python version is now Python 2.6.
@ -148,14 +283,14 @@ Release History
.. _Distribute: https://pypi.python.org/pypi/distribute
1.9.1 (2013-03-08)
~~~~~~~~~~~~~~~~~~
------------------
* Updated to pip 1.3.1 that fixed a major backward incompatible change of
parsing URLs to externally hosted packages that got accidentily included
in pip 1.3.
1.9 (2013-03-07)
~~~~~~~~~~~~~~~~
----------------
* Unset VIRTUAL_ENV environment variable in deactivate.bat (Pull #364)
* Upgraded distribute to 0.6.34.
@ -167,7 +302,7 @@ Release History
1.8.4 (2012-11-25)
~~~~~~~~~~~~~~~~~~
------------------
* Updated distribute to 0.6.31. This fixes #359 (numpy install regression) on
UTF-8 platforms, and provides a workaround on other platforms:
@ -182,7 +317,7 @@ Release History
file size.
1.8.3 (2012-11-21)
~~~~~~~~~~~~~~~~~~
------------------
* Fixed readline on OS X. Thanks minrk
@ -211,14 +346,14 @@ Release History
distribute is the default (like in Debian).
1.8.2 (2012-09-06)
~~~~~~~~~~~~~~~~~~
------------------
* Updated the included pip version to 1.2.1 to fix regressions introduced
there in 1.2.
1.8.1 (2012-09-03)
~~~~~~~~~~~~~~~~~~
------------------
* Fixed distribute version used with `--never-download`. Thanks michr for
report and patch.
@ -228,7 +363,7 @@ Release History
1.8 (2012-09-01)
~~~~~~~~~~~~~~~~
----------------
* **Dropped support for Python 2.4** The minimum supported Python version is
now Python 2.5.
@ -259,7 +394,7 @@ Release History
1.7.2 (2012-06-22)
~~~~~~~~~~~~~~~~~~
------------------
* Updated to distribute 0.6.27.
@ -289,13 +424,13 @@ Release History
1.7.1.2 (2012-02-17)
~~~~~~~~~~~~~~~~~~~~
--------------------
* Fixed minor issue in `--relocatable`. Thanks, Cap Petschulat.
1.7.1.1 (2012-02-16)
~~~~~~~~~~~~~~~~~~~~
--------------------
* Bumped the version string in ``virtualenv.py`` up, too.
@ -303,7 +438,7 @@ Release History
1.7.1 (2012-02-16)
~~~~~~~~~~~~~~~~~~
------------------
* Update embedded pip to version 1.1.
@ -336,7 +471,7 @@ Release History
1.7 (2011-11-30)
~~~~~~~~~~~~~~~~
----------------
* Gave user-provided ``--extra-search-dir`` priority over default dirs for
finding setuptools/distribute (it already had priority for finding pip).
@ -360,19 +495,19 @@ Release History
1.6.4 (2011-07-21)
~~~~~~~~~~~~~~~~~~
------------------
* Restored ability to run on Python 2.4, too.
1.6.3 (2011-07-16)
~~~~~~~~~~~~~~~~~~
------------------
* Restored ability to run on Python < 2.7.
1.6.2 (2011-07-16)
~~~~~~~~~~~~~~~~~~
------------------
* Updated embedded distribute release to 0.6.19.
@ -392,7 +527,7 @@ Release History
1.6.1 (2011-04-30)
~~~~~~~~~~~~~~~~~~
------------------
* Start to use git-flow.
@ -407,7 +542,7 @@ Release History
1.6
~~~
---
* Added Python 3 support! Huge thanks to Vinay Sajip and Vitaly Babiy.
@ -418,7 +553,7 @@ Release History
1.5.2
~~~~~
-----
* Moved main repository to Github: https://github.com/pypa/virtualenv
@ -434,7 +569,7 @@ Release History
1.5.1
~~~~~
-----
* Added ``_weakrefset`` requirement for Python 2.7.1.
@ -442,7 +577,7 @@ Release History
1.5
~~~
---
* Include pip 0.8.1.
@ -460,13 +595,13 @@ Release History
1.4.9
~~~~~
-----
* Include pip 0.7.2
1.4.8
~~~~~
-----
* Fix for Mac OS X Framework builds that use
``--universal-archs=intel``
@ -481,20 +616,20 @@ Release History
1.4.7
~~~~~
-----
* Include pip 0.7
1.4.6
~~~~~
-----
* Allow ``activate.sh`` to skip updating the prompt (by setting
``$VIRTUAL_ENV_DISABLE_PROMPT``).
1.4.5
~~~~~
-----
* Include pip 0.6.3
@ -503,7 +638,7 @@ Release History
1.4.4
~~~~~
-----
* Include pip 0.6.2 and Distribute 0.6.10
@ -519,13 +654,13 @@ Release History
1.4.3
~~~~~
-----
* Include pip 0.6.1
1.4.2
~~~~~
-----
* Fix pip installation on Windows
@ -536,13 +671,13 @@ Release History
1.4.1
~~~~~
-----
* Include pip 0.6
1.4
~~~
---
* Updated setuptools to 0.6c11
@ -552,7 +687,7 @@ Release History
1.3.4
~~~~~
-----
* Virtualenv now copies the actual embedded Python binary on
Mac OS X to fix a hang on Snow Leopard (10.6).
@ -582,7 +717,7 @@ Release History
1.3.3
~~~~~
-----
* Use Windows newlines in ``activate.bat``, which has been reported to help
when using non-ASCII directory names.
@ -605,7 +740,7 @@ Release History
1.3.2
~~~~~
-----
* Remove the ``[install] prefix = ...`` setting from the virtualenv
``distutils.cfg`` -- this has been causing problems for a lot of
@ -618,7 +753,7 @@ Release History
1.3.1
~~~~~
-----
* Real Python 2.6 compatibility. Backported the Python 2.6 updates to
``site.py``, including `user directories
@ -641,7 +776,7 @@ Release History
1.3
~~~
---
* Update to Setuptools 0.6c9
* Added an option ``virtualenv --relocatable EXISTING_ENV``, which
@ -668,7 +803,7 @@ Release History
1.2
~~~
---
* Added a ``--python`` option to select the Python interpreter.
* Add ``warnings`` to the modules copied over, for Python 2.6 support.
@ -677,13 +812,13 @@ Release History
1.1.1
~~~~~
-----
* Added support for Jython 2.5.
1.1
~~~
---
* Added support for Python 2.6.
* Fix a problem with missing ``DLLs/zlib.pyd`` on Windows. Create
@ -698,7 +833,7 @@ Release History
1.0
~~~
---
* Fix build on systems that use ``/usr/lib64``, distinct from
``/usr/lib`` (specifically CentOS x64).
@ -708,7 +843,7 @@ Release History
0.9.2
~~~~~
-----
* Fix include dir copying on Windows (makes compiling possible).
* Include the main ``lib-tk`` in the path.
@ -723,7 +858,7 @@ Release History
0.9.1
~~~~~
-----
* Improve ability to create a virtualenv from inside a virtualenv.
* Fix a little bug in ``bin/activate``.
@ -731,7 +866,7 @@ Release History
0.9
~~~
---
* Added ``lib-dynload`` and ``config`` to things that need to be
copied over in an environment.
@ -747,7 +882,7 @@ Release History
0.8.4
~~~~~
-----
* Windows installs would sometimes give errors about ``sys.prefix`` that
were inaccurate.
@ -755,13 +890,13 @@ Release History
0.8.3
~~~~~
-----
* Added support for Windows.
0.8.2
~~~~~
-----
* Give a better warning if you are on an unsupported platform (Mac
Framework Pythons, and Windows).
@ -770,12 +905,12 @@ Release History
0.8.1
~~~~~
-----
Fixed packaging of the library.
0.8
~~~
---
Initial release. Everything is changed and new!

View File

@ -24,10 +24,9 @@ sys.path.insert(0, os.path.abspath(os.pardir))
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc']
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.extlinks']
# Add any paths that contain templates here, relative to this directory.
## FIXME: disabled for now because I haven't figured out how to use this:
#templates_path = ['_templates']
# The suffix of source filenames.
@ -74,6 +73,11 @@ unused_docs = []
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
extlinks = {
'issue': ('https://github.com/pypa/virtualenv/issues/%s', '#'),
'pull': ('https://github.com/pypa/virtualenv/pull/%s', 'PR #'),
}
# Options for HTML output
# -----------------------

View File

@ -77,8 +77,8 @@ Other Documentation and Links
He also wrote `an example of using virtualenv to try IPython`__.
.. _virtualenvwrapper: https://pypi.python.org/pypi/virtualenvwrapper/
.. __: http://www.doughellmann.com/articles/CompletelyDifferent-2008-05-virtualenvwrapper/index.html
.. __: http://www.doughellmann.com/articles/CompletelyDifferent-2008-02-ipython-and-virtualenv/index.html
.. __: https://doughellmann.com/blog/2008/05/01/virtualenvwrapper/
.. __: https://doughellmann.com/blog/2008/02/01/ipython-and-virtualenv/
* `Pew`_ is another wrapper for virtualenv that makes use of a different
activation technique.

View File

@ -69,13 +69,16 @@ Options
.. option:: --no-setuptools
Do not install setuptools (or pip) in the new
virtualenv.
Do not install setuptools in the new virtualenv.
.. option:: --no-pip
Do not install pip in the new virtualenv.
.. option:: --no-wheel
Do not install wheel in the new virtualenv.
.. option:: --extra-search-dir=DIR
Directory to look for setuptools/pip distributions in.
@ -86,11 +89,13 @@ Options
Provides an alternative prompt prefix for this
environment.
.. option:: --never-download
.. option:: --download
DEPRECATED. Retained only for backward compatibility.
This option has no effect. Virtualenv never downloads
pip or setuptools.
Download preinstalled packages from PyPI.
.. option:: --no-download
Do not download preinstalled packages from PyPI.
.. option:: --no-site-packages

View File

@ -125,6 +125,15 @@ below.
.. _`execution policies`: http://technet.microsoft.com/en-us/library/dd347641.aspx
Removing an Environment
~~~~~~~~~~~~~~~~~~~~~~~
Removing a virtual environment is simply done by deactivating it and deleting the
environment folder with all its contents::
(ENV)$ deactivate
$ rm -r /path/to/ENV
The :option:`--system-site-packages` Option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -245,5 +254,3 @@ As well as the extra directories, the search order includes:
#. The directory where virtualenv.py is located.
#. The current directory.
If no satisfactory local distributions are found, virtualenv will
fail. Virtualenv will never download packages.

View File

@ -1,5 +1,8 @@
[wheel]
universal = 1
[egg_info]
tag_build =
tag_svn_revision = 0
tag_date = 0
tag_build =

View File

@ -15,18 +15,17 @@ try:
def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = None
self.pytest_args = []
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
#self.test_args = []
#self.test_suite = True
def run_tests(self):
# import here, because outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
sys.exit(pytest.main(self.pytest_args))
setup_params = {
'entry_points': {
@ -61,7 +60,24 @@ def read_file(*paths):
long_description = read_file('docs', 'index.rst')
long_description = long_description.strip().split('split here', 1)[0]
# Add release history
long_description += "\n\n" + read_file('docs', 'changes.rst')
changes = read_file('docs', 'changes.rst')
# Only report last two releases for brevity
releases_found = 0
change_lines = []
for line in changes.splitlines():
change_lines.append(line)
if line.startswith('--------------'):
releases_found += 1
if releases_found > 2:
break
changes = '\n'.join(change_lines[:-2]) + '\n'
changes += '`Full Changelog <https://virtualenv.pypa.io/en/latest/changes.html>`_.'
# Replace issue/pull directives
changes = re.sub(r':pull:`(\d+)`', r'PR #\1', changes)
changes = re.sub(r':issue:`(\d+)`', r'#\1', changes)
long_description += '\n\n' + changes
def get_version():
@ -97,6 +113,8 @@ setup(
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
],
keywords='setuptools deployment installation distutils',
author='Ian Bicking',

View File

View File

@ -0,0 +1,96 @@
#!/bin/sh
set -u
ROOT="$(dirname $0)/.."
VIRTUALENV="${ROOT}/virtualenv.py"
TESTENV="/tmp/test_virtualenv_activate.venv"
rm -rf ${TESTENV}
echo "$0: Creating virtualenv ${TESTENV}..." 1>&2
${VIRTUALENV} ${TESTENV} | tee ${ROOT}/tests/test_activate_output.actual
if ! diff ${ROOT}/tests/test_activate_output.expected ${ROOT}/tests/test_activate_output.actual; then
echo "$0: Failed to get expected output from ${VIRTUALENV}!" 1>&2
exit 1
fi
echo "$0: Created virtualenv ${TESTENV}." 1>&2
echo "$0: Activating ${TESTENV}..." 1>&2
. ${TESTENV}/bin/activate
echo "$0: Activated ${TESTENV}." 1>&2
echo "$0: Checking value of \$VIRTUAL_ENV..." 1>&2
if [ "$VIRTUAL_ENV" != "${TESTENV}" ]; then
echo "$0: Expected \$VIRTUAL_ENV to be set to \"${TESTENV}\"; actual value: \"${VIRTUAL_ENV}\"!" 1>&2
exit 2
fi
echo "$0: \$VIRTUAL_ENV = \"${VIRTUAL_ENV}\" -- OK." 1>&2
echo "$0: Checking output of \$(which python)..." 1>&2
if [ "$(which python)" != "${TESTENV}/bin/python" ]; then
echo "$0: Expected \$(which python) to return \"${TESTENV}/bin/python\"; actual value: \"$(which python)\"!" 1>&2
exit 3
fi
echo "$0: Output of \$(which python) is OK." 1>&2
echo "$0: Checking output of \$(which pip)..." 1>&2
if [ "$(which pip)" != "${TESTENV}/bin/pip" ]; then
echo "$0: Expected \$(which pip) to return \"${TESTENV}/bin/pip\"; actual value: \"$(which pip)\"!" 1>&2
exit 4
fi
echo "$0: Output of \$(which pip) is OK." 1>&2
echo "$0: Checking output of \$(which easy_install)..." 1>&2
if [ "$(which easy_install)" != "${TESTENV}/bin/easy_install" ]; then
echo "$0: Expected \$(which easy_install) to return \"${TESTENV}/bin/easy_install\"; actual value: \"$(which easy_install)\"!" 1>&2
exit 5
fi
echo "$0: Output of \$(which easy_install) is OK." 1>&2
echo "$0: Executing a simple Python program..." 1>&2
TESTENV=${TESTENV} python <<__END__
import os, sys
expected_site_packages = os.path.join(os.environ['TESTENV'], 'lib','python%s' % sys.version[:3], 'site-packages')
site_packages = os.path.join(os.environ['VIRTUAL_ENV'], 'lib', 'python%s' % sys.version[:3], 'site-packages')
assert site_packages == expected_site_packages, 'site_packages did not have expected value; actual value: %r' % site_packages
open(os.path.join(site_packages, 'pydoc_test.py'), 'w').write('"""This is pydoc_test.py"""\n')
__END__
if [ $? -ne 0 ]; then
echo "$0: Python script failed!" 1>&2
exit 6
fi
echo "$0: Execution of a simple Python program -- OK." 1>&2
echo "$0: Testing pydoc..." 1>&2
if ! PAGER=cat pydoc pydoc_test | grep 'This is pydoc_test.py' > /dev/null; then
echo "$0: pydoc test failed!" 1>&2
exit 7
fi
echo "$0: pydoc is OK." 1>&2
echo "$0: Deactivating ${TESTENV}..." 1>&2
deactivate
echo "$0: Deactivated ${TESTENV}." 1>&2
echo "$0: OK!" 1>&2
rm -rf ${TESTENV}

View File

@ -0,0 +1,2 @@
New python executable in /tmp/test_virtualenv_activate.venv/bin/python
Installing setuptools, pip, wheel...done.

View File

@ -0,0 +1,139 @@
import virtualenv
import optparse
import os
import shutil
import sys
import tempfile
import pytest
import platform # noqa
from mock import patch, Mock
def test_version():
"""Should have a version string"""
assert virtualenv.virtualenv_version, "Should have version"
@patch('os.path.exists')
def test_resolve_interpreter_with_absolute_path(mock_exists):
"""Should return absolute path if given and exists"""
mock_exists.return_value = True
virtualenv.is_executable = Mock(return_value=True)
test_abs_path = os.path.abspath("/usr/bin/python53")
exe = virtualenv.resolve_interpreter(test_abs_path)
assert exe == test_abs_path, "Absolute path should return as is"
mock_exists.assert_called_with(test_abs_path)
virtualenv.is_executable.assert_called_with(test_abs_path)
@patch('os.path.exists')
def test_resolve_interpreter_with_nonexistent_interpreter(mock_exists):
"""Should SystemExit with an nonexistent python interpreter path"""
mock_exists.return_value = False
with pytest.raises(SystemExit):
virtualenv.resolve_interpreter("/usr/bin/python53")
mock_exists.assert_called_with("/usr/bin/python53")
@patch('os.path.exists')
def test_resolve_interpreter_with_invalid_interpreter(mock_exists):
"""Should exit when with absolute path if not exists"""
mock_exists.return_value = True
virtualenv.is_executable = Mock(return_value=False)
invalid = os.path.abspath("/usr/bin/pyt_hon53")
with pytest.raises(SystemExit):
virtualenv.resolve_interpreter(invalid)
mock_exists.assert_called_with(invalid)
virtualenv.is_executable.assert_called_with(invalid)
def test_activate_after_future_statements():
"""Should insert activation line after last future statement"""
script = [
'#!/usr/bin/env python',
'from __future__ import with_statement',
'from __future__ import print_function',
'print("Hello, world!")'
]
assert virtualenv.relative_script(script) == [
'#!/usr/bin/env python',
'from __future__ import with_statement',
'from __future__ import print_function',
'',
"import os; activate_this=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'activate_this.py'); exec(compile(open(activate_this).read(), activate_this, 'exec'), dict(__file__=activate_this)); del os, activate_this",
'',
'print("Hello, world!")'
]
def test_cop_update_defaults_with_store_false():
"""store_false options need reverted logic"""
class MyConfigOptionParser(virtualenv.ConfigOptionParser):
def __init__(self, *args, **kwargs):
self.config = virtualenv.ConfigParser.RawConfigParser()
self.files = []
optparse.OptionParser.__init__(self, *args, **kwargs)
def get_environ_vars(self, prefix='VIRTUALENV_'):
yield ("no_site_packages", "1")
cop = MyConfigOptionParser()
cop.add_option(
'--no-site-packages',
dest='system_site_packages',
action='store_false',
help="Don't give access to the global site-packages dir to the "
"virtual environment (default)")
defaults = {}
cop.update_defaults(defaults)
assert defaults == {'system_site_packages': 0}
def test_install_python_bin():
"""Should create the right python executables and links"""
tmp_virtualenv = tempfile.mkdtemp()
try:
home_dir, lib_dir, inc_dir, bin_dir = \
virtualenv.path_locations(tmp_virtualenv)
virtualenv.install_python(home_dir, lib_dir, inc_dir, bin_dir, False,
False)
if virtualenv.is_win:
required_executables = [ 'python.exe', 'pythonw.exe']
else:
py_exe_no_version = 'python'
py_exe_version_major = 'python%s' % sys.version_info[0]
py_exe_version_major_minor = 'python%s.%s' % (
sys.version_info[0], sys.version_info[1])
required_executables = [ py_exe_no_version, py_exe_version_major,
py_exe_version_major_minor ]
for pth in required_executables:
assert os.path.exists(os.path.join(bin_dir, pth)), ("%s should "
"exist in bin_dir" % pth)
finally:
shutil.rmtree(tmp_virtualenv)
@pytest.mark.skipif("platform.python_implementation() == 'PyPy'")
def test_always_copy_option():
"""Should be no symlinks in directory tree"""
tmp_virtualenv = tempfile.mkdtemp()
ve_path = os.path.join(tmp_virtualenv, 'venv')
try:
virtualenv.create_environment(ve_path, symlink=False)
for root, dirs, files in os.walk(tmp_virtualenv):
for f in files + dirs:
full_name = os.path.join(root, f)
assert not os.path.islink(full_name), "%s should not be a" \
" symlink (to %s)" % (full_name, os.readlink(full_name))
finally:
shutil.rmtree(tmp_virtualenv)

View File

@ -1,27 +1,40 @@
#!/usr/bin/env python
"""Create a "virtual" Python installation
"""
"""Create a "virtual" Python installation"""
__version__ = "12.0.5"
virtualenv_version = __version__ # legacy
import os
import sys
# If we are running in a new interpreter to create a virtualenv,
# we do NOT want paths from our existing location interfering with anything,
# So we remove this file's directory from sys.path - most likely to be
# the previous interpreter's site-packages. Solves #705, #763, #779
if os.environ.get('VIRTUALENV_INTERPRETER_RUNNING'):
for path in sys.path[:]:
if os.path.realpath(os.path.dirname(__file__)) == os.path.realpath(path):
sys.path.remove(path)
import base64
import sys
import os
import codecs
import optparse
import re
import shutil
import logging
import tempfile
import zlib
import errno
import glob
import distutils.sysconfig
from distutils.util import strtobool
import struct
import subprocess
import tarfile
from distutils.util import strtobool
from os.path import join
try:
import ConfigParser
except ImportError:
import configparser as ConfigParser
__version__ = "14.0.1"
virtualenv_version = __version__ # legacy
if sys.version_info < (2, 6):
print('ERROR: %s' % sys.exc_info()[1])
@ -33,12 +46,6 @@ try:
except NameError:
basestring = str
try:
import ConfigParser
except ImportError:
import configparser as ConfigParser
join = os.path.join
py_version = 'python%s.%s' % (sys.version_info[0], sys.version_info[1])
is_jython = sys.platform.startswith('java')
@ -76,7 +83,7 @@ else:
def get_installed_pythons():
try:
python_core = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE,
"Software\\Python\\PythonCore")
"Software\\Python\\PythonCore")
except WindowsError:
# No registered Python installations
return {}
@ -123,168 +130,21 @@ if majver == 2:
elif majver == 3:
# Some extra modules are needed for Python 3, but different ones
# for different versions.
REQUIRED_MODULES.extend(['_abcoll', 'warnings', 'linecache', 'abc', 'io',
'_weakrefset', 'copyreg', 'tempfile', 'random',
'__future__', 'collections', 'keyword', 'tarfile',
'shutil', 'struct', 'copy', 'tokenize', 'token',
'functools', 'heapq', 'bisect', 'weakref',
'reprlib'])
REQUIRED_MODULES.extend([
'_abcoll', 'warnings', 'linecache', 'abc', 'io', '_weakrefset',
'copyreg', 'tempfile', 'random', '__future__', 'collections',
'keyword', 'tarfile', 'shutil', 'struct', 'copy', 'tokenize',
'token', 'functools', 'heapq', 'bisect', 'weakref', 'reprlib'
])
if minver >= 2:
REQUIRED_FILES[-1] = 'config-%s' % majver
if minver >= 3:
import sysconfig
platdir = sysconfig.get_config_var('PLATDIR')
REQUIRED_FILES.append(platdir)
# The whole list of 3.3 modules is reproduced below - the current
# uncommented ones are required for 3.3 as of now, but more may be
# added as 3.3 development continues.
REQUIRED_MODULES.extend([
#"aifc",
#"antigravity",
#"argparse",
#"ast",
#"asynchat",
#"asyncore",
"base64",
#"bdb",
#"binhex",
#"bisect",
#"calendar",
#"cgi",
#"cgitb",
#"chunk",
#"cmd",
#"codeop",
#"code",
#"colorsys",
#"_compat_pickle",
#"compileall",
#"concurrent",
#"configparser",
#"contextlib",
#"cProfile",
#"crypt",
#"csv",
#"ctypes",
#"curses",
#"datetime",
#"dbm",
#"decimal",
#"difflib",
#"dis",
#"doctest",
#"dummy_threading",
"_dummy_thread",
#"email",
#"filecmp",
#"fileinput",
#"formatter",
#"fractions",
#"ftplib",
#"functools",
#"getopt",
#"getpass",
#"gettext",
#"glob",
#"gzip",
"hashlib",
#"heapq",
"hmac",
#"html",
#"http",
#"idlelib",
#"imaplib",
#"imghdr",
"imp",
"importlib",
#"inspect",
#"json",
#"lib2to3",
#"logging",
#"macpath",
#"macurl2path",
#"mailbox",
#"mailcap",
#"_markupbase",
#"mimetypes",
#"modulefinder",
#"multiprocessing",
#"netrc",
#"nntplib",
#"nturl2path",
#"numbers",
#"opcode",
#"optparse",
#"os2emxpath",
#"pdb",
#"pickle",
#"pickletools",
#"pipes",
#"pkgutil",
#"platform",
#"plat-linux2",
#"plistlib",
#"poplib",
#"pprint",
#"profile",
#"pstats",
#"pty",
#"pyclbr",
#"py_compile",
#"pydoc_data",
#"pydoc",
#"_pyio",
#"queue",
#"quopri",
#"reprlib",
"rlcompleter",
#"runpy",
#"sched",
#"shelve",
#"shlex",
#"smtpd",
#"smtplib",
#"sndhdr",
#"socket",
#"socketserver",
#"sqlite3",
#"ssl",
#"stringprep",
#"string",
#"_strptime",
#"subprocess",
#"sunau",
#"symbol",
#"symtable",
#"sysconfig",
#"tabnanny",
#"telnetlib",
#"test",
#"textwrap",
#"this",
#"_threading_local",
#"threading",
#"timeit",
#"tkinter",
#"tokenize",
#"token",
#"traceback",
#"trace",
#"tty",
#"turtledemo",
#"turtle",
#"unittest",
#"urllib",
#"uuid",
#"uu",
#"wave",
#"weakref",
#"webbrowser",
#"wsgiref",
#"xdrlib",
#"xml",
#"xmlrpc",
#"zipfile",
'base64', '_dummy_thread', 'hashlib', 'hmac',
'imp', 'importlib', 'rlcompleter'
])
if minver >= 4:
REQUIRED_MODULES.extend([
@ -298,6 +158,7 @@ if is_pypy:
# during the bootstrap
REQUIRED_MODULES.extend(['traceback', 'linecache'])
class Logger(object):
"""
@ -322,16 +183,22 @@ class Logger(object):
def debug(self, msg, *args, **kw):
self.log(self.DEBUG, msg, *args, **kw)
def info(self, msg, *args, **kw):
self.log(self.INFO, msg, *args, **kw)
def notify(self, msg, *args, **kw):
self.log(self.NOTIFY, msg, *args, **kw)
def warn(self, msg, *args, **kw):
self.log(self.WARN, msg, *args, **kw)
def error(self, msg, *args, **kw):
self.log(self.ERROR, msg, *args, **kw)
def fatal(self, msg, *args, **kw):
self.log(self.FATAL, msg, *args, **kw)
def log(self, level, msg, *args, **kw):
if args:
if kw:
@ -526,8 +393,7 @@ def _find_file(filename, dirs):
def file_search_dirs():
here = os.path.dirname(os.path.abspath(__file__))
dirs = ['.', here,
join(here, 'virtualenv_support')]
dirs = [here, join(here, 'virtualenv_support')]
if os.path.splitext(os.path.dirname(__file__))[0] != 'virtualenv':
# Probably some boot script; just in case virtualenv is installed...
try:
@ -535,7 +401,8 @@ def file_search_dirs():
except ImportError:
pass
else:
dirs.append(os.path.join(os.path.dirname(virtualenv.__file__), 'virtualenv_support'))
dirs.append(os.path.join(
os.path.dirname(virtualenv.__file__), 'virtualenv_support'))
return [d for d in dirs if os.path.isdir(d)]
@ -714,7 +581,7 @@ def main():
'--no-setuptools',
dest='no_setuptools',
action='store_true',
help='Do not install setuptools (or pip) in the new virtualenv.')
help='Do not install setuptools in the new virtualenv.')
parser.add_option(
'--no-pip',
@ -722,6 +589,12 @@ def main():
action='store_true',
help='Do not install pip in the new virtualenv.')
parser.add_option(
'--no-wheel',
dest='no_wheel',
action='store_true',
help='Do not install wheel in the new virtualenv.')
default_search_dirs = file_search_dirs()
parser.add_option(
'--extra-search-dir',
@ -733,12 +606,20 @@ def main():
"This option can be used multiple times.")
parser.add_option(
'--never-download',
dest="never_download",
action="store_true",
"--download",
dest="download",
default=True,
help="DEPRECATED. Retained only for backward compatibility. This option has no effect. "
"Virtualenv never downloads pip or setuptools.")
action="store_true",
help="Download preinstalled packages from PyPI.",
)
parser.add_option(
"--no-download",
'--never-download',
dest="download",
action="store_false",
help="Do not download preinstalled packages from PyPI.",
)
parser.add_option(
'--prompt',
@ -809,19 +690,16 @@ def main():
make_environment_relocatable(home_dir)
return
if not options.never_download:
logger.warn('The --never-download option is for backward compatibility only.')
logger.warn('Setting it to false is no longer supported, and will be ignored.')
create_environment(home_dir,
site_packages=options.system_site_packages,
clear=options.clear,
unzip_setuptools=options.unzip_setuptools,
prompt=options.prompt,
search_dirs=options.search_dirs,
never_download=True,
download=options.download,
no_setuptools=options.no_setuptools,
no_pip=options.no_pip,
no_wheel=options.no_wheel,
symlink=options.symlink)
if 'after_install' in globals():
after_install(options, home_dir)
@ -937,13 +815,27 @@ def find_wheels(projects, search_dirs):
return wheels
def install_wheel(project_names, py_executable, search_dirs=None):
def install_wheel(project_names, py_executable, search_dirs=None,
download=False):
if search_dirs is None:
search_dirs = file_search_dirs()
wheels = find_wheels(['setuptools', 'pip'], search_dirs)
pythonpath = os.pathsep.join(wheels)
findlinks = ' '.join(search_dirs)
# PIP_FIND_LINKS uses space as the path separator and thus cannot have paths
# with spaces in them. Convert any of those to local file:// URL form.
try:
from urlparse import urljoin
from urllib import pathname2url
except ImportError:
from urllib.parse import urljoin
from urllib.request import pathname2url
def space_path2url(p):
if ' ' not in p:
return p
return urljoin('file:', pathname2url(os.path.abspath(p)))
findlinks = ' '.join(space_path2url(d) for d in search_dirs)
cmd = [
py_executable, '-c',
@ -951,24 +843,31 @@ def install_wheel(project_names, py_executable, search_dirs=None):
] + project_names
logger.start_progress('Installing %s...' % (', '.join(project_names)))
logger.indent += 2
env = {
"PYTHONPATH": pythonpath,
"JYTHONPATH": pythonpath, # for Jython < 3.x
"PIP_FIND_LINKS": findlinks,
"PIP_USE_WHEEL": "1",
"PIP_ONLY_BINARY": ":all:",
"PIP_PRE": "1",
"PIP_USER": "0",
}
if not download:
env["PIP_NO_INDEX"] = "1"
try:
call_subprocess(cmd, show_stdout=False,
extra_env = {
'PYTHONPATH': pythonpath,
'PIP_FIND_LINKS': findlinks,
'PIP_USE_WHEEL': '1',
'PIP_PRE': '1',
'PIP_NO_INDEX': '1'
}
)
call_subprocess(cmd, show_stdout=False, extra_env=env)
finally:
logger.indent -= 2
logger.end_progress()
def create_environment(home_dir, site_packages=False, clear=False,
unzip_setuptools=False,
prompt=None, search_dirs=None, never_download=False,
no_setuptools=False, no_pip=False, symlink=True):
prompt=None, search_dirs=None, download=False,
no_setuptools=False, no_pip=False, no_wheel=False,
symlink=True):
"""
Creates a new environment in ``home_dir``.
@ -986,20 +885,36 @@ def create_environment(home_dir, site_packages=False, clear=False,
install_distutils(home_dir)
to_install = []
if not no_setuptools:
to_install = ['setuptools']
if not no_pip:
to_install.append('pip')
install_wheel(to_install, py_executable, search_dirs)
to_install.append('setuptools')
if not no_pip:
to_install.append('pip')
if not no_wheel:
to_install.append('wheel')
if to_install:
install_wheel(
to_install,
py_executable,
search_dirs,
download=download,
)
install_activate(home_dir, bin_dir, prompt)
install_python_config(home_dir, bin_dir, prompt)
def is_executable_file(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
def path_locations(home_dir):
"""Return the path locations for the environment (where libraries are,
where scripts go, etc)"""
home_dir = os.path.abspath(home_dir)
# XXX: We'd use distutils.sysconfig.get_python_inc/lib but its
# prefix arg is broken: http://bugs.python.org/issue3386
if is_win:
@ -1036,17 +951,7 @@ def path_locations(home_dir):
bin_dir = join(home_dir, 'bin')
elif not is_win:
lib_dir = join(home_dir, 'lib', py_version)
multiarch_exec = '/usr/bin/multiarch-platform'
if is_executable_file(multiarch_exec):
# In Mageia (2) and Mandriva distros the include dir must be like:
# virtualenv/include/multiarch-x86_64-linux/python2.7
# instead of being virtualenv/include/python2.7
p = subprocess.Popen(multiarch_exec, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
# stdout.strip is needed to remove newline character
inc_dir = join(home_dir, 'include', stdout.strip(), py_version + abiflags)
else:
inc_dir = join(home_dir, 'include', py_version + abiflags)
inc_dir = join(home_dir, 'include', py_version + abiflags)
bin_dir = join(home_dir, 'bin')
return home_dir, lib_dir, inc_dir, bin_dir
@ -1085,45 +990,34 @@ def change_prefix(filename, dst_prefix):
def copy_required_modules(dst_prefix, symlink):
import imp
# If we are running under -p, we need to remove the current
# directory from sys.path temporarily here, so that we
# definitely get the modules from the site directory of
# the interpreter we are running under, not the one
# virtualenv.py is installed under (which might lead to py2/py3
# incompatibility issues)
_prev_sys_path = sys.path
if os.environ.get('VIRTUALENV_INTERPRETER_RUNNING'):
sys.path = sys.path[1:]
try:
for modname in REQUIRED_MODULES:
if modname in sys.builtin_module_names:
logger.info("Ignoring built-in bootstrap module: %s" % modname)
continue
try:
f, filename, _ = imp.find_module(modname)
except ImportError:
logger.info("Cannot import bootstrap module: %s" % modname)
for modname in REQUIRED_MODULES:
if modname in sys.builtin_module_names:
logger.info("Ignoring built-in bootstrap module: %s" % modname)
continue
try:
f, filename, _ = imp.find_module(modname)
except ImportError:
logger.info("Cannot import bootstrap module: %s" % modname)
else:
if f is not None:
f.close()
# special-case custom readline.so on OS X, but not for pypy:
if modname == 'readline' and sys.platform == 'darwin' and not (
is_pypy or filename.endswith(join('lib-dynload', 'readline.so'))):
dst_filename = join(dst_prefix, 'lib', 'python%s' % sys.version[:3], 'readline.so')
elif modname == 'readline' and sys.platform == 'win32':
# special-case for Windows, where readline is not a
# standard module, though it may have been installed in
# site-packages by a third-party package
pass
else:
if f is not None:
f.close()
# special-case custom readline.so on OS X, but not for pypy:
if modname == 'readline' and sys.platform == 'darwin' and not (
is_pypy or filename.endswith(join('lib-dynload', 'readline.so'))):
dst_filename = join(dst_prefix, 'lib', 'python%s' % sys.version[:3], 'readline.so')
elif modname == 'readline' and sys.platform == 'win32':
# special-case for Windows, where readline is not a
# standard module, though it may have been installed in
# site-packages by a third-party package
pass
else:
dst_filename = change_prefix(filename, dst_prefix)
copyfile(filename, dst_filename, symlink)
if filename.endswith('.pyc'):
pyfile = filename[:-1]
if os.path.exists(pyfile):
copyfile(pyfile, dst_filename[:-1], symlink)
finally:
sys.path = _prev_sys_path
dst_filename = change_prefix(filename, dst_prefix)
copyfile(filename, dst_filename, symlink)
if filename.endswith('.pyc'):
pyfile = filename[:-1]
if os.path.exists(pyfile):
copyfile(pyfile, dst_filename[:-1], symlink)
def subst_path(prefix_path, prefix, home_dir):
@ -1184,7 +1078,7 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
mkdir(join(lib_dir, 'site-packages'))
import site
site_filename = site.__file__
if site_filename.endswith('.pyc'):
if site_filename.endswith('.pyc') or site_filename.endswith('.pyo'):
site_filename = site_filename[:-1]
elif site_filename.endswith('$py.class'):
site_filename = site_filename.replace('$py.class', '.py')
@ -1479,7 +1373,6 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
def install_activate(home_dir, bin_dir, prompt=None):
home_dir = os.path.abspath(home_dir)
if is_win or is_jython and os._name == 'nt':
files = {
'activate.bat': ACTIVATE_BAT,
@ -1507,6 +1400,10 @@ def install_activate(home_dir, bin_dir, prompt=None):
files['activate.csh'] = ACTIVATE_CSH
files['activate_this.py'] = ACTIVATE_THIS
install_files(home_dir, bin_dir, prompt, files)
def install_files(home_dir, bin_dir, prompt, files):
if hasattr(home_dir, 'decode'):
home_dir = home_dir.decode(sys.getfilesystemencoding())
vname = os.path.basename(home_dir)
@ -1518,6 +1415,15 @@ def install_activate(home_dir, bin_dir, prompt=None):
content = content.replace('__BIN_NAME__', os.path.basename(bin_dir))
writefile(os.path.join(bin_dir, name), content)
def install_python_config(home_dir, bin_dir, prompt=None):
if sys.platform == 'win32' or is_jython and os._name == 'nt':
files = {}
else:
files = {'python-config': PYTHON_CONFIG}
install_files(home_dir, bin_dir, prompt, files)
for name, content in files.items():
make_exe(os.path.join(bin_dir, name))
def install_distutils(home_dir):
distutils_path = change_prefix(distutils.__path__[0], home_dir)
mkdir(distutils_path)
@ -1555,30 +1461,32 @@ def fix_lib64(lib_dir, symlink=True):
instead of lib/pythonX.Y. If this is such a platform we'll just create a
symlink so lib64 points to lib
"""
if [p for p in distutils.sysconfig.get_config_vars().values()
if isinstance(p, basestring) and 'lib64' in p]:
# PyPy's library path scheme is not affected by this.
# Return early or we will die on the following assert.
if is_pypy:
logger.debug('PyPy detected, skipping lib64 symlinking')
return
# PyPy's library path scheme is not affected by this.
# Return early or we will die on the following assert.
if is_pypy:
logger.debug('PyPy detected, skipping lib64 symlinking')
return
# Check we have a lib64 library path
if not [p for p in distutils.sysconfig.get_config_vars().values()
if isinstance(p, basestring) and 'lib64' in p]:
return
logger.debug('This system uses lib64; symlinking lib64 to lib')
logger.debug('This system uses lib64; symlinking lib64 to lib')
assert os.path.basename(lib_dir) == 'python%s' % sys.version[:3], (
"Unexpected python lib dir: %r" % lib_dir)
lib_parent = os.path.dirname(lib_dir)
top_level = os.path.dirname(lib_parent)
lib_dir = os.path.join(top_level, 'lib')
lib64_link = os.path.join(top_level, 'lib64')
assert os.path.basename(lib_parent) == 'lib', (
"Unexpected parent dir: %r" % lib_parent)
if os.path.lexists(lib64_link):
return
if symlink:
os.symlink('lib', lib64_link)
else:
copyfile('lib', lib64_link)
assert os.path.basename(lib_dir) == 'python%s' % sys.version[:3], (
"Unexpected python lib dir: %r" % lib_dir)
lib_parent = os.path.dirname(lib_dir)
top_level = os.path.dirname(lib_parent)
lib_dir = os.path.join(top_level, 'lib')
lib64_link = os.path.join(top_level, 'lib64')
assert os.path.basename(lib_parent) == 'lib', (
"Unexpected parent dir: %r" % lib_parent)
if os.path.lexists(lib64_link):
return
if symlink:
os.symlink('lib', lib64_link)
else:
copyfile('lib', lib64_link)
def resolve_interpreter(exe):
"""
@ -1593,8 +1501,8 @@ def resolve_interpreter(exe):
if os.path.abspath(exe) != exe:
paths = os.environ.get('PATH', '').split(os.pathsep)
for path in paths:
if os.path.exists(os.path.join(path, exe)):
exe = os.path.join(path, exe)
if os.path.exists(join(path, exe)):
exe = join(path, exe)
break
if not os.path.exists(exe):
logger.fatal('The executable %s (from --python=%s) does not exist' % (exe, exe))
@ -2003,71 +1911,70 @@ AVijEPwfucjncQ==
##file activate.sh
ACTIVATE_SH = convert("""
eJytVVFvokAQfudXTLEPtTlLeo9tvMSmJpq02hSvl7u2wRUG2QR2DSxSe7n/frOACEVNLlceRHa+
nfl25pvZDswCnoDPQ4QoTRQsENIEPci4CsBMZBq7CAsuLOYqvmYKTTj3YxnBgiXBudGBjUzBZUJI
BXEqgCvweIyuCjeG4eF2F5x14bcB9KQiQQWrjSddI1/oQIx6SYYeoFjzWIoIhYI1izlbhJjkKO7D
M/QEmKfO9O7WeRo/zr4P7pyHwWxkwitcgwpQ5Ej96OX+PmiFwLeVjFUOrNYKaq1Nud3nR2n8nI2m
k9H0friPTGVsUdptaxGrTEfpNVFEskxpXtUkkCkl1UNF9cgLBkx48J4EXyALuBtAwNYIjF5kcmUU
abMKmMq1ULoiRbgsDEkTSsKSGFCJ6Z8vY/2xYiSacmtyAfCDdCNTVZoVF8vSTQOoEwSnOrngBkws
MYGMBMg8/bMBLSYKS7pYEXP0PqT+ZmBT0Xuy+Pplj5yn4aM9nk72JD8/Wi+Gr98sD9eWSMOwkapD
BbUv91XSvmyVkICt2tmXR4tWmrcUCsjWOpw87YidEC8i0gdTSOFhouJUNxR+4NYBG0MftoCTD9F7
2rTtxG3oPwY1b2HncYwhrlmj6Wq924xtGDWqfdNxap+OYxplEurnMVo9RWks+rH8qKEtx7kZT5zJ
4H7oOFclrN6uFe+d+nW2aIUsSgs/42EIPuOhXq+jEo3S6tX6w2ilNkDnIpHCWdEQhFgwj9pkk7FN
l/y5eQvRSIQ5+TrL05lewxWpt/Lbhes5cJF3mLET1MGhcKCF+40tNWnUulxrpojwDo2sObdje3Bz
N3QeHqf3D7OjEXMVV8LN3ZlvuzoWHqiUcNKHtwNd0IbvPGKYYM31nPKCgkUILw3KL+Y8l7aO1ArS
Ad37nIU0fCj5NE5gQCuC5sOSu+UdI2NeXg/lFkQIlFpdWVaWZRfvqGiirC9o6liJ9FXGYrSY9mI1
D/Ncozgn13vJvsznr7DnkJWXsyMH7e42ljdJ+aqNDF1bFnKWFLdj31xtaJYK6EXFgqmV/ymD/ROG
+n8O9H8f5vsGOWXsL1+1k3g=
eJytVdtu2kAQffdXDAalSVqK6GMrqhIFCaQEIkyp2qZyFnuIVzVrtLsmIZd/76wvYONAHxI/gHdn
dvbMnDPjOkwCrmDOQ4RFrDTMEGKFPtxxHYCtolh6CDMuWszTfMU02nA6l9ECZkwFp1Yd1lEMHhMi
0iBjAVyDzyV6Olxblo/5KTg+gUcL6ImFQg3NOSzXfuRZyV4dJJrdKPQBxYrLSCxQaFgxydksRJV5
1eA3NB+g8Tjtjt+7z/CHzulYCgVaxgh8DmQAysdHL2SS0mAaWBgmx8manbcbj+7o4tydDsaT790L
96o76VM4m+J9AR2gSPzNYywdu1HxtjceeL+MpE4cN3tpipVDiX3O/wfm56Q/GvZHl709kDb2CrCN
pQpvYzoIsuxFULO6JxpRQRQTPz5qYjehH5jw4UEFH+Au4F4AAVshMPojkxctFsasA6LAKCsLRfry
iBGiRkdwSwhIMPQ2j6RZLBlJMDuqPgL8IBVGsc7MmovbLEzJ0RQIGqbE4AVM3KKCO5Iz883PGow0
6VqS2JKQo58TQOUXpvxnXaffTEr99LTZ/OX03Wlv7AxGw+ZLNCRJNiV8+trycdUScaayvGgHCHba
e5h12hVKnXaVS6d9kMTMnANJXXJrbzjdpl8z2NomvQ7YIhI+Kuoj07G4A68ODoZzyB1qOwCaxpS3
en77s0XTIbVzKTHEFSu1dGE4lO+2rALaju26haXr2lZWh2JKVqXZqJJpo2aLgnfLdc8GQ3fYvey5
7ufMrdjHG9zbhjAFox2rROuhVt3TWAbWTpvuXmUZ5lJ5JrcUsz8fON2zi557NR5dXk0qwtwVgrkt
V1AS0b7fVjONQQWFWgfu98ix6r6NiKHCsvfxDY0FFGyBcF0q+bV9cwLbk9kQLAja5FyHS/YXQcUS
zUiIBQs5U+l3wsDn+p2iaS6R+WsDVaJV9Ch0IhRej47KkSwrdd98kJZrmjECmossjt34ZqfifZOx
9wYj75Xj7jWj7qUxR1z9A7WjbI8=
""")
##file activate.fish
ACTIVATE_FISH = convert("""
eJydVW2P2jgQ/s6vmAZQoVpA9/WkqqJaTou0u6x2uZVOVWWZZEKsS+yc7UDpr+84bziQbauLxEvs
eXnsZ56ZIWwTYSAWKUJWGAs7hMJgBEdhEwiMKnSIsBNywUMrDtziPBYmCeBDrFUG7v8HmCTW5n8u
Fu7NJJim81Bl08EQTqqAkEupLOhCgrAQCY2hTU+DQVxIiqgkRNiEBphFEKy+kd1BaFvwFOUBuIxA
oy20BKtAKp3xFMo0QNtCK5mhtMEA6BmSpUELKo38TThwLfguRVNaiRgs0llnEoIR29zfstf18/bv
5T17Wm7vAiiN3ONCzfbfwC3DtWXXDqHfAGX0q6z/bO82j3ebh1VwnbrduwTQbvwcRtesAfMGor/W
L3fs6Xnz8LRlm9fV8/P61sM0LDNwCZjl9gSpCokJRzpryGQ5t8kNGFUt51QjOZGu0Mj35FlYlXEr
yC09EVOp4lEXfF84Lz1qbhBsgl59vDedXI3rTV03xipduSgt9kLytI3XmBp3aV6MPoMQGNUU62T6
uQdeefTy1Hfj10zVHg2pq8fXDoHBiOv94csfXwN49xECqWREy7pwukKfvxdMY2j23vXDPuuxxeE+
JOdCOhxCE3N44B1ZeSLuZh8Mmkr2wEPAmPfKWHA2uxIRjEopdbQYjDz3BWOf14/scfmwoki1eQvX
ExBdF60Mqh+Y/QcX4uiH4Amwzx79KOVFtbL63sXJbtcvy8/3q5rupmO5CnE91wBviQAhjUUegYpL
vVEbpLt2/W+PklRgq5Ku6mp+rpMhhCo/lXthQTxJ2ysO4Ka0ad97S7VT/n6YXus6fzk3fLnBZW5C
KDC6gSO62QDqgFqLCCtPmjegjnLeAdArtSE8VYGbAJ/aLb+vnQutFhk768E9uRbSxhCMzdgEveYw
IZ5ZqFKl6+kz7UR4U+buqQZXu9SIujrAfD7f0FXpozB4Q0gwp31H9mVTZGGC4b871/wm7lvyDLu1
FUyvTj/yvD66k3UPTs08x1AQQaGziOl0S1qRkPG9COtBTSTWM9NzQ4R64B+Px/l3tDzCgxv5C6Ni
e+QaF9xFWrxx0V/G5uvYQOdiZzvYpQUVQSIsTr1TTghI33GnPbTA7/GCqcE3oE3GZurq4HeQXQD6
32XS1ITj/qLjN72ob0hc5C9bzw8MhfmL
eJyFVVFv0zAQfs+vONJO3RDNxCsSQoMVrdK2Vl03CSHkesllMXLsYDvZivjx2GmTOG0YfWhV+7u7
73z33Y1gnTENKeMIeakNPCKUGhP7xcQTbCJ4ZOKcxoZV1GCUMp1t4O0zMxkTQEGVQjicO4dTyIwp
Ppyfu386Q86jWOZwBhq1ZlK8jYIRXEoQ0jhDYAYSpjA2fBsFQVoKG0UKSLAJB9MEJrMXi6uYMiXl
KCrIZYJARQIKTakEGAkmQ+tU5ZSDRTAlRY7CRJMA7GdkgRoNSJ74t1BRxegjR12jWAoGbfpTAeGY
LK4vycN8tb6/uCbLi/VVWGPcx3maPr2AO4VjYB+HMAxAkQT/i/ptfbW4vVrczAZit3eHDNqL13n0
Ya+w+Tq/uyLL1eJmuSaLh9lqNb/0+IzgznqnAjAvzBa4jG0BNmNXfdJUkxTU2I6xRaKcy+e6VApz
WVmoTGFTgwslrYdN03ONrbbMN1E/FQ7H7gOP0UxRjV67TPRBjF3naCMV1mSkYk9MUN7F8cODZzsE
iIHYviIe6n8WeGQxWKuhl+9Xa49uijq7fehXMRxT9VR9f/8jhDcfYSKkSOyxKp22cNIrIk+nzd2b
Yc7FNpHx8FUn15ZfzXEE98JxZEohx4r6kosCT+R9ZkHQtLmXGYSEeH8JCTvYkcRgXAutp9Rw7Jmf
E/J5fktuL25m1tMe3vLdjDt9bNxr2sMo2P3C9BccqGeYhqfQITz6XurXaqdf99LF1mT2YJrvzqCu
5w7dKvV3PzNyOb+7+Hw923dOuB+AX2SxrZs9Lm0xbCH6kmhjUyuWw+7cC7DX8367H3VzDz6oBtty
tMIeobE21JT6HaRS+TbaoqhbE7rgdGs3xtE4cOF3xo0TfxwsdyRlhUoxuzes18r+Jp88zDx1G+kd
/HTrr1BY2CeuyfnbQtAcu9j+pOw6cy9X0k3IuoyKCZPC5ESf6MkgHE5tLiSW3Oa+W2NnrQfkGv/h
7tR5PNFnMBlw4B9NJTxnzKA9fLTT0aXSb5vw7FUKzcTZPddqYHi2T9/axJmEEN3qHncVCuEPaFmq
uEtpcBj2Z1wjrqGReJBHrY6/go21NA==
""")
##file activate.csh
ACTIVATE_CSH = convert("""
eJx9VG1P2zAQ/u5fcYQKNgTNPtN1WxlIQ4KCUEGaxuQ6yYVYSuzKdhqVX7+zk3bpy5YPUXL3PPfc
ne98DLNCWshliVDV1kGCUFvMoJGugMjq2qQIiVSxSJ1cCofD1BYRnOVGV0CfZ0N2DD91DalQSjsw
tQLpIJMGU1euvPe7QeJlkKzgWixlhnAt4aoUVsLnLBiy5NtbJWQ5THX1ZciYKKWwkOFaE04dUm6D
r/zh7pq/3D7Nnid3/HEy+wFHY/gEJydg0aFaQrBFgz1c5DG1IhTs+UZgsBC2GMFBlaeH+8dZXwcW
VPvCjXdlAvCfQsE7al0+07XjZvrSCUevR5dnkVeKlFYZmUztG4BdzL2u9KyLVabTU0bdfg7a0hgs
cSmUg6UwUiQl2iHrcbcVGNvPCiLOe7+cRwG13z9qRGgx2z6DHjfm/Op2yqeT+xvOLzs0PTKHDz2V
tkckFHoQfQRXoGJAj9el0FyJCmEMhzgMS4sB7KPOE2ExoLcSieYwDvR+cP8cg11gKkVJc2wRcm1g
QhYFlXiTaTfO2ki0fQoiFM4tLuO4aZrhOzqR4dIPcWx17hphMBY+Srwh7RTyN83XOWkcSPh1Pg/k
TXX/jbJTbMtUmcxZ+/bbqOsy82suFQg/BhdSOTRhMNBHlUarCpU7JzBhmkKmRejKOQzayQe6MWoa
n1wqWmuh6LZAaHxcdeqIlVLhIBJdO9/kbl0It2oEXQj+eGjJOuvOIR/YGRqvFhttUB2XTvLXYN2H
37CBdbW2W7j2r2+VsCn0doVWcFG1/4y1VwBjfwAyoZhD
eJx1U2FP2zAQ/e5f8TAV3Soo+0zXbYUiDQkKQgVp2ibjJNfFUuIg22nVf885SVFLO3+I7Lt3fr6X
d8eY58ZjYQpCWfuAhFB7yrAyIYf0Ve1SQmLsuU6DWepAw9TnEoOFq0rwdjAUx/hV1Ui1tVWAqy1M
QGYcpaFYx+yVI67LkKwx1UuTEaYGl4X2Bl+zJpAlP/6V2hTDtCq/DYXQhdEeGW040Q/Eb+t9V/e3
U/V88zh/mtyqh8n8J47G+IKTE3gKZJdoYrK3h5MRU1tGYS83gqNc+3yEgyyP93cP820evHLvr2H8
kaYB/peoyY7aVHzpJnE9e+6I5Z+ji4GMTNJWNuOQq6MA1N25p8pW9HWdVWlfsNpPDbdxjgpaahuw
1M7opCA/FFu1uwxC7L8KUqmto1KyQe3rx0I0Eovdf7BVe67U5c1MzSZ310pddGheZoFPWyytRkzU
aCA/I+RkBXhFXr5aWV0SxjhUI6jwdAj8kmhPzX7nTfJFkM3MImp2VdVFFq1vLHSU5szYQK4Ri+Jd
xlW2JBtOGcyYVW7SnB3v6RS91g3gKapZ0oWxbHVteYIIq3iv7QeuSrUj6KSqQ+yqsxDj1ivNQxKF
YON10Q+NH/ARS95i5Tuqq2Vxfvc23f/FO6zrtXXmJr+ZtMY9/A15ZXFWtmch2rEQ4g1ryVHH
""")
##file activate.bat
ACTIVATE_BAT = convert("""
eJx9UdEKgjAUfW6wfxjiIH+hEDKUFHSKLCMI7kNOEkIf9P9pTJ3OLJ/03HPPPed4Es9XS9qqwqgT
PbGKKOdXL4aAFS7A4gvAwgijuiKlqOpGlATS2NeMLE+TjJM9RkQ+SmqAXLrBo1LLIeLdiWlD6jZt
r7VNubWkndkXaxg5GO3UaOOKS6drO3luDDiO5my3iA0YAKGzPRV1ack8cOdhysI0CYzIPzjSiH5X
0QcvC8Lfaj0emsVKYF2rhL5L3fCkVjV76kShi59NHwDniAHzkgDgqBcwOgTMx+gDQQqXCw==
eJx9Ul9LhEAQfxf8DoOclI/dYyFkaCmcq4gZQTBUrincuZFbff12T133TM+nnd35/Zvxlr7XDFhV
mUZHOVhFlOWP3g4DUriIWoVomYZpNBWUtGpaWgImO191pFkSpzlcmgaI70jVX7n2Qp8tuByg+46O
CMHbMq64T+nmlJt082D1T44muCDk2prgEHF4mdI9RaS/QwSt3zSyIAaftRccvqVTBziD1x/WlPD5
xd729NDBb8Nr4DU9QNMKsJeH9pkhPedhQsIkDuCDCa6A+NF9IevVFAohkqizdHetg/tkWvPoftWJ
MCqnOxv7/x7Np6yv9P2Ker5dmX8yNyCkkWnbZy3N5LarczlqL8htx2EM9rQ/2H5BvIsIEi8OEG8U
+g8CsNTr
""")
##file deactivate.bat
DEACTIVATE_BAT = convert("""
eJxzSE3OyFfIT0vj4ipOLVEI8wwKCXX0iXf1C7Pl4spMU0hJTcvMS01RiPf3cYmHyQYE+fsGhCho
cCkAAUibEkTEVhWLMlUlLk6QGixStlyaeCyJDPHw9/Pw93VFsQguim4ZXAJoIUw5DhX47XUM8UCx
EchHtwsohN1bILUgw61c/Vy4AJYPYm4=
eJyFkN0KgkAUhO8F32EQpHqFQEjQUPAPMaErqVxzId3IrV6/XST/UDx3c86c4WMO5FYysKJQFVVp
CEfqxsnJ9DI7SA25i20fFqs3HO+GYLsDZ7h8GM3xfLHrg1QNvpSX4CWpQGvokZk4uqrQAjXjyElB
a5IjCz0r+2dHcehHCe5MZNmB5R7TdqMqECMptHZh6DN/utb7Zs6Cej8OXYE5J04YOKFvD4GkHuJ0
pilSd1jG6n87tDZ+BUwUOepI6CGSkFMYWf0ihvT33Qj1A+tCkSI=
""")
##file activate.ps1
@ -2209,6 +2116,25 @@ m8eg6WYWqR6SL5OjKMGfSrYt/6kxxQtOpeAgj1LXBNmpE2ElmCSIy5H0zFd8gJ924HWijWhb2hRC
VF5PnJ+ts3a9/Mz38RpG/AUSzYUW
""")
##file python-config
PYTHON_CONFIG = convert("""
eJyNVV1P2zAUfc+v8ODBiSABxlulTipbO6p1LWqBgVhlhcZpPYUkctzSivHfd6+dpGloGH2Ja/ue
e+65Hz78xNhtf3x90xmw7vCWsRPGLvpDNuz87MKfdKMWSWxZ4ilNpCLZJiuWc66SVFUOZkkcirll
rfxIBAzOMtImDzSVPBRrekwoX/OZu/0r4lm0DHiG60g86u8sjPw5rCyy86NRkB8QuuBRSqfAKESn
3orLTCQxE3GYkC9tYp8fk89OSwNsmXgizrhUtnumeSgeo5GbLUMk49Rv+2nK48Cm/qMwfp333J2/
dVcAGE0CIQHBsgIeEr4Wij0LtWDLzJ9ze5YEvH2WI6CHTAVcSu9ZCsXtgxu81CIvp6/k4eXsdfo7
PvDCRD75yi41QitfzlcPp1OI7i/1/iQitqnr0iMgQ+A6wa+IKwwdxyk9IiXNAzgquTFU8NIxAVjM
osm1Zz526e+shQ4hKRVci69nPC3Kw4NQEmkQ65E7OodxorSvxjvpBjQHDmWFIQ1mlmzlS5vedseT
/mgIEsMJ7Lxz2bLAF9M5xeLEhdbHxpWOw0GdkJApMVBRF1y+a0z3c9WZPAXGFcFrJgCIB+024uad
0CrzmEoRa3Ub4swNIHPGf7QDV+2uj2OiFWsChgCwjKqN6rp5izpbH6Wc1O1TclQTP/XVwi6anTr1
1sbubjZLI1+VptPSdCfwnFBrB1jvebrTA9uUhU2/9gad7xPqeFkaQcnnLbCViZK8d7R1kxzFrIJV
8EaLYmKYpvGVkig+3C5HCXbM1jGCGekiM2pRCVPyRyXYdPf6kcbWEQ36F5V4Gq9N7icNNw+JHwRE
LTgxRXACpvnQv/PuT0xCCAywY/K4hE6Now2qDwaSE5FB+1agsoUveYDepS83qFcF1NufvULD3fTl
g6Hgf7WBt6lzMeiyyWVn3P1WVbwaczHmTzE9A5SyItTVgFYyvs/L/fXlaNgbw8v3azT+0eikVlWD
/vBHbzQumP23uBCjsYdrL9OWARwxs/nuLOzeXbPJTa/Xv6sUmQir5pC1YRLz3eA+CD8Z0XpcW8v9
MZWF36ryyXXf3yBIz6nzqz8Muyz0m5Qj7OexfYo/Ph3LqvkHUg7AuA==
""")
MH_MAGIC = 0xfeedface
MH_CIGAM = 0xcefaedfe
MH_MAGIC_64 = 0xfeedfacf
@ -2351,6 +2277,6 @@ def mach_o_change(path, what, value):
if __name__ == '__main__':
main()
## TODO:
## Copy python.exe.manifest
## Monkeypatch distutils.sysconfig
# TODO:
# Copy python.exe.manifest
# Monkeypatch distutils.sysconfig

View File

@ -7,20 +7,24 @@ if defined _OLD_VIRTUAL_PROMPT (
if not defined PROMPT (
set "PROMPT=$P$G"
)
set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
)
set "PROMPT=__VIRTUAL_WINPROMPT__ %PROMPT%"
if not defined _OLD_VIRTUAL_PYTHONHOME (
REM Don't use () to avoid problems with them in %PATH%
if defined _OLD_VIRTUAL_PYTHONHOME goto ENDIFVHOME
set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
)
:ENDIFVHOME
set PYTHONHOME=
if defined _OLD_VIRTUAL_PATH (
REM if defined _OLD_VIRTUAL_PATH (
if not defined _OLD_VIRTUAL_PATH goto ENDIFVPATH1
set "PATH=%_OLD_VIRTUAL_PATH%"
) else (
:ENDIFVPATH1
REM ) else (
if defined _OLD_VIRTUAL_PATH goto ENDIFVPATH2
set "_OLD_VIRTUAL_PATH=%PATH%"
)
set "PATH=%VIRTUAL_ENV%\__BIN_NAME__;%PATH%"
:ENDIFVPATH2
:END
set "PATH=%VIRTUAL_ENV%\__BIN_NAME__;%PATH%"

View File

@ -17,13 +17,7 @@ setenv PATH "$VIRTUAL_ENV/__BIN_NAME__:$PATH"
if ("__VIRTUAL_PROMPT__" != "") then
set env_name = "__VIRTUAL_PROMPT__"
else
if (`basename "$VIRTUAL_ENV"` == "__") then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
else
set env_name = `basename "$VIRTUAL_ENV"`
endif
set env_name = `basename "$VIRTUAL_ENV"`
endif
# Could be in a non-interactive environment,

View File

@ -1,35 +1,39 @@
# This file must be used with "source bin/activate.fish" *from fish* (http://fishshell.com)
# you cannot run it directly
# This file must be used using `. bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
# Do not run it directly.
function deactivate -d "Exit virtualenv and return to normal shell environment"
function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
# reset old environment variables
if test -n "$_OLD_VIRTUAL_PATH"
if test -n "$_OLD_VIRTUAL_PATH"
set -gx PATH $_OLD_VIRTUAL_PATH
set -e _OLD_VIRTUAL_PATH
end
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
set -e _OLD_VIRTUAL_PYTHONHOME
end
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
# set an empty local fish_function_path, so fish_prompt doesn't automatically reload
# Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
set -l fish_function_path
# erase the virtualenv's fish_prompt function, and restore the original
# Erase virtualenv's `fish_prompt` and restore the original.
functions -e fish_prompt
functions -c _old_fish_prompt fish_prompt
functions -e _old_fish_prompt
set -e _OLD_FISH_PROMPT_OVERRIDE
end
set -e VIRTUAL_ENV
if test "$argv[1]" != "nondestructive"
# Self destruct!
if test "$argv[1]" != 'nondestructive'
# Self-destruct!
functions -e pydoc
functions -e deactivate
end
end
# unset irrelevant variables
# Unset irrelevant variables.
deactivate nondestructive
set -gx VIRTUAL_ENV "__VIRTUAL_ENV__"
@ -37,38 +41,36 @@ set -gx VIRTUAL_ENV "__VIRTUAL_ENV__"
set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/__BIN_NAME__" $PATH
# unset PYTHONHOME if set
# Unset `$PYTHONHOME` if set.
if set -q PYTHONHOME
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end
function pydoc
python -m pydoc $argv
end
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# fish uses a function instead of an env var to generate the prompt.
# copy the current fish_prompt function as the function _old_fish_prompt
# Copy the current `fish_prompt` function as `_old_fish_prompt`.
functions -c fish_prompt _old_fish_prompt
# with the original prompt function copied, we can override with our own.
function fish_prompt
# Prompt override?
# Save the current $status, for fish_prompts that display it.
set -l old_status $status
# Prompt override provided?
# If not, just prepend the environment name.
if test -n "__VIRTUAL_PROMPT__"
printf "%s%s" "__VIRTUAL_PROMPT__" (set_color normal)
_old_fish_prompt
return
end
# ...Otherwise, prepend env
set -l _checkbase (basename "$VIRTUAL_ENV")
if test $_checkbase = "__"
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal)
_old_fish_prompt
printf '%s%s' "__VIRTUAL_PROMPT__" (set_color normal)
else
printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal)
_old_fish_prompt
printf '%s(%s%s%s) ' (set_color normal) (set_color -o white) (basename "$VIRTUAL_ENV") (set_color normal)
end
end
# Restore the original $status
echo "exit $old_status" | source
_old_fish_prompt
end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
end

View File

@ -2,15 +2,16 @@
# you cannot run it directly
deactivate () {
unset pydoc
unset -f pydoc
# reset old environment variables
if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
if ! [ -z "${_OLD_VIRTUAL_PATH+_}" ] ; then
PATH="$_OLD_VIRTUAL_PATH"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "$_OLD_VIRTUAL_PYTHONHOME" ] ; then
if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
@ -19,18 +20,18 @@ deactivate () {
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
hash -r 2>/dev/null
fi
if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
PS1="$_OLD_VIRTUAL_PS1"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
if [ ! "$1" = "nondestructive" ] ; then
if [ ! "${1-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
@ -47,34 +48,31 @@ PATH="$VIRTUAL_ENV/__BIN_NAME__:$PATH"
export PATH
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "$PYTHONHOME" ] ; then
if ! [ -z "${PYTHONHOME+_}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
unset PYTHONHOME
fi
if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
_OLD_VIRTUAL_PS1="$PS1"
if [ "x__VIRTUAL_PROMPT__" != x ] ; then
PS1="__VIRTUAL_PROMPT__$PS1"
else
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
else
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
fi
PS1="(`basename \"$VIRTUAL_ENV\"`) $PS1"
fi
export PS1
fi
alias pydoc="python -m pydoc"
# Make sure to unalias pydoc if it's already there
alias pydoc 2>/dev/null >/dev/null && unalias pydoc
pydoc () {
python -m pydoc "$@"
}
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
hash -r 2>/dev/null
fi

View File

@ -1,20 +1,19 @@
@echo off
set VIRTUAL_ENV=
if defined _OLD_VIRTUAL_PROMPT (
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
set _OLD_VIRTUAL_PROMPT=
)
if defined _OLD_VIRTUAL_PYTHONHOME (
set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
set _OLD_VIRTUAL_PYTHONHOME=
)
if defined _OLD_VIRTUAL_PATH (
set "PATH=%_OLD_VIRTUAL_PATH%"
set _OLD_VIRTUAL_PATH=
)
:END
@echo off
set VIRTUAL_ENV=
REM Don't use () to avoid problems with them in %PATH%
if not defined _OLD_VIRTUAL_PROMPT goto ENDIFVPROMPT
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
set _OLD_VIRTUAL_PROMPT=
:ENDIFVPROMPT
if not defined _OLD_VIRTUAL_PYTHONHOME goto ENDIFVHOME
set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
set _OLD_VIRTUAL_PYTHONHOME=
:ENDIFVHOME
if not defined _OLD_VIRTUAL_PATH goto ENDIFVPATH
set "PATH=%_OLD_VIRTUAL_PATH%"
set _OLD_VIRTUAL_PATH=
:ENDIFVPATH

View File

@ -0,0 +1,78 @@
#!__VIRTUAL_ENV__/__BIN_NAME__/python
import sys
import getopt
import sysconfig
valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
'ldflags', 'help']
if sys.version_info >= (3, 2):
valid_opts.insert(-1, 'extension-suffix')
valid_opts.append('abiflags')
if sys.version_info >= (3, 3):
valid_opts.append('configdir')
def exit_with_usage(code=1):
sys.stderr.write("Usage: {0} [{1}]\n".format(
sys.argv[0], '|'.join('--'+opt for opt in valid_opts)))
sys.exit(code)
try:
opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
except getopt.error:
exit_with_usage()
if not opts:
exit_with_usage()
pyver = sysconfig.get_config_var('VERSION')
getvar = sysconfig.get_config_var
opt_flags = [flag for (flag, val) in opts]
if '--help' in opt_flags:
exit_with_usage(code=0)
for opt in opt_flags:
if opt == '--prefix':
print(sysconfig.get_config_var('prefix'))
elif opt == '--exec-prefix':
print(sysconfig.get_config_var('exec_prefix'))
elif opt in ('--includes', '--cflags'):
flags = ['-I' + sysconfig.get_path('include'),
'-I' + sysconfig.get_path('platinclude')]
if opt == '--cflags':
flags.extend(getvar('CFLAGS').split())
print(' '.join(flags))
elif opt in ('--libs', '--ldflags'):
abiflags = getattr(sys, 'abiflags', '')
libs = ['-lpython' + pyver + abiflags]
libs += getvar('LIBS').split()
libs += getvar('SYSLIBS').split()
# add the prefix/lib/pythonX.Y/config dir, but only if there is no
# shared library in prefix/lib/.
if opt == '--ldflags':
if not getvar('Py_ENABLE_SHARED'):
libs.insert(0, '-L' + getvar('LIBPL'))
if not getvar('PYTHONFRAMEWORK'):
libs.extend(getvar('LINKFORSHARED').split())
print(' '.join(libs))
elif opt == '--extension-suffix':
ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
if ext_suffix is None:
ext_suffix = sysconfig.get_config_var('SO')
print(ext_suffix)
elif opt == '--abiflags':
if not getattr(sys, 'abiflags', None):
exit_with_usage()
print(sys.abiflags)
elif opt == '--configdir':
print(sysconfig.get_config_var('LIBPL'))

Some files were not shown because too many files have changed in this diff Show More