Skip to content
Snippets Groups Projects
Commit df112375 authored by Simon Rose's avatar Simon Rose
Browse files

E3-944: Warn if building from install path

If a user runs the build from the E3_SITEMODS_PATH, then it can happen that
false dependencies get registered due to how the generated .d files are
parsed to determine module dependencies. Specifically, if you have header
file being used that is located at

${E3_SITEMODS_PATH}/e3-module/module/src/header.h

and it is _not_ being installed, then the dependency parsing script will
see a dependency as an absolute path, and so register that your module
depends on the module `e3-module` version `module`, which is obviously
not what was intended.

While we don't want to stricly _prevent_ a user from building there, it
seems wise to _warn_ a user that there may be unintended consequences.
parent 61169507
No related branches found
No related tags found
1 merge request!99E3-944: Warn if building from install path
Pipeline #120184 passed with warnings
......@@ -2,7 +2,7 @@
consistency_checks: module_name_check loc-check
ifneq (require,$(E3_MODULE_NAME))
consistency_checks: sitemods_check
consistency_checks: sitemods_check build_path_check
endif
# Check that the module name satisfies a few conditions before we go on.
......@@ -19,8 +19,13 @@ ifeq ($(filter RULES_SITEMODS,$(notdir $(MAKEFILE_LIST))),)
endif
# Check that e3 wrappers are using EPICS_MODULE_TAG to manage local source mode
.PHONU: loc-check
.PHONY: loc-check
loc-check:
ifneq (,$(findstring -loc,$(E3_MODULE_SRC_PATH)))
$(error DEPRECATED: Local source mode "-loc" has been deprecated. Please comment out the EPICS_MODULE_TAG to use local source mode.)
endif
.PHONY: build_path_check
build_path_check:
$(if $(filter $(abspath $(E3_MODULES_PATH))/%,$(abspath $(TOP))),$(warning It is ill-advised to build a module from the module install location.)\
$(warning Please note that you may obtain unexpected results.))
......@@ -109,6 +109,7 @@ EXCLUDE_ARCHS+=debug
*args,
module_version: str = "",
cell_path: str = "",
**kwargs,
):
"""Attempt to run `make <target> <args>` for the current wrapper."""
......@@ -119,6 +120,9 @@ EXCLUDE_ARCHS+=debug
if target == "uninstall":
target = "celluninstall"
env = os.environ.copy()
env.update(kwargs)
args = list(args)
if module_version:
args.append(f"E3_MODULE_VERSION={module_version}")
......@@ -130,6 +134,7 @@ EXCLUDE_ARCHS+=debug
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
env=env,
)
outs, errs = p.communicate()
return p.returncode, outs, errs
......
......@@ -39,3 +39,13 @@ def test_add_missing_build_number(wrapper: Wrapper):
rc, outs, _ = wrapper.run_make("vars")
assert rc == 0
assert f"E3_MODULE_VERSION = {version}+0" in outs.splitlines()
def test_warning_if_building_from_sitemods(wrapper: Wrapper):
rc, _, errs = wrapper.run_make(
"build_path_check", E3_MODULES_PATH=wrapper.path / ".."
)
assert rc == 0
assert (
"It is ill-advised to build a module from the module install location." in errs
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment