Cisco-Talos / clamav

ClamAV - Documentation is here: https://docs.clamav.net
https://www.clamav.net/
GNU General Public License v2.0
4.38k stars 703 forks source link

`ninja clean` does not delete files generated by rustc #1184

Open dilyanpalauzov opened 8 months ago

dilyanpalauzov commented 8 months ago

I compile clamav 1.3.0 using the ninja generator (ccmake -GNinja) out-of-tree (VPATH build). Then I call ninja clean and ninja -t clean. Before ninja clean the build directory is 1.4Gb, afterwards it is 919Mb, with x86_64-unknown-linux-gnu being 700Mb.

I expect that ninja clean deletes everything, which the next run of ninja will create again.

micahsnyder commented 8 months ago

Interesting. I agree it should delete the files generated by rustc.

It seems like we may be able to solve this with ADDITIONAL_CLEAN_FILES

https://stackoverflow.com/questions/62450774/cmake-clean-additional-generated-files

dilyanpalauzov commented 2 months ago

When I build clamav, build.ninja contains:

# Custom command for x86_64-unknown-linux-gnu/release/libclamav_rust.a

build x86_64-unknown-linux-gnu/release/libclamav_rust.a | ${cmake_ninja_workdir}x86_64-unknown-linux-gnu/release/libclamav_rust.a: CUSTOM_COMMAND /src/mail/clamav-1.4.0/libclamav_rust/build.rs /src/mail/clamav-1.4.0/libclamav_rust/src/alz.rs /src/mail/clamav-1.4.0/libclamav_rust/src/cdiff.rs /src/mail/clamav-1.4.0/libclamav_rust/src/css_image_extract.rs /src/mail/clamav-1.4.0/libclamav_rust/src/ctx.rs /src/mail/clamav-1.4.0/libclamav_rust/src/evidence.rs /src/mail/clamav-1.4.0/libclamav_rust/src/ffi_util.rs /src/mail/clamav-1.4.0/libclamav_rust/src/fmap.rs /src/mail/clamav-1.4.0/libclamav_rust/src/fuzzy_hash.rs /src/mail/clamav-1.4.0/libclamav_rust/src/lib.rs /src/mail/clamav-1.4.0/libclamav_rust/src/logging.rs /src/mail/clamav-1.4.0/libclamav_rust/src/onenote.rs /src/mail/clamav-1.4.0/libclamav_rust/src/scanners.rs /src/mail/clamav-1.4.0/libclamav_rust/src/sys.rs /src/mail/clamav-1.4.0/libclamav_rust/src/util.rs
  COMMAND = cd /src/mail/clamav-1.4.0/libclamav_rust && /usr/local/bin/cmake -E env CARGO_CMD=build CARGO_TARGET_DIR=/src/mail/clamav-1.4.0/build MAINTAINER_MODE=OFF CARGO_INCLUDE_DIRECTORIES="/usr/local/include/libxml2;/usr/local/include;/usr/local/include;/src/mail/clamav-1.4.0/build/libclamav;/src/mail/clamav-1.4.0/libclamunrar_iface;/src/mail/clamav-1.4.0/libclamav/..;/src/mail/clamav-1.4.0/build;/usr/local/include/json-c;/src/mail/clamav-1.4.0/libclamav;/src/mail/clamav-1.4.0/libclamav;/src/mail/clamav-1.4.0/libclamav;/src/mail/clamav-1.4.0/libclamav;/src/mail/clamav-1.4.0/build/libclamav;/src/mail/clamav-1.4.0/libclamav;/src/mail/clamav-1.4.0/libclammspack/mspack;/src/mail/clamav-1.4.0/libclamav_rust;/src/mail/clamav-1.4.0/build;/usr/local/include;/usr/local/include;/usr/local/include;/usr/local/include;/usr/local/include;/usr/local/include/libxml2;/usr/local/include/libxml2;/usr/local/include;/usr/local/include/json-c;/usr/include" RUSTFLAGS=-Z\ threads=1 /usr/local/bin/cargo build --offline --target x86_64-unknown-linux-gnu --release --target-dir /src/mail/clamav-1.4.0/build
  DESC = Building clamav_rust in /src/mail/clamav-1.4.0/build with:  /usr/local/bin/cargo build --offline --target x86_64-unknown-linux-gnu --release --target-dir /src/mail/clamav-1.4.0/build
  restat = 1

Cleaning the files, created by cargo, is a matter of calling:

cd /src/mail/clamav-1.4.0/ && /usr/local/bin/cargo clean --release --target-dir /src/mail/clamav-1.4.0/build

which prints:

Removed 592 files, 221.3MiB total