#!/usr/bin/env python
# Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.

import re
import subprocess
import sys

def main():
  job = subprocess.Popen(['xcodebuild', '-version'],
                         stdout=subprocess.PIPE,
                         stderr=subprocess.STDOUT)
  stdout, stderr = job.communicate()
  if job.returncode != 0:
    print >>sys.stderr, stdout
    print >>sys.stderr, stderr
    raise Exception('Error %d running xcodebuild!' % job.returncode)
  matches = re.findall('^Xcode (\d+)\.(\d+)(\.(\d+))?$', stdout, re.MULTILINE)
  if len(matches) > 0:
    major = int(matches[0][0])
    minor = int(matches[0][1])

    if major >= 4:
      return 'com.apple.compilers.llvmgcc42'
    elif major == 3 and minor >= 1:
      return '4.2'
    else:
      raise Exception('Unknown XCode Version "%s"' % version_match)
  else:
    raise Exception('Could not parse output of xcodebuild "%s"' % stdout)

if __name__ == '__main__':
  if sys.platform != 'darwin':
    raise Exception("This script only runs on Mac")
  print main()

#!/usr/bin/env python
# Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.

import re
import subprocess
import sys

def main():
  job = subprocess.Popen(['xcodebuild', '-version'],
                         stdout=subprocess.PIPE,
                         stderr=subprocess.STDOUT)
  stdout, stderr = job.communicate()
  if job.returncode != 0:
    print >>sys.stderr, stdout
    print >>sys.stderr, stderr
    raise Exception('Error %d running xcodebuild!' % job.returncode)
  matches = re.findall('^Xcode (\d+)\.(\d+)(\.(\d+))?$', stdout, re.MULTILINE)
  if len(matches) > 0:
    major = int(matches[0][0])
    minor = int(matches[0][1])

    if major == 3 and minor >= 1:
      return '4.2'
    elif major == 4 and minor < 5:
      return 'com.apple.compilers.llvmgcc42'
    elif major == 4 and minor >= 5:
      # XCode seems to select the specific clang version automatically
      return 'com.apple.compilers.llvm.clang.1_0'
    else:
      raise Exception('Unknown XCode Version "%s"' % version_match)
  else:
    raise Exception('Could not parse output of xcodebuild "%s"' % stdout)

if __name__ == '__main__':
  if sys.platform != 'darwin':
    raise Exception("This script only runs on Mac")
  print main()

Revert "Revert "Use clang on mac if XCode >= 4.5""
Revert "Revert "Use clang on mac if XCode >= 4.5""

The V8 dependency has been removed, so we should be able to enable clang on mac
again.

R=ricow@google.com

Review URL: https://codereview.chromium.org//14751012

git-svn-id: c93d8a2297af3b929165606efe145742a534bc71@22304 260f80e4-7a28-3924-810f-c04153c831b5
