1# Copyright (C) 2010 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15LOCAL_PATH := $(call my-dir) 16 17# build smali jar 18# ============================================================ 19 20include $(CLEAR_VARS) 21 22LOCAL_MODULE := smali 23 24LOCAL_MODULE_TAGS := optional 25 26#LOCAL_MODULE_CLASS and LOCAL_IS_HOST_MODULE must be defined before calling $(local-intermediates-dir) 27LOCAL_MODULE_CLASS := JAVA_LIBRARIES 28LOCAL_IS_HOST_MODULE := true 29 30intermediates := $(call local-intermediates-dir,COMMON) 31 32GEN := $(addprefix $(intermediates)/, \ 33 smaliLexer.java \ 34 smaliParser.java \ 35 smaliTreeWalker.java \ 36 ) 37 38ANTLR_JAR = $(call java-lib-deps,antlr,true) 39 40$(intermediates)/smaliTreeWalker.java: $(intermediates)/smaliParser.java $(intermediates)/smaliLexer.java 41$(intermediates)/smaliParser.java: $(intermediates)/smaliLexer.java 42 43$(GEN): $(ANTLR_JAR) 44$(GEN): PRIVATE_PATH := $(LOCAL_PATH) 45$(GEN): PRIVATE_CUSTOM_TOOL = java -jar $(ANTLR_JAR) -fo $(dir $@) $< 46$(GEN): $(intermediates)/%.java : $(LOCAL_PATH)/src/main/antlr3/org/jf/smali/%.g 47 $(transform-generated-source) 48 49LOCAL_GENERATED_SOURCES += $(GEN) 50 51LOCAL_SRC_FILES := \ 52 $(call all-java-files-under, src/main/java) \ 53 $(call all-java-files-under, ../dexlib/src/main/java) \ 54 $(call all-java-files-under, ../util/src/main/java) 55 56LOCAL_JAR_MANIFEST := manifest.txt 57 58LOCAL_STATIC_JAVA_LIBRARIES := \ 59 antlr-runtime \ 60 commons-cli-1.2 61 62#extract the current version from the pom file 63SMALI_VERSION := $(shell xsltproc $(LOCAL_PATH)/../extract-property.xslt $(LOCAL_PATH)/../pom.xml) 64 65#create a new smali.properties file using the correct version 66$(intermediates)/resources/smali.properties: 67 $(hide) mkdir -p $(dir $@) 68 $(hide) echo "application.version=$(SMALI_VERSION)" > $@ 69 70LOCAL_JAVA_RESOURCE_FILES := $(intermediates)/resources/smali.properties 71 72include $(BUILD_HOST_JAVA_LIBRARY) 73 74 75 76# copy smali script 77# ============================================================ 78 79include $(CLEAR_VARS) 80LOCAL_IS_HOST_MODULE := true 81LOCAL_MODULE_CLASS := EXECUTABLES 82LOCAL_MODULE_TAGS := optional 83LOCAL_MODULE := smali 84 85include $(BUILD_SYSTEM)/base_rules.mk 86 87$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/smali.jar 88$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/../scripts/smali | $(ACP) 89 @echo "Copy: $(PRIVATE_MODULE) ($@)" 90 $(copy-file-to-new-target) 91 $(hide) chmod 755 $@