summaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
authorIan Stakenvicius <axs@gentoo.org>2017-01-27 13:28:01 -0500
committerAndrew Bartlett <abartlet@samba.org>2017-03-10 07:31:12 +0100
commit5bbcd09382a65f9fb86b446bfbaf58a9b6e13aa1 (patch)
treef4ce0450804e867e52a6993159ecb7ff55ca0714 /buildtools
parent9a9e3423d8c7be6350cba20cb6001fc14d47d336 (diff)
downloadsamba-5bbcd09382a65f9fb86b446bfbaf58a9b6e13aa1.tar.gz
waf: disable-python - add option globally to build system
This commit adds --disable-python as an option to the build system. It adds PYTHON_BUILD_IS_ENABLED() to bld, to be used with enabled= on other modules, and adjusts SAMBA_PYTHON() to set enabled=False if PYTHON_BUILD_IS_ENABLED() is false. Signed-off-by: Ian Stakenvicius <axs@gentoo.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/wafsamba/samba_python.py28
-rw-r--r--buildtools/wafsamba/wscript10
2 files changed, 37 insertions, 1 deletions
diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_python.py
index bba059edf98..40b42fcf79a 100644
--- a/buildtools/wafsamba/samba_python.py
+++ b/buildtools/wafsamba/samba_python.py
@@ -40,6 +40,18 @@ def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)):
@conf
def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True):
+ if conf.env.disable_python:
+ 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
+ del(conf.env.defines['PYTHONDIR'])
+ del(conf.env.defines['PYTHONARCHDIR'])
+ return
+
if conf.env["python_headers_checked"] == []:
if conf.env['EXTRA_PYTHON']:
conf.setenv('extrapython')
@@ -79,6 +91,12 @@ def _check_python_headers(conf, mandatory):
conf.env['PYTHON_SO_ABI_FLAG'].replace('_', '-'))
+def PYTHON_BUILD_IS_ENABLED(self):
+ return self.CONFIG_SET('HAVE_PYTHON_H')
+
+Build.BuildContext.PYTHON_BUILD_IS_ENABLED = PYTHON_BUILD_IS_ENABLED
+
+
def SAMBA_PYTHON(bld, name,
source='',
deps='',
@@ -93,6 +111,11 @@ def SAMBA_PYTHON(bld, name,
enabled=True):
'''build a python extension for Samba'''
+ # force-disable when we can't build python modules, so
+ # every single call doesn't need to pass this in.
+ if not bld.PYTHON_BUILD_IS_ENABLED():
+ enabled = False
+
if bld.env['IS_EXTRA_PYTHON']:
name = 'extra-' + name
@@ -140,7 +163,10 @@ Build.BuildContext.SAMBA_PYTHON = SAMBA_PYTHON
def pyembed_libname(bld, name, extrapython=False):
- return name + bld.env['PYTHON_SO_ABI_FLAG']
+ if bld.env['PYTHON_SO_ABI_FLAG']:
+ return name + bld.env['PYTHON_SO_ABI_FLAG']
+ else:
+ return name
Build.BuildContext.pyembed_libname = pyembed_libname
diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
index fcaaf1b792e..4eef008cf88 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,8 +283,14 @@ 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.disable_python and conf.env.EXTRA_PYTHON):
+ Logs.error('ERROR: cannot specify both --disable-python and --extra-python.')
+ sys.exit(1)
+
if (conf.env.AUTOCONF_HOST and
conf.env.AUTOCONF_BUILD and
conf.env.AUTOCONF_BUILD != conf.env.AUTOCONF_HOST):