@ -27,45 +27,6 @@ csv.field_size_limit(sys.maxsize)
INFER_ANALYZE_BINARY = ' InferAnalyze '
def get_infer_version ( ) :
try :
return subprocess . check_output ( [
utils . get_cmd_in_bin_dir ( INFER_ANALYZE_BINARY ) , ' -version ' ] )
except subprocess . CalledProcessError :
utils . stdout ( ' Failed to run {0} binary, exiting '
. format ( INFER_ANALYZE_BINARY ) )
sys . exit ( os . EX_UNAVAILABLE )
# https://github.com/python/cpython/blob/aa8ea3a6be22c92e774df90c6a6ee697915ca8ec/Lib/argparse.py
class VersionAction ( argparse . _VersionAction ) :
def __call__ ( self , parser , namespace , values , option_string = None ) :
# set self.version so that argparse version action knows it
self . version = get_infer_version ( )
super ( VersionAction , self ) . __call__ ( parser ,
namespace ,
values ,
option_string )
def get_pwd ( ) :
pwd = os . getenv ( ' PWD ' )
if pwd is not None :
try :
# Compare whether 'PWD' and '.' point to same place
# Approach is borrowed from llvm implementation of
# llvm::sys::fs::current_path (implemented in Path.inc file)
pwd_stat = os . stat ( pwd )
dot_stat = os . stat ( ' . ' )
if pwd_stat . st_dev == dot_stat . st_dev and \
pwd_stat . st_ino == dot_stat . st_ino :
return pwd
except OSError :
# fallthrough to default case
pass
return os . getcwd ( )
base_parser = argparse . ArgumentParser ( add_help = False )
base_group = base_parser . add_argument_group ( ' global arguments ' )
base_group . add_argument ( ' -o ' , ' --out ' , metavar = ' <directory> ' ,
@ -99,10 +60,6 @@ base_group.add_argument('--android-harness', action='store_true',
help = ''' [experimental] Create harness to detect bugs
involving the Android lifecycle ''' )
base_parser . add_argument ( ' -v ' , ' --version ' ,
help = ''' Print the version of Infer and exit ''' ,
action = VersionAction )
base_group . add_argument ( ' --pmd-xml ' ,
action = ' store_true ' ,
help = ''' Output issues in (PMD) XML format. ''' )
@ -124,7 +81,7 @@ infer_group.add_argument('--buck', action='store_true', dest='buck',
infer_group . add_argument ( ' -pr ' , ' --project_root ' ,
dest = ' project_root ' ,
default = get_p wd( ) ,
default = os. getc wd( ) ,
help = ' Location of the project root '
' (default is current directory) ' )
@ -279,8 +236,6 @@ class AnalyzerWrapper(object):
for path in self . javac . args . classpath . split ( os . pathsep ) :
if os . path . isfile ( path ) :
infer_options + = [ ' -ziplib ' , os . path . abspath ( path ) ]
elif self . args . project_root :
infer_options + = [ ' -project_root ' , self . args . project_root ]
infer_options = map ( utils . decode_or_not , infer_options )
infer_options_str = ' ' . join ( infer_options )