build: use python f-strings
Change-Id: I5a6537d263d8bd6297b0975f34c90dd76b9468cd
This commit is contained in:
1 parent
4a9e0b194b
commit
b6e10dd86a
3 files changed
+20
-19
No files matched your search
+3
-3
@@ -3,8 +3,8 @@ top = '..'
|
||||
|
||||
def build(bld):
|
||||
bld.program(
|
||||
target='../unit-tests',
|
||||
target=f'{top}/unit-tests',
|
||||
name='unit-tests',
|
||||
source=bld.path.ant_glob(['*.cpp'] + ['%s/**/*.cpp' % tool for tool in bld.env.BUILD_TOOLS]),
|
||||
use=['core-objects'] + ['%s-objects' % tool for tool in bld.env.BUILD_TOOLS],
|
||||
source=bld.path.ant_glob(['*.cpp'] + [f'{tool}/**/*.cpp' for tool in bld.env.BUILD_TOOLS]),
|
||||
use=['core-objects'] + [f'{tool}-objects' for tool in bld.env.BUILD_TOOLS],
|
||||
install_path=None)
|
||||
+9
-9
@@ -6,12 +6,12 @@ from waflib import Options
|
||||
def options(opt):
|
||||
for subdir in opt.path.ant_glob('*', dir=True, src=False):
|
||||
tool = subdir.path_from(opt.path)
|
||||
opt.add_option('--enable-%s' % tool,
|
||||
help='Build tool %s (enabled by default)' % tool,
|
||||
action='store_true', dest='enable_%s' % tool)
|
||||
opt.add_option('--disable-%s' % tool,
|
||||
help='Do not build tool %s' % tool,
|
||||
action='store_true', dest='disable_%s' % tool)
|
||||
opt.add_option(f'--enable-{tool}',
|
||||
help=f'Build tool {tool} (enabled by default)',
|
||||
action='store_true', dest=f'enable_{tool}')
|
||||
opt.add_option(f'--disable-{tool}',
|
||||
help=f'Do not build tool {tool}',
|
||||
action='store_true', dest=f'disable_{tool}')
|
||||
opt.recurse(str(tool), mandatory=False)
|
||||
|
||||
def configure(conf):
|
||||
@@ -23,11 +23,11 @@ def configure(conf):
|
||||
tool = subdir.path_from(conf.path)
|
||||
all_tools.add(tool)
|
||||
|
||||
is_enabled = getattr(Options.options, 'enable_%s' % tool)
|
||||
is_disabled = getattr(Options.options, 'disable_%s' % tool)
|
||||
is_enabled = getattr(Options.options, f'enable_{tool}')
|
||||
is_disabled = getattr(Options.options, f'disable_{tool}')
|
||||
|
||||
if is_enabled and is_disabled:
|
||||
conf.fatal('--enable-%s and --disable-%s cannot be both specified' % (tool, tool))
|
||||
conf.fatal(f'--enable-{tool} and --disable-{tool} cannot be both specified')
|
||||
|
||||
if is_enabled:
|
||||
enabled_tools.add(tool)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from waflib import Context, Logs, Utils
|
||||
import os, subprocess
|
||||
|
||||
VERSION = '22.12'
|
||||
APPNAME = 'ndn-tools'
|
||||
@@ -107,16 +108,16 @@ def version(ctx):
|
||||
# first, try to get a version string from git
|
||||
gotVersionFromGit = False
|
||||
try:
|
||||
cmd = ['git', 'describe', '--always', '--match', '%s*' % GIT_TAG_PREFIX]
|
||||
out = subprocess.check_output(cmd, universal_newlines=True).strip()
|
||||
cmd = ['git', 'describe', '--always', '--match', f'{GIT_TAG_PREFIX}*']
|
||||
out = subprocess.run(cmd, capture_output=True, check=True, text=True).stdout.strip()
|
||||
if out:
|
||||
gotVersionFromGit = True
|
||||
if out.startswith(GIT_TAG_PREFIX):
|
||||
Context.g_module.VERSION = out.lstrip(GIT_TAG_PREFIX)
|
||||
else:
|
||||
# no tags matched
|
||||
Context.g_module.VERSION = '%s-commit-%s' % (VERSION_BASE, out)
|
||||
except (OSError, subprocess.CalledProcessError):
|
||||
Context.g_module.VERSION = f'{VERSION_BASE}-commit-{out}'
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
pass
|
||||
|
||||
versionFile = ctx.path.find_node('VERSION.info')
|
||||
@@ -134,14 +135,14 @@ def version(ctx):
|
||||
# already up-to-date
|
||||
return
|
||||
except EnvironmentError as e:
|
||||
Logs.warn('%s exists but is not readable (%s)' % (versionFile, e.strerror))
|
||||
Logs.warn(f'{versionFile} exists but is not readable ({e.strerror})')
|
||||
else:
|
||||
versionFile = ctx.path.make_node('VERSION.info')
|
||||
|
||||
try:
|
||||
versionFile.write(Context.g_module.VERSION)
|
||||
except EnvironmentError as e:
|
||||
Logs.warn('%s is not writable (%s)' % (versionFile, e.strerror))
|
||||
Logs.warn(f'{versionFile} is not writable ({e.strerror})')
|
||||
|
||||
def dist(ctx):
|
||||
ctx.algo = 'tar.xz'
|
||||
|
||||
Reference in new issue
Block a user