Workaround long paths on Windows by excluding the offending component.

Fortunately we don't need phantomjs anyway.

BUG=451985
R=kjellander@chromium.org

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

git-svn-id: http://src.chromium.org/svn/trunk/deps/third_party/webrtc/webrtc.DEPS@293837 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
diff --git a/build_apprtc_closure.py b/build_apprtc_closure.py
index 81a8e76..6233b36 100755
--- a/build_apprtc_closure.py
+++ b/build_apprtc_closure.py
@@ -9,6 +9,7 @@
 the node toolchain we downloaded earlier.
 """
 
+import fileinput
 import os
 import shutil
 import sys
@@ -16,6 +17,17 @@
 import utils
 
 
+# Phantomjs generates very deep paths in the node_modules structure and
+# Windows can't deal with that, so just hack that out.
+def _WorkaroundPhantomJsOnWin(samples_path):
+  if utils.GetPlatform() is 'win':
+    package_json = os.path.join(samples_path, 'package.json')
+
+    for line in fileinput.input(package_json, inplace=True):
+      if not 'phantomjs' in line:
+        print line
+
+
 def main():
   node_path = os.path.abspath('node')
   if not os.path.exists(node_path):
@@ -25,6 +37,7 @@
     return 'Expected webrtc-samples at %s.' % os.path.abspath(samples_path)
 
   os.chdir(samples_path)
+  _WorkaroundPhantomJsOnWin(samples_path)
   
   if utils.GetPlatform() is 'win':
     npm_bin = os.path.join(node_path, 'npm.cmd')