Skip to content

Commit

Permalink
upgrade waf to 2.0.26
Browse files Browse the repository at this point in the history
  • Loading branch information
pustotnik committed Dec 9, 2023
1 parent f0993e3 commit 346df3f
Show file tree
Hide file tree
Showing 20 changed files with 552 additions and 277 deletions.
2 changes: 1 addition & 1 deletion src/zenmake/waf/waf-light
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.

import os, sys, inspect

VERSION="2.0.23"
VERSION="2.0.26"
REVISION="x"
GIT="x"
INSTALL="x"
Expand Down
2 changes: 1 addition & 1 deletion src/zenmake/waf/waflib/Configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def find_program(self, filename, **kw):

var = kw.get('var', '')
if not var:
var = re.sub(r'[-.]', '_', filename[0].upper())
var = re.sub(r'\W', '_', filename[0].upper())

path_list = kw.get('path_list', '')
if path_list:
Expand Down
8 changes: 4 additions & 4 deletions src/zenmake/waf/waflib/Context.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class imp(object):
import imp

# the following 3 constants are updated on each new release (do not touch)
HEXVERSION=0x2001700
HEXVERSION=0x2001a00
"""Constant updated on new releases"""

WAFVERSION="2.0.23"
WAFVERSION="2.0.26"
"""Constant updated on new releases"""

WAFREVISION="cc6b34cf555d354c34f554c41206134072588de7"
WAFREVISION="0fb985ce1932c6f3e7533f435e4ee209d673776e"
"""Git revision when the waf version is updated"""

WAFNAME="waf"
Expand Down Expand Up @@ -144,7 +144,7 @@ def foo(ctx):
:type fun: string
.. inheritance-diagram:: waflib.Context.Context waflib.Build.BuildContext waflib.Build.InstallContext waflib.Build.UninstallContext waflib.Build.StepContext waflib.Build.ListContext waflib.Configure.ConfigurationContext waflib.Scripting.Dist waflib.Scripting.DistCheck waflib.Build.CleanContext
:top-classes: waflib.Context.Context
"""

errors = Errors
Expand Down
8 changes: 7 additions & 1 deletion src/zenmake/waf/waflib/Scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,11 @@ def archive(self):

for x in files:
archive_name = self.get_base_name() + '/' + x.path_from(self.base_path)
zip.write(x.abspath(), archive_name, zipfile.ZIP_DEFLATED)
if os.environ.get('SOURCE_DATE_EPOCH'):
# TODO: parse that timestamp
zip.writestr(zipfile.ZipInfo(archive_name), x.read(), zipfile.ZIP_DEFLATED)
else:
zip.write(x.abspath(), archive_name, zipfile.ZIP_DEFLATED)
zip.close()
else:
self.fatal('Valid algo types are tar.bz2, tar.gz, tar.xz or zip')
Expand Down Expand Up @@ -425,6 +429,8 @@ def add_tar_file(self, x, tar):
tinfo.gid = 0
tinfo.uname = 'root'
tinfo.gname = 'root'
if os.environ.get('SOURCE_DATE_EPOCH'):
tinfo.mtime = int(os.environ.get('SOURCE_DATE_EPOCH'))

if os.path.isfile(p):
with open(p, 'rb') as f:
Expand Down
2 changes: 1 addition & 1 deletion src/zenmake/waf/waflib/TaskGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def feature(*k):
Decorator that registers a task generator method that will be executed when the
object attribute ``feature`` contains the corresponding key(s)::
from waflib.Task import feature
from waflib.TaskGen import feature
@feature('myfeature')
def myfunction(self):
print('that is my feature!')
Expand Down
1 change: 1 addition & 0 deletions src/zenmake/waf/waflib/Tools/ccroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class link_task(Task.Task):
Base class for all link tasks. A task generator is supposed to have at most one link task bound in the attribute *link_task*. See :py:func:`waflib.Tools.ccroot.apply_link`.
.. inheritance-diagram:: waflib.Tools.ccroot.stlink_task waflib.Tools.c.cprogram waflib.Tools.c.cshlib waflib.Tools.cxx.cxxstlib waflib.Tools.cxx.cxxprogram waflib.Tools.cxx.cxxshlib waflib.Tools.d.dprogram waflib.Tools.d.dshlib waflib.Tools.d.dstlib waflib.Tools.ccroot.fake_shlib waflib.Tools.ccroot.fake_stlib waflib.Tools.asm.asmprogram waflib.Tools.asm.asmshlib waflib.Tools.asm.asmstlib
:top-classes: waflib.Tools.ccroot.link_task
"""
color = 'YELLOW'

Expand Down
17 changes: 16 additions & 1 deletion src/zenmake/waf/waflib/Tools/msvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ def options(opt):
opt.add_option('--msvc_targets', type='string', help = 'msvc targets, eg: "x64,arm"', default='')
opt.add_option('--no-msvc-lazy', action='store_false', help = 'lazily check msvc target environments', default=True, dest='msvc_lazy')

class MSVCVersion(object):
def __init__(self, ver):
m = re.search(r'^(.*)\s+(\d+[.]\d+)', ver)
if m:
self.name = m.group(1)
self.number = float(m.group(2))
else:
self.name = ver
self.number = 0.

def __lt__(self, other):
if self.number == other.number:
return self.name < other.name
return self.number < other.number

@conf
def setup_msvc(conf, versiondict):
"""
Expand All @@ -125,7 +140,7 @@ def setup_msvc(conf, versiondict):
platforms=Utils.to_list(conf.env.MSVC_TARGETS) or [i for i,j in all_msvc_platforms+all_icl_platforms+all_wince_platforms]
desired_versions = getattr(Options.options, 'msvc_version', '').split(',')
if desired_versions == ['']:
desired_versions = conf.env.MSVC_VERSIONS or list(reversed(sorted(versiondict.keys())))
desired_versions = conf.env.MSVC_VERSIONS or list(sorted(versiondict.keys(), key=MSVCVersion, reverse=True))

# Override lazy detection by evaluating after the fact.
lazy_detect = getattr(Options.options, 'msvc_lazy', True)
Expand Down
66 changes: 37 additions & 29 deletions src/zenmake/waf/waflib/Tools/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,17 @@ def build(bld):
Piece of Python code used in :py:class:`waflib.Tools.python.pyo` and :py:class:`waflib.Tools.python.pyc` for byte-compiling python files
"""

DISTUTILS_IMP = ['from distutils.sysconfig import get_config_var, get_python_lib']
DISTUTILS_IMP = """
try:
from distutils.sysconfig import get_config_var, get_python_lib
except ImportError:
from sysconfig import get_config_var, get_path
def get_python_lib(*k, **kw):
keyword='platlib' if kw.get('plat_specific') else 'purelib'
if 'prefix' in kw:
return get_path(keyword, vars={'installed_base': kw['prefix'], 'platbase': kw['prefix']})
return get_path(keyword)
""".splitlines()

@before_method('process_source')
@feature('py')
Expand Down Expand Up @@ -219,7 +229,7 @@ def get_python_variables(self, variables, imports=None):
try:
out = self.cmd_and_log(self.env.PYTHON + ['-c', '\n'.join(program)], env=os_env)
except Errors.WafError:
self.fatal('The distutils module is unusable: install "python-devel"?')
self.fatal('Could not run %r' % self.env.PYTHON)
self.to_log(out)
return_values = []
for s in out.splitlines():
Expand Down Expand Up @@ -291,7 +301,8 @@ def python_cross_compile(self, features='pyembed pyext'):
@conf
def check_python_headers(conf, features='pyembed pyext'):
"""
Check for headers and libraries necessary to extend or embed python by using the module *distutils*.
Check for headers and libraries necessary to extend or embed python.
It may use the module *distutils* or sysconfig in newer Python versions.
On success the environment variables xxx_PYEXT and xxx_PYEMBED are added:
* PYEXT: for compiling python extensions
Expand All @@ -315,7 +326,7 @@ def check_python_headers(conf, features='pyembed pyext'):
conf.fatal('Could not find the python executable')

# so we actually do all this for compatibility reasons and for obtaining pyext_PATTERN below
v = 'prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS LDVERSION'.split()
v = 'prefix SO EXT_SUFFIX LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS LDVERSION'.split()
try:
lst = conf.get_python_variables(["get_config_var('%s') or ''" % x for x in v])
except RuntimeError:
Expand All @@ -328,7 +339,7 @@ def check_python_headers(conf, features='pyembed pyext'):
x = 'MACOSX_DEPLOYMENT_TARGET'
if dct[x]:
env[x] = conf.environ[x] = str(dct[x])
env.pyext_PATTERN = '%s' + dct['SO'] # not a mistake
env.pyext_PATTERN = '%s' + (dct['EXT_SUFFIX'] or dct['SO']) # SO is deprecated in 3.5 and removed in 3.11


# Try to get pythonX.Y-config
Expand Down Expand Up @@ -439,7 +450,7 @@ def check_python_headers(conf, features='pyembed pyext'):
env.LIBPATH_PYEXT = env.LIBPATH_PYEMBED
env.LIB_PYEXT = env.LIB_PYEMBED

conf.to_log("Include path for Python extensions (found via distutils module): %r\n" % (dct['INCLUDEPY'],))
conf.to_log("Found an include path for Python extensions: %r\n" % (dct['INCLUDEPY'],))
env.INCLUDES_PYEXT = [dct['INCLUDEPY']]
env.INCLUDES_PYEMBED = [dct['INCLUDEPY']]

Expand All @@ -452,15 +463,21 @@ def check_python_headers(conf, features='pyembed pyext'):
env.append_unique('CXXFLAGS_PYEXT', ['-fno-strict-aliasing'])

if env.CC_NAME == "msvc":
from distutils.msvccompiler import MSVCCompiler
dist_compiler = MSVCCompiler()
dist_compiler.initialize()
env.append_value('CFLAGS_PYEXT', dist_compiler.compile_options)
env.append_value('CXXFLAGS_PYEXT', dist_compiler.compile_options)
env.append_value('LINKFLAGS_PYEXT', dist_compiler.ldflags_shared)
try:
from distutils.msvccompiler import MSVCCompiler
except ImportError:
# From https://github.com/python/cpython/blob/main/Lib/distutils/msvccompiler.py
env.append_value('CFLAGS_PYEXT', [ '/nologo', '/Ox', '/MD', '/W3', '/GX', '/DNDEBUG'])
env.append_value('CXXFLAGS_PYEXT', [ '/nologo', '/Ox', '/MD', '/W3', '/GX', '/DNDEBUG'])
env.append_value('LINKFLAGS_PYEXT', ['/DLL', '/nologo', '/INCREMENTAL:NO'])
else:
dist_compiler = MSVCCompiler()
dist_compiler.initialize()
env.append_value('CFLAGS_PYEXT', dist_compiler.compile_options)
env.append_value('CXXFLAGS_PYEXT', dist_compiler.compile_options)
env.append_value('LINKFLAGS_PYEXT', dist_compiler.ldflags_shared)

# See if it compiles
conf.check(header_name='Python.h', define_name='HAVE_PYTHON_H', uselib='PYEMBED', fragment=FRAG, errmsg='Distutils not installed? Broken python installation? Get python-config now!')
conf.check(header_name='Python.h', define_name='HAVE_PYTHON_H', uselib='PYEMBED', fragment=FRAG, errmsg='Could not build a Python embedded interpreter')

@conf
def check_python_version(conf, minver=None):
Expand Down Expand Up @@ -506,17 +523,9 @@ def check_python_version(conf, minver=None):
else:
# Finally, try to guess
if Utils.is_win32:
(python_LIBDEST, pydir) = conf.get_python_variables(
["get_config_var('LIBDEST') or ''",
"get_python_lib(standard_lib=0) or ''"])
(pydir,) = conf.get_python_variables(["get_python_lib(standard_lib=0) or ''"])
else:
python_LIBDEST = None
(pydir,) = conf.get_python_variables( ["get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env.PREFIX])
if python_LIBDEST is None:
if conf.env.LIBDIR:
python_LIBDEST = os.path.join(conf.env.LIBDIR, 'python' + pyver)
else:
python_LIBDEST = os.path.join(conf.env.PREFIX, 'lib', 'python' + pyver)
(pydir,) = conf.get_python_variables(["get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env.PREFIX])

if 'PYTHONARCHDIR' in conf.env:
# Check if --pythonarchdir was specified
Expand All @@ -526,7 +535,7 @@ def check_python_version(conf, minver=None):
pyarchdir = conf.environ['PYTHONARCHDIR']
else:
# Finally, try to guess
(pyarchdir, ) = conf.get_python_variables( ["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r) or ''" % conf.env.PREFIX])
(pyarchdir, ) = conf.get_python_variables(["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r) or ''" % conf.env.PREFIX])
if not pyarchdir:
pyarchdir = pydir

Expand Down Expand Up @@ -585,13 +594,12 @@ def configure(conf):
if ret == 'unknown version':
conf.fatal('Could not check the %s version' % module_name)

from distutils.version import LooseVersion
def num(*k):
if isinstance(k[0], int):
return LooseVersion('.'.join([str(x) for x in k]))
return Utils.loose_version('.'.join([str(x) for x in k]))
else:
return LooseVersion(k[0])
d = {'num': num, 'ver': LooseVersion(ret)}
return Utils.loose_version(k[0])
d = {'num': num, 'ver': Utils.loose_version(ret)}
ev = eval(condition, {}, d)
if not ev:
conf.fatal('The %s version does not satisfy the requirements' % module_name)
Expand Down

0 comments on commit 346df3f

Please sign in to comment.