com php-src: support for static analyzers other than visual studio: win32/build/config.w32 win32/build/confutils.js
| From: | Anatol Belski | Date: | Sat, 01 Mar 2014 19:15:10 +0000 |
| Subject: | com php-src: support for static analyzers other than visual studio: win32/build/config.w32 win32/build/confutils.js | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76295@lists.php.net to get a copy of this message | ||
Commit: cf90bd92bf7b86cc8cd055220a92bb2a60f4098e
Author: Anatol Belski <ab@php.net> Sat, 1 Mar 2014 20:15:10 +0100
Parents: 0bbacd86788504eb601178d8f6e3e3ed8f37ee0f
Branches: PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cf90bd92bf7b86cc8cd055220a92bb2a60f4098e
Log:
support for static analyzers other than visual studio
Changed paths:
M win32/build/config.w32
M win32/build/confutils.js
Diff:
diff --git a/win32/build/config.w32 b/win32/build/config.w32
index 0caa3c6..4d2451b 100644
--- a/win32/build/config.w32
+++ b/win32/build/config.w32
@@ -444,8 +444,37 @@ if (PHP_SECURITY_FLAGS == "yes") {
ADD_FLAG("LDFLAGS", "/NXCOMPAT /DYNAMICBASE ");
}
-ARG_ENABLE("static-analyze", "Enable the VC compiler static analyze",
"no");
-if (PHP_STATIC_ANALYZE == "yes") {
+/* XXX add and implement clang keyword for clang analyzer */
+ARG_WITH("analyzer", "Enable static analyzer. Pass vs for Visual Studio, pvs for
PVS-Studio", "no");
+if (PHP_ANALYZER == "vs") {
ADD_FLAG("CFLAGS", " /analyze ");
ADD_FLAG("CFLAGS", " /wd6308 ");
+} else if (PHP_ANALYZER == "pvs") {
+ var pvs_studio = false;
+
+ if (FSO.FileExists(PROGRAM_FILES + "\\PVS-Studio\\x64\\PVS-Studio.exe")) {
+ pvs_studio = PROGRAM_FILES + "\\PVS-Studio\\x86\\PVS-Studio.exe";
+ } else if (FSO.FileExists(PROGRAM_FILESx86 + "\\PVS-Studio\\x64\\PVS-Studio.exe")) {
+ pvs_studio = PROGRAM_FILESx86 + "\\PVS-Studio\\x64\\PVS-Studio..exe";
+ }
+
+ if (!pvs_studio) {
+ WARNING("Couldn't find PVS-Studio binaries, static analyze was disabled");
+ PHP_ANALYZER = "no";
+ } else {
+ var pvscfg = FSO.CreateTextFile("PVS-Studio.conf", true);
+ DEFINE("PVS_STUDIO", pvs_studio);
+
+ pvscfg.WriteLine("exclude-path = " + VCINSTALLDIR);
+ if (FSO.FolderExists(PROGRAM_FILESx86 + "\\windows kits\\")) {
+ pvscfg.WriteLine("exclude-path = " + PROGRAM_FILESx86 + "\\windows kits\\");
+ } else if (FSO.FolderExists(PROGRAM_FILES + "\\windows kits\\")) {
+ pvscfg.WriteLine("exclude-path = " + PROGRAM_FILES + "\\windows kits\\");
+ }
+ pvscfg.WriteLine("vcinstalldir = " + VCINSTALLDIR);
+ pvscfg.WriteLine("platform = " + (X64 ? 'x64' : 'Win32'));
+ pvscfg.WriteLine("preprocessor = visualcpp");
+ pvscfg.WriteLine("language = C");
+ }
}
+
diff --git a/win32/build/confutils.js b/win32/build/confutils.js
index e674964..5ccdfa1 100644
--- a/win32/build/confutils.js
+++ b/win32/build/confutils.js
@@ -26,6 +26,8 @@ var FSO = WScript.CreateObject("Scripting.FileSystemObject");
var MFO = null;
var SYSTEM_DRIVE = WshShell.Environment("Process").Item("SystemDrive");
var PROGRAM_FILES = WshShell.Environment("Process").Item("ProgramFiles");
+var PROGRAM_FILESx86 =
WshShell.Environment("Process").Item("ProgramFiles(x86)");
+var VCINSTALLDIR = WshShell.Environment("Process").Item("VCINSTALLDIR");
var DSP_FLAGS = new Array();
var PHP_SRC_DIR=FSO.GetParentFolderName(WScript.ScriptFullName);
@@ -1388,6 +1390,11 @@ function ADD_SOURCES(dir, file_list, target, obj_dir)
}
} else {
MFO.WriteLine(sub_build + obj + ": " + dir + "\\" + src);
+
+ if (PHP_ANALYZER == "pvs") {
+ MFO.WriteLine("\t@\"$(PVS_STUDIO)\" --cl-params $(" + flags + ")
$(CFLAGS) $(" + bd_flags_name + ") /c " + dir + "\\" + src + "
--source-file " + dir + "\\" + src
+ + " --cfg PVS-Studio.conf ");
+ }
MFO.WriteLine("\t@$(CC) $(" + flags + ") $(CFLAGS) $(" + bd_flags_name +
") /c " + dir + "\\" + src + " /Fo" + sub_build + obj);
}
}
@@ -1555,8 +1562,10 @@ function write_summary()
} else {
ar[4] = ['Optimization', PHP_DEBUG == "yes" ? "disabled" :
"PGO disabled"];
}
- if (PHP_STATIC_ANALYZE == "yes") {
+ if (PHP_ANALYZER == "vs") {
ar[5] = ['Static analyzer', 'Visual Studio'];
+ } else if (PHP_ANALYZER == "pvs") {
+ ar[5] = ['Static analyzer', 'PVS-Studio'];
} else {
ar[5] = ['Static analyzer', 'disabled'];
}