Skip to content

Commit

Permalink
waf: disable-python - add option globally to build system
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>
Reviewed-by: Douglas Bagnall <[email protected]>
  • Loading branch information
axs-gentoo authored and abartlet committed Mar 10, 2017
1 parent 9a9e342 commit 5bbcd09
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
28 changes: 27 additions & 1 deletion buildtools/wafsamba/samba_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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='',
Expand All @@ -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

Expand Down Expand Up @@ -140,7 +163,10 @@ def SAMBA_PYTHON(bld, name,


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

Expand Down
10 changes: 10 additions & 0 deletions buildtools/wafsamba/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 5bbcd09

Please sign in to comment.