bin/sync : call tools/git-sync-deps now

Also, update some docs.

NOTRY=true
Change-Id: I7ad3375fc1cbf8f71ed42a460ecfe29ef6c1d85e
Reviewed-on: https://skia-review.googlesource.com/7657
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
diff --git a/bin/sync b/bin/sync
index d95d4a8..163584d 100755
--- a/bin/sync
+++ b/bin/sync
@@ -7,7 +7,7 @@
 
 # This script will update Skia's dependencies as necessary.
 
-# Depends on: Python, Git, and depot_tools.
+# Depends on: Python and Git
 
 # To retreive and use all optional deps:
 #
@@ -18,67 +18,36 @@
 import subprocess
 import sys
 
-skia_dir = os.path.join(os.path.dirname(__file__), os.pardir)
+HASH_FILE = '.deps_sha1'
+DEPS_FLAG = '--deps='
+DEPS_FILE = 'DEPS'
 
-skia_opt_deps = [arg for arg in sys.argv[1:] if arg.startswith('--deps=')]
+skia_opt_deps = [arg[len(DEPS_FLAG):] for arg in sys.argv[1:] if arg.startswith(DEPS_FLAG)]
 
-os.chdir(skia_dir)
+os.chdir(os.path.join(os.path.dirname(__file__), os.pardir))
 
-if not os.path.isfile('DEPS'):
+if not os.path.isfile(DEPS_FILE):
   sys.stderr.write('DEPS file missing')
   exit(1)
 
 deps_hasher = hashlib.sha1()
-with open('DEPS', 'r') as f:
+with open(DEPS_FILE, 'r') as f:
   deps_hasher.update(f.read())
 deps_hasher.update(repr(skia_opt_deps))
 deps_hash = deps_hasher.hexdigest()
 current_deps_hash = None
-if os.path.isfile('.deps_sha1'):
-  with open('.deps_sha1', 'r') as f:
+if os.path.isfile(HASH_FILE):
+  with open(HASH_FILE, 'r') as f:
     current_deps_hash = f.read().strip()
 
-default_gclient_config = '''
-solutions = [
-  { "name"        : ".",
-    "url"         : "https://skia.googlesource.com/skia.git",
-    "deps_file"   : "DEPS",
-    "managed"     : False,
-    "custom_deps" : {
-    },
-    "safesync_url": "",
-  },
-]
-cache_dir = None
-'''
-
-# Must use gclient.bat rather than gclient on windows (at least on mingw)
-gclient = 'gclient'
-if sys.platform == 'win32' or sys.platform == 'cygwin':
-  gclient = 'gclient.bat'
-
 if current_deps_hash != deps_hash:
-  # `gclient sync` is very slow, so skip whenever we can.
-  try:
-    subprocess.call([gclient, '--version'])
-  except:
-    sys.stdout.write('gclient missing from $PATH, please install ' +
-                     'depot_tools\n    https://skia.org/user/quick/desktop\n')
-    exit(1)
-  if not os.path.isfile('.gclient'):
-    with open('.gclient', 'w') as o:
-      o.write(default_gclient_config)
-  command = [gclient, 'sync'] + skia_opt_deps
-  try:
-    sys.stdout.write('%r\n' % command)
-    subprocess.check_call(command)
-  except:
-    sys.stderr.write('\n%r failed.\n' % command)
-    try:
-      os.remove('.deps_sha1')  # Unknown state.
-    except:
-      pass
-    exit(1)
+  if os.path.isfile(HASH_FILE):
+    os.remove(HASH_FILE)
+  command = [sys.executable, os.path.join('tools', 'git-sync-deps')]
+  command.extend(skia_opt_deps)
+  sys.stdout.write('%r\n' % command)
+  sys.stdout.flush()
+  subprocess.check_call(command)
   # Only write hash after a successful sync.
-  with open('.deps_sha1', 'w') as o:
+  with open(HASH_FILE, 'w') as o:
     o.write(deps_hash)
diff --git a/site/dev/design/sync.md b/site/dev/design/sync.md
index 7443dba..1172058 100644
--- a/site/dev/design/sync.md
+++ b/site/dev/design/sync.md
@@ -2,12 +2,10 @@
 ====
 
 [`sync`](https://skia.googlesource.com/skia.git/+/master/bin/sync)
-is a Python program that wraps `gclient sync`.  Motivations for using it:
+is a Python program that wraps `tools/git-sync-deps`.  Motivations for using it:
 
 -  Written in Python, so it will work on all platforms.
 
--  Sets up gclient better than `gclient config`, which has been broken.
-
 -  Checks to see if the `DEPS` file has changed since it last ran
    `gclient sync`.  If not, it skips that step.
 
diff --git a/site/user/quick/ios.md b/site/user/quick/ios.md
index e2c6fc8..44534ac 100644
--- a/site/user/quick/ios.md
+++ b/site/user/quick/ios.md
@@ -22,7 +22,8 @@
     cd skia
 
     # Create the project files.
-    GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0" python bin/sync-and-gyp
+    python tools/git-sync-deps
+    GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0" ./gyp_skia
     # Build and run SampleApp.
     xed out/gyp/SampleApp.xcodeproj # opens the SampleApp project in Xcode
 
@@ -60,12 +61,14 @@
 
 You can then generate the Xcode projects by running:
 
-    GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0" python bin/sync-and-gyp
+    python tools/git-sync-deps
+    GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0" ./gyp_skia
 
 Alternatively, you can do:
 
+    python tools/git-sync-deps
     export GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0"
-    python bin/sync-and-gyp
+    ./gyp_skia
 
 Build and run tests
 -------------------
@@ -99,7 +102,7 @@
 Build and run SampleApp in the XCode IDE
 ----------------------------------------
 
-  * Run `sync-and-gyp` as described above.
+  * Run `git-sync-deps` and `gyp_skia` as described above.
   * In the Finder, navigate to $SKIA_INSTALLDIR/trunk/out/gyp
   * Double-click SampleApp.xcodeproj ; this will launch XCode and open the SampleApp project
   * Make sure the SampleApp target is selected, and choose an iOS device to run on