You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.3 KiB

sources = glob(['**/*.java','**/*.json'])
dependencies = [
'//dependencies/java/android/support/v4:android-support-v4',
'//infer/annotations:annotations',
'//infer/lib/java/android:android',
]
java_library(
name = 'checkers',
srcs = sources,
deps = dependencies,
visibility = [
'PUBLIC'
]
)
out = 'out'
inferconfig_file = '$(location //infer/tests/codetoanalyze/java:inferconfig)'
copy_inferconfig = ' '.join(['cp', inferconfig_file, '$SRCDIR'])
clean_cmd = ' '.join(['rm', '-rf', out])
classpath = ':'.join([('$(classpath ' + path + ')') for path in dependencies])
def mk_infer_cmd(tag, srcs, stacktrace):
infer_cmd_main = ' '.join([
'infer',
'--no-progress-bar',
'--absolute-paths',
'-o', out,
'-a', 'crashcontext',
'--stacktrace', stacktrace,
'--',
'javac',
'-cp', classpath,
srcs])
out_rename = ' '.join(['cp',
out + '/crashcontext/crashcontext.json',
'$OUT' + "." + tag])
return ' && '.join([infer_cmd_main, out_rename])
infer_cmds = [
mk_infer_cmd(
"MinimalCrashExample",
"MinimalCrashExample.java",
"MinimalCrashExample.stacktrace.json"
),
mk_infer_cmd(
"MultiStackFrameCrashExample",
"MultiStackFrameCrashExample.java",
"MultiStackFrameCrashExample.stacktrace.json"
),
mk_infer_cmd(
"BranchingCallsExample",
"BranchingCallsExample.java",
"BranchingCallsExample.stacktrace.json"
),
mk_infer_cmd(
"MethodNameClashExample",
"MethodNameClashExample.java",
"MethodNameClashExample.stacktrace.json"
),
mk_infer_cmd(
"NativeMethodExample",
"NativeMethodExample.java",
"NativeMethodExample.stacktrace.json"
)
]
# Copy the last crashcontext.json because buck expects it as the output file.
# This will only contain the results for the last run infer_cmd above.
copy_cmd = ' '.join(['cp', out + '/crashcontext/crashcontext.json', '$OUT'])
command = ' && '.join([clean_cmd, copy_inferconfig, ' && '.join(infer_cmds), copy_cmd])
genrule(
name = 'analyze',
srcs = sources,
out = 'crashcontext.json',
cmd = command,
deps = dependencies + [':checkers'],
visibility = [
'PUBLIC',
]
)