Simplify and optimize FindCycles

Finding cycles in a directed graph only requires a simple depth first
traversal, it does not require checking every path in the graph.

This is now fast enough to actually identify and print cycles between
targets.

Changes the error message slightly for file and target cycles,
and adds tests for both those cases.

Patch from cjhopman@chromium.org.

R=scottmg@chromium.org

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

git-svn-id: http://gyp.googlecode.com/svn/trunk@1992 78cadc50-ecff-11dd-a971-7dbc132099af
6 files changed