[pypy-commit] pypy win32-optionals: improve error message if option violates require= kwarg, add largeaddressaware, pass tests
mattip
noreply at buildbot.pypy.org
Thu May 14 00:05:17 CEST 2015
Author: mattip <matti.picus at gmail.com>
Branch: win32-optionals
Changeset: r77317:7fce038262bd
Date: 2015-05-14 01:03 +0300
http://bitbucket.org/pypy/pypy/changeset/7fce038262bd/
Log: improve error message if option violates require= kwarg, add
largeaddressaware, pass tests
diff --git a/rpython/config/config.py b/rpython/config/config.py
--- a/rpython/config/config.py
+++ b/rpython/config/config.py
@@ -98,7 +98,7 @@
raise AttributeError("can't option subgroup")
self._cfgimpl_values[name] = getattr(opt, 'default', None)
- def setoption(self, name, value, who):
+ def setoption(self, name, value, who, requirer='nobody'):
if name not in self._cfgimpl_values:
raise AttributeError('unknown option %s' % (name,))
child = getattr(self._cfgimpl_descr, name)
@@ -108,8 +108,10 @@
if oldvalue == value or who in ("default", "suggested"):
return
raise ConflictConfigError('cannot override value to %s for '
- 'option %s' % (value, name))
- child.setoption(self, value, who)
+ 'option %s because it violates a '
+ 'requirement of %r option(s)' % (
+ value, name, child._requirer))
+ child.setoption(self, value, who, requirer)
self._cfgimpl_value_owners[name] = who
def suggest(self, **kwargs):
@@ -215,6 +217,7 @@
self._name = name
self.doc = doc
self.cmdline = cmdline
+ self._requirer = []
def validate(self, value):
raise NotImplementedError('abstract base class')
@@ -222,12 +225,13 @@
def getdefault(self):
return self.default
- def setoption(self, config, value, who):
+ def setoption(self, config, value, who, requirer='nobody'):
name = self._name
if who == "default" and value is None:
pass
elif not self.validate(value):
- raise ConfigError('invalid value %s for option %s' % (value, name))
+ raise ConfigError('invalid value %s for option %s, required by %r' % (value, name, requirer))
+ self._requirer.append(requirer)
config._cfgimpl_values[name] = value
def getkey(self, value):
@@ -259,7 +263,7 @@
suggests = {}
self._suggests = suggests
- def setoption(self, config, value, who):
+ def setoption(self, config, value, who, requirer='nobody'):
name = self._name
for path, reqvalue in self._requires.get(value, []):
toplevel = config._cfgimpl_get_toplevel()
@@ -268,12 +272,12 @@
who2 = 'default'
else:
who2 = 'required'
- homeconfig.setoption(name, reqvalue, who2)
+ homeconfig.setoption(name, reqvalue, who2, self._name)
for path, reqvalue in self._suggests.get(value, []):
toplevel = config._cfgimpl_get_toplevel()
homeconfig, name = toplevel._cfgimpl_get_home_by_path(path)
homeconfig.suggestoption(name, reqvalue)
- super(ChoiceOption, self).setoption(config, value, who)
+ super(ChoiceOption, self).setoption(config, value, who, requirer)
def validate(self, value):
return value is None or value in self.values
@@ -303,7 +307,7 @@
def validate(self, value):
return isinstance(value, bool)
- def setoption(self, config, value, who):
+ def setoption(self, config, value, who, requirer='nobody'):
name = self._name
if value and self._validator is not None:
toplevel = config._cfgimpl_get_toplevel()
@@ -316,14 +320,14 @@
who2 = 'default'
else:
who2 = 'required'
- homeconfig.setoption(name, reqvalue, who2)
+ homeconfig.setoption(name, reqvalue, who2, self._name)
if value and self._suggests is not None:
for path, reqvalue in self._suggests:
toplevel = config._cfgimpl_get_toplevel()
homeconfig, name = toplevel._cfgimpl_get_home_by_path(path)
homeconfig.suggestoption(name, reqvalue)
- super(BoolOption, self).setoption(config, value, who)
+ super(BoolOption, self).setoption(config, value, who, requirer)
def add_optparse_option(self, argnames, parser, config):
callback = BoolConfigUpdate(config, self, True)
@@ -358,9 +362,9 @@
return False
return True
- def setoption(self, config, value, who):
+ def setoption(self, config, value, who, requirer='nobody'):
try:
- super(IntOption, self).setoption(config, int(value), who)
+ super(IntOption, self).setoption(config, int(value), who, requirer)
except TypeError as e:
raise ConfigError(*e.args)
@@ -379,9 +383,9 @@
return False
return True
- def setoption(self, config, value, who):
+ def setoption(self, config, value, who, requirer='nobody'):
try:
- super(FloatOption, self).setoption(config, float(value), who)
+ super(FloatOption, self).setoption(config, float(value), who, requirer)
except TypeError as e:
raise ConfigError(*e.args)
@@ -396,9 +400,9 @@
def validate(self, value):
return isinstance(value, str)
- def setoption(self, config, value, who):
+ def setoption(self, config, value, who, requirer='nobody'):
try:
- super(StrOption, self).setoption(config, value, who)
+ super(StrOption, self).setoption(config, value, who, requirer)
except TypeError as e:
raise ConfigError(*e.args)
diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -31,12 +31,13 @@
MAINDIR = os.path.dirname(os.path.dirname(__file__))
CACHE_DIR = os.path.realpath(os.path.join(MAINDIR, '_cache'))
+host_platform = sys.platform
PLATFORMS = [
'maemo',
'distutils',
'arm',
+ host_platform
]
-host_platform = sys.platform
translation_optiondescription = OptionDescription(
"translation", "Translation Options", [
@@ -55,13 +56,6 @@
BoolOption("shared", "Build as a shared library",
default=False, cmdline="--shared"),
- ChoiceOption("subsystem", "Target subsystem ('nowindow' and 'console_and_nowindow' avaiable only on Windows)",
- ["console", "nowindow", "console_and_nowindow"],
- default="console",
- requires={"nowindow": [("translation.platform", "win32")],
- "console_and_nowindow":[("translation.platform", "win32")]},
- cmdline="--subsystem"),
-
BoolOption("log", "Include debug prints in the translation (PYPYLOG=...)",
default=True, cmdline="--log"),
@@ -276,11 +270,22 @@
]),
ChoiceOption("platform",
- "target platform", [host_platform] + PLATFORMS, default=host_platform,
+ "target platform", PLATFORMS, default=host_platform,
cmdline='--platform',
suggests={"arm": [("translation.gcrootfinder", "shadowstack"),
("translation.jit_backend", "arm")]}),
+ ChoiceOption("subsystem", "Target subsystem ('nowindow' and 'console_and_nowindow' avaiable only on Windows)",
+ ["console", "nowindow", "console_and_nowindow"],
+ default="console",
+ requires={"nowindow": [("translation.platform", "win32")],
+ "console_and_nowindow":[("translation.platform", "win32")]},
+ cmdline="--subsystem"),
+
+ BoolOption("largeaddressaware",
+ "rewrite the windows 32-bit exe to support more than 2GB of memory on 64-bit windows",
+ requires=[("translation.platform", "win32")],
+ default=False, cmdline="--largeaddressaware"),
])
def get_combined_translation_config(other_optdescr=None,
diff --git a/rpython/conftest.py b/rpython/conftest.py
--- a/rpython/conftest.py
+++ b/rpython/conftest.py
@@ -1,3 +1,4 @@
+import sys
import py, pytest
from rpython.tool import leakfinder
@@ -34,7 +35,7 @@
group.addoption('--view', action="store_true", dest="view", default=False,
help="view translation tests' flow graphs with Pygame")
group.addoption('-P', '--platform', action="store", dest="platform",
- type="string", default="host",
+ type="string", default=sys.platform,
help="set up tests to use specified platform as compile/run target")
group = parser.getgroup("JIT options")
group.addoption('--viewloops', action="store_true",
More information about the pypy-commit
mailing list