When are .did files created?

I run either:

dfx canister create dependent
dfx canister create dependency
dfx build -vv dependent

or

dfx deploy -vv dependent

In both cases the Bash test

test "$(ls .dfx/local/canisters/idl)" != ""

fails.

Why does it fail? When (by which command) are .did files created in .dfx/local/canisters/idl?

Tested with DFX 0.19.0.

I need this for [WIP] feat: rebuild only necessary canisters by vporton · Pull Request #3710 · dfinity/sdk · GitHub (also please review it at Speed up DFX by recompiling only changed canisters).

Oh, I found: It is done in a hellish way in fn step_prebuild_all.

I am going as a part of my work on [WIP] feat: rebuild only necessary canisters by vporton · Pull Request #3710 · dfinity/sdk · GitHub to move this from prebuild to postbuild.