commit c068f3d23eb6572a86543da7ee05418212f3a9ea Author: Ian Stakenvicius Date: Fri Jan 27 13:28:01 2017 -0500 waf: disable-python - add option globally to build system diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_python.py index 057a017..47b26c2 100644 --- a/buildtools/wafsamba/samba_python.py +++ b/buildtools/wafsamba/samba_python.py @@ -40,22 +40,31 @@ def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)): @conf def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True): - if conf.env["python_headers_checked"] == []: - if conf.env['EXTRA_PYTHON']: - conf.setenv('extrapython') - _check_python_headers(conf, mandatory=True) - conf.setenv('default') - - _check_python_headers(conf, mandatory) - conf.env["python_headers_checked"] = "yes" - - if conf.env['EXTRA_PYTHON']: - extraversion = conf.all_envs['extrapython']['PYTHON_VERSION'] - if extraversion == conf.env['PYTHON_VERSION']: - raise Utils.WafError("extrapython %s is same as main python %s" % ( - extraversion, conf.env['PYTHON_VERSION'])) + if not conf.env.disable_python: + if conf.env["python_headers_checked"] == []: + if conf.env['EXTRA_PYTHON']: + conf.setenv('extrapython') + _check_python_headers(conf, mandatory=True) + conf.setenv('default') + + _check_python_headers(conf, mandatory) + conf.env["python_headers_checked"] = "yes" + + if conf.env['EXTRA_PYTHON']: + extraversion = conf.all_envs['extrapython']['PYTHON_VERSION'] + if extraversion == conf.env['PYTHON_VERSION']: + raise Utils.WafError("extrapython %s is same as main python %s" % ( + extraversion, conf.env['PYTHON_VERSION'])) + + else: + conf.msg("python headers", "using cache") + else: - conf.msg("python headers", "using cache") + if mandatory: + raise Utils.WafError("Cannot check for python headers when --disable-python specified") + + conf.msg("python headers", "Check disabled due to --disable-python") + # we don't want PYTHONDIR in config.h, as otherwise changing # --prefix causes a complete rebuild @@ -77,6 +86,14 @@ def _check_python_headers(conf, mandatory): conf.env['PYTHON_SO_ABI_FLAG'] = '' +def PYTHON_BUILD_IS_ENABLED(self): + if self.CONFIG_SET('HAVE_PYTHON_H'): + return True + return False + +Build.BuildContext.PYTHON_BUILD_IS_ENABLED = PYTHON_BUILD_IS_ENABLED + + def SAMBA_PYTHON(bld, name, source='', deps='', @@ -89,8 +106,9 @@ def SAMBA_PYTHON(bld, name, vars=None, install=True, enabled=True): - '''build a python extension for Samba''' + '''build a python extension for Samba''' + if bld.PYTHON_BUILD_IS_ENABLED(): if bld.env['IS_EXTRA_PYTHON']: name = 'extra-' + name diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index 8802e5a..c5c0081 100644 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -196,6 +196,10 @@ def set_options(opt): help='tag release in git at the same time', type='string', action='store', dest='TAG_RELEASE') + opt.add_option('--disable-python', + help='do not generate python modules', + action='store_true', dest='disable_python', default=False) + opt.add_option('--extra-python', type=str, help=("build selected libraries for the specified " "additional version of Python " @@ -279,6 +283,8 @@ def configure(conf): conf.env.AUTOCONF_HOST = Options.options.AUTOCONF_HOST conf.env.AUTOCONF_PROGRAM_PREFIX = Options.options.AUTOCONF_PROGRAM_PREFIX + conf.env.disable_python = Options.options.disable_python + conf.env.EXTRA_PYTHON = Options.options.EXTRA_PYTHON if (conf.env.AUTOCONF_HOST and