Plumb through "sanitizer" like "mode" and "arch".

Change-Id: Ic866b3c6ddeb503d4760eae6efdd84df2673f69e
Reviewed-on: https://dart-review.googlesource.com/c/recipes/+/142061
Reviewed-by: Alexander Thomas <athom@google.com>
diff --git a/README.recipes.md b/README.recipes.md
index 063d5a1..42f78bf 100644
--- a/README.recipes.md
+++ b/README.recipes.md
@@ -64,7 +64,7 @@
 
 Deletes the debug log file
 
-&mdash; **def [download\_browser](/recipe_modules/dart/api.py#844)(self, runtime, version):**
+&mdash; **def [download\_browser](/recipe_modules/dart/api.py#853)(self, runtime, version):**
 
 &mdash; **def [download\_parent\_isolate](/recipe_modules/dart/api.py#155)(self):**
 
diff --git a/recipe_modules/dart/api.py b/recipe_modules/dart/api.py
index c392f9b..df0acc4 100644
--- a/recipe_modules/dart/api.py
+++ b/recipe_modules/dart/api.py
@@ -674,6 +674,8 @@
         'simarmv6', 'simarmv5te', 'simarm64', 'simdbc', 'simdbc64', 'armsimdbc',
         'armsimdbc64', 'simarm_x64'
     ], 'x64')
+    sanitizer = self._get_option(
+        builder_fragments, ['asan', 'lsan', 'msan', 'tsan', 'ubsan'], 'none')
     runtime = self._get_option(
       builder_fragments,
       ['none', 'd8', 'jsshell', 'edge', 'ie11', 'firefox', 'safari', 'chrome'],
@@ -711,6 +713,7 @@
         'system': system,
         'mode': mode,
         'arch': arch,
+        'sanitizer': sanitizer,
         'build_root': build_root,
         'copy-coredumps': False,
         'checked_in_sdk_version': checked_in_sdk_version,
@@ -779,11 +782,14 @@
   def _run_gn(self, step):
     mode = step.environment['mode']
     arch = step.environment['arch']
+    sanitizer = step.environment['sanitizer']
     args = step.args
     if not self._has_specific_argument(args, ['-m', '--mode']):
       args = ['-m%s' % mode] + args
     if not self._has_specific_argument(args, ['-a', '--arch']):
       args = ['-a%s' % arch] + args
+    if not self._has_specific_argument(args, ['--sanitizer']):
+      args = ['--sanitizer=%s' % sanitizer] + args
     with self.m.context(env={'GOMA_DIR': self.m.goma.goma_dir}):
       self.m.python(step.name,
                     self.m.path['checkout'].join('tools', 'gn.py'),
@@ -794,11 +800,14 @@
   def _run_build(self, step):
     mode = step.environment['mode']
     arch = step.environment['arch']
+    sanitizer = step.environment['sanitizer']
     args = step.args
     if not self._has_specific_argument(args, ['-m', '--mode']):
       args = ['-m%s' % mode] + args
     if not self._has_specific_argument(args, ['-a', '--arch']):
       args = ['-a%s' % arch] + args
+    if not self._has_specific_argument(args, ['--sanitizer']):
+      args = ['--sanitizer=%s' % sanitizer] + args
     deferred_result = self.build(name=step.name, build_args=args)
     deferred_result.get_result() # raises build errors
 
diff --git a/recipe_modules/dart/examples/example.expected/analyzer-linux-release.json b/recipe_modules/dart/examples/example.expected/analyzer-linux-release.json
index 7ca7a09..361150e 100644
--- a/recipe_modules/dart/examples/example.expected/analyzer-linux-release.json
+++ b/recipe_modules/dart/examples/example.expected/analyzer-linux-release.json
@@ -938,6 +938,7 @@
       "python",
       "-u",
       "[CACHE]/builder/sdk/tools/build.py",
+      "--sanitizer=none",
       "-ax64",
       "-mrelease",
       "--no-start-goma",
diff --git a/recipe_modules/dart/examples/example.expected/example-mac.json b/recipe_modules/dart/examples/example.expected/example-mac.json
index ecbf230..cb1d552 100644
--- a/recipe_modules/dart/examples/example.expected/example-mac.json
+++ b/recipe_modules/dart/examples/example.expected/example-mac.json
@@ -936,6 +936,7 @@
       "python",
       "-u",
       "[CACHE]/builder/sdk/tools/build.py",
+      "--sanitizer=none",
       "-ax64",
       "-mrelease",
       "--no-start-goma",
diff --git a/recipe_modules/dart/examples/example.expected/vm-win.json b/recipe_modules/dart/examples/example.expected/vm-win.json
index b43edfb..bb13dee 100644
--- a/recipe_modules/dart/examples/example.expected/vm-win.json
+++ b/recipe_modules/dart/examples/example.expected/vm-win.json
@@ -818,6 +818,7 @@
       "python",
       "-u",
       "[CACHE]\\builder\\sdk\\tools\\gn.py",
+      "--sanitizer=none",
       "-asimarm_x64",
       "-mrelease",
       "--bytecode",
@@ -967,6 +968,7 @@
       "python",
       "-u",
       "[CACHE]\\builder\\sdk\\tools\\build.py",
+      "--sanitizer=none",
       "-mrelease",
       "--arch=x64",
       "runtime",
diff --git a/recipes/dart/neo.expected/builders_dart2js-win-debug-x64-firefox-try.json b/recipes/dart/neo.expected/builders_dart2js-win-debug-x64-firefox-try.json
index 36ee5d7..569661c 100644
--- a/recipes/dart/neo.expected/builders_dart2js-win-debug-x64-firefox-try.json
+++ b/recipes/dart/neo.expected/builders_dart2js-win-debug-x64-firefox-try.json
@@ -528,6 +528,7 @@
       "python",
       "-u",
       "[CACHE]/builder/sdk/tools/build.py",
+      "--sanitizer=none",
       "-ax64",
       "-mdebug",
       "foo",