From 1f456a7bb2e9658c596a1c8872ac9754c3012070 Mon Sep 17 00:00:00 2001 From: Ashley Pittman Date: Thu, 3 Nov 2022 23:04:45 +0000 Subject: [PATCH] DAOS-623 build: Use AddMethod for adding methods to environments. (#10654) * Apply change to compiler_setup. Signed-off-by: Ashley Pittman --- SConstruct | 36 +++++------ site_scons/compiler_setup.py | 7 ++- site_scons/daos_build.py | 63 ++++++++++---------- src/cart/SConscript | 2 +- src/cart/utils/SConscript | 4 +- src/client/api/SConscript | 2 +- src/client/dfs/SConscript | 2 +- src/client/dfuse/SConscript | 3 +- src/client/pydaos/SConscript | 5 +- src/common/SConscript | 4 +- src/common/tests/SConscript | 4 +- src/control/SConscript | 37 +++++------- src/engine/tests/SConscript | 4 +- src/gurt/SConscript | 3 +- src/tests/SConscript | 3 +- src/tests/ftest/SConscript | 6 +- src/tests/suite/SConscript | 3 +- src/utils/SConscript | 2 +- src/utils/wrap/mpi/SConscript | 9 ++- utils/sl/fake_scons/SCons/Script/__init__.py | 60 +++++++++++++++++-- 20 files changed, 149 insertions(+), 110 deletions(-) diff --git a/SConstruct b/SConstruct index fce55bb4ca8..5c88692c072 100644 --- a/SConstruct +++ b/SConstruct @@ -22,11 +22,6 @@ wrap scons-3.""") SCons.Warnings.warningAsException() -try: - input = raw_input # pylint: disable=redefined-builtin -except NameError: - pass - def get_version(env): """ Read version from VERSION file """ @@ -50,6 +45,8 @@ API_VERSION = f'{API_VERSION_MAJOR}.{API_VERSION_MINOR}.{API_VERSION_FIX}' def update_rpm_version(version, tag): """ Update the version (and release) in the RPM spec file """ + + # pylint: disable=consider-using-f-string spec = open("utils/rpms/daos.spec", "r").readlines() # pylint: disable=consider-using-with current_version = 0 release = 0 @@ -151,6 +148,7 @@ def build_misc(build_prefix): def scons(): # pylint: disable=too-many-locals,too-many-branches """Execute build""" if COMMAND_LINE_TARGETS == ['release']: + # pylint: disable=consider-using-f-string try: # pylint: disable=import-outside-toplevel import pygit2 @@ -329,7 +327,6 @@ def scons(): # pylint: disable=too-many-locals,too-many-branches # Scons strips out the environment, however to be able to build daos using the interception # library we need to add a few things back in. if 'LD_PRELOAD' in os.environ: - # pylint: disable=invalid-sequence-index env['ENV']['LD_PRELOAD'] = os.environ['LD_PRELOAD'] for key in ['D_LOG_FILE', 'DAOS_AGENT_DRPC_DIR', 'D_LOG_MASK', 'DD_MASK', 'DD_SUBSYS']: @@ -348,7 +345,6 @@ def scons(): # pylint: disable=too-many-locals,too-many-branches if 'VIRTUAL_ENV' in os.environ: env.PrependENVPath('PATH', os.path.join(os.environ['VIRTUAL_ENV'], 'bin')) - # pylint: disable=invalid-sequence-index env['ENV']['VIRTUAL_ENV'] = os.environ['VIRTUAL_ENV'] prereqs = PreReqComponent(env, opts, commits_file) @@ -376,18 +372,21 @@ def scons(): # pylint: disable=too-many-locals,too-many-branches set_defaults(env, daos_version) - base_env = env.Clone() - - base_env_mpi = env.Clone() + # Add project specific methods to SCons environments. + daos_build.setup(env) + compiler_setup.setup(env) - compiler_setup.base_setup(env) + base_env = env.Clone() if not GetOption('help') and not GetOption('clean'): - mpi = daos_build.configure_mpi(base_env_mpi) - if not mpi: + base_env_mpi = env.d_configure_mpi() + if not base_env_mpi: print("\nSkipping compilation for tests that need MPI") print("Install and load mpich or openmpi\n") - base_env_mpi = None + else: + base_env_mpi = None + + env.compiler_setup() args = GetOption('analyze_stack') if args is not None: @@ -407,12 +406,9 @@ def scons(): # pylint: disable=too-many-locals,too-many-branches buildinfo.save('.build_vars.json') # also install to $PREFIX/lib to work with existing avocado test code if prereqs.test_requested(): - daos_build.install(env, "lib/daos/", - ['.build_vars.sh', '.build_vars.json']) - env.Install('$PREFIX/lib/daos/TESTING/ftest/util', - ['site_scons/env_modules.py']) - env.Install('$PREFIX/lib/daos/TESTING/ftest/', - ['ftest.sh']) + env.Install('$PREFIX/lib/daos', ['.build_vars.sh', '.build_vars.json']) + env.Install('$PREFIX/lib/daos/TESTING/ftest/util', ['site_scons/env_modules.py']) + env.Install('$PREFIX/lib/daos/TESTING/ftest/', ['ftest.sh']) env.Install("$PREFIX/lib64/daos", "VERSION") diff --git a/site_scons/compiler_setup.py b/site_scons/compiler_setup.py index 222a32fa2f1..3f5b48432e0 100644 --- a/site_scons/compiler_setup.py +++ b/site_scons/compiler_setup.py @@ -22,7 +22,7 @@ '-Wno-unused-function'] -def base_setup(env): +def _base_setup(env): """Setup the scons environment for the compiler Include all our preferred compile options for the chosen @@ -84,3 +84,8 @@ def base_setup(env): env.AppendIfSupported(CCFLAGS=PP_ONLY_FLAGS) env['BSETUP'] = compiler + + +def setup(env): + """Add daos specific method to environment""" + env.AddMethod(_base_setup, 'compiler_setup') diff --git a/site_scons/daos_build.py b/site_scons/daos_build.py index 76f146ee942..564de1ab677 100644 --- a/site_scons/daos_build.py +++ b/site_scons/daos_build.py @@ -8,7 +8,6 @@ from SCons.Script import Depends from SCons.Script import Exit from env_modules import load_mpi -import compiler_setup libraries = {} missing = set() @@ -23,12 +22,11 @@ def __hash__(self): return hash(self.lstr) -def add_rpaths(env, install_off, set_cgo_ld, is_bin): +def _add_rpaths(env, install_off, set_cgo_ld, is_bin): """Add relative rpath entries""" if GetOption('no_rpath'): if set_cgo_ld: - env.AppendENVPath("CGO_LDFLAGS", env.subst("$_LIBDIRFLAGS "), - sep=" ") + env.AppendENVPath("CGO_LDFLAGS", env.subst("$_LIBDIRFLAGS "), sep=" ") return env.AppendUnique(RPATH_FULL=['$PREFIX/lib64']) rpaths = env.subst("$RPATH_FULL").split() @@ -45,18 +43,17 @@ def add_rpaths(env, install_off, set_cgo_ld, is_bin): continue relpath = os.path.relpath(rpath, prefix) if relpath != rpath: - joined = os.path.normpath(os.path.join(install_off, relpath)) - path = r'\$$ORIGIN/%s' % (joined) if set_cgo_ld: - env.AppendENVPath("CGO_LDFLAGS", "-Wl,-rpath=$ORIGIN/%s/%s" % - (install_off, relpath), sep=" ") + env.AppendENVPath("CGO_LDFLAGS", f'-Wl,-rpath=$ORIGIN/{install_off}/{relpath}', + sep=" ") else: - env.AppendUnique(RPATH=[DaosLiteral(path)]) + joined = os.path.normpath(os.path.join(install_off, relpath)) + env.AppendUnique(RPATH=[DaosLiteral(fr'\$$ORIGIN/{joined}')]) for rpath in rpaths: path = os.path.join(prefix, rpath) if is_bin: # NB: Also use full path so intermediate linking works - env.AppendUnique(LINKFLAGS=["-Wl,-rpath-link=%s" % path]) + env.AppendUnique(LINKFLAGS=[f'-Wl,-rpath-link={path}']) else: # NB: Also use full path so intermediate linking works env.AppendUnique(RPATH=[path]) @@ -65,11 +62,12 @@ def add_rpaths(env, install_off, set_cgo_ld, is_bin): env.AppendENVPath("CGO_LDFLAGS", env.subst("$_LIBDIRFLAGS $_RPATH"), sep=" ") -def add_build_rpath(env, pathin="."): +def _add_build_rpath(env, pathin="."): """Add a build directory to rpath""" + path = Dir(pathin).path - env.AppendUnique(LINKFLAGS=["-Wl,-rpath-link=%s" % path]) - env.AppendENVPath("CGO_LDFLAGS", "-Wl,-rpath-link=%s" % path, sep=" ") + env.AppendUnique(LINKFLAGS=[f'-Wl,-rpath-link={path}']) + env.AppendENVPath('CGO_LDFLAGS', f'-Wl,-rpath-link={path}', sep=' ') # We actually run installed binaries from the build area to generate # man pages. In such cases, we need LD_LIBRARY_PATH set to pick up # the dependencies @@ -117,7 +115,7 @@ def _add_lib(libtype, libname, target): libraries[libname][libtype] = target -def run_command(env, target, sources, daos_libs, command): +def _run_command(env, target, sources, daos_libs, command): """Run Command builder""" static_deps, shared_deps = _known_deps(env, LIBS=daos_libs) result = env.Command(target, sources + static_deps + shared_deps, command) @@ -141,7 +139,7 @@ def library(env, *args, **kwargs): """build SharedLibrary with relative RPATH""" denv = env.Clone() denv.Replace(RPATH=[]) - add_rpaths(denv, kwargs.get('install_off', '..'), False, False) + _add_rpaths(denv, kwargs.get('install_off', '..'), False, False) lib = denv.SharedLibrary(*args, **kwargs) libname = _get_libname(*args, **kwargs) _add_lib('shared', libname, lib) @@ -156,7 +154,7 @@ def program(env, *args, **kwargs): denv = env.Clone() denv.AppendUnique(LINKFLAGS=['-pie']) denv.Replace(RPATH=[]) - add_rpaths(denv, kwargs.get('install_off', '..'), False, True) + _add_rpaths(denv, kwargs.get('install_off', '..'), False, True) prog = denv.Program(*args, **kwargs) static_deps, shared_deps = _known_deps(env, **kwargs) Depends(prog, static_deps) @@ -169,7 +167,7 @@ def test(env, *args, **kwargs): denv = env.Clone() denv.AppendUnique(LINKFLAGS=['-pie']) denv.Replace(RPATH=[]) - add_rpaths(denv, kwargs.get("install_off", None), False, True) + _add_rpaths(denv, kwargs.get("install_off", None), False, True) testbuild = denv.Program(*args, **kwargs) static_deps, shared_deps = _known_deps(env, **kwargs) Depends(testbuild, static_deps) @@ -182,13 +180,6 @@ def add_static_library(name, target): _add_lib('static', name, target) -def install(env, subdir, files): - """install file to the subdir""" - denv = env.Clone() - path = "$PREFIX/%s" % subdir - denv.Install(path, files) - - def _find_mpicc(env): """find mpicc""" @@ -199,7 +190,7 @@ def _find_mpicc(env): env.Replace(CC="mpicc") env.Replace(LINK="mpicc") env.PrependENVPath('PATH', os.path.dirname(mpicc)) - compiler_setup.base_setup(env) + env.compiler_setup() return True @@ -220,11 +211,13 @@ def _configure_mpi_pkg(env): return True -def configure_mpi(env): +def _configure_mpi(self): """Check if mpi exists and configure environment""" if GetOption('help'): - return True + return None + + env = self.Clone() env['CXX'] = None @@ -235,8 +228,16 @@ def configure_mpi(env): if not load_mpi(mpi): continue if _find_mpicc(env): - print("%s is installed" % mpi) - return True - print("No %s installed and/or loaded" % mpi) + print(f'{mpi} is installed') + return env + print(f'No {mpi} installed and/or loaded') print("No MPI installed") - return False + return None + + +def setup(env): + """Add daos specific methods to environment""" + env.AddMethod(_add_build_rpath, 'd_add_build_rpath') + env.AddMethod(_configure_mpi, 'd_configure_mpi') + env.AddMethod(_run_command, 'd_run_command') + env.AddMethod(_add_rpaths, 'd_add_rpaths') diff --git a/src/cart/SConscript b/src/cart/SConscript index 41bc0aa165c..92a65ac415d 100644 --- a/src/cart/SConscript +++ b/src/cart/SConscript @@ -56,7 +56,7 @@ def scons(): Import('env', 'prereqs', 'swim_targets', 'CART_VERSION') - daos_build.add_build_rpath(env) + env.d_add_build_rpath() env.Alias('install', '$PREFIX') diff --git a/src/cart/utils/SConscript b/src/cart/utils/SConscript index a30c10146f1..aed67a025fd 100644 --- a/src/cart/utils/SConscript +++ b/src/cart/utils/SConscript @@ -4,8 +4,6 @@ # """Build crt_utils component""" -import daos_build - LIB_SRC = ['crt_utils.c'] @@ -25,7 +23,7 @@ def scons(): prereqs.require(env, 'protobufc') - daos_build.add_build_rpath(env) + env.d_add_build_rpath() # Generate cart utility shared objects build_utility_shared_obj(env) diff --git a/src/client/api/SConscript b/src/client/api/SConscript index ecaee481f5b..f97dc0e9c88 100644 --- a/src/client/api/SConscript +++ b/src/client/api/SConscript @@ -9,7 +9,7 @@ def scons(): """Execute build""" Import('env', 'API_VERSION', 'prereqs', 'libdaos_tgts') - daos_build.add_build_rpath(env) + env.d_add_build_rpath() env.AppendUnique(LIBPATH=[Dir('.')]) denv = env.Clone() prereqs.require(denv, 'protobufc') diff --git a/src/client/dfs/SConscript b/src/client/dfs/SConscript index 2850c727713..07c66109266 100644 --- a/src/client/dfs/SConscript +++ b/src/client/dfs/SConscript @@ -31,7 +31,7 @@ def scons(): """Execute build""" Import('env') - daos_build.add_build_rpath(env) + env.d_add_build_rpath() denv = env.Clone() diff --git a/src/client/dfuse/SConscript b/src/client/dfuse/SConscript index 98d381faca3..0b5fed1b8f2 100644 --- a/src/client/dfuse/SConscript +++ b/src/client/dfuse/SConscript @@ -1,7 +1,6 @@ """Build DFuse""" import os import daos_build -import compiler_setup HEADERS = ['ioil_io.h', 'ioil_defines.h', 'ioil_api.h', 'ioil.h'] COMMON_SRC = ['dfuse_obj_da.c', 'dfuse_vector.c'] @@ -180,7 +179,7 @@ def scons(): il_env = base_env.Clone() il_env['CC'] = 'gcc' il_env['CXX'] = None - compiler_setup.base_setup(il_env) + il_env.compiler_setup() # Set options which are used throughout the src. dfuse_env = env.Clone(LIBS=[]) diff --git a/src/client/pydaos/SConscript b/src/client/pydaos/SConscript index c3a952f77eb..7f87824ee00 100644 --- a/src/client/pydaos/SConscript +++ b/src/client/pydaos/SConscript @@ -1,7 +1,6 @@ """Build pydaos client""" import sys import daos_build -import compiler_setup def build_shim_module(): @@ -10,7 +9,7 @@ def build_shim_module(): if GetOption('help'): return - version = "{}.{}".format(sys.version_info.major, sys.version_info.minor) + version = f'{sys.version_info.major}.{sys.version_info.minor}' Import('base_env') @@ -24,7 +23,7 @@ def build_shim_module(): new_env['CC'] = 'gcc' new_env.AppendUnique(CCFLAGS='-pthread') - compiler_setup.base_setup(new_env) + new_env.compiler_setup() obj = new_env.SharedObject('pydaos_shim', 'pydaos_shim.c', SHLINKFLAGS=[], diff --git a/src/common/SConscript b/src/common/SConscript index 7af6eb0b3c3..d9d98427877 100644 --- a/src/common/SConscript +++ b/src/common/SConscript @@ -44,8 +44,8 @@ def scons(): env.AppendUnique(LIBPATH=[Dir('.')]) base_env.AppendUnique(LIBPATH=[Dir('.')]) - daos_build.add_build_rpath(base_env) - daos_build.add_build_rpath(env) + base_env.d_add_build_rpath() + env.d_add_build_rpath() # Hack alert, the argobots headers are required but the shared # library isn't so add the dependency so the include path diff --git a/src/common/tests/SConscript b/src/common/tests/SConscript index 2bf86783a22..f0ffd263c4a 100644 --- a/src/common/tests/SConscript +++ b/src/common/tests/SConscript @@ -63,8 +63,8 @@ def scons(): unit_env = tenv.Clone() unit_env.AppendUnique(OBJPREFIX='utest_') - common_mock_ld_script = "%s/common-mock-ld-opts" % Dir('.').srcnode() - unit_env.AppendUnique(LINKFLAGS=['-Wl,@%s' % common_mock_ld_script]) + common_mock_ld_script = f"{Dir('.').srcnode()}/common-mock-ld-opts" + unit_env.AppendUnique(LINKFLAGS=[f'-Wl,@{common_mock_ld_script}']) mock_test_utils = unit_env.SharedObject(['test_mocks.c', 'test_utils.c']) drpc_test_utils = unit_env.SharedObject(['../drpc.c']) + mock_test_utils diff --git a/src/control/SConscript b/src/control/SConscript index cfdfa7c2348..9659c52c60f 100644 --- a/src/control/SConscript +++ b/src/control/SConscript @@ -1,4 +1,3 @@ -#!/bin/env python """Build DAOS Control Plane""" # pylint: disable=too-many-locals import sys @@ -7,7 +6,6 @@ import subprocess from os.path import join, isdir from os import urandom from binascii import b2a_hex -import daos_build Import('env', 'prereqs', 'daos_version', 'conf_dir') @@ -111,20 +109,19 @@ def install_go_bin(denv, gosrc, libs, name, install_name): def go_ldflags(): "Create the ldflags option for the Go build." path = 'github.com/daos-stack/daos/src/control/build' - return ' '.join(['-ldflags', - '"-X {}.DaosVersion={}'.format(path, daos_version), - '-X {}.ConfigDir={}'.format(path, conf_dir), - '-B %s"' % gen_build_id()]) + return ' '.join([f'-X {path}.DaosVersion={daos_version}', + f'-X {path}.ConfigDir={conf_dir}', + f'-B {gen_build_id()}']) # Must be run from the top of the source dir in order to # pick up the vendored modules. # Propagate useful GO environment variables from the caller if 'GOCACHE' in os.environ: denv['ENV']['GOCACHE'] = os.environ['GOCACHE'] - target = daos_build.run_command(denv, build_bin, src, libs, - f'cd {gosrc}; {GO_BIN} build -mod vendor {go_ldflags()} ' - + f'{get_build_flags(denv)} ' - + f'{get_build_tags(denv)} ' - + f'-o {build_bin} {install_src}') + target = denv.d_run_command(build_bin, src, libs, + f'cd {gosrc}; {GO_BIN} build -mod vendor -ldflags "{go_ldflags()}" ' + + f'{get_build_flags(denv)} ' + + f'{get_build_tags(denv)} ' + + f'-o {build_bin} {install_src}') # Use the intermediate build location in order to play nicely # with --install-sandbox. AlwaysBuild(target) @@ -147,11 +144,11 @@ def configure_go(denv): context.Result(0) return 0 - context.Display('Checking %s version... ' % GO_BIN) + context.Display(f'Checking {GO_BIN} version... ') cmd_rc = subprocess.run([GO_BIN, 'version'], check=True, stdout=subprocess.PIPE) out = cmd_rc.stdout.decode('utf-8') if len(out.split(' ')) < 3: - context.Result('failed to get version from "%s"' % out) + context.Result(f'failed to get version from "{out}"') return 0 # go version go1.2.3 Linux/amd64 @@ -159,10 +156,9 @@ def configure_go(denv): if len([x for x, y in zip(go_version.split('.'), MIN_GO_VERSION.split('.')) if int(x) < int(y)]) > 0: - context.Result('%s is too old (min supported: %s) ' - % (go_version, MIN_GO_VERSION)) + context.Result(f'{go_version} is too old (min supported: {MIN_GO_VERSION}) ') return 0 - context.Result('%s' % go_version) + context.Result(str(go_version)) return 1 conf = Configure(denv, custom_tests={'CheckGoVersion': check_go_version}) @@ -210,7 +206,7 @@ def scons(): prereqs.require(denv, 'ofi', 'hwloc') prereqs.require(denv, 'ucx') # Sets CGO_LDFLAGS for rpath options - daos_build.add_rpaths(denv, "..", True, True) + denv.d_add_rpaths("..", True, True) denv.AppendENVPath("CGO_CFLAGS", denv.subst("$_CPPINCFLAGS"), sep=" ") if prereqs.client_requested(): install_go_bin(denv, gosrc, None, "daos_agent", "daos_agent") @@ -241,7 +237,7 @@ def scons(): SConscript('lib/spdk/SConscript', exports='denv') - daos_build.add_rpaths(denv, "..", True, True) + denv.d_add_rpaths("..", True, True) # Copy setup_spdk.sh script to be executed at daos_server runtime. senv.Install(join('$PREFIX', 'share/daos/control'), @@ -268,12 +264,11 @@ def scons(): aenv.AppendENVPath("CGO_LDFLAGS", ldopts, sep=" ") aenv.AppendENVPath("CGO_CFLAGS", - senv.subst("-I$SPDK_PREFIX/include " - "-I$OFI_PREFIX/include"), + senv.subst("-I$SPDK_PREFIX/include -I$OFI_PREFIX/include"), sep=" ") # Sets CGO_LDFLAGS for rpath - daos_build.add_rpaths(aenv, None, True, True) + aenv.d_add_rpaths(None, True, True) install_go_bin(aenv, gosrc, ['nvme_control'], "daos_server_helper", "daos_server_helper") if is_firmware_mgmt_build(denv): diff --git a/src/engine/tests/SConscript b/src/engine/tests/SConscript index 2e5d64319b5..ee91b4765ef 100644 --- a/src/engine/tests/SConscript +++ b/src/engine/tests/SConscript @@ -9,8 +9,8 @@ def scons(): unit_env = denv.Clone() unit_env.AppendUnique(OBJPREFIX='utest_') - common_mock_ld_script = "%s/../../common/tests/common-mock-ld-opts" % Dir('.').srcnode() - unit_env.AppendUnique(LINKFLAGS=['-Wl,@%s' % common_mock_ld_script]) + common_mock_ld_script = f"{Dir('.').srcnode()}/../../common/tests/common-mock-ld-opts" + unit_env.AppendUnique(LINKFLAGS=[f'-Wl,@{common_mock_ld_script}']) Depends('drpc_progress_tests', common_mock_ld_script) daos_build.test(unit_env, 'drpc_progress_tests', diff --git a/src/gurt/SConscript b/src/gurt/SConscript index 541c8a969d1..36a592e3d0a 100644 --- a/src/gurt/SConscript +++ b/src/gurt/SConscript @@ -1,4 +1,3 @@ -#!python # (C) Copyright 2016-2021 Intel Corporation. # # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -15,7 +14,7 @@ def scons(): Import('env', 'prereqs', 'CART_VERSION') - daos_build.add_build_rpath(env) + env.d_add_build_rpath() env.AppendUnique(LIBPATH=[Dir('.')]) env.AppendUnique(CPPPATH=[Dir('.').srcnode()]) diff --git a/src/tests/SConscript b/src/tests/SConscript index e8571b77846..77300527aec 100644 --- a/src/tests/SConscript +++ b/src/tests/SConscript @@ -1,6 +1,5 @@ """Build tests""" import daos_build -import compiler_setup def build_dts_library(env, prereqs, dc_credit): @@ -17,7 +16,7 @@ def build_tests(prereqs, env): """build the tests""" Import('libdaos_tgts', 'cmd_parser') denv = env.Clone() - compiler_setup.base_setup(denv) + denv.compiler_setup() libs_server = ['dts', 'daos_tests', 'daos_common_pmem', 'cart', 'gurt', 'uuid', 'pthread', 'dpar', 'isal', 'protobuf-c', 'cmocka'] diff --git a/src/tests/ftest/SConscript b/src/tests/ftest/SConscript index 189033bf27a..176baf0efef 100644 --- a/src/tests/ftest/SConscript +++ b/src/tests/ftest/SConscript @@ -21,12 +21,10 @@ def scons(): 'telemetry', 'deployment', 'performance', 'scrubber'] for sub_dir in dirs: - env.Install(os.path.join(ftest_install_dir, sub_dir), - Glob("%s/*.*" % sub_dir)) + env.Install(os.path.join(ftest_install_dir, sub_dir), Glob(f'{sub_dir}/*.*')) # Glob doesn't recurse, and CaRT test dir nests deeper than the others - env.Install(os.path.join(ftest_install_dir, 'cart'), - Glob("%s/*/*.*" % 'cart')) + env.Install(os.path.join(ftest_install_dir, 'cart'), Glob('cart/*/*.*')) # Builders SConscript('cart/SConscript') diff --git a/src/tests/suite/SConscript b/src/tests/suite/SConscript index e6368f61bb0..1a4b42970c5 100644 --- a/src/tests/suite/SConscript +++ b/src/tests/suite/SConscript @@ -2,7 +2,6 @@ import sys import subprocess import daos_build -import compiler_setup TEST_CMOCKA_SKIP = """ #include @@ -79,7 +78,7 @@ def scons(): libraries += ['uuid', 'cmocka', 'pthread', 'isal', 'dpar'] dfuse_env = base_env.Clone() - compiler_setup.base_setup(dfuse_env) + dfuse_env.compiler_setup() dfusetest = daos_build.program(dfuse_env, File("dfuse_test.c"), LIBS='cmocka') denv.Install('$PREFIX/bin/', dfusetest) diff --git a/src/utils/SConscript b/src/utils/SConscript index 169bae8a7ee..8f761c1a45e 100644 --- a/src/utils/SConscript +++ b/src/utils/SConscript @@ -13,7 +13,7 @@ def scons(): libs = ['daos', 'daos_common', 'uuid', 'dfs', 'duns', 'gurt', 'cart', 'dl'] - daos_build.add_build_rpath(env) + env.d_add_build_rpath() env.AppendUnique(LIBPATH=[Dir('.')]) env.AppendUnique(LIBPATH=[Dir('../client/dfs')]) diff --git a/src/utils/wrap/mpi/SConscript b/src/utils/wrap/mpi/SConscript index 9a8853736be..a651285e2f7 100644 --- a/src/utils/wrap/mpi/SConscript +++ b/src/utils/wrap/mpi/SConscript @@ -1,13 +1,12 @@ """Build mpi abstraction libraries""" import daos_build -import compiler_setup def build_dpar(env, mpi_env): """Build MPI abstraction library""" senv = env.Clone() - compiler_setup.base_setup(senv) + senv.compiler_setup() serial_lib = daos_build.library(senv, 'dpar', ['dpar_stub.c'], LIBS=['pthread', 'dl']) senv.Install('$PREFIX/lib64/', serial_lib) @@ -31,11 +30,11 @@ def scons(): env.AppendUnique(LIBPATH=[Dir('.')]) base_env.AppendUnique(LIBPATH=[Dir('.')]) - daos_build.add_build_rpath(env) - daos_build.add_build_rpath(base_env) + env.d_add_build_rpath() + base_env.d_add_build_rpath() if base_env_mpi: base_env_mpi.AppendUnique(LIBPATH=[Dir('.')]) - daos_build.add_build_rpath(base_env_mpi) + base_env_mpi.d_add_build_rpath() build_dpar(base_env, base_env_mpi) diff --git a/utils/sl/fake_scons/SCons/Script/__init__.py b/utils/sl/fake_scons/SCons/Script/__init__.py index d17e0d43181..f52aead4a9d 100644 --- a/utils/sl/fake_scons/SCons/Script/__init__.py +++ b/utils/sl/fake_scons/SCons/Script/__init__.py @@ -21,7 +21,6 @@ import os import sys -import copy # pylint: disable=no-self-use # pylint: disable=too-many-public-methods @@ -192,7 +191,28 @@ def Alias(self, *_args, **_kw): def __getitem__(self, x): """Fake __getitem__""" - return [] + + class myItem(): + """Fake class for Env variables""" + + def __index__(self): + return 0 + + def __getitem__(self, x): + """Fake __getitem__""" + + def __setitem__(self, x, value): + """Fake __setitem__""" + return + + return myItem() + + def __setitem__(self, x, value): + """Fake __setitem__""" + return + + def __index__(self): + return 0 def Install(self, *_args, **_kw): """Fake Install""" @@ -209,12 +229,16 @@ def Object(self, *_args, **_kw): """Fake Object""" return [] + def SConscript(self, s_dir): + "Fake SConscript" + return + def Replace(self, *_args, **_kw): """Fake Replace""" def Clone(self, *_args, **_kw): """Fake Replace""" - return copy.copy(self) + return DefaultEnvironment() def Append(self, *_args, **_kw): """Fake Append""" @@ -237,7 +261,15 @@ def GetOption(self, *_args, **_kw): """Fake GetOption""" return [] - def AppendENVPath(self, key, value): + def SetOption(self, key, value): + """Fake SetOption""" + return + + def ParseConfig(self, command): + """Fake ParseConfig""" + return + + def AppendENVPath(self, key, value, sep=None): """Fake AppendENVPath""" return @@ -245,6 +277,26 @@ def PrependENVPath(self, key, value): """Fake PrependENVPath""" return + def d_add_build_rpath(self, pathin='.'): + """Fake d_add_build_rpath""" + return + + def d_add_rpaths(self, offset, set_go, is_bin): + """Fake d_add_rpaths""" + return + + def d_configure_mpi(self): + """Fake d_configure_mpi""" + return DefaultEnvironment() + + def compiler_setup(self): + """Fake compiler_setup""" + return + + def Preprocess(self, files): + """Fake Preprocess""" + return + class Variables(): """Fake variables"""