IDL compiler: --write-file-only-if-changed

The crucial --write-file-only-if-changed flag was never implemented
in the Python compiler.
This adds it, so we avoid unnecessary recompiles on Ninja
(for bindings that don't change).

Also refactor slightly, so CG just generates code and returns it, leaving
the actual file writing to the compiler.
(Better modularity, and avoids having to pass in this flag.)

BUG=239771
R=haraken
NOTRY=true

Review URL: https://codereview.chromium.org/177303002

git-svn-id: svn://svn.chromium.org/blink/trunk@167675 bbb929c8-8fbe-4397-9dbb-9b2b20218538