@@ -444,8 +444,37 @@ if (PHP_SECURITY_FLAGS == "yes") {
444
444
ADD_FLAG ( "LDFLAGS" , "/NXCOMPAT /DYNAMICBASE " ) ;
445
445
}
446
446
447
- ARG_ENABLE ( "static-analyze" , "Enable the VC compiler static analyze" , "no" ) ;
448
- if ( PHP_STATIC_ANALYZE == "yes" ) {
447
+ /* XXX add and implement clang keyword for clang analyzer */
448
+ ARG_WITH ( "analyzer" , "Enable static analyzer. Pass vs for Visual Studio, pvs for PVS-Studio" , "no" ) ;
449
+ if ( PHP_ANALYZER == "vs" ) {
449
450
ADD_FLAG ( "CFLAGS" , " /analyze " ) ;
450
451
ADD_FLAG ( "CFLAGS" , " /wd6308 " ) ;
452
+ } else if ( PHP_ANALYZER == "pvs" ) {
453
+ var pvs_studio = false ;
454
+
455
+ if ( FSO . FileExists ( PROGRAM_FILES + "\\PVS-Studio\\x64\\PVS-Studio.exe" ) ) {
456
+ pvs_studio = PROGRAM_FILES + "\\PVS-Studio\\x86\\PVS-Studio.exe" ;
457
+ } else if ( FSO . FileExists ( PROGRAM_FILESx86 + "\\PVS-Studio\\x64\\PVS-Studio.exe" ) ) {
458
+ pvs_studio = PROGRAM_FILESx86 + "\\PVS-Studio\\x64\\PVS-Studio.exe" ;
459
+ }
460
+
461
+ if ( ! pvs_studio ) {
462
+ WARNING ( "Couldn't find PVS-Studio binaries, static analyze was disabled" ) ;
463
+ PHP_ANALYZER = "no" ;
464
+ } else {
465
+ var pvscfg = FSO . CreateTextFile ( "PVS-Studio.conf" , true ) ;
466
+ DEFINE ( "PVS_STUDIO" , pvs_studio ) ;
467
+
468
+ pvscfg . WriteLine ( "exclude-path = " + VCINSTALLDIR ) ;
469
+ if ( FSO . FolderExists ( PROGRAM_FILESx86 + "\\windows kits\\" ) ) {
470
+ pvscfg . WriteLine ( "exclude-path = " + PROGRAM_FILESx86 + "\\windows kits\\" ) ;
471
+ } else if ( FSO . FolderExists ( PROGRAM_FILES + "\\windows kits\\" ) ) {
472
+ pvscfg . WriteLine ( "exclude-path = " + PROGRAM_FILES + "\\windows kits\\" ) ;
473
+ }
474
+ pvscfg . WriteLine ( "vcinstalldir = " + VCINSTALLDIR ) ;
475
+ pvscfg . WriteLine ( "platform = " + ( X64 ? 'x64' : 'Win32' ) ) ;
476
+ pvscfg . WriteLine ( "preprocessor = visualcpp" ) ;
477
+ pvscfg . WriteLine ( "language = C" ) ;
478
+ }
451
479
}
480
+
0 commit comments