← index #7331PR #13085
Duplicate · high · value 1.364
QUERY · ISSUE

CMake generated clean target not working properly

openby alphaFredopened 2021-05-29updated 2021-05-29

When using the the make clean target generated by CMake an incomplete specification of the outputs of the MICROPY_QSTRDEFS_COLLECTED custom target in py/mkrules.cmake leads to issues.

When this custom command is executed:

add_custom_command(
    OUTPUT ${MICROPY_QSTRDEFS_COLLECTED}
    COMMAND ${Python3_EXECUTABLE} ${MICROPY_PY_DIR}/makeqstrdefs.py cat qstr _ ${MICROPY_GENHDR_DIR}/qstr ${MICROPY_QSTRDEFS_COLLECTED}
    DEPENDS ${MICROPY_QSTRDEFS_SPLIT}
    VERBATIM
    COMMAND_EXPAND_LISTS
)

Two files are generated:

  1. qstrdefs.collected.h
  2. qstrdefs.collected.h.hash

But only qstrdefs.collected.h is specified as an OUTPUT. Hence when executing the make cleantarget qstrdefs.collected.h.hashis not removed (since CMake does not know of its existence). This leads to incomplete generation of qstrdefs.generated.h and in turn to a failing build.

This can be easily fixed by adding the hash file as an output like so:

...
set(MICROPY_QSTRDEFS_COLLECTED_HASH "${MICROPY_GENHDR_DIR}/qstrdefs.collected.h.hash")
...
add_custom_command(
    OUTPUT ${MICROPY_QSTRDEFS_COLLECTED} ${MICROPY_QSTRDEFS_COLLECTED_HASH}
    COMMAND ${Python3_EXECUTABLE} ${MICROPY_PY_DIR}/makeqstrdefs.py cat qstr _ ${MICROPY_GENHDR_DIR}/qstr ${MICROPY_QSTRDEFS_COLLECTED}
    DEPENDS ${MICROPY_QSTRDEFS_SPLIT}
    VERBATIM
    COMMAND_EXPAND_LISTS
)
CANDIDATE · PULL REQUEST

Fixes for makeqstrdefs.py getting broken by "clean" on cmake

mergedby xyzzy42opened 2023-11-28updated 2023-12-15
py-core

Using "clean" with the cmake build leaves the build directory in a broken state, due to stale makeqstrdefs.py hash files.

This fixes the cmake issue that the hash files are not deleted on a clean when they should be.

makeqstrdefs.py is also updated so that stale hash files left behind with the output is deleted will not prevent generation of the output. While cmake + clean will not do this anymore, it could still happen for other reasons. I've found a good goal for a robust build system is that any generated file can be deleted and it will correctly cope with this.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied