[Git][NTPsec/ntpsec][master] Make `waf bin_test` work with `--enable-pylib=none`

Hal Murray (@hal.murray) gitlab at mg.gitlab.com
Thu Jan 30 12:20:03 UTC 2025



Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
e14856ba by James Browning at 2025-01-30T12:16:42+00:00
Make `waf bin_test` work with `--enable-pylib=none`

- - - - -


3 changed files:

- pylib/wscript
- wafhelpers/bin_test.py
- wscript


Changes:

=====================================
pylib/wscript
=====================================
@@ -11,9 +11,11 @@ def options(opt):
 
 def configure(conf):
     conf.load('python')
-    if not conf.env.ENABLE_CROSS:
-        conf.check_python_version((2, 6, 0))
-    conf.check_python_headers(features='pyext')  # Extension-only, no embedded
+    if 'none' == conf.env['ntpc']:
+        return
+    conf.check_python_version((2, 6, 0))  # Check ver even in cross
+    if 'ext' == conf.env['ntpc']:  # Extension-only, no embedded
+        conf.check_python_headers(features='pyext')
     try:
         conf.check_python_module('curses')
         conf.env['PYTHON_CURSES'] = True
@@ -30,11 +32,14 @@ def configure(conf):
         conf.check_python_module('gps', condition="ver >= num(3, 18)")
         conf.env['PYTHON_GPS'] = True
     except conf.errors.ConfigurationError:
-        pprint("YELLOW", "WARNING: ntploggps will not be built/installed since "
-               "python gps module >= 3.18 was not found")
+        pprint("YELLOW", "WARNING: ntploggps will not be built/installed "
+               "since python gps module >= 3.18 was not found")
 
 
 def build(ctx):
+    if 'none' == ctx.env['ntpc']:
+        return
+
     srcnode = ctx.srcnode.make_node('pylib')
     bldnode = ctx.bldnode.make_node('pylib')
     target1 = bldnode.make_node('control.py')
@@ -56,13 +61,10 @@ def build(ctx):
     # including during 'install'. They are now disabled but retained as a
     # comment.
 
-    ## Remove generated files to ensure they are properly updated
-    #ctx.exec_command("rm -f %s" % target1.abspath())
-    #ctx.exec_command("rm -f %s" % target2.abspath())
+    # # Remove generated files to ensure they are properly updated
+    # ctx.exec_command("rm -f %s" % target1.abspath())
+    # ctx.exec_command("rm -f %s" % target2.abspath())
 
-    if ctx.env['ntpc'] is None:
-        return
-        
     # Make sure Python sees .py as well as .pyc/.pyo
     ctx(
         features="subst",
@@ -74,7 +76,10 @@ def build(ctx):
         before=['pyc', 'pyo'],
         cwd=srcnode,
         rule='${PYTHON} ${SRC} >${TGT}',
-        source=["../wafhelpers/pythonize-header", "../include/ntp_control.h"],
+        source=[
+            "../wafhelpers/pythonize-header",
+            "../include/ntp_control.h"
+        ],
         target=target1,
     )
 


=====================================
wafhelpers/bin_test.py
=====================================
@@ -6,7 +6,6 @@
 from __future__ import print_function
 import os
 import os.path
-import sys
 import waflib.Context
 import waflib.Logs
 import waflib.Utils
@@ -89,17 +88,8 @@ def cmd_bin_test(ctx):
     """Run a suite of binary tests."""
     fails = 0
 
-    cmd = ctx.env['PYTHON'] + ['-c',
-        'from __future__ import print_function;'
-        'import ntp.util;'
-        'print(ntp.util.stdversion())']
-    p = waflib.Utils.subprocess.Popen(cmd, env={'PYTHONPATH': '%s/main/tests/pylib' %
-                                                 waflib.Context.out_dir},
-                         universal_newlines=True,
-                         stdin=waflib.Utils.subprocess.PIPE,
-                         stdout=waflib.Utils.subprocess.PIPE,
-                         stderr=waflib.Utils.subprocess.PIPE, cwd=waflib.Context.out_dir)
-    version = p.communicate()[0].rstrip()
+    with open(str(ctx.bldnode) + "/VERSION.bld") as fp:
+        version = fp.read().strip()
 
     if ctx.env['PYTHON_ARGPARSE']:
         cmd_map_python.update(cmd_map_python_argparse)


=====================================
wscript
=====================================
@@ -4,12 +4,10 @@
 
 from __future__ import print_function
 
-from datetime import datetime
 import itertools
 import os
 import shlex
 import sys
-import time
 
 from waflib import Build
 from waflib import Context
@@ -138,7 +136,7 @@ def configure(ctx):
     # the real PATH first, but append the sbin directories.
     ctx.find_program(
         "ldconfig", var="BIN_LDCONFIG", mandatory=False,
-        path_list=(os.environ.get('PATH','').split(os.pathsep) +
+        path_list=(os.environ.get('PATH', '').split(os.pathsep) +
             ["/sbin", "/usr/sbin", "/usr/local/sbin"]))
 
     # Ensure m4 is present, or bison will fail with SIGPIPE
@@ -515,17 +513,17 @@ int main(int argc, char **argv) {
         ctx.env.INCLUDES = ["/usr/local/include"]
         ctx.env.LIBPATH = ["/usr/local/lib"]
         if os.path.isdir("/usr/local/ssl/"):
-          # This assumes OpenSSL is the only thing that was in /usr/local/
-          ctx.env.INCLUDES = ["/usr/local/ssl/include"]
-          ctx.env.LIBPATH = ["/usr/local/ssl/lib"]
+            # This assumes OpenSSL is the only thing that was in /usr/local/
+            ctx.env.INCLUDES = ["/usr/local/ssl/include"]
+            ctx.env.LIBPATH = ["/usr/local/ssl/lib"]
     elif ctx.env.DEST_OS == "netbsd" and os.path.isdir("/usr/pkg/include"):
         ctx.env.INCLUDES = ["/usr/pkg/include"]
         ctx.env.LIBPATH = ["/usr/pkg/lib"]
         ctx.env.LDFLAGS += ["-rpath=/usr/pkg/lib"]
         if os.path.isdir("/usr/local/ssl/"):
-          # This assumes OpenSSL is the only thing that was in /usr/pkg/
-          ctx.env.INCLUDES = ["/usr/local/ssl/include"]
-          ctx.env.LIBPATH = ["/usr/local/ssl/lib"]
+            # This assumes OpenSSL is the only thing that was in /usr/pkg/
+            ctx.env.INCLUDES = ["/usr/local/ssl/include"]
+            ctx.env.LIBPATH = ["/usr/local/ssl/lib"]
     elif ctx.env.DEST_OS == "linux" and os.path.isdir("/usr/local/ssl/"):
         # This supports building OpenSSL from source
         # That allows using OpenSSL 1.1.1 on older CentOS
@@ -533,9 +531,9 @@ int main(int argc, char **argv) {
         # see HOWTO-OpenSSL
         ctx.env.INCLUDES = ["/usr/local/ssl/include"]
         if os.path.isdir("/usr/local/ssl/lib64/"):
-          ctx.env.LIBPATH = ["/usr/local/ssl/lib64"]
+            ctx.env.LIBPATH = ["/usr/local/ssl/lib64"]
         else:
-          ctx.env.LIBPATH = ["/usr/local/ssl/lib"]
+            ctx.env.LIBPATH = ["/usr/local/ssl/lib"]
     elif ctx.env.DEST_OS == "darwin":
         # macports location
         if os.path.isdir("/opt/local/include"):
@@ -668,8 +666,8 @@ int main(int argc, char **argv) {
         #  We could add ifdefs, but old crypto is deprecated in favor of CMAC
         #  and so far, all the systems that we want to support are new enough.
         ('CMAC_CTX_new', ["openssl/cmac.h"], "CRYPTO", True),
-	# Next should be above, but it needs a library
-	# EVP_PKEY_new_CMAC_key added in OpenSSL 1.1.1
+        # Next should be above, but it needs a library
+        # EVP_PKEY_new_CMAC_key added in OpenSSL 1.1.1
         ('EVP_PKEY_new_CMAC_key', ["openssl/cmac.h"], "CRYPTO", False))
     for ft in required_functions:
         probe_function(ctx, function=ft[0],
@@ -714,7 +712,7 @@ int main(int argc, char **argv) {
         "linux/serial.h",
         "net/if6.h",
         ("net/route.h", ["sys/types.h", "sys/socket.h", "net/if.h"]),
-        "openssl/opensslv.h",  # just for wafhelper OpenSSL 
+        "openssl/opensslv.h",  # just for wafhelper OpenSSL
         "priv.h",           # Solaris
         "stdatomic.h",
         "sys/clockctl.h",   # NetBSD
@@ -920,12 +918,13 @@ int main(int argc, char **argv) {
     ctx.recurse("pylib")
     ctx.env.PYSHEBANG = ctx.options.pyshebang
     msg_setting("PYSHEBANG", ctx.env.PYSHEBANG)
-    # Convert the Python directories to absolute paths.
-    # This makes them behave the same as PREFIX.
-    ctx.env.PYTHONDIR = os.path.abspath(ctx.env.PYTHONDIR)
-    ctx.env.PYTHONARCHDIR = os.path.abspath(ctx.env.PYTHONARCHDIR)
-    msg_setting("PYTHONDIR", ctx.env.PYTHONDIR)
-    msg_setting("PYTHONARCHDIR", ctx.env.PYTHONARCHDIR)
+    if 'none' != ctx.env['ntpc']:
+        # Convert the Python directories to absolute paths.
+        # This makes them behave the same as PREFIX.
+        ctx.env.PYTHONDIR = os.path.abspath(ctx.env.PYTHONDIR)
+        ctx.env.PYTHONARCHDIR = os.path.abspath(ctx.env.PYTHONARCHDIR)
+        msg_setting("PYTHONDIR", ctx.env.PYTHONDIR)
+        msg_setting("PYTHONARCHDIR", ctx.env.PYTHONARCHDIR)
 
 
 class check(BuildContext):
@@ -1051,6 +1050,9 @@ def build(ctx):
         ctx.recurse("ntpd")
         return
 
+    with open(str(ctx.bldnode) + "/VERSION.bld", "w") as fp:
+        fp.write("ntpsec-" + ctx.env.NTPSEC_VERSION_EXTENDED)
+
     if ctx.cmd == "build":
         # It's a waf gotcha that if there are object files (including
         # .pyc and .pyo files) in a source directory, compilation to
@@ -1071,13 +1073,13 @@ def build(ctx):
         ctx.recurse("libparse")
     ctx.recurse("libntp")
     if not ctx.env.DISABLE_NTS:
-      ctx.recurse("libaes_siv")
+        ctx.recurse("libaes_siv")
     ctx.recurse("ntpd")
     ctx.recurse("ntpfrob")
     ctx.recurse("ntptime")
     ctx.recurse("pylib")
     if ctx.env.ENABLE_ATTIC:
-      ctx.recurse("attic")
+        ctx.recurse("attic")
     ctx.recurse("etc")
     ctx.recurse("tests")
 
@@ -1089,14 +1091,16 @@ def build(ctx):
     if ctx.env['PYTHON_CURSES']:
         python_scripts.add("ntpclients/ntpmon.py")
 
-    # Make sure the python scripts compile, but don't install them
-    ctx(
-        features="py",
-        source=python_scripts,
-        install_path=None,
-    )
+    scripts = ["ntpclients/ntpleapfetch"]
 
-    scripts = ["ntpclients/ntpleapfetch"] + list(python_scripts)
+    if 'none' != ctx.env['ntpc']:
+        scripts += list(python_scripts)
+        # Make sure the python scripts compile, but don't install them
+        ctx(
+            features="py",
+            source=python_scripts,
+            install_path=None,
+        )
 
     ctx(
         features="subst",



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/e14856ba72d6cba74aea40bf2fcb61fc76e749c3

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/e14856ba72d6cba74aea40bf2fcb61fc76e749c3
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20250130/33b0ccc9/attachment-0001.htm>


More information about the vc mailing list