Followup fixes for recipe roll

Simplifying some environment madness. Nobody gets to modify default_env.
Always apply it in run.__call__(). Add depot_tools path to PATH in
default_env. Result is simpler but now default_env is applied in many
more places, which should be harmless.

BUG=skia:

Change-Id: I8299d50bde2bc3e2d47568a267d1d962a3fc3d56
Reviewed-on: https://skia-review.googlesource.com/9916
Reviewed-by: Ravi Mistry <rmistry@google.com>
Commit-Queue: Eric Boren <borenet@google.com>
diff --git a/infra/bots/recipe_modules/flavor/flutter_flavor.py b/infra/bots/recipe_modules/flavor/flutter_flavor.py
index be3a9f0..0f0302b 100644
--- a/infra/bots/recipe_modules/flavor/flutter_flavor.py
+++ b/infra/bots/recipe_modules/flavor/flutter_flavor.py
@@ -21,32 +21,31 @@
     out_dir = configuration
 
     with self.m.step.context({'cwd': flutter_dir}):
-
       # Runhook to generate the gn binary in buildtools.
       self.m.run(
           self.m.step,
           'runhook',
           cmd=['gclient', 'runhooks'])
 
-    # Setup GN args.
-    gn_args = [
-        '--runtime-mode=%s' % configuration,
-    ]
-    if 'Android' in extra_config:
-      gn_args.append('--android')
-      out_dir = 'android_' + out_dir
+      # Setup GN args.
+      gn_args = [
+          '--runtime-mode=%s' % configuration,
+      ]
+      if 'Android' in extra_config:
+        gn_args.append('--android')
+        out_dir = 'android_' + out_dir
 
-    # Delete out_dir so that we start from a clean slate. See skbug/6310.
-    self.m.run.rmtree(flutter_dir.join('out', out_dir))
+      # Delete out_dir so that we start from a clean slate. See skbug/6310.
+      self.m.run.rmtree(flutter_dir.join('out', out_dir))
 
-    # Run GN.
-    self.m.run(
-        self.m.step,
-        'gn_gen',
-        cmd=['flutter/tools/gn'] + gn_args)
+      # Run GN.
+      self.m.run(
+          self.m.step,
+          'gn_gen',
+          cmd=['flutter/tools/gn'] + gn_args)
 
-    # Build Flutter.
-    self.m.run(
-        self.m.step,
-        'build_flutter',
-        cmd=['ninja', '-C', 'out/' + out_dir, '-j100'])
+      # Build Flutter.
+      self.m.run(
+          self.m.step,
+          'build_flutter',
+          cmd=['ninja', '-C', 'out/' + out_dir, '-j100'])
diff --git a/infra/bots/recipe_modules/flavor/gn_android_flavor.py b/infra/bots/recipe_modules/flavor/gn_android_flavor.py
index ce57ab6..36c14df 100644
--- a/infra/bots/recipe_modules/flavor/gn_android_flavor.py
+++ b/infra/bots/recipe_modules/flavor/gn_android_flavor.py
@@ -23,18 +23,11 @@
         svg_dir       = self.m.vars.android_data_dir + 'svgs',
         tmp_dir       = self.m.vars.android_data_dir)
 
-  def _strip_environment(self):
-    self.m.vars.default_env = {k: v for (k,v)
-                               in self.m.vars.default_env.iteritems()
-                               if k in ['PATH']}
-
   def _run(self, title, *cmd, **kwargs):
-    self._strip_environment()
     with self.m.step.context({'cwd': self.m.vars.skia_dir}):
       return self.m.run(self.m.step, title, cmd=list(cmd), **kwargs)
 
   def _py(self, title, script, infra_step=True):
-    self._strip_environment()
     with self.m.step.context({'cwd': self.m.vars.skia_dir}):
       return self.m.run(self.m.python, title, script=script,
                         infra_step=infra_step)
diff --git a/infra/bots/recipe_modules/flavor/gn_flavor.py b/infra/bots/recipe_modules/flavor/gn_flavor.py
index 6040447..4ee2f8e 100644
--- a/infra/bots/recipe_modules/flavor/gn_flavor.py
+++ b/infra/bots/recipe_modules/flavor/gn_flavor.py
@@ -124,13 +124,7 @@
     ninja = 'ninja.exe' if 'Win' in os else 'ninja'
     gn = self.m.vars.skia_dir.join('bin', gn)
 
-    env = self.m.step.get_from_context('env', {})
-    env.update(self.m.vars.default_env)
-    env['PATH'] = self.m.path.pathsep.join([
-        env.get('PATH', '%(PATH)s'),
-        str(self.m.bot_update._module.PACKAGE_REPO_ROOT),
-    ])
-    with self.m.step.context({'cwd': self.m.vars.skia_dir, 'env': env}):
+    with self.m.step.context({'cwd': self.m.vars.skia_dir}):
       self._py('fetch-gn', self.m.vars.skia_dir.join('bin', 'fetch-gn'))
       self._run('gn gen', [gn, 'gen', self.out_dir, '--args=' + gn_args])
       self._run('ninja', [ninja, '-C', self.out_dir])
@@ -149,14 +143,14 @@
   def step(self, name, cmd):
     app = self.m.vars.skia_out.join(self.m.vars.configuration, cmd[0])
     cmd = [app] + cmd[1:]
-    env = self.m.step.get_from_context('env') or {}
+    env = self.m.step.get_from_context('env', {})
 
     clang_linux = str(self.m.vars.slave_dir.join('clang_linux'))
     extra_config = self.m.vars.builder_cfg.get('extra_config', '')
 
     if 'SAN' in extra_config:
       # Sanitized binaries may want to run clang_linux/bin/llvm-symbolizer.
-      self.m.vars.default_env['PATH'] = '%%(PATH)s:%s' % clang_linux + '/bin'
+      env['PATH'] = '%%(PATH)s:%s' % clang_linux + '/bin'
     elif 'Ubuntu' == self.m.vars.builder_cfg.get('os', ''):
       cmd = ['catchsegv'] + cmd
 
diff --git a/infra/bots/recipe_modules/flavor/pdfium_flavor.py b/infra/bots/recipe_modules/flavor/pdfium_flavor.py
index 141b126..84645f2 100644
--- a/infra/bots/recipe_modules/flavor/pdfium_flavor.py
+++ b/infra/bots/recipe_modules/flavor/pdfium_flavor.py
@@ -43,7 +43,7 @@
         gn_args.append('pdf_use_skia=true')
 
 
-      env = self.m.step.get_from_context('env') or {}
+      env = self.m.step.get_from_context('env', {})
       env['CHROMIUM_BUILDTOOLS_PATH'] = str(pdfium_dir.join('buildtools'))
       with self.m.step.context({'env': env}):
         self.m.run(