@ -56,6 +56,18 @@ let build_mode_of_string path =
 
			
		
	
		
		
			
				
					
					  |  " xcodebuild "  ->  Xcode 
  |  " xcodebuild "  ->  Xcode 
 
			
		
	
		
		
			
				
					
					  |  cmd  ->  failwithf  " Unsupported build command %s "  cmd 
  |  cmd  ->  failwithf  " Unsupported build command %s "  cmd 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					let  string_of_build_mode  =  function  
			
		
	
		
		
			
				
					
					  |  Analyze  ->  " analyze " 
 
			
		
	
		
		
			
				
					
					  |  Ant  ->  " ant " 
 
			
		
	
		
		
			
				
					
					  |  Buck  ->  " buck " 
 
			
		
	
		
		
			
				
					
					  |  ClangCompilationDatabase  ->  " clang-compilation-database " 
 
			
		
	
		
		
			
				
					
					  |  Gradle  ->  " gradle " 
 
			
		
	
		
		
			
				
					
					  |  Java  ->  " java " 
 
			
		
	
		
		
			
				
					
					  |  Javac  ->  " javac " 
 
			
		
	
		
		
			
				
					
					  |  Make  ->  " make/cc " 
 
			
		
	
		
		
			
				
					
					  |  Mvn  ->  " maven " 
 
			
		
	
		
		
			
				
					
					  |  Ndk  ->  " ndk-build " 
 
			
		
	
		
		
			
				
					
					  |  Xcode  ->  " xcodebuild " 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					let  remove_results_dir  ()  = let  remove_results_dir  ()  =  
			
		
	
		
		
			
				
					
					  rmtree  Config . results_dir 
  rmtree  Config . results_dir 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -118,7 +130,7 @@ let run_command cmd_list after_wait =
 
			
		
	
		
		
			
				
					
					  let  exit_code  =  match  status  with  Unix . WEXITED  i  ->  i  |  _  ->  1  in 
  let  exit_code  =  match  status  with  Unix . WEXITED  i  ->  i  |  _  ->  1  in 
 
			
		
	
		
		
			
				
					
					  after_wait  exit_code  ; 
  after_wait  exit_code  ; 
 
			
		
	
		
		
			
				
					
					  if  exit_code  < >  0  then  ( 
  if  exit_code  < >  0  then  ( 
 
			
		
	
		
		
			
				
					
					    L . " Failed to execute: %s@ \n "  ( String . concat  "   "  cmd_list )  ; 
    L . do_ err " Failed to execute: %s@ \n "  ( String . concat  "   "  cmd_list )  ; 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					    exit  exit_code 
    exit  exit_code 
 
			
		
	
		
		
			
				
					
					  ) 
  ) 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -140,9 +152,11 @@ let capture build_cmd = function
 
			
		
	
		
		
			
				
					
					  |  Analyze  -> 
  |  Analyze  -> 
 
			
		
	
		
		
			
				
					
					      () 
      () 
 
			
		
	
		
		
			
				
					
					  |  Buck  when  Config . use_compilation_database  < >  None  -> 
  |  Buck  when  Config . use_compilation_database  < >  None  -> 
 
			
		
	
		
		
			
				
					
					      L . stdout  " Capturing using Buck's compilation database...@ \n " ; 
 
			
		
	
		
		
			
				
					
					      let  json_cdb  =  CaptureCompilationDatabase . get_compilation_database_files_buck  ()  in 
      let  json_cdb  =  CaptureCompilationDatabase . get_compilation_database_files_buck  ()  in 
 
			
		
	
		
		
			
				
					
					      CaptureCompilationDatabase . capture_files_in_database  json_cdb 
      CaptureCompilationDatabase . capture_files_in_database  json_cdb 
 
			
		
	
		
		
			
				
					
					  |  ClangCompilationDatabase  ->  ( 
  |  ClangCompilationDatabase  ->  ( 
 
			
		
	
		
		
			
				
					
					      L . stdout  " Capturing using a compilation database file...@ \n " ; 
 
			
		
	
		
		
			
				
					
					      match  Config . rest  with 
      match  Config . rest  with 
 
			
		
	
		
		
			
				
					
					      |  arg  ::  _  ->  CaptureCompilationDatabase . capture_files_in_database  [ arg ] 
      |  arg  ::  _  ->  CaptureCompilationDatabase . capture_files_in_database  [ arg ] 
 
			
		
	
		
		
			
				
					
					      |  _  -> 
      |  _  -> 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -152,10 +166,12 @@ let capture build_cmd = function
 
			
		
	
		
		
			
				
					
					          Config . print_usage_exit  () 
          Config . print_usage_exit  () 
 
			
		
	
		
		
			
				
					
					    ) 
    ) 
 
			
		
	
		
		
			
				
					
					  |  Xcode  when  Config . xcpretty  -> 
  |  Xcode  when  Config . xcpretty  -> 
 
			
		
	
		
		
			
				
					
					      L . stdout  " Capturing using xcpretty...@ \n " ; 
 
			
		
	
		
		
			
				
					
					      check_xcpretty  () ; 
      check_xcpretty  () ; 
 
			
		
	
		
		
			
				
					
					      let  json_cdb  =  CaptureCompilationDatabase . get_compilation_database_files_xcodebuild  ()  in 
      let  json_cdb  =  CaptureCompilationDatabase . get_compilation_database_files_xcodebuild  ()  in 
 
			
		
	
		
		
			
				
					
					      CaptureCompilationDatabase . capture_files_in_database  json_cdb 
      CaptureCompilationDatabase . capture_files_in_database  json_cdb 
 
			
		
	
		
		
			
				
					
					  |  build_mode  -> 
  |  build_mode  -> 
 
			
		
	
		
		
			
				
					
					      L . stdout  " Capturing in %s mode...@. "  ( string_of_build_mode  build_mode ) ; 
 
			
		
	
		
		
			
				
					
					      let  in_buck_mode  =  build_mode  =  Buck  in 
      let  in_buck_mode  =  build_mode  =  Buck  in 
 
			
		
	
		
		
			
				
					
					      let  infer_py  =  Config . lib_dir  //  " python "  //  " infer.py "  in 
      let  infer_py  =  Config . lib_dir  //  " python "  //  " infer.py "  in 
 
			
		
	
		
		
			
				
					
					      run_command  ( 
      run_command  ( 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -207,6 +223,7 @@ let run_parallel_analysis () =
 
			
		
	
		
		
			
				
					
					  let  multicore_dir  =  Config . results_dir  //  Config . multicore_dir_name  in 
  let  multicore_dir  =  Config . results_dir  //  Config . multicore_dir_name  in 
 
			
		
	
		
		
			
				
					
					  rmtree  multicore_dir  ; 
  rmtree  multicore_dir  ; 
 
			
		
	
		
		
			
				
					
					  create_path  multicore_dir  ; 
  create_path  multicore_dir  ; 
 
			
		
	
		
		
			
				
					
					  InferAnalyze . print_stdout_legend  () ; 
 
			
		
	
		
		
			
				
					
					  InferAnalyze . main  ( multicore_dir  //  " Makefile " )  ; 
  InferAnalyze . main  ( multicore_dir  //  " Makefile " )  ; 
 
			
		
	
		
		
			
				
					
					  let  cwd  =  Unix . getcwd  ()  in 
  let  cwd  =  Unix . getcwd  ()  in 
 
			
		
	
		
		
			
				
					
					  Unix . chdir  multicore_dir  ; 
  Unix . chdir  multicore_dir  ; 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -244,7 +261,11 @@ let report () =
 
			
		
	
		
		
			
				
					
					          " --project-root " ;  Config . project_root ; 
          " --project-root " ;  Config . project_root ; 
 
			
		
	
		
		
			
				
					
					          " --results-dir " ;  Config . results_dir 
          " --results-dir " ;  Config . results_dir 
 
			
		
	
		
		
			
				
					
					        ]  in 
        ]  in 
 
			
		
	
		
		
			
				
					
					      Unix . waitpid  ( Unix . fork_exec  ~ prog  ~ args : ( prog  ::  args )  () )  | >  ignore 
      match  ( Unix . waitpid  ( Unix . fork_exec  ~ prog  ~ args : ( prog  ::  args )  () ) )  with 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					      |  Result . Ok  _  ->  () 
 
			
		
	
		
		
			
				
					
					      |  Result . Error  _  -> 
 
			
		
	
		
		
			
				
					
					          L . stderr  " ** Error running the reporting script:@ \n **   %s %s@ \n ** See error above@. " 
 
			
		
	
		
		
			
				
					
					            prog  ( String . concat  ~ sep : "   "  args ) 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					let  analyze  =  function let  analyze  =  function  
			
		
	
		
		
			
				
					
					  |  Buck  when  Config . use_compilation_database  =  None  -> 
  |  Buck  when  Config . use_compilation_database  =  None  -> 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -256,7 +277,7 @@ let analyze = function
 
			
		
	
		
		
			
				
					
					      () 
      () 
 
			
		
	
		
		
			
				
					
					  |  Analyze  |  Ant  |  Buck  |  ClangCompilationDatabase  |  Gradle  |  Make  |  Mvn  |  Ndk  |  Xcode  -> 
  |  Analyze  |  Ant  |  Buck  |  ClangCompilationDatabase  |  Gradle  |  Make  |  Mvn  |  Ndk  |  Xcode  -> 
 
			
		
	
		
		
			
				
					
					      if  not  ( Sys . file_exists  Config . ( results_dir  //  captured_dir_name ) )  then  ( 
      if  not  ( Sys . file_exists  Config . ( results_dir  //  captured_dir_name ) )  then  ( 
 
			
		
	
		
		
			
				
					
					        L . " There was nothing to analyze, exiting "  ; 
        L . std err " There was nothing to analyze, exiting "  ; 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					        Config . print_usage_exit  () 
        Config . print_usage_exit  () 
 
			
		
	
		
		
			
				
					
					      ) ; 
      ) ; 
 
			
		
	
		
		
			
				
					
					      ( match  Config . analyzer  with 
      ( match  Config . analyzer  with 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -287,7 +308,7 @@ let () =
 
			
		
	
		
		
			
				
					
					  create_results_dir  ()  ; 
  create_results_dir  ()  ; 
 
			
		
	
		
		
			
				
					
					  (*  re-set log files, as default files were in results_dir removed above  *) 
  (*  re-set log files, as default files were in results_dir removed above  *) 
 
			
		
	
		
		
			
				
					
					  L . set_log_file_identifier  Config . current_exe  ( Some  ( CLOpt . exe_name  Config . current_exe ) )  ; 
  L . set_log_file_identifier  Config . current_exe  ( Some  ( CLOpt . exe_name  Config . current_exe ) )  ; 
 
			
		
	
		
		
			
				
					
					  if  Config . is_originator  then  L . " %s@ \n "  Config . version_string  ; 
  if  Config . is_originator  then  L . do_ out " %s@ \n "  Config . version_string  ; 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					  register_perf_stats_report  ()  ; 
  register_perf_stats_report  ()  ; 
 
			
		
	
		
		
			
				
					
					  touch_start_file  ()  ; 
  touch_start_file  ()  ; 
 
			
		
	
		
		
			
				
					
					  capture  build_cmd  build_mode  ; 
  capture  build_cmd  build_mode  ;