diff options
29 files changed, 466 insertions, 295 deletions
diff --git a/core/base_rules.mk b/core/base_rules.mk index 87ef414bd0..72278ce298 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -34,14 +34,27 @@ ifdef LOCAL_IS_HOST_MODULE ifneq ($(LOCAL_IS_HOST_MODULE),true) $(error $(LOCAL_PATH): LOCAL_IS_HOST_MODULE must be "true" or empty, not "$(LOCAL_IS_HOST_MODULE)") endif - my_prefix := HOST_ + ifeq ($(LOCAL_HOST_PREFIX),) + my_prefix := HOST_ + else + my_prefix := $(LOCAL_HOST_PREFIX) + endif my_host := host- else my_prefix := TARGET_ my_host := endif +ifeq ($(my_prefix),HOST_CROSS_) + my_host_cross := true +else + my_host_cross := +endif + my_module_tags := $(LOCAL_MODULE_TAGS) +ifeq ($(my_host_cross),true) + my_module_tags := +endif ########################################################### ## Validate and define fallbacks for input LOCAL_* variables. @@ -150,15 +163,18 @@ ifndef LOCAL_NO_2ND_ARCH_MODULE_SUFFIX my_register_name := $(LOCAL_MODULE)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX) endif endif +ifeq ($(my_host_cross),true) + my_register_name := host_cross_$(LOCAL_MODULE) +endif # Make sure that this IS_HOST/CLASS/MODULE combination is unique. module_id := MODULE.$(if \ - $(LOCAL_IS_HOST_MODULE),HOST,TARGET).$(LOCAL_MODULE_CLASS).$(my_register_name) + $(LOCAL_IS_HOST_MODULE),$($(my_prefix)OS),TARGET).$(LOCAL_MODULE_CLASS).$(my_register_name) ifdef $(module_id) $(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id))) endif $(module_id) := $(LOCAL_PATH) -intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX)) +intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross)) intermediates.COMMON := $(call local-intermediates-dir,COMMON) generated_sources_dir := $(call local-generated-sources-dir) @@ -225,6 +241,8 @@ $(cleantarget):: $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH) $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE) $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host) +$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PREFIX := $(my_prefix) + $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates) $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX) @@ -358,6 +376,7 @@ endif ifdef LOCAL_2ND_ARCH_VAR_PREFIX ALL_MODULES.$(my_register_name).FOR_2ND_ARCH := true endif +ALL_MODULES.$(my_register_name).FOR_HOST_CROSS := $(my_host_cross) INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name) diff --git a/core/binary.mk b/core/binary.mk index cb045cc8f1..4bf31ad50c 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -145,7 +145,7 @@ endif # MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because # all code is position independent, and then those warnings get promoted to # errors. -ifndef USE_MINGW +ifneq ($($(my_prefix)OS),windows) ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) my_cflags += -fpie else @@ -186,11 +186,20 @@ endif # clang is enabled by default for host builds # enable it unless we've specifically disabled clang above ifdef LOCAL_IS_HOST_MODULE - ifneq ($(HOST_OS),windows) + ifneq ($($(my_prefix)OS),windows) ifeq ($(my_clang),) my_clang := true endif endif +# Add option to make clang the default for device build +else ifeq ($(USE_CLANG_PLATFORM_BUILD),true) + ifeq ($(my_clang),) + my_clang := true + endif +endif + +ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true) + my_clang := endif my_cpp_std_version := -std=gnu++14 @@ -209,12 +218,6 @@ endif my_cppflags := $(my_cpp_std_version) $(my_cppflags) -# Add option to make clang the default for device build -ifeq ($(USE_CLANG_PLATFORM_BUILD),true) - ifeq ($(my_clang),) - my_clang := true - endif -endif # arch-specific static libraries go first so that generic ones can depend on them my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries) @@ -235,10 +238,6 @@ my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LINKER) include $(BUILD_SYSTEM)/config_sanitizers.mk -ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true) - my_clang := -endif - # Add in libcompiler_rt for all regular device builds ifeq (,$(LOCAL_SDK_VERSION)$(WITHOUT_LIBCOMPILER_RT)) my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES) @@ -307,17 +306,17 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_glob else # LOCAL_IS_HOST_MODULE ifeq ($(my_clang),true) -my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS) -my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CONLYFLAGS) -my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS) -my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS) -my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES) +my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS) +my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) +my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) +my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS) +my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES) else -my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS) -my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CONLYFLAGS) -my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS) -my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS) -my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES) +my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS) +my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) +my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS) +my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS) +my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES) endif # my_clang $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes) @@ -618,13 +617,13 @@ else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c) my_static_libraries += libprotobuf-c-nano else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full) ifdef LOCAL_SDK_VERSION - my_static_libraries += libprotobuf-cpp-full + my_static_libraries += libprotobuf-cpp-full-ndk else my_shared_libraries += libprotobuf-cpp-full endif else ifdef LOCAL_SDK_VERSION - my_static_libraries += libprotobuf-cpp-lite + my_static_libraries += libprotobuf-cpp-lite-ndk else my_shared_libraries += libprotobuf-cpp-lite endif @@ -1015,9 +1014,9 @@ endif import_includes := $(intermediates)/import_includes import_includes_deps := $(strip \ $(foreach l, $(installed_shared_library_module_names), \ - $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes) \ + $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes) \ $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \ - $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes)) + $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) $(import_includes): PRIVATE_IMPORT_EXPORT_INCLUDES := $(import_includes_deps) $(import_includes) : $(LOCAL_MODULE_MAKEFILE) $(import_includes_deps) @echo Import includes file: $@ @@ -1122,7 +1121,7 @@ endif built_static_libraries := \ $(foreach lib,$(my_static_libraries), \ $(call intermediates-dir-for, \ - STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix)) + STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix)) ifdef LOCAL_SDK_VERSION built_static_libraries += $(my_ndk_stl_static_lib) @@ -1131,7 +1130,7 @@ endif built_whole_libraries := \ $(foreach lib,$(my_whole_static_libraries), \ $(call intermediates-dir-for, \ - STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix)) + STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix)) # We don't care about installed static libraries, since the # libraries have already been linked into the module at that point. diff --git a/core/build-system.html b/core/build-system.html index caade583b7..3f638c3b07 100644 --- a/core/build-system.html +++ b/core/build-system.html @@ -462,26 +462,17 @@ LOCAL_GENERATED_SOURCES += $(GEN) <p>Sometimes you need to set flags specifically for different platforms. Here is a list of which values the different build-system defined variables will be set to and some examples.</p> -<p>For a device build, <code>TARGET_OS</code> is <code>linux</code> (we're using -linux!), and <code>TARGET_ARCH</code> is <code>arm</code>.</p> -<p>For a simulator build, <code>TARGET_OS</code> and <code>TARGET_ARCH</code> -are set to the same as <code>HOST_OS</code> and <code>HOST_ARCH</code> are -on your platform. <code>TARGET_PRODUCT</code> is the name of the target -hardware/product you are building for. The value <code>sim</code> is used -for the simulator. We haven't thought through the full extent of customization -that will happen here, but likely there will be additional UI configurations -specified here as well.</p> <table cellspacing=25> <tr> <td valign=top align=center> <b>HOST_OS</b><br/> linux<br/> - darwin<br/> - (cygwin) + darwin </td> <td valign=top align=center> <b>HOST_ARCH</b><br/> - x86 + x86<br/> + x86_64 </td> <td valign=top align=center> <b>HOST_BUILD_TYPE</b><br/> @@ -491,42 +482,40 @@ specified here as well.</p> </tr> <tr> <td valign=top align=center> - <b>TARGET_OS</b><br/> - linux<br/> - darwin<br/> - (cygwin) - </td> - <td valign=top align=center> <b>TARGET_ARCH</b><br/> arm<br/> - x86 + arm64<br/> + mips<br/> + mips64<br/> + x86<br/> + x86_64 </td> <td valign=top align=center> <b>TARGET_BUILD_TYPE</b><br/> release<br/> debug </td> - <td valign=top align=center> - <b>TARGET_PRODUCT</b><br/> - sim<br/> - dream<br/> - sooner - </td> </tr> </table> +<p>There are also special variables to use instead of conditionals. Many of the +normal variables (LOCAL_SRC_FILES, LOCAL_CFLAGS, etc) can be conditionally added +to with _{arch} _{32|64}, and for the host, _{os}.</p> + <h4>Some Examples</h4> <pre>ifeq ($(TARGET_BUILD_TYPE),release) LOCAL_CFLAGS += -DNDEBUG=1 endif +LOCAL_CFLAGS_arm += -DTARGET_IS_ARM + +LOCAL_CFLAGS_64 += -DBIG_POINTER + # from libutils -ifeq ($(TARGET_OS),linux) # Use the futex based mutex and condition variable # implementation from android-arm because it's shared mem safe -LOCAL_SRC_FILES += futex_synchro.c -LOCAL_LDLIBS += -lrt -ldl -endif +LOCAL_SRC_FILES_linux += futex_synchro.c +LOCAL_LDLIBS_linux += -lrt -ldl </pre> @@ -554,7 +543,7 @@ LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED) the unstripped executables so GDB can find the symbols. <code>LOCAL_UNSTRIPPED_PATH</code> is not necessary if you only specified <code>LOCAL_MODULE_RELATIVE_PATH</code>.</p> -<p>Look in <code>config/envsetup.make</code> for all of the variables defining +<p>Look in <code>core/envsetup.mk</code> for all of the variables defining places to build things.</p> <p>FYI: If you're installing an executable to /sbin, you probably also want to set <code>LOCAL_FORCE_STATIC_EXCUTABLE := true</code> in your Android.mk, which @@ -587,6 +576,11 @@ alphabetically.</p> and definitions that are specific to either the host or the target builds. Do not set variables that start with HOST_ or TARGET_ in your makefiles. </li> + <li><b>HOST_CROSS_</b> - These contain the directories and definitions that + are specific to cross-building host binaries. The common case is building + windows host tools on linux. Do not set variables that start with + HOST_CROSS_ in your makefiles. + </li> <li><b>BUILD_</b> and <b>CLEAR_VARS</b> - These contain the names of well-defined template makefiles to include. Some examples are CLEAR_VARS and BUILD_HOST_PACKAGE.</li> @@ -773,13 +767,13 @@ LOCAL_POST_PROCESS_COMMAND := /Developer/Tools/Rez -d __DARWIN__ -t APPL\<br/> </code></p> <h4>LOCAL_PREBUILT_EXECUTABLES</h4> -<p>When including $(BUILD_PREBUILT) or $(BUILD_HOST_PREBUILT), set these to -executables that you want copied. They're located automatically into the +<p>When including $(BUILD_MULTI_PREBUILT) or $(BUILD_HOST_PREBUILT), set these +to executables that you want copied. They're located automatically into the right bin directory.</p> <h4>LOCAL_PREBUILT_LIBS</h4> -<p>When including $(BUILD_PREBUILT) or $(BUILD_HOST_PREBUILT), set these to -libraries that you want copied. They're located automatically into the +<p>When including $(BUILD_MULTI_PREBUILT) or $(BUILD_HOST_PREBUILT), set these +to libraries that you want copied. They're located automatically into the right lib directory.</p> <h4>LOCAL_SHARED_LIBRARIES</h4> @@ -836,6 +830,16 @@ set <code>LOCAL_UNSTRIPPED_PATH</code>, the unstripped binaries will also use the relative path.</p> <p>See <a href="#moving-modules">Putting modules elsewhere</a> for more.</p> +<h4>LOCAL_MODULE_HOST_OS</h4> +<p>This specifies which OSes are supported by this host module. It is not used +for target builds. The accepted values here are combinations of +<code>linux</code>, <code>darwin</code>, and <code>windows</code>. By default, +linux and darwin(MacOS) are considered to be supported. If a module should +build under windows, you must specify windows, and any others to be supported. +Some examples:</p> +<p><code>LOCAL_MODULE_HOST_OS := linux<br/> +LOCAL_MODULE_HOST_OS := darwin linux windows</code></p> + <h4>LOCAL_UNSTRIPPED_PATH</h4> <p>Instructs the build system to put the unstripped version of the module somewhere other than what's normal for its type. Usually, you override this @@ -878,10 +882,10 @@ system expects, it fails printing an error message explaining what happened. If you make a change that requires an update, you need to update two places so this message will be printed. <ul> - <li>In config/envsetup.make, increment the + <li>In core/envsetup.mk, increment the CORRECT_BUILD_ENV_SEQUENCE_NUMBER definition.</li> <li>In buildspec.mk.default, update the BUILD_ENV_SEQUENCE_DUMBER - definition to match the one in config/envsetup.make</li> + definition to match the one in core/envsetup.mk</li> </ul> The scripts automatically get the value from the build system, so they will trigger the warning as well. @@ -900,53 +904,39 @@ isn't actually built in to it, you can add those make targets to for some other dependency that isn't created automatically.</p> <h4>LOCAL_BUILT_MODULE</h4> +<p class=warning>This should not be used, since multiple binaries are now +created from a single module defintiion.</p> <p>When a module is built, the module is created in an intermediate directory then copied to its final location. LOCAL_BUILT_MODULE is the full path to the intermediate file. See LOCAL_INSTALLED_MODULE for the path to the final installed location of the module.</p> -<h4>LOCAL_HOST</h4> -<p>Set by the host_xxx.make includes to tell base_rules.make and the other -includes that we're building for the host. Kenneth did this as part of -openbinder, and I would like to clean it up so the rules, includes and -definitions aren't duplicated for host and target.</p> +<h4>LOCAL_IS_HOST_MODULE</h4> +<p>Set by the host_xxx.mk includes to tell base_rules.mk and the other +includes that we're building for the host.</p> <h4>LOCAL_INSTALLED_MODULE</h4> +<p class=warning>This should not be used, since multiple binaries are now +created from a single module defintiion.</p> <p>The fully qualified path name of the final location of the module. See LOCAL_BUILT_MODULE for the location of the intermediate file that the make rules should actually be constructing.</p> -<h4>LOCAL_REPLACE_VARS</h4> -<p>Used in some stuff remaining from the openbinder for building scripts -with particular values set,</p> - -<h4>LOCAL_SCRIPTS</h4> -<p>Used in some stuff remaining from the openbinder build system that we -might find handy some day.</p> - <h4>LOCAL_MODULE_CLASS</h4> <p>Which kind of module this is. This variable is used to construct other -variable names used to locate the modules. See base_rules.make and -envsetup.make.</p> - -<h4>LOCAL_MODULE_NAME</h4> -<p>Set to the leaf name of the LOCAL_BUILT_MODULE. I'm not sure, -but it looks like it's just used in the WHO_AM_I variable to identify -in the pretty printing what's being built.</p> +variable names used to locate the modules. See base_rules.mk and +envsetup.mk.</p> <h4>LOCAL_MODULE_SUFFIX</h4> <p>The suffix that will be appended to <code>LOCAL_MODULE</code> to form <code>LOCAL_MODULE_NAME</code>. For example, .so, .a, .dylib.</p> <h4>LOCAL_STRIP_MODULE</h4> -<p>Calculated in base_rules.make to determine if this module should actually -be stripped or not, based on whether <code>LOCAL_STRIPPABLE_MODULE</code> -is set, and whether the combo is configured to ever strip modules. With -Iliyan's stripping tool, this might change.</p> - -<h4>LOCAL_STRIPPABLE_MODULE</h4> -<p>Set by the include makefiles if that type of module is strippable. -Executables and shared libraries are.</p> +<p>If set to true (the default), the binary will be stripped and a debug +link will be set up so that GDB will still work. If set to no_debuglink, +the binary will be stripped, but no debug link will be added. If set to +keep_symbols, it will strip the debug information, but keep the symbol table. +Any other value will prevent stripping.</p> <h4>LOCAL_SYSTEM_SHARED_LIBRARIES</h4> <p>Used while building the base libraries: libc, libm, libdl. Usually diff --git a/core/ccache.mk b/core/ccache.mk index 34e5e1c382..c99d933e68 100644 --- a/core/ccache.mk +++ b/core/ccache.mk @@ -37,11 +37,6 @@ ifneq ($(USE_CCACHE),) export CCACHE_CPP2 := true CCACHE_HOST_TAG := $(HOST_PREBUILT_TAG) - # If we are cross-compiling Windows binaries on Linux - # then use the linux ccache binary instead. - ifeq ($(HOST_OS)-$(BUILD_OS),windows-linux) - CCACHE_HOST_TAG := linux-$(HOST_PREBUILT_ARCH) - endif ccache := prebuilts/misc/$(CCACHE_HOST_TAG)/ccache/ccache # Check that the executable is here. ccache := $(strip $(wildcard $(ccache))) diff --git a/core/clang/HOST_CROSS_windows.mk b/core/clang/HOST_CROSS_windows.mk new file mode 100644 index 0000000000..74adb58422 --- /dev/null +++ b/core/clang/HOST_CROSS_windows.mk @@ -0,0 +1,56 @@ + +include $(BUILD_SYSTEM)/clang/x86.mk + +CLANG_CONFIG_x86_HOST_CROSS_TRIPLE := i686-pc-mingw32 + +CLANG_CONFIG_x86_HOST_CROSS_EXTRA_ASFLAGS := \ + $(CLANG_CONFIG_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_ASFLAGS) \ + -target $(CLANG_CONFIG_x86_HOST_CROSS_TRIPLE) + +CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CFLAGS := \ + $(CLANG_CONFIG_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_ASFLAGS) + +CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CONLYFLAGS := \ + $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_CONLYFLAGS) + +CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CPPFLAGS := \ + $(CLANG_CONFIG_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_CPPFLAGS) \ + -target $(CLANG_CONFIG_x86_HOST_CROSS_TRIPLE) + +CLANG_CONFIG_x86_HOST_CROSS_EXTRA_LDFLAGS := \ + $(CLANG_CONFIG_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_LDFLAGS) \ + -target $(CLANG_CONFIG_x86_HOST_CROSS_TRIPLE) + +CLANG_HOST_CROSS_GLOBAL_CFLAGS := \ + $(call convert-to-host-clang-flags,$(HOST_CROSS_GLOBAL_CFLAGS)) \ + $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CFLAGS) + +CLANG_HOST_CROSS_GLOBAL_CONLYFLAGS := \ + $(call convert-to-host-clang-flags,$(HOST_CROSS_GLOBAL_CONLYFLAGS)) \ + $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CONLYFLAGS) + +CLANG_HOST_CROSS_GLOBAL_CPPFLAGS := \ + $(call convert-to-host-clang-flags,$(HOST_CROSS_GLOBAL_CPPFLAGS)) \ + $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CPPFLAGS) + +CLANG_HOST_CROSS_GLOBAL_LDFLAGS := \ + $(call convert-to-host-clang-flags,$(HOST_CROSS_GLOBAL_LDFLAGS)) \ + $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_LDFLAGS) + +HOST_CROSS_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-i686.a diff --git a/core/clang/HOST_x86.mk b/core/clang/HOST_x86.mk index f14a9c32fb..0ec64adbaf 100644 --- a/core/clang/HOST_x86.mk +++ b/core/clang/HOST_x86.mk @@ -16,9 +16,6 @@ CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CPPFLAGS) CLANG_CONFIG_x86_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_LDFLAGS) endif -ifeq ($(HOST_OS),windows) -CLANG_CONFIG_x86_HOST_TRIPLE := i686-pc-mingw32 -endif CLANG_CONFIG_x86_HOST_EXTRA_ASFLAGS := \ $(CLANG_CONFIG_EXTRA_ASFLAGS) \ diff --git a/core/clang/HOST_x86_64.mk b/core/clang/HOST_x86_64.mk index 1211e73819..d46cb67e43 100644 --- a/core/clang/HOST_x86_64.mk +++ b/core/clang/HOST_x86_64.mk @@ -16,9 +16,6 @@ CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EX CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CPPFLAGS) CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_LDFLAGS) endif -ifeq ($(HOST_OS),windows) -CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-pc-mingw64 -endif CLANG_CONFIG_x86_64_HOST_EXTRA_ASFLAGS := \ $(CLANG_CONFIG_EXTRA_ASFLAGS) \ diff --git a/core/clang/HOST_x86_common.mk b/core/clang/HOST_x86_common.mk index 74b5a69b14..fc98dd5835 100644 --- a/core/clang/HOST_x86_common.mk +++ b/core/clang/HOST_x86_common.mk @@ -48,7 +48,3 @@ CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS := \ -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/lib32/ endif endif # Linux - -ifeq ($(HOST_OS),windows) -# nothing required here yet -endif diff --git a/core/clang/config.mk b/core/clang/config.mk index 910c1a43fc..03d773054b 100644 --- a/core/clang/config.mk +++ b/core/clang/config.mk @@ -84,6 +84,12 @@ CLANG_CONFIG_HOST_EXTRA_CFLAGS := CLANG_CONFIG_HOST_EXTRA_CPPFLAGS := CLANG_CONFIG_HOST_EXTRA_LDFLAGS := +# Clang flags for all host cross rules +CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS := +CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS := +CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS := +CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS := + # Clang flags for all target rules CLANG_CONFIG_TARGET_EXTRA_ASFLAGS := CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc @@ -126,6 +132,10 @@ clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX) include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk endif +ifdef HOST_CROSS_OS +include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_OS).mk +endif + # TARGET config clang_2nd_arch_prefix := include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk diff --git a/core/clear_vars.mk b/core/clear_vars.mk index e2f14443bd..d0d4ff9e33 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -173,6 +173,13 @@ LOCAL_MODULE_TARGET_ARCH_WARN:= LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH:= LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH_WARN:= LOCAL_MODULE_HOST_ARCH:= +LOCAL_MODULE_HOST_ARCH_WARN:= +LOCAL_MODULE_UNSUPPORTED_HOST_ARCH:= +LOCAL_MODULE_UNSUPPORTED_HOST_ARCH_WARN:= +LOCAL_MODULE_HOST_CROSS_ARCH:= +LOCAL_MODULE_HOST_CROSS_ARCH_WARN:= +LOCAL_MODULE_UNSUPPORTED_HOST_CROSS_ARCH:= +LOCAL_MODULE_UNSUPPORTED_HOST_CROSS_ARCH_WARN:= LOCAL_NO_FPIE := LOCAL_CXX_STL := default LOCAL_NATIVE_COVERAGE := @@ -268,10 +275,27 @@ LOCAL_C_INCLUDES_$(HOST_OS):= LOCAL_GENERATED_SOURCES_$(HOST_OS):= LOCAL_REQUIRED_MODULES_$(HOST_OS):= +ifdef HOST_CROSS_OS +LOCAL_SRC_FILES_$(HOST_CROSS_OS):= +LOCAL_STATIC_LIBRARIES_$(HOST_CROSS_OS):= +LOCAL_SHARED_LIBRARIES_$(HOST_CROSS_OS):= +LOCAL_CFLAGS_$(HOST_CROSS_OS):= +LOCAL_CPPFLAGS_$(HOST_CROSS_OS):= +LOCAL_LDFLAGS_$(HOST_CROSS_OS):= +LOCAL_LDLIBS_$(HOST_CROSS_OS):= +LOCAL_ASFLAGS_$(HOST_CROSS_OS):= +LOCAL_C_INCLUDES_$(HOST_CROSS_OS):= +LOCAL_GENERATED_SOURCES_$(HOST_CROSS_OS):= +LOCAL_REQUIRED_MODULES_$(HOST_CROSS_OS):= +endif + LOCAL_SRC_FILES_$(HOST_OS)_$(HOST_ARCH):= ifdef HOST_2ND_ARCH LOCAL_SRC_FILES_$(HOST_OS)_$(HOST_2ND_ARCH):= endif +ifdef HOST_CROSS_OS +LOCAL_SRC_FILES_$(HOST_CROSS_OS)_$(HOST_CROSS_ARCH):= +endif LOCAL_SRC_FILES_32:= LOCAL_SRC_FILES_64:= diff --git a/core/combo/HOST_CROSS_windows-x86.mk b/core/combo/HOST_CROSS_windows-x86.mk new file mode 100644 index 0000000000..f5095949d8 --- /dev/null +++ b/core/combo/HOST_CROSS_windows-x86.mk @@ -0,0 +1,55 @@ +# +# Copyright (C) 2006 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. +# + +# Settings to use MinGW as a cross-compiler under Linux +# Included by combo/select.make + +$(combo_var_prefix)GLOBAL_CFLAGS += -DUSE_MINGW -DWIN32_LEAN_AND_MEAN +$(combo_var_prefix)GLOBAL_CFLAGS += -Wno-unused-parameter +$(combo_var_prefix)GLOBAL_CFLAGS += --sysroot=prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32 +$(combo_var_prefix)GLOBAL_CFLAGS += -m32 +$(combo_var_prefix)GLOBAL_LDFLAGS += -m32 +TOOLS_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/bin/x86_64-w64-mingw32- +$(combo_var_prefix)C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/include +$(combo_var_prefix)C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/lib/gcc/x86_64-w64-mingw32/4.8.3/include +$(combo_var_prefix)GLOBAL_LD_DIRS += -Lprebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/lib32 + +# Workaround differences in inttypes.h between host and target. +# See bug 12708004. +$(combo_var_prefix)GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS +# Use C99-compliant printf functions (%zd). +$(combo_var_prefix)GLOBAL_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 +# Admit to using >= Win2K. +$(combo_var_prefix)GLOBAL_CFLAGS += -D_WIN32_WINNT=0x0500 +# Get 64-bit off_t and related functions. +$(combo_var_prefix)GLOBAL_CFLAGS += -D_FILE_OFFSET_BITS=64 + +$(combo_var_prefix)CC := $(TOOLS_PREFIX)gcc +$(combo_var_prefix)CXX := $(TOOLS_PREFIX)g++ +$(combo_var_prefix)AR := $(TOOLS_PREFIX)ar + +$(combo_var_prefix)GLOBAL_LDFLAGS += \ + --enable-stdcall-fixup + +ifneq ($(strip $(BUILD_HOST_static)),) +# Statically-linked binaries are desirable for sandboxed environment +$(combo_var_prefix)GLOBAL_LDFLAGS += -static +endif # BUILD_HOST_static + +$(combo_var_prefix)SHLIB_SUFFIX := .dll +$(combo_var_prefix)EXECUTABLE_SUFFIX := .exe + +$(combo_var_prefix)IS_64_BIT := diff --git a/core/combo/HOST_windows-x86.mk b/core/combo/HOST_windows-x86.mk deleted file mode 100644 index 30c1c755da..0000000000 --- a/core/combo/HOST_windows-x86.mk +++ /dev/null @@ -1,62 +0,0 @@ -# -# Copyright (C) 2006 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. -# - -# Settings to use MinGW as a cross-compiler under Linux -# Included by combo/select.make - -HOST_ACP_UNAVAILABLE := true -$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -DUSE_MINGW -DWIN32_LEAN_AND_MEAN -$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -Wno-unused-parameter -$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += --sysroot=prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32 -$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -m32 -$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -m32 -TOOLS_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/bin/x86_64-w64-mingw32- -$(combo_2nd_arch_prefix)HOST_C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/include -$(combo_2nd_arch_prefix)HOST_C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/lib/gcc/x86_64-w64-mingw32/4.8.3/include -$(combo_2nd_arch_prefix)HOST_GLOBAL_LD_DIRS += -Lprebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/lib32 - -# Workaround differences in inttypes.h between host and target. -# See bug 12708004. -$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -# Use C99-compliant printf functions (%zd). -$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 -# Admit to using >= Win2K. -$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D_WIN32_WINNT=0x0500 -# Get 64-bit off_t and related functions. -$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D_FILE_OFFSET_BITS=64 - -$(combo_2nd_arch_prefix)HOST_CC := $(TOOLS_PREFIX)gcc$(TOOLS_EXE_SUFFIX) -$(combo_2nd_arch_prefix)HOST_CXX := $(TOOLS_PREFIX)g++$(TOOLS_EXE_SUFFIX) -$(combo_2nd_arch_prefix)HOST_AR := $(TOOLS_PREFIX)ar$(TOOLS_EXE_SUFFIX) - -$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += \ - --enable-stdcall-fixup - -ifneq ($(strip $(BUILD_HOST_static)),) -# Statically-linked binaries are desirable for sandboxed environment -$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -static -endif # BUILD_HOST_static - -############################################################ -## Macros after this line are shared by the 64-bit config. - -HOST_SHLIB_SUFFIX := .dll -HOST_EXECUTABLE_SUFFIX := .exe - -# $(1): The file to check -define get-file-size -stat --format "%s" "$(1)" | tr -d '\n' -endef diff --git a/core/combo/HOST_windows-x86_64.mk b/core/combo/HOST_windows-x86_64.mk deleted file mode 100644 index 49b74e2599..0000000000 --- a/core/combo/HOST_windows-x86_64.mk +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (C) 2006 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. -# - -# Settings to use MinGW as a cross-compiler under Linux -# Included by combo/select.make - -# right now we get these from the environment, but we should -# pick them from the tree somewhere -TOOLS_PREFIX := /usr/bin/amd64-mingw32msvc- - -HOST_ACP_UNAVAILABLE := true -HOST_GLOBAL_CFLAGS += -DUSE_MINGW -HOST_C_INCLUDES += /usr/lib/gcc/amd64-mingw32msvc/4.4.2/include -HOST_GLOBAL_LD_DIRS += -L/usr/amd64-mingw32msvc/lib - -# Workaround differences in inttypes.h between host and target. -# See bug 12708004. -HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -# Use C99-compliant printf functions (%zd). -HOST_GLOBAL_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 -# Admit to using >= Win2K. -HOST_GLOBAL_CFLAGS += -D_WIN32_WINNT=0x0500 - -HOST_CC := $(TOOLS_PREFIX)gcc$(TOOLS_EXE_SUFFIX) -HOST_CXX := $(TOOLS_PREFIX)g++$(TOOLS_EXE_SUFFIX) -HOST_AR := $(TOOLS_PREFIX)ar$(TOOLS_EXE_SUFFIX) - -HOST_GLOBAL_LDFLAGS += --enable-stdcall-fixup -ifneq ($(strip $(BUILD_HOST_static)),) -# Statically-linked binaries are desirable for sandboxed environment -HOST_GLOBAL_LDFLAGS += -static -endif # BUILD_HOST_static diff --git a/core/config.mk b/core/config.mk index 6fb490c7a9..e7a1d2020a 100644 --- a/core/config.mk +++ b/core/config.mk @@ -257,6 +257,13 @@ combo_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX) include $(BUILD_SYSTEM)/combo/select.mk endif +# Load the windows cross compiler under Linux +ifdef HOST_CROSS_OS +combo_target := HOST_CROSS_ +combo_2nd_arch_prefix := +include $(BUILD_SYSTEM)/combo/select.mk +endif + # on windows, the tools have .exe at the end, and we depend on the # host config stuff being done first @@ -603,6 +610,17 @@ $(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS += $($(HOST_2ND_ARCH_VAR_PREFIX)HO $(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS += $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CPPFLAGS) endif +ifdef HOST_CROSS_OS +HOST_CROSS_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS) +HOST_CROSS_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS) +HOST_CROSS_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS) +HOST_CROSS_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS) +HOST_CROSS_GLOBAL_LD_DIRS += -L$(HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES) +HOST_CROSS_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_CROSS_OUT_HEADERS) +HOST_CROSS_GLOBAL_CFLAGS += $(HOST_CROSS_RELEASE_CFLAGS) +HOST_CROSS_GLOBAL_CPPFLAGS += $(HOST_CROSS_RELEASE_CPPFLAGS) +endif + # allow overriding default Java libraries on a per-target basis ifeq ($(TARGET_DEFAULT_JAVA_LIBRARIES),) TARGET_DEFAULT_JAVA_LIBRARIES := core-libart core-junit ext framework okhttp diff --git a/core/cxx_stl_setup.mk b/core/cxx_stl_setup.mk index cda45a0ec1..72e91e7f1c 100644 --- a/core/cxx_stl_setup.mk +++ b/core/cxx_stl_setup.mk @@ -1,6 +1,6 @@ ############################################################# ## Set up flags based on LOCAL_CXX_STL. -## Input variables: LOCAL_CXX_STL +## Input variables: LOCAL_CXX_STL, my_prefix ## Output variables: My_cflags, my_c_includes, my_shared_libraries, etc. ############################################################# diff --git a/core/definitions.mk b/core/definitions.mk index 8480512e54..f56a49b6e2 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -87,11 +87,17 @@ TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES := $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES := HOST_DEPENDENCIES_ON_SHARED_LIBRARIES := $(HOST_2ND_ARCH_VAR_PREFIX)HOST_DEPENDENCIES_ON_SHARED_LIBRARIES := +HOST_CROSS_DEPENDENCIES_ON_SHARED_LIBRARIES := # Generated class file names for Android resource. # They are escaped and quoted so can be passed safely to a bash command. ANDROID_RESOURCE_GENERATED_CLASSES := 'R.class' 'R$$*.class' 'Manifest.class' 'Manifest$$*.class' +# Display names for various build targets +TARGET_DISPLAY := target +HOST_DISPLAY := host +HOST_CROSS_DISPLAY := host cross + ########################################################### ## Debugging; prints a variable list to stdout ########################################################### @@ -422,7 +428,8 @@ endef # $(2): target name, like "NotePad" # $(3): if non-empty, this is a HOST target. # $(4): if non-empty, force the intermediates to be COMMON -# $(5): if non-empty, force the intermedistes to be for the 2nd arch +# $(5): if non-empty, force the intermediates to be for the 2nd arch +# $(6): if non-empty, force the intermediates to be for the host cross os define intermediates-dir-for $(strip \ $(eval _idfClass := $(strip $(1))) \ @@ -431,7 +438,7 @@ $(strip \ $(eval _idfName := $(strip $(2))) \ $(if $(_idfName),, \ $(error $(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \ - $(eval _idfPrefix := $(if $(strip $(3)),HOST,TARGET)) \ + $(eval _idfPrefix := $(if $(strip $(3)),$(if $(strip $(6)),HOST_CROSS,HOST),TARGET)) \ $(eval _idf2ndArchPrefix := $(if $(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \ $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \ $(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \ @@ -449,13 +456,14 @@ endef # # $(1): if non-empty, force the intermediates to be COMMON # $(2): if non-empty, force the intermediates to be for the 2nd arch +# $(3): if non-empty, force the intermediates to be for the host cross os define local-intermediates-dir $(strip \ $(if $(strip $(LOCAL_MODULE_CLASS)),, \ $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-intermediates-dir)) \ $(if $(strip $(LOCAL_MODULE)),, \ $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-intermediates-dir)) \ - $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(LOCAL_IS_HOST_MODULE),$(1),$(2)) \ + $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(LOCAL_IS_HOST_MODULE),$(1),$(2),$(3)) \ ) endef @@ -1106,7 +1114,7 @@ endef ########################################################### define transform-host-cpp-to-o -@echo "host C++: $(PRIVATE_MODULE) <= $<" +@echo "$($(PRIVATE_PREFIX)DISPLAY) C++: $(PRIVATE_MODULE) <= $<" @mkdir -p $(dir $@) $(hide) $(PRIVATE_CXX) \ $(addprefix -I , $(PRIVATE_C_INCLUDES)) \ @@ -1114,7 +1122,7 @@ $(hide) $(PRIVATE_CXX) \ $(addprefix -isystem ,\ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ $(filter-out $(PRIVATE_C_INCLUDES), \ - $(HOST_PROJECT_INCLUDES) \ + $($(PRIVATE_PREFIX)PROJECT_INCLUDES) \ $(PRIVATE_HOST_C_INCLUDES)))) \ -c \ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ @@ -1144,7 +1152,7 @@ $(hide) $(PRIVATE_CC) \ $(addprefix -isystem ,\ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ $(filter-out $(PRIVATE_C_INCLUDES), \ - $(HOST_PROJECT_INCLUDES) \ + $($(PRIVATE_PREFIX)PROJECT_INCLUDES) \ $(PRIVATE_HOST_C_INCLUDES)))) \ -c \ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ @@ -1157,12 +1165,12 @@ $(hide) $(PRIVATE_CC) \ endef define transform-host-c-to-o-no-deps -@echo "host C: $(PRIVATE_MODULE) <= $<" +@echo "$($(PRIVATE_PREFIX)DISPLAY) C: $(PRIVATE_MODULE) <= $<" $(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_CONLYFLAGS) $(PRIVATE_DEBUG_CFLAGS)) endef define transform-host-s-to-o-no-deps -@echo "host asm: $(PRIVATE_MODULE) <= $<" +@echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<" $(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS)) endef @@ -1181,7 +1189,7 @@ endef ########################################################### define transform-host-m-to-o-no-deps -@echo "host ObjC: $(PRIVATE_MODULE) <= $<" +@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<" $(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS)) endef @@ -1338,19 +1346,19 @@ $(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs; lib_to_include=$$ldir/$(notdir $(1)); \ filelist=; \ subdir=0; \ - for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) t $(1) | \grep '\.o$$'`; do \ + for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) t $(1) | \grep '\.o$$'`; do \ if [ -e $$ldir/$$f ]; then \ mkdir $$ldir/$$subdir; \ ext=$$subdir/; \ subdir=$$((subdir+1)); \ - $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) m $$lib_to_include $$f; \ + $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) m $$lib_to_include $$f; \ else \ ext=; \ fi; \ - $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \ + $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \ filelist="$$filelist $$ldir/$$ext$$f"; \ done ; \ - $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_ARFLAGS) \ + $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) \ $(PRIVATE_ARFLAGS) $@ $$filelist endef @@ -1364,12 +1372,12 @@ endef # Explicitly delete the archive first so that ar doesn't # try to add to an existing archive. define transform-host-o-to-static-lib -@echo "host StaticLib: $(PRIVATE_MODULE) ($@)" +@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)" @mkdir -p $(dir $@) @rm -f $@ $(extract-and-include-host-whole-static-libs) -$(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) \ - $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_ARFLAGS) \ +$(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) \ + $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) \ $(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS)) endef @@ -1383,11 +1391,11 @@ endef ifneq ($(HOST_CUSTOM_LD_COMMAND),true) define transform-host-o-to-shared-lib-inner $(hide) $(PRIVATE_CXX) \ - -Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES) \ - -Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \ - -Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \ + -Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_INTERMEDIATE_LIBRARIES) \ + -Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \ + -Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \ -shared -Wl,-soname,$(notdir $@) \ - $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \ + $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_LD_DIRS) \ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ $(PRIVATE_HOST_GLOBAL_LDFLAGS) \ ) \ @@ -1408,13 +1416,13 @@ endef endif define transform-host-o-to-shared-lib -@echo "host SharedLib: $(PRIVATE_MODULE) ($@)" +@echo "$($(PRIVATE_PREFIX)DISPLAY) SharedLib: $(PRIVATE_MODULE) ($@)" @mkdir -p $(dir $@) $(transform-host-o-to-shared-lib-inner) endef define transform-host-o-to-package -@echo "host Package: $(PRIVATE_MODULE) ($@)" +@echo "$($(PRIVATE_PREFIX)DISPLAY) Package: $(PRIVATE_MODULE) ($@)" @mkdir -p $(dir $@) $(transform-host-o-to-shared-lib-inner) endef @@ -1582,8 +1590,8 @@ HOST_FPIE_FLAGS := else HOST_FPIE_FLAGS := -pie # Force the correct entry point to workaround a bug in binutils that manifests with -pie -ifeq ($(HOST_OS),windows) -HOST_FPIE_FLAGS += -Wl,-e_mainCRTStartup +ifeq ($(HOST_CROSS_OS),windows) +HOST_CROSS_FPIE_FLAGS += -Wl,-e_mainCRTStartup endif endif @@ -1600,10 +1608,10 @@ $(hide) $(PRIVATE_CXX) \ $(if $(filter true,$(NATIVE_COVERAGE)),-lgcov) \ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \ $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ - -Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES) \ - -Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \ - -Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \ - $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \ + -Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_INTERMEDIATE_LIBRARIES) \ + -Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \ + -Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \ + $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_LD_DIRS) \ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ $(PRIVATE_HOST_GLOBAL_LDFLAGS) \ ) \ @@ -1614,7 +1622,7 @@ endef endif define transform-host-o-to-executable -@echo "host Executable: $(PRIVATE_MODULE) ($@)" +@echo "$($(PRIVATE_PREFIX)DISPLAY) Executable: $(PRIVATE_MODULE) ($@)" @mkdir -p $(dir $@) $(transform-host-o-to-executable-inner) endef @@ -2105,7 +2113,7 @@ endef # Note: we intentionally don't clean PRIVATE_CLASS_INTERMEDIATES_DIR # in transform-java-to-classes for the sake of vm-tests. define transform-host-java-to-package -@echo "host Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))" +@echo "$($(PRIVATE_PREFIX)DISPLAY) Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))" $(call compile-java,$(HOST_JAVAC),$(PRIVATE_BOOTCLASSPATH)) endef diff --git a/core/droiddoc.mk b/core/droiddoc.mk index aae2aba4d6..893461aead 100644 --- a/core/droiddoc.mk +++ b/core/droiddoc.mk @@ -23,6 +23,7 @@ LOCAL_IS_HOST_MODULE := $(call true-or-empty,$(LOCAL_IS_HOST_MODULE)) ifeq ($(LOCAL_IS_HOST_MODULE),true) my_prefix := HOST_ +LOCAL_HOST_PREFIX := else my_prefix := TARGET_ endif diff --git a/core/dumpvar.mk b/core/dumpvar.mk index 510bc7d082..c7fb8dbc68 100644 --- a/core/dumpvar.mk +++ b/core/dumpvar.mk @@ -80,6 +80,7 @@ $(info TARGET_2ND_CPU_VARIANT=$(TARGET_2ND_CPU_VARIANT)) $(info HOST_ARCH=$(HOST_ARCH)) $(info HOST_OS=$(HOST_OS)) $(info HOST_OS_EXTRA=$(HOST_OS_EXTRA)) +$(info HOST_CROSS_OS=$(HOST_CROSS_OS)) $(info HOST_BUILD_TYPE=$(HOST_BUILD_TYPE)) $(info BUILD_ID=$(BUILD_ID)) $(info OUT_DIR=$(OUT_DIR)) diff --git a/core/envsetup.mk b/core/envsetup.mk index c76e9a6b32..ecfca9f606 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -52,12 +52,11 @@ endif # BUILD_OS is the real host doing the build. BUILD_OS := $(HOST_OS) -# Under Linux, if USE_MINGW is set, we change HOST_OS to Windows to build the -# Windows SDK. Only a subset of tools and SDK will manage to build properly. +HOST_CROSS_OS := +# We can cross-build Windows binaries on Linux ifeq ($(HOST_OS),linux) -ifdef USE_MINGW - HOST_OS := windows -endif +HOST_CROSS_OS := windows +HOST_CROSS_ARCH := x86 endif ifeq ($(HOST_OS),) @@ -128,11 +127,6 @@ $(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT)) $(error must be empty or one of: eng user userdebug) endif -ifdef USE_MINGW -# We only build sdk host tools in the MinGW windows build. -# Build it as 32-bit as well. -HOST_PREFER_32_BIT := true -endif SDK_HOST_ARCH := x86 # Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE) @@ -213,8 +207,12 @@ HOST_OUT_ROOT := $(HOST_OUT_ROOT_$(HOST_BUILD_TYPE)) HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_PREBUILT_ARCH) HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_PREBUILT_ARCH) HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE)) +# TODO: remove +BUILD_OUT := $(HOST_OUT) -BUILD_OUT := $(OUT_DIR)/host/$(BUILD_OS)-$(HOST_PREBUILT_ARCH) +HOST_CROSS_OUT_release := $(HOST_OUT_ROOT_release)/windows-$(HOST_PREBUILT_ARCH) +HOST_CROSS_OUT_debug := $(HOST_OUT_ROOT_debug)/windows-$(HOST_PREBUILT_ARCH) +HOST_CROSS_OUT := $(HOST_CROSS_OUT_$(HOST_BUILD_TYPE)) TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product @@ -232,6 +230,9 @@ HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib64 HOST_OUT_JAVA_LIBRARIES := $(HOST_OUT)/framework HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon +HOST_CROSS_OUT_EXECUTABLES := $(HOST_CROSS_OUT)/bin +HOST_CROSS_OUT_SHARED_LIBRARIES := $(HOST_CROSS_OUT)/lib + HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj HOST_OUT_HEADERS := $(HOST_OUT_INTERMEDIATES)/include HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib @@ -239,9 +240,16 @@ HOST_OUT_NOTICE_FILES := $(HOST_OUT_INTERMEDIATES)/NOTICE_FILES HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj HOST_OUT_FAKE := $(HOST_OUT)/fake_packages +HOST_CROSS_OUT_INTERMEDIATES := $(HOST_CROSS_OUT)/obj +HOST_CROSS_OUT_HEADERS := $(HOST_CROSS_OUT_INTERMEDIATES)/include +HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES := $(HOST_CROSS_OUT_INTERMEDIATES)/lib +HOST_CROSS_OUT_NOTICE_FILES := $(HOST_CROSS_OUT_INTERMEDIATES)/NOTICE_FILES + HOST_OUT_GEN := $(HOST_OUT)/gen HOST_OUT_COMMON_GEN := $(HOST_COMMON_OUT_ROOT)/gen +HOST_CROSS_OUT_GEN := $(HOST_CROSS_OUT)/gen + # Out for HOST_2ND_ARCH HOST_2ND_ARCH_VAR_PREFIX := 2ND_ HOST_2ND_ARCH_MODULE_SUFFIX := _32 diff --git a/core/host_executable.mk b/core/host_executable.mk index 5601b015eb..bc55ef94af 100644 --- a/core/host_executable.mk +++ b/core/host_executable.mk @@ -1,5 +1,6 @@ LOCAL_IS_HOST_MODULE := true my_prefix := HOST_ +LOCAL_HOST_PREFIX := include $(BUILD_SYSTEM)/multilib.mk ifndef LOCAL_MODULE_HOST_ARCH @@ -50,5 +51,30 @@ endif LOCAL_2ND_ARCH_VAR_PREFIX := endif # HOST_2ND_ARCH +ifdef HOST_CROSS_OS +my_prefix := HOST_CROSS_ +LOCAL_HOST_PREFIX := $(my_prefix) +include $(BUILD_SYSTEM)/module_arch_supported.mk +ifeq ($(my_module_arch_supported),true) +# Build for Windows +OVERRIDE_BUILT_MODULE_PATH := +# we don't want others using the cross compiled version +saved_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE) +saved_LOCAL_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE) +LOCAL_BUILT_MODULE := +LOCAL_INSTALLED_MODULE := +LOCAL_INTERMEDIATE_TARGETS := + +ifeq ($(LOCAL_NO_FPIE),) +LOCAL_LDFLAGS += $(HOST_CROSS_FPIE_FLAGS) +endif + +include $(BUILD_SYSTEM)/host_executable_internal.mk +LOCAL_BUILT_MODULE := $(saved_LOCAL_BUILT_MODULE) +LOCAL_INSTALLED_MODULE := $(saved_LOCAL_INSTALLED_MODULE) +endif +LOCAL_HOST_PREFIX := +endif + LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := my_module_arch_supported := diff --git a/core/host_executable_internal.mk b/core/host_executable_internal.mk index c59f15122f..b682ffdaa9 100644 --- a/core/host_executable_internal.mk +++ b/core/host_executable_internal.mk @@ -9,7 +9,7 @@ ifeq ($(strip $(LOCAL_MODULE_CLASS)),) LOCAL_MODULE_CLASS := EXECUTABLES endif ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),) -LOCAL_MODULE_SUFFIX := $(HOST_EXECUTABLE_SUFFIX) +LOCAL_MODULE_SUFFIX := $($(my_prefix)EXECUTABLE_SUFFIX) endif $(call host-executable-hook) @@ -26,7 +26,7 @@ ifndef skip_build_from_source include $(BUILD_SYSTEM)/binary.mk -my_host_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_LIBPROFILE_RT) +my_host_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT) $(LOCAL_BUILT_MODULE): PRIVATE_HOST_LIBPROFILE_RT := $(my_host_libprofile_rt) $(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries) diff --git a/core/host_shared_library.mk b/core/host_shared_library.mk index 6964cc950e..49000a4dcd 100644 --- a/core/host_shared_library.mk +++ b/core/host_shared_library.mk @@ -1,5 +1,6 @@ LOCAL_IS_HOST_MODULE := true my_prefix := HOST_ +LOCAL_HOST_PREFIX := include $(BUILD_SYSTEM)/multilib.mk ifndef LOCAL_MODULE_HOST_ARCH @@ -35,6 +36,26 @@ endif LOCAL_2ND_ARCH_VAR_PREFIX := endif # HOST_2ND_ARCH +ifdef HOST_CROSS_OS +my_prefix := HOST_CROSS_ +LOCAL_HOST_PREFIX := $(my_prefix) +include $(BUILD_SYSTEM)/module_arch_supported.mk +ifeq ($(my_module_arch_supported),true) +# Build for Windows +OVERRIDE_BUILT_MODULE_PATH := +LOCAL_BUILT_MODULE := +LOCAL_MODULE_SUFFIX := +# We don't want makefiles using the cross-compiled host tool +saved_LOCAL_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE) +LOCAL_INSTALLED_MODULE := +LOCAL_INTERMEDIATE_TARGETS := + +include $(BUILD_SYSTEM)/host_shared_library_internal.mk +LOCAL_INSTALLED_MODULE := $(saved_LOCAL_INSTALLED_MODULE) +endif +LOCAL_HOST_PREFIX := +endif + my_module_arch_supported := ########################################################### diff --git a/core/host_shared_library_internal.mk b/core/host_shared_library_internal.mk index 9da778ae6f..740c9414cb 100644 --- a/core/host_shared_library_internal.mk +++ b/core/host_shared_library_internal.mk @@ -11,7 +11,7 @@ ifeq ($(strip $(LOCAL_MODULE_CLASS)),) LOCAL_MODULE_CLASS := SHARED_LIBRARIES endif ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),) -LOCAL_MODULE_SUFFIX := $(HOST_SHLIB_SUFFIX) +LOCAL_MODULE_SUFFIX := $($(my_prefix)SHLIB_SUFFIX) endif ifneq ($(strip $(OVERRIDE_BUILT_MODULE_PATH)),) $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH) @@ -34,11 +34,11 @@ ifndef skip_build_from_source # Put the built modules of all shared libraries in a common directory # to simplify the link line. -OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES) +OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES) include $(BUILD_SYSTEM)/binary.mk -my_host_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_LIBPROFILE_RT) +my_host_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT) $(LOCAL_BUILD_MODULE): PRIVATE_HOST_LIBPROFILE_RT := $(my_host_libprofile_rt) $(LOCAL_BUILT_MODULE): \ diff --git a/core/host_static_library.mk b/core/host_static_library.mk index dd7462d85d..aa8c0e3d82 100644 --- a/core/host_static_library.mk +++ b/core/host_static_library.mk @@ -1,5 +1,6 @@ LOCAL_IS_HOST_MODULE := true my_prefix := HOST_ +LOCAL_HOST_PREFIX := include $(BUILD_SYSTEM)/multilib.mk ifndef LOCAL_MODULE_HOST_ARCH @@ -35,6 +36,22 @@ endif LOCAL_2ND_ARCH_VAR_PREFIX := endif # HOST_2ND_ARCH +ifdef HOST_CROSS_OS +my_prefix := HOST_CROSS_ +LOCAL_HOST_PREFIX := $(my_prefix) +include $(BUILD_SYSTEM)/module_arch_supported.mk +ifeq ($(my_module_arch_supported),true) +# Build for Windows +OVERRIDE_BUILT_MODULE_PATH := +LOCAL_BUILT_MODULE := +LOCAL_INSTALLED_MODULE := +LOCAL_INTERMEDIATE_TARGETS := + +include $(BUILD_SYSTEM)/host_static_library_internal.mk +endif +LOCAL_HOST_PREFIX := +endif + my_module_arch_supported := ########################################################### diff --git a/core/main.mk b/core/main.mk index 9ae308660c..def86f52fb 100644 --- a/core/main.mk +++ b/core/main.mk @@ -449,16 +449,6 @@ ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),) $(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL) endif -# Bring in all modules that need to be built. -ifeq ($(HOST_OS),windows) -SDK_ONLY := true -endif - -ifeq ($(SDK_ONLY),true) -include $(TOPDIR)sdk/build/windows_sdk_whitelist.mk -include $(TOPDIR)development/build/windows_sdk_whitelist.mk - -else # !SDK_ONLY # # Typical build; include any Android.mk files we can find. # @@ -466,8 +456,6 @@ subdirs := $(TOP) FULL_BUILD := true -endif # !SDK_ONLY - # Before we go and include all of the module makefiles, stash away # the PRODUCT_* values so that later we can verify they are not modified. stash_product_vars:=true @@ -579,6 +567,8 @@ $(strip $(foreach m,$(1),\ $(m)))) endef +# If a module is for a cross host os, the required modules must be for +# that OS too. # If a module is built for 32-bit, the required modules must be 32-bit too; # Otherwise if the module is an exectuable or shared library, # the required modules must be 64-bit; @@ -586,6 +576,8 @@ endef $(foreach m,$(ALL_MODULES),\ $(eval r := $(ALL_MODULES.$(m).REQUIRED))\ $(if $(r),\ + $(if $(ALL_MODULES.$(m).FOR_HOST_CROSS),\ + $(eval r := $(addprefix host_cross_,$(r))))\ $(if $(ALL_MODULES.$(m).FOR_2ND_ARCH),\ $(eval r_r := $(call get-32-bit-modules-if-we-can,$(r))),\ $(if $(filter EXECUTABLES SHARED_LIBRARIES,$(ALL_MODULES.$(m).CLASS)),\ @@ -608,32 +600,40 @@ $(foreach m,$(ALL_MODULES), \ $(eval r := $(call module-installed-files,$(r))) \ $(eval t_m := $(filter $(TARGET_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \ $(eval h_m := $(filter $(HOST_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \ + $(eval hc_m := $(filter $(HOST_CROSS_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \ $(eval t_r := $(filter $(TARGET_OUT_ROOT)/%, $(r))) \ $(eval h_r := $(filter $(HOST_OUT_ROOT)/%, $(r))) \ + $(eval hc_r := $(filter $(HOST_CROSS_OUT_ROOT)/%, $(r))) \ $(eval t_m := $(filter-out $(t_r), $(t_m))) \ $(eval h_m := $(filter-out $(h_r), $(h_m))) \ + $(eval hc_m := $(filter-out $(hc_r), $(hc_m))) \ $(if $(t_m), $(eval $(call add-required-deps, $(t_m),$(t_r)))) \ $(if $(h_m), $(eval $(call add-required-deps, $(h_m),$(h_r)))) \ + $(if $(hc_m), $(eval $(call add-required-deps, $(hc_m),$(hc_r)))) \ ) \ ) t_m := h_m := +hc_m := t_r := h_r := +hc_r := # Establish the dependecies on the shared libraries. # It also adds the shared library module names to ALL_MODULES.$(m).REQUIRED, # so they can be expanded to product_MODULES later. -# $(1): TARGET_ or HOST_. +# $(1): TARGET_ or HOST_ or HOST_CROSS_. # $(2): non-empty for 2nd arch. +# $(3): non-empty for host cross compile. define resolve-shared-libs-depes $(foreach m,$($(if $(2),$($(1)2ND_ARCH_VAR_PREFIX))$(1)DEPENDENCIES_ON_SHARED_LIBRARIES),\ $(eval p := $(subst :,$(space),$(m)))\ $(eval mod := $(firstword $(p)))\ $(eval deps := $(subst $(comma),$(space),$(lastword $(p))))\ $(if $(2),$(eval deps := $(addsuffix $($(1)2ND_ARCH_MODULE_SUFFIX),$(deps))))\ - $(eval r := $(filter $($(1)OUT_ROOT)/%,$(call module-installed-files,\ + $(if $(3),$(eval deps := $(addprefix host_cross_,$(deps))))\ + $(eval r := $(filter $($(1)OUT)/%,$(call module-installed-files,\ $(deps))))\ $(eval $(call add-required-deps,$(word 2,$(p)),$(r)))\ $(eval ALL_MODULES.$(mod).REQUIRED += $(deps))) @@ -647,6 +647,9 @@ $(call resolve-shared-libs-depes,HOST_) ifdef HOST_2ND_ARCH $(call resolve-shared-libs-depes,HOST_,true) endif +ifdef HOST_CROSS_OS +$(call resolve-shared-libs-depes,HOST_CROSS_,,true) +endif m := r := diff --git a/core/multilib.mk b/core/multilib.mk index e0615b27d9..a3ced65d2c 100644 --- a/core/multilib.mk +++ b/core/multilib.mk @@ -13,11 +13,3 @@ ifeq (,$(filter 32 64 first both none,$(my_module_multilib))) $(error $(LOCAL_PATH): Invalid LOCAL_MULTILIB specified for module $(LOCAL_MODULE)) endif endif # my_module_multilib defined - -# Windows is a special case. Linux and Darwin are both multilib builds, but we -# don't have a 64-bit Windows build, so make sure it's not a multilib build. -ifdef LOCAL_IS_HOST_MODULE -ifeq ($(HOST_OS),windows) -my_module_multilib := 32 -endif -endif diff --git a/core/notice_files.mk b/core/notice_files.mk index 43a5435271..cf2dad675c 100644 --- a/core/notice_files.mk +++ b/core/notice_files.mk @@ -14,6 +14,7 @@ ifeq ($(LOCAL_MODULE_CLASS),NOTICE_FILES) # so my_prefix is not set at this point. ifeq ($(LOCAL_IS_HOST_MODULE),true) my_prefix := HOST_ + LOCAL_HOST_PREFIX := else my_prefix := TARGET_ endif @@ -56,6 +57,7 @@ endif # In case it's actually a host file module_installed_filename := $(patsubst $(HOST_OUT)%,%,$(module_installed_filename)) +module_installed_filename := $(patsubst $(HOST_CROSS_OUT)%,%,$(module_installed_filename)) installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt diff --git a/core/prebuilt.mk b/core/prebuilt.mk index d3f9d1a3a5..ed25f71aa1 100644 --- a/core/prebuilt.mk +++ b/core/prebuilt.mk @@ -8,6 +8,7 @@ ifdef LOCAL_IS_HOST_MODULE my_prefix := HOST_ + LOCAL_HOST_PREFIX := else my_prefix := TARGET_ endif @@ -52,4 +53,26 @@ endif # $(my_skip_non_preferred_arch) not true LOCAL_2ND_ARCH_VAR_PREFIX := +ifdef LOCAL_IS_HOST_MODULE +ifdef HOST_CROSS_OS +ifneq (,$(filter EXECUTABLES STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))) +my_prefix := HOST_CROSS_ +LOCAL_HOST_PREFIX := $(my_prefix) +include $(BUILD_SYSTEM)/module_arch_supported.mk +ifeq ($(my_module_arch_supported),true) +# host cross compilation is supported +OVERRIDE_BUILT_MODULE_PATH := +LOCAL_BUILT_MODULE := +LOCAL_INSTALLED_MODULE := +LOCAL_MODULE_STEM := +LOCAL_BUILT_MODULE_STEM := +LOCAL_INSTALLED_MODULE_STEM := +LOCAL_INTERMEDIATE_TARGETS := +include $(BUILD_SYSTEM)/prebuilt_internal.mk +endif +LOCAL_HOST_PREFIX := +endif +endif +endif + my_module_arch_supported := diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py index c7a9e2b599..42007eb0de 100644 --- a/tools/releasetools/blockimgdiff.py +++ b/tools/releasetools/blockimgdiff.py @@ -106,11 +106,13 @@ class DataImage(Image): assert not (trim and pad) partial = len(self.data) % self.blocksize + padded = False if partial > 0: if trim: self.data = self.data[:-partial] elif pad: self.data += '\0' * (self.blocksize - partial) + padded = True else: raise ValueError(("data for DataImage must be multiple of %d bytes " "unless trim or pad is specified") % @@ -120,14 +122,23 @@ class DataImage(Image): self.total_blocks = len(self.data) / self.blocksize self.care_map = RangeSet(data=(0, self.total_blocks)) - self.clobbered_blocks = RangeSet() + # When the last block is padded, we always write the whole block even for + # incremental OTAs. Because otherwise the last block may get skipped if + # unchanged for an incremental, but would fail the post-install + # verification if it has non-zero contents in the padding bytes. + # Bug: 23828506 + if padded: + clobbered_blocks = [self.total_blocks-1, self.total_blocks] + else: + clobbered_blocks = [] + self.clobbered_blocks = clobbered_blocks self.extended = RangeSet() zero_blocks = [] nonzero_blocks = [] reference = '\0' * self.blocksize - for i in range(self.total_blocks): + for i in range(self.total_blocks-1 if padded else self.total_blocks): d = self.data[i*self.blocksize : (i+1)*self.blocksize] if d == reference: zero_blocks.append(i) @@ -136,17 +147,25 @@ class DataImage(Image): nonzero_blocks.append(i) nonzero_blocks.append(i+1) - self.file_map = {"__ZERO": RangeSet(zero_blocks), - "__NONZERO": RangeSet(nonzero_blocks)} + assert zero_blocks or nonzero_blocks or clobbered_blocks + + self.file_map = dict() + if zero_blocks: + self.file_map["__ZERO"] = RangeSet(data=zero_blocks) + if nonzero_blocks: + self.file_map["__NONZERO"] = RangeSet(data=nonzero_blocks) + if clobbered_blocks: + self.file_map["__COPY"] = RangeSet(data=clobbered_blocks) def ReadRangeSet(self, ranges): return [self.data[s*self.blocksize:e*self.blocksize] for (s, e) in ranges] def TotalSha1(self, include_clobbered_blocks=False): - # DataImage always carries empty clobbered_blocks, so - # include_clobbered_blocks can be ignored. - assert self.clobbered_blocks.size() == 0 - return sha1(self.data).hexdigest() + if not include_clobbered_blocks: + ranges = self.care_map.subtract(self.clobbered_blocks) + return sha1(self.ReadRangeSet(ranges)).hexdigest() + else: + return sha1(self.data).hexdigest() class Transfer(object): @@ -492,6 +511,7 @@ class BlockImageDiff(object): # Zero out extended blocks as a workaround for bug 20881595. if self.tgt.extended: out.append("zero %s\n" % (self.tgt.extended.to_string_raw(),)) + total += self.tgt.extended.size() # We erase all the blocks on the partition that a) don't contain useful # data in the new image and b) will not be touched by dm-verity. @@ -502,7 +522,7 @@ class BlockImageDiff(object): out.append("erase %s\n" % (new_dontcare.to_string_raw(),)) out.insert(0, "%d\n" % (self.version,)) # format version number - out.insert(1, str(total) + "\n") + out.insert(1, "%d\n" % (total,)) if self.version >= 2: # version 2 only: after the total block count, we give the number # of stash slots needed, and the maximum size needed (in blocks) |