[python3] Fix goma integration

Additionally, update ninja to fix a rebuild issue.

Change-Id: I162ac7165410b642a4a918eeacc8ab514634496d
Reviewed-on: https://fuchsia-review.googlesource.com/c/cobalt/+/556026
Fuchsia-Auto-Submit: Zach Bush <zmbush@google.com>
Reviewed-by: Steve Fung <stevefung@google.com>
Commit-Queue: Zach Bush <zmbush@google.com>
diff --git a/cobalt.ensure b/cobalt.ensure
index 469544e..35a3111 100644
--- a/cobalt.ensure
+++ b/cobalt.ensure
@@ -12,9 +12,12 @@
 # dart
 fuchsia/dart-sdk/${platform} git_revision:cd41b767a29dbb1cbf4f2b66e7a45b5ac822448f
 
+# python
+infra/3pp/tools/cpython3/${platform} version:3.8.6.chromium.10
+
 # Ninja
 @Subdir bin
-infra/ninja/${platform} version:1.9.0
+fuchsia/third_party/ninja/${platform} git_revision:c8f8f2a9e3016ab7a9ecb2e8b084cf441f3ae88e
 
 # GN
 gn/gn/${platform} git_revision:239533d2d91a04b3317ca9101cf7189f4e651e4d
@@ -22,7 +25,7 @@
 
 # Goma
 @Subdir goma
-fuchsia/third_party/goma/client/${platform} git_revision:9c15a8cecf525a4fbc7d4a11685e7dbd61cdc830
+fuchsia/third_party/goma/client/${platform} git_revision:a73a64a6e613a91fb5df0ec85c0a4ab94a4bd148
 
 # Go
 @Subdir golang
diff --git a/cobaltb.py b/cobaltb.py
index 29129c3..d9a9736 100755
--- a/cobaltb.py
+++ b/cobaltb.py
@@ -33,6 +33,7 @@
 PRIVACY_ENCODING_PARAMS_PATH = os.path.join(THIS_DIR, 'src', 'algorithms',
                                             'privacy', 'data',
                                             'privacy_encoding_params')
+PYTHON_CMD = os.path.join(SYSROOT_DIR, 'bin', 'python3')
 
 _logger = logging.getLogger()
 _verbose_count = 0
@@ -130,7 +131,9 @@
 
 def _goma_login(args):
   goma_dir = os.path.join(SYSROOT_DIR, 'goma')
-  subprocess.check_call(['%s/goma_auth' % goma_dir, 'login'])
+  if args.goma_dir:
+    goma_dir = args.goma_dir
+  subprocess.check_call([PYTHON_CMD, '%s/goma_auth.py' % goma_dir, 'login'])
 
 
 def _build(args):
@@ -160,7 +163,7 @@
       start_goma = True
     if start_goma:
       try:
-        if subprocess.check_output(['%s/goma_auth' % goma_dir, 'info']).strip() == 'Not logged in':
+        if subprocess.check_output([PYTHON_CMD, '%s/goma_auth.py' % goma_dir, 'info']).strip() == 'Not logged in':
           print()
           print()
           print("Goma is not logged in and will not be used. Please run: `./cobaltb.py goma_login`")
@@ -175,7 +178,7 @@
         print()
         use_goma = False
       if use_goma:
-        subprocess.check_call(['%s/goma_ctl.py' % goma_dir, 'ensure_start'])
+        subprocess.check_call([PYTHON_CMD, '%s/goma_ctl.py' % goma_dir, 'ensure_start'])
 
   if args.release:
     gn_args.append('is_debug=false')
@@ -649,6 +652,10 @@
   ########################################################
   sub_parser = subparsers.add_parser(
       'goma_login', parents=[parent_parser], help='Logs in to the goma service.')
+  sub_parser.add_argument(
+      '--goma_dir',
+      default='',
+      help='The dir where goma is installed (defaults to sysroot/goma')
   sub_parser.set_defaults(func=_goma_login)
 
   ########################################################