Fixed compilation with BUILD_TOOLS enabled

This commit mainly reverts parts of following commits:
    0eebc21db831211738acc938566bbc29d68d45db
    d8109b7a4fede1660e0dbd73735f1a9e3fd79eec
    e59595806c045916ab4ef15ef7047c1a728b2da9
    2d6cd58ee1cd7c5073980f358c71b2898ad16b4c

They declared  lots of stuff deprecated, but in
fact it's not deprecated just a bit different
usage pipeline. Anyway, deprecation shall not
happen spontaneously as a part of other changes.
And for sure shall not break anything.