tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

should_use_hermetic_xcode.py (1664B)


      1 #!/usr/bin/env python3
      2 
      3 # Copyright 2016 The Chromium Authors
      4 # Use of this source code is governed by a BSD-style license that can be
      5 # found in the LICENSE file.
      6 
      7 """
      8 Prints "1" if Chrome targets should be built with hermetic Xcode.
      9 Prints "2" if Chrome targets should be built with hermetic Xcode, but the OS
     10 version does not meet the minimum requirements of the hermetic version of Xcode.
     11 Prints "3" if FORCE_MAC_TOOLCHAIN is set for an iOS target_os
     12 Otherwise prints "0".
     13 
     14 Usage:
     15  python should_use_hermetic_xcode.py <target_os>
     16 """
     17 
     18 
     19 import argparse
     20 import os
     21 import sys
     22 
     23 _THIS_DIR_PATH = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
     24 _BUILD_PATH = os.path.join(_THIS_DIR_PATH, os.pardir)
     25 sys.path.insert(0, _BUILD_PATH)
     26 
     27 import mac_toolchain
     28 
     29 
     30 def _IsCorpMachine():
     31  if sys.platform == 'darwin':
     32    return os.path.isdir('/Library/GoogleCorpSupport/')
     33  if sys.platform.startswith('linux'):
     34    import subprocess
     35    try:
     36      return subprocess.check_output(['lsb_release',
     37                                      '-sc']).rstrip() == b'rodete'
     38    except:
     39      return False
     40  return False
     41 
     42 
     43 def main():
     44  parser = argparse.ArgumentParser(description='Download hermetic Xcode.')
     45  parser.add_argument('platform')
     46  args = parser.parse_args()
     47 
     48  force_toolchain = os.environ.get('FORCE_MAC_TOOLCHAIN')
     49  if force_toolchain and args.platform == 'ios':
     50    return "3"
     51  allow_corp = args.platform == 'mac' and _IsCorpMachine()
     52  if force_toolchain or allow_corp:
     53    if not mac_toolchain.PlatformMeetsHermeticXcodeRequirements():
     54      return "2"
     55    return "1"
     56  else:
     57    return "0"
     58 
     59 
     60 if __name__ == '__main__':
     61  print(main())
     62  sys.exit(0)