diff --git a/.gitignore b/.gitignore index 4b97e6051..9ec5c82f1 100644 --- a/.gitignore +++ b/.gitignore @@ -97,4 +97,4 @@ buck-out/ /infer/annotations/annot_classes/ /infer/annotations/annotations.jar /infer/annotations/processor_classes/ -/infer/annotations/processor.jar \ No newline at end of file +/infer/lib/java/processor.jar diff --git a/infer/Makefile b/infer/Makefile index 0470bc0c9..435ec34eb 100644 --- a/infer/Makefile +++ b/infer/Makefile @@ -12,8 +12,8 @@ all: clang java llvm checkCopyright java: make -C $(SRCDIR) java - make -C $(MODELS) java make -C $(ANNOTATIONS) + make -C $(MODELS) java clang: make -C $(SRCDIR) clang @@ -27,5 +27,5 @@ checkCopyright: clean: make -C $(SRCDIR) clean - make -C $(MODELS) clean make -C $(ANNOTATIONS) clean + make -C $(MODELS) clean diff --git a/infer/annotations/BUCK b/infer/annotations/BUCK index 690a28717..edffaffde 100644 --- a/infer/annotations/BUCK +++ b/infer/annotations/BUCK @@ -5,11 +5,3 @@ prebuilt_jar( 'PUBLIC', ] ) - -prebuilt_jar( - name = 'processor', - binary_jar = 'processor.jar', - visibility = [ - 'PUBLIC', - ] -) diff --git a/infer/annotations/Makefile b/infer/annotations/Makefile index 9e1ddced6..29fd89ff6 100644 --- a/infer/annotations/Makefile +++ b/infer/annotations/Makefile @@ -1,24 +1,30 @@ -DEPENDENCIES = ../../dependencies +CWD = $(shell pwd) +DEPENDENCIES = $(CWD)/../../dependencies +LIB = $(CWD)/../lib/java JSR_JAR = $(DEPENDENCIES)/java/jsr-305/jsr305.jar -ANNOT_SOURCES = `find com/facebook/infer/annotation -name "*.java"` -PROCESSOR_SOURCES = `find com/facebook/infer/annotprocess -name "*.java"` +ANNOT_SOURCES = $(shell find com/facebook/infer/annotation -name "*.java") +PROCESSOR_SOURCES = $(shell find com/facebook/infer/annotprocess -name "*.java") ANNOT_CLASSES = 'annot_classes' PROCESSOR_CLASSES = 'processor_classes' -all: annotations processor +ANNOTATIONS_JAR = $(CWD)/annotations.jar +PROCESSOR_JAR = $(LIB)/processor.jar -annotations: +all: $(ANNOTATIONS_JAR) $(PROCESSOR_JAR) + +$(ANNOTATIONS_JAR): $(ANNOT_SOURCES) mkdir -p $(ANNOT_CLASSES) javac -cp $(JSR_JAR) $(ANNOT_SOURCES) -d $(ANNOT_CLASSES) - cd $(ANNOT_CLASSES) && jar cvf annotations.jar com && cp annotations.jar ../ + cd $(ANNOT_CLASSES) && jar cvf $(ANNOTATIONS_JAR) com -processor: +$(PROCESSOR_JAR): $(PROCESSOR_SOURCES) mkdir -p $(PROCESSOR_CLASSES) javac $(PROCESSOR_SOURCES) -d $(PROCESSOR_CLASSES) - cd $(PROCESSOR_CLASSES) && cp -r ../resources/META-INF . && jar cvMf processor.jar com META-INF && cp processor.jar ../ + jar cvMf processor.jar -C resources META-INF -C $(PROCESSOR_CLASSES) com + mv processor.jar $(PROCESSOR_JAR) clean: rm -rf $(ANNOT_CLASSES) - rm -f annotations.jar + rm -f $(ANNOTATIONS_JAR) rm -rf $(PROCESSOR_CLASSES) - rm -f processor.jar + rm -f $(PROCESSOR_JAR) diff --git a/infer/bin/jwlib.py b/infer/bin/jwlib.py index 8dc618dcc..c5acc07ec 100644 --- a/infer/bin/jwlib.py +++ b/infer/bin/jwlib.py @@ -26,6 +26,15 @@ parser.add_argument('-bootclasspath', type=str) parser.add_argument('-d', dest='classes_out', default=current_directory) +class AnnotationProcessorNotFound(Exception): + + def __init__(self, path): + self.path = path + + def __str__(self): + return repr(self.path + ' not found') + + class CompilerCall: def __init__(self, arguments): @@ -44,6 +53,9 @@ class CompilerCall: if self.args.bootclasspath is not None: javac_cmd += ['-bootclasspath', self.args.bootclasspath] + if not os.path.isfile(utils.ANNOT_PROCESSOR_JAR): + raise AnnotationProcessorNotFound(utils.ANNOT_PROCESSOR_JAR) + if self.args.classpath is None: classpath = utils.ANNOT_PROCESSOR_JAR else: diff --git a/infer/bin/utils.py b/infer/bin/utils.py index aaee6c816..53eff5466 100644 --- a/infer/bin/utils.py +++ b/infer/bin/utils.py @@ -28,10 +28,7 @@ BIN_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) LIB_DIRECTORY = os.path.join(BIN_DIRECTORY, '..', 'lib', 'java') TMP_DIRECTORY = tempfile.gettempdir() MODELS_JAR = os.path.join(LIB_DIRECTORY, 'models.jar') - -ANNOT_PROCESSOR_JAR = os.path.join( - BIN_DIRECTORY, '..', 'annotations', 'processor.jar') - +ANNOT_PROCESSOR_JAR = os.path.join(LIB_DIRECTORY, 'processor.jar') DEFAULT_INFER_OUT = os.path.join(os.getcwd(), 'infer-out') CSV_PERF_FILENAME = 'performances.csv'