platform_build/core/static_java_library.mk

140 lines
5.1 KiB
Makefile
Raw Normal View History

#
# Copyright (C) 2008 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Standard rules for building a "static" java library.
# Static java libraries are not installed, nor listed on any
# classpaths. They can, however, be included wholesale in
# other java modules.
LOCAL_UNINSTALLABLE_MODULE := true
LOCAL_IS_STATIC_JAVA_LIBRARY := true
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
# Hack to build static Java library with Android resource
# See bug 5714516
all_resources :=
need_compile_res :=
# A static Java library needs to explicily set LOCAL_RESOURCE_DIR.
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
ifdef LOCAL_RESOURCE_DIR
need_compile_res := true
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
all_resources := $(strip \
$(foreach dir, $(LOCAL_RESOURCE_DIR), \
$(addprefix $(dir)/, \
$(patsubst res/%,%, \
$(call find-subdir-assets,$(dir)) \
) \
) \
))
# By default we should remove the R/Manifest classes from a static Java library,
# because they will be regenerated in the app that uses it.
# But if the static Java library will be used by a library, then we may need to
# keep the generated classes with "LOCAL_JAR_EXCLUDE_FILES := none".
ifndef LOCAL_JAR_EXCLUDE_FILES
LOCAL_JAR_EXCLUDE_FILES := $(ANDROID_RESOURCE_GENERATED_CLASSES)
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
endif
ifeq (none,$(LOCAL_JAR_EXCLUDE_FILES))
LOCAL_JAR_EXCLUDE_FILES :=
endif
proguard_options_file :=
intermediates.COMMON := $(call local-intermediates-dir,COMMON)
ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
proguard_options_file := $(intermediates.COMMON)/proguard_options
endif
[DO NOT MERGE] Compile using Jack. This allows to compile dex targeted java sources using Jack and Jill. Default is still to compile with the legacy toolchain. Default can be switched to the new toolchain by setting environement variable: export ANDROID_COMPILE_WITH_JACK=true Toolchain can also be forced for one module by defining LOCAL_JACK_ENABLED:=full # disabled, full, incremental in the mk portion defining the module. Jack execution environement can be controlled with: Global variable ANDROID_JACK_VM allow to change the jvm executing Jack. Global variable ANDROID_JACK_VM_ARGS allows to change default args given to the jvm. Global variable ANDROID_JACK_EXTRA_ARGS allows to define some default args to give to Jack LOCAL_JACK_VM_ARGS allows to override default args given to the jvm for the module. LOCAL_JACK_EXTRA_ARGS allows to override default args passed to Jack. This includes cherry-picks of the following changes: b4c49cba57dafdcdfb693a549c5a1dc1beb71c25 22c3fa6d73adcf14b38c7cf03446d4e2a892f682 138768c1bbb49d549c4b14281fa5f0bffac7d933 5dd3e1d31293aaaae7c0c213743a7ca77d2dd688 83d5d040479e09a3dea6b7f88ca9a57c4ae984ac 8bc90fd2d6ccf70b65d2d3aad22b0453b86a262d 140274707e31c9585aa28b0de2f1418c64ecd272 0fbc9ff2a2eed243aabaa75e911e55c4cf4b8d4c 833b427d72c91c1d1b7f8ac99fb87a6742eb6f43 f9a27f45b49f670c0258c1b6c19056ae85ac1e45 2809666941aceea4af65ec6f9cea8cce1c1392ed 37822c443d3d2ba88dd009c994f088906a0f5568 c6b44d43c38b80a52ed9ade7f9b503685dd129a7 d2a76c14bf60f45a4bf19721a09a10f758c42a66 06744f60fc48d0a33bd538497e77b624adee7d75 95573d5036e3de1ff26d1a9fc9e832c1b0a476a1 b821391614896e6156ffa3e4c2b0f4aef7e80793 2794e7b5824ba1ea5687c7dcaaf7c7062edfa2bb 801f2c44d0a919284c72eca2be708aedb3a79d88 c76d99dca10bd41a30cbfce4699866716a1d4eaf f528e132d60fc8c982e41c242017beb6d4f7df76 76a5e0bd1abc19d9d5664a59b9602bb24e15c259 e25b3984ff5c74aa2a49d14b7df7aa9527096c32 Partially, only Jack related parts werekept ec46a3b71f2746ec209d60ca03f6129d5b129f75 abee3a9f4171a7aaf39c743e7032721b02f43f07 77cbe10fd9c27747f98825f4923a0cfc65b28faf daf07db4cd5d10b706164904a28323e6223b8aa3 b6bfb5893a64dc23dd4dbcbcbe62fe885bd68632 Ie all Jack related changes untill b6bfb5893a64dc23dd4dbcbcbe62fe885bd68632 except a96cc59ab508c1c803c15f4e5f22ab2415b6ac26 "Use Jack by default" Change-Id: If9d47ef1c4fd1e6765ad2a47d816c1ad3cfab0e3
2014-09-08 14:45:14 +02:00
LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS)
[DO NOT MERGE] Compile using Jack. This allows to compile dex targeted java sources using Jack and Jill. Default is still to compile with the legacy toolchain. Default can be switched to the new toolchain by setting environement variable: export ANDROID_COMPILE_WITH_JACK=true Toolchain can also be forced for one module by defining LOCAL_JACK_ENABLED:=full # disabled, full, incremental in the mk portion defining the module. Jack execution environement can be controlled with: Global variable ANDROID_JACK_VM allow to change the jvm executing Jack. Global variable ANDROID_JACK_VM_ARGS allows to change default args given to the jvm. Global variable ANDROID_JACK_EXTRA_ARGS allows to define some default args to give to Jack LOCAL_JACK_VM_ARGS allows to override default args given to the jvm for the module. LOCAL_JACK_EXTRA_ARGS allows to override default args passed to Jack. This includes cherry-picks of the following changes: b4c49cba57dafdcdfb693a549c5a1dc1beb71c25 22c3fa6d73adcf14b38c7cf03446d4e2a892f682 138768c1bbb49d549c4b14281fa5f0bffac7d933 5dd3e1d31293aaaae7c0c213743a7ca77d2dd688 83d5d040479e09a3dea6b7f88ca9a57c4ae984ac 8bc90fd2d6ccf70b65d2d3aad22b0453b86a262d 140274707e31c9585aa28b0de2f1418c64ecd272 0fbc9ff2a2eed243aabaa75e911e55c4cf4b8d4c 833b427d72c91c1d1b7f8ac99fb87a6742eb6f43 f9a27f45b49f670c0258c1b6c19056ae85ac1e45 2809666941aceea4af65ec6f9cea8cce1c1392ed 37822c443d3d2ba88dd009c994f088906a0f5568 c6b44d43c38b80a52ed9ade7f9b503685dd129a7 d2a76c14bf60f45a4bf19721a09a10f758c42a66 06744f60fc48d0a33bd538497e77b624adee7d75 95573d5036e3de1ff26d1a9fc9e832c1b0a476a1 b821391614896e6156ffa3e4c2b0f4aef7e80793 2794e7b5824ba1ea5687c7dcaaf7c7062edfa2bb 801f2c44d0a919284c72eca2be708aedb3a79d88 c76d99dca10bd41a30cbfce4699866716a1d4eaf f528e132d60fc8c982e41c242017beb6d4f7df76 76a5e0bd1abc19d9d5664a59b9602bb24e15c259 e25b3984ff5c74aa2a49d14b7df7aa9527096c32 Partially, only Jack related parts werekept ec46a3b71f2746ec209d60ca03f6129d5b129f75 abee3a9f4171a7aaf39c743e7032721b02f43f07 77cbe10fd9c27747f98825f4923a0cfc65b28faf daf07db4cd5d10b706164904a28323e6223b8aa3 b6bfb5893a64dc23dd4dbcbcbe62fe885bd68632 Ie all Jack related changes untill b6bfb5893a64dc23dd4dbcbcbe62fe885bd68632 except a96cc59ab508c1c803c15f4e5f22ab2415b6ac26 "Use Jack by default" Change-Id: If9d47ef1c4fd1e6765ad2a47d816c1ad3cfab0e3
2014-09-08 14:45:14 +02:00
#################################
include $(BUILD_SYSTEM)/configure_local_jack.mk
#################################
ifdef LOCAL_JACK_ENABLED
ifndef LOCAL_JACK_PROGUARD_FLAGS
LOCAL_JACK_PROGUARD_FLAGS := $(LOCAL_PROGUARD_FLAGS)
endif
LOCAL_JACK_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_JACK_PROGUARD_FLAGS)
endif # LOCAL_JACK_ENABLED
endif # LOCAL_RESOURCE_DIR
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
all_res_assets := $(all_resources)
include $(BUILD_SYSTEM)/java_library.mk
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
ifeq (true,$(need_compile_res))
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
R_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.stamp
include $(BUILD_SYSTEM)/android_manifest.mk
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
ifeq ($(LOCAL_SDK_RES_VERSION),)
LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
endif
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
framework_res_package_export :=
framework_res_package_export_deps :=
# Please refer to package.mk
ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
ifneq ($(filter-out current system_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current system_current,$(LOCAL_SDK_RES_VERSION))),)
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
framework_res_package_export := \
$(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar
framework_res_package_export_deps := $(framework_res_package_export)
else
framework_res_package_export := \
$(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
framework_res_package_export_deps := \
$(dir $(framework_res_package_export))src/R.stamp
endif
endif
$(R_file_stamp): PRIVATE_MODULE := $(LOCAL_MODULE)
# add --non-constant-id to prevent inlining constants.
$(R_file_stamp): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id
$(R_file_stamp): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR)
$(R_file_stamp): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
$(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := $(intermediates.COMMON)/public_resources.xml
$(R_file_stamp): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
$(R_file_stamp): PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)
ifneq (,$(filter-out current system_current, $(LOCAL_SDK_VERSION)))
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
$(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
else
$(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
endif
$(R_file_stamp): PRIVATE_ASSET_DIR :=
$(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
$(R_file_stamp): PRIVATE_MANIFEST_PACKAGE_NAME :=
$(R_file_stamp): PRIVATE_MANIFEST_INSTRUMENTATION_FOR :=
$(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export_deps)
@echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)"
$(create-resource-java-files)
$(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@
$(LOCAL_BUILT_MODULE): $(R_file_stamp)
[DO NOT MERGE] Compile using Jack. This allows to compile dex targeted java sources using Jack and Jill. Default is still to compile with the legacy toolchain. Default can be switched to the new toolchain by setting environement variable: export ANDROID_COMPILE_WITH_JACK=true Toolchain can also be forced for one module by defining LOCAL_JACK_ENABLED:=full # disabled, full, incremental in the mk portion defining the module. Jack execution environement can be controlled with: Global variable ANDROID_JACK_VM allow to change the jvm executing Jack. Global variable ANDROID_JACK_VM_ARGS allows to change default args given to the jvm. Global variable ANDROID_JACK_EXTRA_ARGS allows to define some default args to give to Jack LOCAL_JACK_VM_ARGS allows to override default args given to the jvm for the module. LOCAL_JACK_EXTRA_ARGS allows to override default args passed to Jack. This includes cherry-picks of the following changes: b4c49cba57dafdcdfb693a549c5a1dc1beb71c25 22c3fa6d73adcf14b38c7cf03446d4e2a892f682 138768c1bbb49d549c4b14281fa5f0bffac7d933 5dd3e1d31293aaaae7c0c213743a7ca77d2dd688 83d5d040479e09a3dea6b7f88ca9a57c4ae984ac 8bc90fd2d6ccf70b65d2d3aad22b0453b86a262d 140274707e31c9585aa28b0de2f1418c64ecd272 0fbc9ff2a2eed243aabaa75e911e55c4cf4b8d4c 833b427d72c91c1d1b7f8ac99fb87a6742eb6f43 f9a27f45b49f670c0258c1b6c19056ae85ac1e45 2809666941aceea4af65ec6f9cea8cce1c1392ed 37822c443d3d2ba88dd009c994f088906a0f5568 c6b44d43c38b80a52ed9ade7f9b503685dd129a7 d2a76c14bf60f45a4bf19721a09a10f758c42a66 06744f60fc48d0a33bd538497e77b624adee7d75 95573d5036e3de1ff26d1a9fc9e832c1b0a476a1 b821391614896e6156ffa3e4c2b0f4aef7e80793 2794e7b5824ba1ea5687c7dcaaf7c7062edfa2bb 801f2c44d0a919284c72eca2be708aedb3a79d88 c76d99dca10bd41a30cbfce4699866716a1d4eaf f528e132d60fc8c982e41c242017beb6d4f7df76 76a5e0bd1abc19d9d5664a59b9602bb24e15c259 e25b3984ff5c74aa2a49d14b7df7aa9527096c32 Partially, only Jack related parts werekept ec46a3b71f2746ec209d60ca03f6129d5b129f75 abee3a9f4171a7aaf39c743e7032721b02f43f07 77cbe10fd9c27747f98825f4923a0cfc65b28faf daf07db4cd5d10b706164904a28323e6223b8aa3 b6bfb5893a64dc23dd4dbcbcbe62fe885bd68632 Ie all Jack related changes untill b6bfb5893a64dc23dd4dbcbcbe62fe885bd68632 except a96cc59ab508c1c803c15f4e5f22ab2415b6ac26 "Use Jack by default" Change-Id: If9d47ef1c4fd1e6765ad2a47d816c1ad3cfab0e3
2014-09-08 14:45:14 +02:00
ifdef LOCAL_JACK_ENABLED
$(noshrob_classes_jack): $(R_file_stamp)
$(full_classes_jack): $(R_file_stamp)
endif # LOCAL_JACK_ENABLED
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
$(full_classes_compiled_jar): $(R_file_stamp)
endif # need_compile_res
Support to build static Java library with Android resource Bug: 5714516 The rationale behind this change: - the library is compiled into a jar file, but its R class is generated making the constant not constant (static, not final static) (aapt option --non-constant-id). Also the jar file does not contain the R class. - this allows the integer value to not be inlined in the compiled class files. Note that this prevents using switch statements. - the main project use this jar file as a normal static library: it will add all the class files except the R.class. - the main project uses the library res folder as a resource folder with lower priority than the main project (basically the main project is an overlay. This is accomplished using aapt's --auto-add-overlay to handle resources only in the main project (which the normal overlay mechanism doesn't allow). - the main project creates R classes in the main project's package but also in the library's package. This is done with aapt's --extra-packages which accept as many packages as needed, separated by a :. - manifest merging is not done yet, so activities/services/permissions/etc... have to be manually declared in the main app. To use a static library with Android resource in your app, 1. Add the library's resource dir to your app as an overlay: LOCAL_RESOURCE_DIR := <app_resource_dir> <static_library_resource_dirs> 2. Set the proper aapt flags: LOCAL_AAPT_FLAGS := <apps_own_flags> --auto-add-overlay \ --extra-packages <lib1_package_name>:<lib2_package_name>:... Change-Id: Ifb4d2300b952ea4aaee74da1bb0c6c72ea0698a3
2011-12-14 23:29:28 +01:00
# Reset internal variables.
all_res_assets :=
LOCAL_IS_STATIC_JAVA_LIBRARY :=