File tree Expand file tree Collapse file tree 10 files changed +113
-22
lines changed Expand file tree Collapse file tree 10 files changed +113
-22
lines changed Original file line number Diff line number Diff line change
1
+ [buildfile]
2
+ includes = //DEFS
1
3
2
4
[project]
3
5
ignore = .git, .ml, .mli
Original file line number Diff line number Diff line change
1
+ import os
2
+
3
+ original_java_library = java_library
4
+ def java_library(
5
+ name,
6
+ deps=[],
7
+ **kwargs
8
+ ):
9
+ compile_name = name + '_compile'
10
+ top_deps = []
11
+
12
+ if 'GENERATE_INFER_GENRULES' in os.environ:
13
+ export_srcs_name = name + '_export_srcs'
14
+ genrule(
15
+ name = export_srcs_name,
16
+ srcs = kwargs.get('srcs', []),
17
+ cmd = 'mkdir -p $OUT && cp -R $SRCDIR/* $OUT/',
18
+ out = 'src_copy',
19
+ )
20
+ infer_name = name + '_infer'
21
+ genrule(
22
+ name = infer_name,
23
+ cmd = ' '.join([
24
+ os.getenv('INFER_BIN', 'infer'),
25
+ '--results-dir', '$OUT',
26
+ '--classpath', '$(classpath :{})'.format(compile_name),
27
+ '--sourcepath', '$(location :{})'.format(export_srcs_name),
28
+ '--generated-classes', '$(location :{})'.format(compile_name),
29
+ '--', 'genrule'
30
+ ]),
31
+ out = 'infer_out',
32
+ )
33
+ top_deps += [':' + infer_name, ':' + export_srcs_name]
34
+
35
+ original_java_library(
36
+ name=name,
37
+ exported_deps=[
38
+ ':' + compile_name,
39
+ ],
40
+ deps=top_deps,
41
+ visibility = kwargs.get('visibility', [])
42
+ )
43
+ original_java_library(
44
+ name=compile_name,
45
+ deps=deps,
46
+ **kwargs
47
+ )
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ $(JAR_OUTPUT): $(JAVA_SOURCE_FILES)
24
24
25
25
.PHONY : genrule
26
26
genrule : $(JAR_OUTPUT )
27
- cd $(ROOT_DIR ) && $(call silent_on_success, INFER_BIN=$(INFER_BIN ) NO_BUCKD=1 buck build --no-cache //infer/tests/codetoanalyze/java/infer:run_infer )
27
+ cd $(ROOT_DIR ) && $(call silent_on_success, INFER_BIN=$(INFER_BIN ) NO_BUCKD=1 GENERATE_INFER_GENRULES=1 buck build --no-cache //infer/tests/build_systems/genrule/module2:module2_infer )
28
28
29
29
infer-out/report.json : genrule $(INFER_BIN ) $(JAVA_SOURCE_FILES )
30
30
cd $(ROOT_DIR ) && $(call silent_on_success, INFER_BIN=$(INFER_BIN ) NO_BUCKD=1 $(INFER_BIN ) -a $(ANALYZER ) --results-dir $(CURDIR ) /infer-out -- buck build --no-cache //infer/tests/codetoanalyze/java/infer:compile)
Original file line number Diff line number Diff line change
1
+ java_library (
2
+ name = 'annotations' ,
3
+ srcs = ['Nullable.java' ],
4
+ visibility = [
5
+ 'PUBLIC'
6
+ ],
7
+ )
Original file line number Diff line number Diff line change
1
+ package genrule .annotations ;
2
+
3
+ public @interface Nullable {
4
+ }
Original file line number Diff line number Diff line change
1
+ java_library (
2
+ name = 'module1' ,
3
+ srcs = ['Class1.java' ],
4
+ deps = [
5
+ '//infer/tests/build_systems/genrule/annotations:annotations' ,
6
+ ],
7
+ visibility = [
8
+ 'PUBLIC'
9
+ ],
10
+ )
Original file line number Diff line number Diff line change
1
+ package genrule .module1 ;
2
+
3
+ import genrule .annotations .Nullable ;
4
+
5
+ public class Class1 {
6
+
7
+ @ Nullable
8
+ public static String returnsNull () {
9
+ return null ;
10
+ }
11
+
12
+ void localNPE1 () {
13
+ Object obj = null ;
14
+ obj .toString ();
15
+ }
16
+
17
+ }
Original file line number Diff line number Diff line change
1
+ java_library (
2
+ name = 'module2' ,
3
+ srcs = ['Class2.java' ],
4
+ deps = [
5
+ '//infer/tests/build_systems/genrule/module1:module1'
6
+ ]
7
+ )
Original file line number Diff line number Diff line change
1
+ package genrule .module2 ;
2
+
3
+ import genrule .module1 .Class1 ;
4
+
5
+ public class Class2 {
6
+
7
+ void interTargetNPE () {
8
+ Object obj = Class1 .returnsNull ();
9
+ obj .toString ();
10
+ }
11
+
12
+ void localNPE2 () {
13
+ Object obj = null ;
14
+ obj .toString ();
15
+ }
16
+
17
+ }
Original file line number Diff line number Diff line change 2
2
3
3
import os
4
4
5
- sources = glob (['**/*.java' ])
6
-
7
5
java_library (
8
6
name = 'compile' ,
9
- srcs = sources ,
7
+ srcs = glob ([ '**/*.java' ]) ,
10
8
deps = [
11
9
'//dependencies/java/guava:guava' ,
12
10
'//dependencies/java/jsr-305:jsr-305' ,
@@ -19,21 +17,3 @@ java_library(
19
17
'PUBLIC'
20
18
]
21
19
)
22
-
23
- genrule (
24
- name = 'run_infer' ,
25
- srcs = sources ,
26
- out = 'infer-out' ,
27
- bash = ' ' .join ([
28
- os .getenv ('INFER_BIN' , 'infer' ),
29
- '--sourcepath' ,
30
- '$SRCDIR' ,
31
- '--classpath' ,
32
- '$(classpath :compile)' ,
33
- '--generated-classes' ,
34
- '$(location :compile)' ,
35
- '--out' ,
36
- '$OUT' ,
37
- '--' ,
38
- 'genrule' ]),
39
- )
You can’t perform that action at this time.
0 commit comments