[FL-3080] fbt: PVS support (#2286)
* fbt: added firmware_pvscheck & firmware_pvs targets for *nix * fbt: pvs support on Windows * fbt: additional fixes & docs for PVS support * fbt: fixes for updater env configuration * github: reworked pvs workflow * vscode: added PVS shortcut * pvs: added --ignore-ccache flag * fbt: pvs: opening web browser if there are warnings * fbt: pvs: added browser handler for mac * github: fixed report path for PVS * fbt: pvs: fixed report upload path * removed intentional PVS warning * fixed more PVS warnings * fixed secplus_v1 PVS warning * fbt: added PVSNOBROWSER flag * github: setting PVSNOBROWSER for pvs runs * fbt: less debug output Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -32,6 +32,7 @@ def BuildAppElf(env, app):
|
||||
ext_apps_work_dir = env.subst("$EXT_APPS_WORK_DIR")
|
||||
app_work_dir = os.path.join(ext_apps_work_dir, app.appid)
|
||||
|
||||
env.SetDefault(_APP_ICONS=[])
|
||||
env.VariantDir(app_work_dir, app._appdir, duplicate=False)
|
||||
|
||||
app_env = env.Clone(FAP_SRC_DIR=app._appdir, FAP_WORK_DIR=app_work_dir)
|
||||
@@ -63,6 +64,7 @@ def BuildAppElf(env, app):
|
||||
icon_bundle_name=f"{app.fap_icon_assets_symbol if app.fap_icon_assets_symbol else app.appid }_icons",
|
||||
)
|
||||
app_env.Alias("_fap_icons", fap_icons)
|
||||
env.Append(_APP_ICONS=[fap_icons])
|
||||
|
||||
private_libs = []
|
||||
|
||||
|
@@ -31,6 +31,8 @@ Other:
|
||||
run linters
|
||||
format, format_py:
|
||||
run code formatters
|
||||
firmware_pvs:
|
||||
generate a PVS-Studio report
|
||||
|
||||
For more targets & info, see documentation/fbt.md
|
||||
"""
|
||||
|
106
scripts/fbt_tools/pvsstudio.py
Normal file
106
scripts/fbt_tools/pvsstudio.py
Normal file
@@ -0,0 +1,106 @@
|
||||
from SCons.Builder import Builder
|
||||
from SCons.Action import Action
|
||||
from SCons.Script import Delete, Mkdir, GetBuildFailures
|
||||
import multiprocessing
|
||||
import webbrowser
|
||||
import atexit
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
__no_browser = False
|
||||
|
||||
|
||||
def _set_browser_action(target, source, env):
|
||||
if env["PVSNOBROWSER"]:
|
||||
global __no_browser
|
||||
__no_browser = True
|
||||
|
||||
|
||||
def emit_pvsreport(target, source, env):
|
||||
target_dir = env["REPORT_DIR"]
|
||||
if env["PLATFORM"] == "win32":
|
||||
# Report generator on Windows emits to a subfolder of given output folder
|
||||
target_dir = target_dir.Dir("fullhtml")
|
||||
return [target_dir.File("index.html")], source
|
||||
|
||||
|
||||
def atexist_handler():
|
||||
global __no_browser
|
||||
if __no_browser:
|
||||
return
|
||||
|
||||
for bf in GetBuildFailures():
|
||||
if bf.node.exists and bf.node.name.endswith(".html"):
|
||||
# macOS
|
||||
if sys.platform == "darwin":
|
||||
subprocess.run(["open", bf.node.abspath])
|
||||
else:
|
||||
webbrowser.open(bf.node.abspath)
|
||||
break
|
||||
|
||||
|
||||
def generate(env):
|
||||
env.SetDefault(
|
||||
PVSNCORES=multiprocessing.cpu_count(),
|
||||
PVSOPTIONS=[
|
||||
"@.pvsoptions",
|
||||
"-j${PVSNCORES}",
|
||||
# "--incremental", # kinda broken on PVS side
|
||||
],
|
||||
PVSCONVOPTIONS=[
|
||||
"-a",
|
||||
"GA:1,2,3",
|
||||
"-t",
|
||||
"fullhtml",
|
||||
"--indicate-warnings",
|
||||
],
|
||||
)
|
||||
|
||||
if env["PLATFORM"] == "win32":
|
||||
env.SetDefault(
|
||||
PVSCHECKBIN="CompilerCommandsAnalyzer.exe",
|
||||
PVSCONVBIN="PlogConverter.exe",
|
||||
)
|
||||
else:
|
||||
env.SetDefault(
|
||||
PVSCHECKBIN="pvs-studio-analyzer",
|
||||
PVSCONVBIN="plog-converter",
|
||||
)
|
||||
|
||||
if not env["VERBOSE"]:
|
||||
env.SetDefault(
|
||||
PVSCHECKCOMSTR="\tPVS\t${TARGET}",
|
||||
PVSCONVCOMSTR="\tPVSREP\t${TARGET}",
|
||||
)
|
||||
|
||||
env.Append(
|
||||
BUILDERS={
|
||||
"PVSCheck": Builder(
|
||||
action=Action(
|
||||
'${PVSCHECKBIN} analyze ${PVSOPTIONS} -f "${SOURCE}" -o "${TARGET}"',
|
||||
"${PVSCHECKCOMSTR}",
|
||||
),
|
||||
suffix=".log",
|
||||
src_suffix=".json",
|
||||
),
|
||||
"PVSReport": Builder(
|
||||
action=Action(
|
||||
[
|
||||
Delete("${TARGET.dir}"),
|
||||
# PlogConverter.exe and plog-converter have different behavior
|
||||
Mkdir("${TARGET.dir}") if env["PLATFORM"] == "win32" else None,
|
||||
Action(_set_browser_action, None),
|
||||
'${PVSCONVBIN} ${PVSCONVOPTIONS} "${SOURCE}" -o "${REPORT_DIR}"',
|
||||
],
|
||||
"${PVSCONVCOMSTR}",
|
||||
),
|
||||
emitter=emit_pvsreport,
|
||||
src_suffix=".log",
|
||||
),
|
||||
}
|
||||
)
|
||||
atexit.register(atexist_handler)
|
||||
|
||||
|
||||
def exists(env):
|
||||
return True
|
Reference in New Issue
Block a user