# Copyright 2017 The Tulsi Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Logic to translate Xcode options to Bazel options."""


class BazelOptions(object):
  """Converts Xcode features into Bazel command line flags."""

  def __init__(self, xcode_env):
    """Creates a new BazelOptions object.

    Args:
      xcode_env: A dictionary of Xcode environment variables.

    Returns:
      A BazelOptions instance.
    """
    self.xcode_env = xcode_env

  def bazel_feature_flags(self):
    """Returns a list of bazel flags for the current Xcode env configuration."""
    flags = []
    if self.xcode_env.get('ENABLE_ADDRESS_SANITIZER') == 'YES':
      flags.extend([
          '--features=asan',
      ])

    return flags

@@ -1191,27 +1191,116 @@
 ags.
-ext
+app
 end(
-%5B%0A          
+'--features=asan')%0A    if self.xcode_env.get('ENABLE_THREAD_SANITIZER') == 'YES':%0A      flags.append(
 '--f
@@ -1311,22 +1311,127 @@
 res=
-a
+t
 san'
-,
+)
 %0A    
-  %5D
+if self.xcode_env.get('ENABLE_UNDEFINED_BEHAVIOR_SANITIZER') == 'YES':%0A      flags.append('--features=ubsan'
 )%0A%0A 

Support enabling tsan and ubsan from Xcode UI