head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC6:1.1.1.4
	netbsd-11-0-RC5:1.1.1.4
	netbsd-11-0-RC4:1.1.1.4
	netbsd-11-0-RC3:1.1.1.4
	netbsd-11-0-RC2:1.1.1.4
	netbsd-11-0-RC1:1.1.1.4
	perseant-exfatfs-base-20250801:1.1.1.4
	netbsd-11:1.1.1.4.0.24
	netbsd-11-base:1.1.1.4
	netbsd-10-1-RELEASE:1.1.1.4
	perseant-exfatfs-base-20240630:1.1.1.4
	perseant-exfatfs:1.1.1.4.0.22
	perseant-exfatfs-base:1.1.1.4
	netbsd-8-3-RELEASE:1.1.1.4
	netbsd-9-4-RELEASE:1.1.1.4
	netbsd-10-0-RELEASE:1.1.1.4
	netbsd-10-0-RC6:1.1.1.4
	netbsd-10-0-RC5:1.1.1.4
	netbsd-10-0-RC4:1.1.1.4
	netbsd-10-0-RC3:1.1.1.4
	netbsd-10-0-RC2:1.1.1.4
	netbsd-10-0-RC1:1.1.1.4
	netbsd-10:1.1.1.4.0.20
	netbsd-10-base:1.1.1.4
	netbsd-9-3-RELEASE:1.1.1.4
	cjep_sun2x:1.1.1.4.0.18
	cjep_sun2x-base:1.1.1.4
	cjep_staticlib_x-base1:1.1.1.4
	netbsd-9-2-RELEASE:1.1.1.4
	cjep_staticlib_x:1.1.1.4.0.16
	cjep_staticlib_x-base:1.1.1.4
	netbsd-9-1-RELEASE:1.1.1.4
	phil-wifi-20200421:1.1.1.4
	phil-wifi-20200411:1.1.1.4
	phil-wifi-20200406:1.1.1.4
	netbsd-8-2-RELEASE:1.1.1.4
	netbsd-9-0-RELEASE:1.1.1.4
	netbsd-9-0-RC2:1.1.1.4
	netbsd-9-0-RC1:1.1.1.4
	netbsd-9:1.1.1.4.0.14
	netbsd-9-base:1.1.1.4
	netbsd-8-1-RELEASE:1.1.1.4
	netbsd-8-1-RC1:1.1.1.4
	pgoyette-compat-merge-20190127:1.1.1.4
	pgoyette-compat-20190127:1.1.1.4
	pgoyette-compat-20190118:1.1.1.4
	pgoyette-compat-1226:1.1.1.4
	pgoyette-compat-1126:1.1.1.4
	pgoyette-compat-1020:1.1.1.4
	pgoyette-compat-0930:1.1.1.4
	pgoyette-compat-0906:1.1.1.4
	netbsd-7-2-RELEASE:1.1.1.3
	pgoyette-compat-0728:1.1.1.4
	netbsd-8-0-RELEASE:1.1.1.4
	pgoyette-compat-0625:1.1.1.4
	netbsd-8-0-RC2:1.1.1.4
	pgoyette-compat-0521:1.1.1.4
	pgoyette-compat-0502:1.1.1.4
	pgoyette-compat-0422:1.1.1.4
	netbsd-8-0-RC1:1.1.1.4
	pgoyette-compat-0415:1.1.1.4
	pgoyette-compat-0407:1.1.1.4
	pgoyette-compat-0330:1.1.1.4
	pgoyette-compat-0322:1.1.1.4
	pgoyette-compat-0315:1.1.1.4
	netbsd-7-1-2-RELEASE:1.1.1.3
	pgoyette-compat:1.1.1.4.0.12
	pgoyette-compat-base:1.1.1.4
	netbsd-7-1-1-RELEASE:1.1.1.3
	perseant-stdc-iso10646:1.1.1.4.0.10
	perseant-stdc-iso10646-base:1.1.1.4
	netbsd-8:1.1.1.4.0.8
	netbsd-8-base:1.1.1.4
	prg-localcount2-base3:1.1.1.4
	prg-localcount2-base2:1.1.1.4
	prg-localcount2-base1:1.1.1.4
	prg-localcount2:1.1.1.4.0.6
	prg-localcount2-base:1.1.1.4
	pgoyette-localcount-20170426:1.1.1.4
	bouyer-socketcan-base1:1.1.1.4
	pgoyette-localcount-20170320:1.1.1.4
	netbsd-7-1:1.1.1.3.0.10
	netbsd-7-1-RELEASE:1.1.1.3
	netbsd-7-1-RC2:1.1.1.3
	netbsd-7-nhusb-base-20170116:1.1.1.3
	bouyer-socketcan:1.1.1.4.0.4
	bouyer-socketcan-base:1.1.1.4
	pgoyette-localcount-20170107:1.1.1.4
	netbsd-7-1-RC1:1.1.1.3
	pgoyette-localcount-20161104:1.1.1.4
	netbsd-7-0-2-RELEASE:1.1.1.3
	localcount-20160914:1.1.1.4
	netbsd-7-nhusb:1.1.1.3.0.8
	netbsd-7-nhusb-base:1.1.1.3
	pgoyette-localcount-20160806:1.1.1.4
	pgoyette-localcount-20160726:1.1.1.4
	pgoyette-localcount:1.1.1.4.0.2
	pgoyette-localcount-base:1.1.1.4
	netbsd-7-0-1-RELEASE:1.1.1.3
	netbsd-7-0:1.1.1.3.0.6
	netbsd-7-0-RELEASE:1.1.1.3
	netbsd-7-0-RC3:1.1.1.3
	netbsd-7-0-RC2:1.1.1.3
	netbsd-7-0-RC1:1.1.1.3
	clang-237755:1.1.1.3
	clang-232565:1.1.1.3
	clang-227398:1.1.1.3
	tls-maxphys-base:1.1.1.3
	tls-maxphys:1.1.1.3.0.4
	netbsd-7:1.1.1.3.0.2
	netbsd-7-base:1.1.1.3
	clang-215315:1.1.1.3
	clang-209886:1.1.1.3
	yamt-pagecache:1.1.1.2.0.4
	yamt-pagecache-base9:1.1.1.2
	tls-earlyentropy:1.1.1.2.0.2
	tls-earlyentropy-base:1.1.1.3
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.2
	riastradh-drm2-base3:1.1.1.2
	clang-202566:1.1.1.2
	clang-201163:1.1.1.1
	clang-199312:1.1.1.1
	clang-198450:1.1.1.1
	clang-196603:1.1.1.1
	clang-195771:1.1.1.1
	LLVM:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2013.11.28.14.14.48;	author joerg;	state Exp;
branches
	1.1.1.1;
next	;
commitid	ow8OybrawrB1f3fx;

1.1.1.1
date	2013.11.28.14.14.48;	author joerg;	state Exp;
branches;
next	1.1.1.2;
commitid	ow8OybrawrB1f3fx;

1.1.1.2
date	2014.03.04.19.53.21;	author joerg;	state Exp;
branches
	1.1.1.2.2.1
	1.1.1.2.4.1;
next	1.1.1.3;
commitid	29z1hJonZISIXprx;

1.1.1.3
date	2014.05.30.18.14.49;	author joerg;	state Exp;
branches
	1.1.1.3.4.1;
next	1.1.1.4;
commitid	8q0kdlBlCn09GACx;

1.1.1.4
date	2016.02.27.22.23.00;	author joerg;	state dead;
branches;
next	;
commitid	DKbhbwSVAW5DxBWy;

1.1.1.2.2.1
date	2014.08.10.07.08.25;	author tls;	state Exp;
branches;
next	;
commitid	t01A1TLTYxkpGMLx;

1.1.1.2.4.1
date	2014.03.04.19.53.21;	author yamt;	state dead;
branches;
next	1.1.1.2.4.2;
commitid	WSrDtL5nYAUyiyBx;

1.1.1.2.4.2
date	2014.05.22.16.19.48;	author yamt;	state Exp;
branches;
next	;
commitid	WSrDtL5nYAUyiyBx;

1.1.1.3.4.1
date	2014.05.30.18.14.49;	author tls;	state dead;
branches;
next	1.1.1.3.4.2;
commitid	jTnpym9Qu0o4R1Nx;

1.1.1.3.4.2
date	2014.08.19.23.49.27;	author tls;	state Exp;
branches;
next	;
commitid	jTnpym9Qu0o4R1Nx;


desc
@@


1.1
log
@Initial revision
@
text
@#!/usr/bin/python

# [PR 11661] Note that we hardwire to /usr/bin/python because we
# want to the use the system version of Python on Mac OS X.
# This one has the scripting bridge enabled.

import sys
if sys.version_info < (2, 7):
    print "set-xcode-analyzer requires Python 2.7 or later"
    sys.exit(1)
    
import os
import subprocess
import re
import tempfile
import shutil
import stat
from AppKit import *

def FindClangSpecs(path):
  print "(+) Searching for xcspec file in: ", path
  for root, dirs, files in os.walk(path):
    for f in files:
      if f.endswith(".xcspec") and f.startswith("Clang LLVM"):
        yield os.path.join(root, f)

def ModifySpec(path, isBuiltinAnalyzer, pathToChecker):
  t = tempfile.NamedTemporaryFile(delete=False)
  foundAnalyzer = False
  with open(path) as f:
    if isBuiltinAnalyzer:
      # First search for CLANG_ANALYZER_EXEC.  Newer
      # versions of Xcode set EXEC_PATH to be CLANG_ANALYZER_EXEC.
      with open(path) as f2:
        for line in f2:
          if line.find("CLANG_ANALYZER_EXEC") >= 0:
            pathToChecker = "$(CLANG_ANALYZER_EXEC)"
            break
    # Now create a new file.
    for line in f:
      if not foundAnalyzer:
        if line.find("Static Analyzer") >= 0:
          foundAnalyzer = True
      else:
        m = re.search('^(\s*ExecPath\s*=\s*")', line)
        if m:
          line = "".join([m.group(0), pathToChecker, '";\n'])
          # Do not modify further ExecPath's later in the xcspec.
          foundAnalyzer = False
      t.write(line)
  t.close()
  print "(+) processing:", path
  try:
    shutil.copy(t.name, path)
    os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
  except IOError, why:
    print "    (-) Cannot update file:", why, "\n"
  except OSError, why:
    print "    (-) Cannot update file:", why, "\n"
  os.unlink(t.name)

def main():
  from optparse import OptionParser
  parser = OptionParser('usage: %prog [options]')
  parser.set_description(__doc__)
  parser.add_option("--use-checker-build", dest="path",
                    help="Use the Clang located at the provided absolute path, e.g. /Users/foo/checker-1")
  parser.add_option("--use-xcode-clang", action="store_const", 
                    const="$(CLANG)", dest="default",
                    help="Use the Clang bundled with Xcode")
  (options, args) = parser.parse_args()
  if options.path is None and options.default is None:
    parser.error("You must specify a version of Clang to use for static analysis.  Specify '-h' for details")

  # determine if Xcode is running
  for x in NSWorkspace.sharedWorkspace().runningApplications():
    if x.localizedName().find("Xcode") >= 0:
      print "(-) You must quit Xcode first before modifying its configuration files."
      sys.exit(1)

  isBuiltinAnalyzer = False
  if options.path:
    # Expand tildes.
    path = os.path.expanduser(options.path)
    if not path.endswith("clang"):
      print "(+) Using Clang bundled with checker build:", path
      path = os.path.join(path, "bin", "clang");
    else:
      print "(+) Using Clang located at:", path
  else:
    print "(+) Using the Clang bundled with Xcode"
    path = options.default
    isBuiltinAnalyzer = True
  
  try:
    xcode_path = subprocess.check_output(["xcode-select", "-print-path"])
  except AttributeError:
    # Fall back to the default install location when using Python < 2.7.0
    xcode_path = "/Developer"
  if (xcode_path.find(".app/") != -1):
    # Cut off the 'Developer' dir, as the xcspec lies in another part
    # of the Xcode.app subtree.
    xcode_path = os.path.dirname(xcode_path)
  
  foundSpec = False
  for x in FindClangSpecs(xcode_path):
    foundSpec = True
    ModifySpec(x, isBuiltinAnalyzer, path)
    
  if foundSpec == False:
      print "(-) No compiler configuration file was found.  Xcode's analyzer has not been updated."

if __name__ == '__main__':
  main()

@


1.1.1.1
log
@Import Clang 3.4rc1 r195771.
@
text
@@


1.1.1.2
log
@Import Clang 3.5svn r202566.
@
text
@d11 1
a11 1

d68 1
a68 1
  parser.add_option("--use-xcode-clang", action="store_const",
d94 1
a94 1

d104 1
a104 1

d109 1
a109 1

d115 1
@


1.1.1.2.2.1
log
@Rebase.
@
text
@d103 1
a103 1
    xcode_path = xcode_path.rsplit('/Developer', 1)[0]
@


1.1.1.3
log
@Import Clang 3.5svn r209886.
@
text
@d103 1
a103 1
    xcode_path = xcode_path.rsplit('/Developer', 1)[0]
@


1.1.1.4
log
@Mark files without clang-261930 as dead.
@
text
@@


1.1.1.3.4.1
log
@file set-xcode-analyzer was added on branch tls-maxphys on 2014-08-19 23:49:27 +0000
@
text
@d1 114
@


1.1.1.3.4.2
log
@Rebase to HEAD as of a few days ago.
@
text
@a0 114
#!/usr/bin/python

# [PR 11661] Note that we hardwire to /usr/bin/python because we
# want to the use the system version of Python on Mac OS X.
# This one has the scripting bridge enabled.

import sys
if sys.version_info < (2, 7):
    print "set-xcode-analyzer requires Python 2.7 or later"
    sys.exit(1)

import os
import subprocess
import re
import tempfile
import shutil
import stat
from AppKit import *

def FindClangSpecs(path):
  print "(+) Searching for xcspec file in: ", path
  for root, dirs, files in os.walk(path):
    for f in files:
      if f.endswith(".xcspec") and f.startswith("Clang LLVM"):
        yield os.path.join(root, f)

def ModifySpec(path, isBuiltinAnalyzer, pathToChecker):
  t = tempfile.NamedTemporaryFile(delete=False)
  foundAnalyzer = False
  with open(path) as f:
    if isBuiltinAnalyzer:
      # First search for CLANG_ANALYZER_EXEC.  Newer
      # versions of Xcode set EXEC_PATH to be CLANG_ANALYZER_EXEC.
      with open(path) as f2:
        for line in f2:
          if line.find("CLANG_ANALYZER_EXEC") >= 0:
            pathToChecker = "$(CLANG_ANALYZER_EXEC)"
            break
    # Now create a new file.
    for line in f:
      if not foundAnalyzer:
        if line.find("Static Analyzer") >= 0:
          foundAnalyzer = True
      else:
        m = re.search('^(\s*ExecPath\s*=\s*")', line)
        if m:
          line = "".join([m.group(0), pathToChecker, '";\n'])
          # Do not modify further ExecPath's later in the xcspec.
          foundAnalyzer = False
      t.write(line)
  t.close()
  print "(+) processing:", path
  try:
    shutil.copy(t.name, path)
    os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
  except IOError, why:
    print "    (-) Cannot update file:", why, "\n"
  except OSError, why:
    print "    (-) Cannot update file:", why, "\n"
  os.unlink(t.name)

def main():
  from optparse import OptionParser
  parser = OptionParser('usage: %prog [options]')
  parser.set_description(__doc__)
  parser.add_option("--use-checker-build", dest="path",
                    help="Use the Clang located at the provided absolute path, e.g. /Users/foo/checker-1")
  parser.add_option("--use-xcode-clang", action="store_const",
                    const="$(CLANG)", dest="default",
                    help="Use the Clang bundled with Xcode")
  (options, args) = parser.parse_args()
  if options.path is None and options.default is None:
    parser.error("You must specify a version of Clang to use for static analysis.  Specify '-h' for details")

  # determine if Xcode is running
  for x in NSWorkspace.sharedWorkspace().runningApplications():
    if x.localizedName().find("Xcode") >= 0:
      print "(-) You must quit Xcode first before modifying its configuration files."
      sys.exit(1)

  isBuiltinAnalyzer = False
  if options.path:
    # Expand tildes.
    path = os.path.expanduser(options.path)
    if not path.endswith("clang"):
      print "(+) Using Clang bundled with checker build:", path
      path = os.path.join(path, "bin", "clang");
    else:
      print "(+) Using Clang located at:", path
  else:
    print "(+) Using the Clang bundled with Xcode"
    path = options.default
    isBuiltinAnalyzer = True

  try:
    xcode_path = subprocess.check_output(["xcode-select", "-print-path"])
  except AttributeError:
    # Fall back to the default install location when using Python < 2.7.0
    xcode_path = "/Developer"
  if (xcode_path.find(".app/") != -1):
    # Cut off the 'Developer' dir, as the xcspec lies in another part
    # of the Xcode.app subtree.
    xcode_path = xcode_path.rsplit('/Developer', 1)[0]

  foundSpec = False
  for x in FindClangSpecs(xcode_path):
    foundSpec = True
    ModifySpec(x, isBuiltinAnalyzer, path)

  if foundSpec == False:
      print "(-) No compiler configuration file was found.  Xcode's analyzer has not been updated."

if __name__ == '__main__':
  main()
@


1.1.1.2.4.1
log
@file set-xcode-analyzer was added on branch yamt-pagecache on 2014-05-22 16:19:48 +0000
@
text
@d1 114
@


1.1.1.2.4.2
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@a0 114
#!/usr/bin/python

# [PR 11661] Note that we hardwire to /usr/bin/python because we
# want to the use the system version of Python on Mac OS X.
# This one has the scripting bridge enabled.

import sys
if sys.version_info < (2, 7):
    print "set-xcode-analyzer requires Python 2.7 or later"
    sys.exit(1)

import os
import subprocess
import re
import tempfile
import shutil
import stat
from AppKit import *

def FindClangSpecs(path):
  print "(+) Searching for xcspec file in: ", path
  for root, dirs, files in os.walk(path):
    for f in files:
      if f.endswith(".xcspec") and f.startswith("Clang LLVM"):
        yield os.path.join(root, f)

def ModifySpec(path, isBuiltinAnalyzer, pathToChecker):
  t = tempfile.NamedTemporaryFile(delete=False)
  foundAnalyzer = False
  with open(path) as f:
    if isBuiltinAnalyzer:
      # First search for CLANG_ANALYZER_EXEC.  Newer
      # versions of Xcode set EXEC_PATH to be CLANG_ANALYZER_EXEC.
      with open(path) as f2:
        for line in f2:
          if line.find("CLANG_ANALYZER_EXEC") >= 0:
            pathToChecker = "$(CLANG_ANALYZER_EXEC)"
            break
    # Now create a new file.
    for line in f:
      if not foundAnalyzer:
        if line.find("Static Analyzer") >= 0:
          foundAnalyzer = True
      else:
        m = re.search('^(\s*ExecPath\s*=\s*")', line)
        if m:
          line = "".join([m.group(0), pathToChecker, '";\n'])
          # Do not modify further ExecPath's later in the xcspec.
          foundAnalyzer = False
      t.write(line)
  t.close()
  print "(+) processing:", path
  try:
    shutil.copy(t.name, path)
    os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
  except IOError, why:
    print "    (-) Cannot update file:", why, "\n"
  except OSError, why:
    print "    (-) Cannot update file:", why, "\n"
  os.unlink(t.name)

def main():
  from optparse import OptionParser
  parser = OptionParser('usage: %prog [options]')
  parser.set_description(__doc__)
  parser.add_option("--use-checker-build", dest="path",
                    help="Use the Clang located at the provided absolute path, e.g. /Users/foo/checker-1")
  parser.add_option("--use-xcode-clang", action="store_const",
                    const="$(CLANG)", dest="default",
                    help="Use the Clang bundled with Xcode")
  (options, args) = parser.parse_args()
  if options.path is None and options.default is None:
    parser.error("You must specify a version of Clang to use for static analysis.  Specify '-h' for details")

  # determine if Xcode is running
  for x in NSWorkspace.sharedWorkspace().runningApplications():
    if x.localizedName().find("Xcode") >= 0:
      print "(-) You must quit Xcode first before modifying its configuration files."
      sys.exit(1)

  isBuiltinAnalyzer = False
  if options.path:
    # Expand tildes.
    path = os.path.expanduser(options.path)
    if not path.endswith("clang"):
      print "(+) Using Clang bundled with checker build:", path
      path = os.path.join(path, "bin", "clang");
    else:
      print "(+) Using Clang located at:", path
  else:
    print "(+) Using the Clang bundled with Xcode"
    path = options.default
    isBuiltinAnalyzer = True

  try:
    xcode_path = subprocess.check_output(["xcode-select", "-print-path"])
  except AttributeError:
    # Fall back to the default install location when using Python < 2.7.0
    xcode_path = "/Developer"
  if (xcode_path.find(".app/") != -1):
    # Cut off the 'Developer' dir, as the xcspec lies in another part
    # of the Xcode.app subtree.
    xcode_path = os.path.dirname(xcode_path)

  foundSpec = False
  for x in FindClangSpecs(xcode_path):
    foundSpec = True
    ModifySpec(x, isBuiltinAnalyzer, path)

  if foundSpec == False:
      print "(-) No compiler configuration file was found.  Xcode's analyzer has not been updated."

if __name__ == '__main__':
  main()
@


