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.

47 lines
1.1 KiB

import os
original_java_library = java_library
def java_library(
name,
deps=[],
**kwargs
):
compile_name = name + '_compile'
top_deps = []
if 'GENERATE_INFER_GENRULES' in os.environ:
export_srcs_name = name + '_export_srcs'
genrule(
name = export_srcs_name,
srcs = kwargs.get('srcs', []),
cmd = 'mkdir -p $OUT && cp -R $SRCDIR/* $OUT/',
out = 'src_copy',
)
infer_name = name + '_infer'
genrule(
name = infer_name,
cmd = ' '.join([
os.getenv('INFER_BIN', 'infer'),
'--results-dir', '$OUT',
'--classpath', '$(classpath :{})'.format(compile_name),
'--sourcepath', '$(location :{})'.format(export_srcs_name),
'--generated-classes', '$(location :{})'.format(compile_name),
]),
out = 'infer_out',
)
top_deps += [':' + infer_name, ':' + export_srcs_name]
original_java_library(
name=name,
exported_deps=[
':' + compile_name,
],
deps=top_deps,
visibility = kwargs.get('visibility', [])
)
original_java_library(
name=compile_name,
deps=deps,
**kwargs
)