19b6ec9471cebdbd68639492825956b96f807e382Ben Gruver# Copyright (C) 2010 The Android Open Source Project
29b6ec9471cebdbd68639492825956b96f807e382Ben Gruver#
39b6ec9471cebdbd68639492825956b96f807e382Ben Gruver# Licensed under the Apache License, Version 2.0 (the "License");
49b6ec9471cebdbd68639492825956b96f807e382Ben Gruver# you may not use this file except in compliance with the License.
59b6ec9471cebdbd68639492825956b96f807e382Ben Gruver# You may obtain a copy of the License at
69b6ec9471cebdbd68639492825956b96f807e382Ben Gruver#
79b6ec9471cebdbd68639492825956b96f807e382Ben Gruver#      http://www.apache.org/licenses/LICENSE-2.0
89b6ec9471cebdbd68639492825956b96f807e382Ben Gruver#
99b6ec9471cebdbd68639492825956b96f807e382Ben Gruver# Unless required by applicable law or agreed to in writing, software
109b6ec9471cebdbd68639492825956b96f807e382Ben Gruver# distributed under the License is distributed on an "AS IS" BASIS,
119b6ec9471cebdbd68639492825956b96f807e382Ben Gruver# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
129b6ec9471cebdbd68639492825956b96f807e382Ben Gruver# See the License for the specific language governing permissions and
139b6ec9471cebdbd68639492825956b96f807e382Ben Gruver# limitations under the License.
149b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
159b6ec9471cebdbd68639492825956b96f807e382Ben GruverLOCAL_PATH := $(call my-dir)
169b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
179b6ec9471cebdbd68639492825956b96f807e382Ben Gruver# build baksmali jar
189b6ec9471cebdbd68639492825956b96f807e382Ben Gruver# ============================================================
199b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
209b6ec9471cebdbd68639492825956b96f807e382Ben Gruverinclude $(CLEAR_VARS)
219b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
22f3d921d1f8eb52f20440a0e43f604a7aae972e94Ben GruverLOCAL_MODULE := baksmalilib
239b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
249b6ec9471cebdbd68639492825956b96f807e382Ben GruverLOCAL_MODULE_TAGS := optional
259b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
269b6ec9471cebdbd68639492825956b96f807e382Ben Gruver#LOCAL_MODULE_CLASS and LOCAL_IS_HOST_MODULE must be defined before calling $(local-intermediates-dir)
279b6ec9471cebdbd68639492825956b96f807e382Ben GruverLOCAL_MODULE_CLASS := JAVA_LIBRARIES
289b6ec9471cebdbd68639492825956b96f807e382Ben GruverLOCAL_IS_HOST_MODULE := true
299b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
309b6ec9471cebdbd68639492825956b96f807e382Ben Gruverintermediates := $(call local-intermediates-dir,COMMON)
319b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
329b6ec9471cebdbd68639492825956b96f807e382Ben GruverLOCAL_SRC_FILES := \
339b6ec9471cebdbd68639492825956b96f807e382Ben Gruver	$(call all-java-files-under, src/main/java) \
349b6ec9471cebdbd68639492825956b96f807e382Ben Gruver	$(call all-java-files-under, ../util/src/main/java)
359b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
369b6ec9471cebdbd68639492825956b96f807e382Ben GruverLOCAL_JAR_MANIFEST := manifest.txt
379b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
389b6ec9471cebdbd68639492825956b96f807e382Ben GruverLOCAL_STATIC_JAVA_LIBRARIES := \
395fd395796e215a80c722815bf180728948868f18Ben Gruver	dexlib2
409b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
41f3d921d1f8eb52f20440a0e43f604a7aae972e94Ben Gruver#read in the version number
421d4637b3d94732a4eaa83b129054ee9245bed24eBen GruverBAKSMALI_VERSION := $(shell cat $(LOCAL_PATH)/../build.gradle | \
431d4637b3d94732a4eaa83b129054ee9245bed24eBen Gruver    grep -o -e "^version = '\(.*\)'" | grep -o -e "[0-9.]\+")
441d4637b3d94732a4eaa83b129054ee9245bed24eBen Gruver
451d4637b3d94732a4eaa83b129054ee9245bed24eBen GruverBAKSMALI_VERSION := $(BAKSMALI_VERSION)-aosp
469b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
479b6ec9471cebdbd68639492825956b96f807e382Ben Gruver#create a new baksmali.properties file using the correct version
489b6ec9471cebdbd68639492825956b96f807e382Ben Gruver$(intermediates)/resources/baksmali.properties:
499b6ec9471cebdbd68639492825956b96f807e382Ben Gruver	$(hide) mkdir -p $(dir $@)
509b6ec9471cebdbd68639492825956b96f807e382Ben Gruver	$(hide) echo "application.version=$(BAKSMALI_VERSION)" > $@
519b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
529b6ec9471cebdbd68639492825956b96f807e382Ben GruverLOCAL_JAVA_RESOURCE_FILES := $(intermediates)/resources/baksmali.properties
539b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
549b6ec9471cebdbd68639492825956b96f807e382Ben Gruverinclude $(BUILD_HOST_JAVA_LIBRARY)
559b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
569b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
579b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
589b6ec9471cebdbd68639492825956b96f807e382Ben Gruver# copy baksmali script
599b6ec9471cebdbd68639492825956b96f807e382Ben Gruver# ============================================================
609b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
619b6ec9471cebdbd68639492825956b96f807e382Ben Gruverinclude $(CLEAR_VARS)
629b6ec9471cebdbd68639492825956b96f807e382Ben GruverLOCAL_IS_HOST_MODULE := true
639b6ec9471cebdbd68639492825956b96f807e382Ben GruverLOCAL_MODULE_CLASS := EXECUTABLES
649b6ec9471cebdbd68639492825956b96f807e382Ben GruverLOCAL_MODULE_TAGS := optional
659b6ec9471cebdbd68639492825956b96f807e382Ben GruverLOCAL_MODULE := baksmali
669b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
679b6ec9471cebdbd68639492825956b96f807e382Ben Gruverinclude $(BUILD_SYSTEM)/base_rules.mk
689b6ec9471cebdbd68639492825956b96f807e382Ben Gruver
69f3d921d1f8eb52f20440a0e43f604a7aae972e94Ben Gruver$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/baksmalilib.jar
709b6ec9471cebdbd68639492825956b96f807e382Ben Gruver$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/../scripts/baksmali | $(ACP)
719b6ec9471cebdbd68639492825956b96f807e382Ben Gruver	@echo "Copy: $(PRIVATE_MODULE) ($@)"
729b6ec9471cebdbd68639492825956b96f807e382Ben Gruver	$(copy-file-to-new-target)
739b6ec9471cebdbd68639492825956b96f807e382Ben Gruver	$(hide) chmod 755 $@