diff --git a/require-ess/tools/driver.makefile b/require-ess/tools/driver.makefile index ed99c3cbeade7585556b741d3f466462fe8888b2..a501fc09aaec34cecdcd796afb5d6a98bbe1b4dd 100644 --- a/require-ess/tools/driver.makefile +++ b/require-ess/tools/driver.makefile @@ -219,11 +219,11 @@ DBD_SRCS = $(if ${DBDS},$(filter-out -none-,${DBDS}),$(wildcard menu*.dbd *Recor DBD_SRCS += ${DBDS_${EPICSVERSION}} export DBD_SRCS -#record dbd files given in DBDS -RECORDS1 = $(patsubst %Record.dbd, %, $(filter-out dev%, $(filter %Record.dbd, $(notdir ${DBD_SRCS})))) -#record dbd files included by files given in DBDS -RECORDS2 = $(filter-out dev%, $(shell ${MAKEHOME}/expandDBD -r $(addprefix -I, $(sort $(dir ${DBD_SRCS}))) $(realpath ${DBDS}) 2> /dev/null)) -RECORDS = $(sort ${RECORDS1} ${RECORDS2}) +# Read dbd files from source files. Note that this assumes that any xxxRecord.(c|cpp|...) has +# a corresponding xxxRecord.dbd, which is used to generate xxxRecord.h; this is standard usage +# in EPICS. However, if such a .dbd file does not exist, then the build will fail due to the +# "missing" header file. +RECORDS = $(filter %Record,$(basename $(notdir $(SRCS)))) export RECORDS MENUS = $(patsubst %.dbd,%.h,$(wildcard menu*.dbd)) @@ -237,7 +237,8 @@ DBDINSTALLS += $(MENUS) DBDINSTALLS += $(BPTS) export DBDINSTALLS -HDRS = ${HEADERS} $(addprefix ${COMMON_DIR}/,$(addsuffix Record.h,${RECORDS})) +HDRS = ${HEADERS} +HDRS += $(RECORDS:%=${COMMON_DIR}/%.h) HDRS += ${HEADERS_${EPICSVERSION}} export HDRS @@ -576,9 +577,10 @@ debug:: build: MODULEINFOS build: ${MODULEDBD} -build: $(addprefix ${COMMON_DIR}/,$(addsuffix Record.h,${RECORDS})) build: ${DEPFILE} +COMMON_INC = ${RECORDS:%=${COMMON_DIR}/%.h} + # Include default EPICS Makefiles (version dependent). # Avoid library installation when doing 'make build'. INSTALL_LOADABLE_SHRLIBS= diff --git a/require-ess/tools/expandDBD b/require-ess/tools/expandDBD index a4eb61d9bf587a20b652b1f74407efe61dcb7e51..9be4a07b283854a389f3f7c0ed9336bc316c1697 100755 --- a/require-ess/tools/expandDBD +++ b/require-ess/tools/expandDBD @@ -58,41 +58,16 @@ def expand_dbd_file(current_file, dbdlines, includes): print(line) -def parse_record_dbd_file(current_file, dbdlines, includes): - """Recursively search through .dbd files for xRecord.dbd, and print the record names.""" - for line in dbdlines: - if BLANK_LINE_REGEX.match(line): - continue - m = RECORD_REGEX.search(line) - if m: - if find_dbd_file(m.group(1), includes): - print(m.group(2)) - else: - print( - "File '{group}' not found".format(group=m.group(1)), file=sys.stderr - ) - sys.exit(1) - continue - m = INCLUDE_REGEX.search(line) - if m: - lines = open_dbd_file(current_file, m.group(1), includes) - parse_record_dbd_file(m.group(1), lines, includes) - - -def handle_dbd_file(dbdfiles, include, record_types): +def handle_dbd_file(dbdfiles, include): """Process the .dbd files.""" for dbdfile in dbdfiles: lines = open_dbd_file("command line", dbdfile, include) - if record_types: - parse_record_dbd_file(dbdfile, lines, include) - else: - expand_dbd_file(dbdfile, lines, include) + expand_dbd_file(dbdfile, lines, include) def main(): parser = argparse.ArgumentParser() parser.add_argument("-I", "--include", action="append") - parser.add_argument("-r", "--record-types", action="store_true") parser.add_argument("dbdfiles", nargs="+") args = parser.parse_args() diff --git a/tests/test_build.py b/tests/test_build.py index 5a412897dbb1b90fab608a2128d25e164e5d8fb4..e6505d03f408d9181f5fd35422f26e012df7bc91 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -717,3 +717,17 @@ def test_metadata_not_installed_if_arch_fails(wrapper: Wrapper): ) assert rc == 2 assert not (wrapper.package_dir / f"{wrapper.name}_meta.yaml").exists() + + +def test_missing_record_dbd_file_causes_build_failure(wrapper: Wrapper): + wrapper.add_file("fooRecord.c") + wrapper.add_var_to_module_makefile("SOURCES", "fooRecord.c") + + rc, _, errs = wrapper.run_make("build") + assert rc != 0 + assert re.search( + RE_MISSING_FILE.format( + filename=re.escape(f"../O.{wrapper.base_version}_Common/fooRecord.dbd") + ), + errs, + ) diff --git a/tests/test_expand_dbd.py b/tests/test_expand_dbd.py index ee7d081ef2cbcdc7cc4642539476f9c2dc00028c..37dff8d4fa8318cdc14c0c78787ad07931a4bc60 100644 --- a/tests/test_expand_dbd.py +++ b/tests/test_expand_dbd.py @@ -75,33 +75,3 @@ def test_do_not_skip_repeated_include_common_dbd(tmp_path, expanddbdtcl): ) assert result.returncode == 0 assert result.stdout == "content\ncontent\n" - - -def test_record_names_from_dbds(tmp_path, expanddbdtcl): - dbd_a = tmp_path / "a.dbd" - dbd_a.write_text("include aRecord.dbd") - - dbd_record = tmp_path / "aRecord.dbd" - dbd_record.touch() - - result = subprocess.run( - [expanddbdtcl, "-r", "-I", str(tmp_path), dbd_a], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - encoding="utf-8", - ) - assert result.returncode == 0 - assert result.stdout.splitlines() == ["a"] - - -def test_missing_record_names_from_dbds(tmp_path, expanddbdtcl): - dbd_a = tmp_path / "a.dbd" - dbd_a.write_text("include aRecord.dbd") - - result = subprocess.run( - [expanddbdtcl, "-r", "-I", str(tmp_path), dbd_a], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - encoding="utf-8", - ) - assert result.returncode == 1