Convert more of art to Android.bp
Convert dex2oat, imgdiag, patchoat, and profman to Android.bp.
Test: m -j test-art-host
Test: mmma -j art
Change-Id: If2acd47189e5a944732c2c00c2bf31265f887161
diff --git a/Android.bp b/Android.bp
index 77b9ac3..f7e909d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -22,11 +22,15 @@
"build",
"compiler",
"dalvikvm",
+ "dex2oat",
"dexdump",
"dexlayout",
"dexlist",
"disassembler",
+ "imgdiag",
"oatdump",
+ "patchoat",
+ "profman",
"runtime",
"sigchainlib",
"tools/cpp-define-generator",
diff --git a/Android.mk b/Android.mk
index 5a17379..d43118c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -76,11 +76,7 @@
########################################################################
# product rules
-include $(art_path)/dex2oat/Android.mk
include $(art_path)/oatdump/Android.mk
-include $(art_path)/imgdiag/Android.mk
-include $(art_path)/patchoat/Android.mk
-include $(art_path)/profman/Android.mk
include $(art_path)/tools/Android.mk
include $(art_path)/tools/ahat/Android.mk
include $(art_path)/tools/dexfuzz/Android.mk
diff --git a/build/Android.executable.mk b/build/Android.executable.mk
index c35833d..f38a14d 100644
--- a/build/Android.executable.mk
+++ b/build/Android.executable.mk
@@ -249,20 +249,3 @@
)
)
endef
-
-# Note: the order is important because of static linking resolution.
-ART_STATIC_DEPENDENCIES := \
- libziparchive \
- libnativehelper \
- libnativebridge \
- libnativeloader \
- libsigchain_dummy \
- liblog \
- libz \
- libbacktrace \
- libcutils \
- libunwindbacktrace \
- libutils \
- libbase \
- liblz4 \
- liblzma
diff --git a/build/art.go b/build/art.go
index da4609d..f694505 100644
--- a/build/art.go
+++ b/build/art.go
@@ -181,6 +181,7 @@
func init() {
soong.RegisterModuleType("art_cc_library", artLibrary)
soong.RegisterModuleType("art_cc_binary", artBinary)
+ soong.RegisterModuleType("art_cc_test", artTest)
soong.RegisterModuleType("art_cc_defaults", artDefaultsFactory)
soong.RegisterModuleType("art_global_defaults", artGlobalDefaultsFactory)
}
@@ -221,6 +222,15 @@
return module, props
}
+func artTest() (blueprint.Module, []interface{}) {
+ test := cc.NewTest(android.HostAndDeviceSupported)
+ module, props := test.Init()
+
+ android.AddCustomizer(test, &artCustomLinkerCustomizer{})
+ android.AddCustomizer(test, &artPrefer32BitCustomizer{})
+ return module, props
+}
+
func envDefault(ctx android.BaseContext, key string, defaultValue string) string {
ret := ctx.AConfig().Getenv(key)
if ret == "" {
diff --git a/dex2oat/Android.bp b/dex2oat/Android.bp
new file mode 100644
index 0000000..7826a11
--- /dev/null
+++ b/dex2oat/Android.bp
@@ -0,0 +1,107 @@
+//
+// Copyright (C) 2011 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.
+//
+
+cc_defaults {
+ name: "dex2oat-defaults",
+ host_supported: true,
+ defaults: ["art_defaults"],
+ srcs: ["dex2oat.cc"],
+
+ target: {
+ android: {
+ // Use the 32-bit version of dex2oat on devices
+ compile_multilib: "prefer32",
+
+ sanitize: {
+ // ASan slows down dex2oat by ~3.5x, which translates into
+ // extremely slow first boot. Disabled to help speed up
+ // SANITIZE_TARGET mode.
+ // Bug: 22233158
+ address: false,
+ },
+ },
+
+ host: {
+ ldflags: [
+ // We need this because GC stress mode makes use of
+ // _Unwind_GetIP and _Unwind_Backtrace and the symbols are also
+ // defined in libgcc_eh.a(unwind-dw2.o)
+ // TODO: Having this is not ideal as it might obscure errors.
+ // Try to get rid of it.
+ "-z muldefs",
+ ],
+ },
+ },
+
+
+ include_dirs: [
+ "art/cmdline",
+ ],
+}
+
+cc_binary {
+ name: "dex2oat",
+ defaults: [
+ "dex2oat-defaults",
+ ],
+ shared_libs: [
+ "libart",
+ "libart-compiler",
+ "libsigchain",
+ ],
+}
+
+cc_binary {
+ name: "dex2oatd",
+ defaults: [
+ "art_debug_defaults",
+ "dex2oat-defaults",
+ ],
+ shared_libs: [
+ "libartd",
+ "libartd-compiler",
+ "libsigchain",
+ ],
+}
+
+cc_binary {
+ name: "dex2oats",
+ device_supported: false,
+ static_executable: true,
+ defaults: ["dex2oat-defaults"],
+ static_libs: [
+ "libart-compiler",
+ "libart",
+ "libvixl-arm",
+ "libvixl-arm64",
+ ] + art_static_dependencies,
+}
+
+cc_binary {
+ name: "dex2oatds",
+ device_supported: false,
+ static_executable: true,
+ defaults: [
+ "art_debug_defaults",
+ "dex2oat-defaults",
+ ],
+ static_libs: [
+ "libartd-compiler",
+ "libartd",
+ "libvixld-arm",
+ "libvixld-arm64",
+ ] + art_static_dependencies,
+}
diff --git a/dex2oat/Android.mk b/dex2oat/Android.mk
deleted file mode 100644
index 32424ca..0000000
--- a/dex2oat/Android.mk
+++ /dev/null
@@ -1,78 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-
-# ASan slows down dex2oat by ~3.5x, which translates into extremely slow first
-# boot. Disabled to help speed up SANITIZE_TARGET mode.
-# The supported way of using SANITIZE_TARGET is by first running a normal build,
-# followed by a SANITIZE_TARGET=address build on top of it (in the same build
-# tree). By disabling this module in SANITIZE_TARGET build, we keep the regular,
-# uninstrumented version of it.
-# Bug: 22233158
-ifeq (,$(filter address, $(SANITIZE_TARGET)))
-
-LOCAL_PATH := $(call my-dir)
-
-include art/build/Android.executable.mk
-
-DEX2OAT_SRC_FILES := \
- dex2oat.cc
-
-# TODO: Remove this when the framework (installd) supports pushing the
-# right instruction-set parameter for the primary architecture.
-ifneq ($(filter ro.zygote=zygote64,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES)),)
- dex2oat_target_arch := 64
-else
- dex2oat_target_arch := 32
-endif
-
-ifeq ($(HOST_PREFER_32_BIT),true)
- # We need to explicitly restrict the host arch to 32-bit only, as
- # giving 'both' would make build-art-executable generate a build
- # rule for a 64-bit dex2oat executable too.
- dex2oat_host_arch := 32
-else
- dex2oat_host_arch := both
-endif
-
-ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
- $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libcutils libart-compiler libsigchain,art/compiler,target,ndebug,$(dex2oat_target_arch)))
-endif
-
-ifeq ($(ART_BUILD_TARGET_DEBUG),true)
- $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libcutils libartd-compiler libsigchain,art/compiler,target,debug,$(dex2oat_target_arch)))
-endif
-
-# We always build dex2oat and dependencies, even if the host build is
-# otherwise disabled, since they are used to cross compile for the target.
-ifeq ($(ART_BUILD_HOST_NDEBUG),true)
- $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libcutils libart-compiler libsigchain libziparchive liblz4,art/compiler,host,ndebug,$(dex2oat_host_arch)))
- ifeq ($(ART_BUILD_HOST_STATIC),true)
- $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libart libart-compiler libart libvixl-arm libvixl-arm64 $(ART_STATIC_DEPENDENCIES),art/compiler,host,ndebug,$(dex2oat_host_arch),static))
- endif
-endif
-
-ifeq ($(ART_BUILD_HOST_DEBUG),true)
- $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libcutils libartd-compiler libsigchain libziparchive liblz4,art/compiler,host,debug,$(dex2oat_host_arch)))
- ifeq ($(ART_BUILD_HOST_STATIC),true)
- $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libartd libartd-compiler libartd libvixld-arm libvixld-arm64 $(ART_STATIC_DEPENDENCIES),art/compiler,host,debug,$(dex2oat_host_arch),static))
- endif
-endif
-
-# Clear locals now they've served their purpose.
-dex2oat_target_arch :=
-dex2oat_host_arch :=
-
-endif
diff --git a/imgdiag/Android.bp b/imgdiag/Android.bp
new file mode 100644
index 0000000..4c0772d
--- /dev/null
+++ b/imgdiag/Android.bp
@@ -0,0 +1,71 @@
+//
+// Copyright (C) 2014 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.
+//
+
+// Build variants {target,host} x {debug,ndebug} x {32,64}
+
+cc_defaults {
+ name: "imgdiag-defaults",
+ host_supported: true,
+ srcs: ["imgdiag.cc"],
+ defaults: ["art_defaults"],
+
+ // Note that this tool needs to be built for both 32-bit and 64-bit since it requires
+ // that the image it's analyzing be the same ISA as the runtime ISA.
+ compile_multilib: "both",
+
+ shared_libs: ["libbacktrace"],
+ target: {
+ android: {
+ shared_libs: ["libcutils"],
+ },
+ host: {
+ shared_libs: ["libziparchive"],
+ },
+ },
+ include_dirs: [
+ "art/cmdline",
+ ],
+ multilib: {
+ lib32: {
+ suffix: "32",
+ },
+ lib64: {
+ suffix: "64",
+ },
+ },
+ symlink_preferred_arch: true,
+}
+
+art_cc_binary {
+ name: "imgdiag",
+ defaults: ["imgdiag-defaults"],
+ shared_libs: [
+ "libart",
+ "libart-compiler",
+ ],
+}
+
+art_cc_binary {
+ name: "imgdiagd",
+ defaults: [
+ "imgdiag-defaults",
+ "art_debug_defaults",
+ ],
+ shared_libs: [
+ "libartd",
+ "libartd-compiler",
+ ],
+}
diff --git a/imgdiag/Android.mk b/imgdiag/Android.mk
deleted file mode 100644
index 278527f..0000000
--- a/imgdiag/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (C) 2014 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include art/build/Android.executable.mk
-
-IMGDIAG_SRC_FILES := \
- imgdiag.cc
-
-# Note that this tool needs to be built for both 32-bit and 64-bit since it requires
-# that the image it's analyzing be the same ISA as the runtime ISA.
-
-# Build variants {target,host} x {debug,ndebug} x {32,64}
-#
-# Honor HOST_PREFER_32_BIT, as building a 64-bit imgdiag executable
-# when HOST_PREFER_32_BIT is true would require an unmet dependency on
-# 64-bit libbacktrace.
-$(eval $(call build-art-multi-executable,imgdiag,$(IMGDIAG_SRC_FILES),libart-compiler libbacktrace,libcutils,libziparchive,art/compiler,both,$(HOST_PREFER_32_BIT)))
diff --git a/patchoat/Android.bp b/patchoat/Android.bp
new file mode 100644
index 0000000..8d8d6d1
--- /dev/null
+++ b/patchoat/Android.bp
@@ -0,0 +1,46 @@
+//
+// Copyright (C) 2014 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.
+//
+
+cc_defaults {
+ name: "patchoat-defaults",
+ host_supported: true,
+ defaults: ["art_defaults"],
+ srcs: ["patchoat.cc"],
+ target: {
+ android: {
+ compile_multilib: "prefer32",
+ },
+ },
+}
+
+art_cc_binary {
+ name: "patchoat",
+ defaults: ["patchoat-defaults"],
+ shared_libs: [
+ "libart",
+ ],
+}
+
+art_cc_binary {
+ name: "patchoatd",
+ defaults: [
+ "patchoat-defaults",
+ "art_debug_defaults",
+ ],
+ shared_libs: [
+ "libartd",
+ ],
+}
diff --git a/patchoat/Android.mk b/patchoat/Android.mk
deleted file mode 100644
index 8f9ffca..0000000
--- a/patchoat/Android.mk
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# Copyright (C) 2014 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include art/build/Android.executable.mk
-
-PATCHOAT_SRC_FILES := \
- patchoat.cc
-
-# TODO: Remove this when the framework (installd) supports pushing the
-# right instruction-set parameter for the primary architecture.
-ifneq ($(filter ro.zygote=zygote64,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES)),)
- patchoat_arch := 64
-else
- patchoat_arch := 32
-endif
-
-ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
- $(eval $(call build-art-executable,patchoat,$(PATCHOAT_SRC_FILES),libcutils libsigchain,art/compiler,target,ndebug,$(patchoat_arch)))
-endif
-ifeq ($(ART_BUILD_TARGET_DEBUG),true)
- $(eval $(call build-art-executable,patchoat,$(PATCHOAT_SRC_FILES),libcutils libsigchain,art/compiler,target,debug,$(patchoat_arch)))
-endif
-
-# We always build patchoat and dependencies, even if the host build is otherwise disabled, since they are used to cross compile for the target.
-ifeq ($(ART_BUILD_HOST_NDEBUG),true)
- $(eval $(call build-art-executable,patchoat,$(PATCHOAT_SRC_FILES),libcutils libsigchain,art/compiler,host,ndebug))
-endif
-ifeq ($(ART_BUILD_HOST_DEBUG),true)
- $(eval $(call build-art-executable,patchoat,$(PATCHOAT_SRC_FILES),libcutils libsigchain,art/compiler,host,debug))
-endif
diff --git a/profman/Android.bp b/profman/Android.bp
new file mode 100644
index 0000000..f3b4e14
--- /dev/null
+++ b/profman/Android.bp
@@ -0,0 +1,54 @@
+//
+// Copyright (C) 2016 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.
+//
+
+cc_defaults {
+ name: "profman-defaults",
+ host_supported: true,
+ defaults: ["art_defaults"],
+ srcs: [
+ "profman.cc",
+ "profile_assistant.cc",
+ ],
+
+ target: {
+ android: {
+ compile_multilib: "prefer32",
+ },
+ },
+
+ include_dirs: [
+ "art/cmdline",
+ ],
+}
+
+art_cc_binary {
+ name: "profman",
+ defaults: ["profman-defaults"],
+ shared_libs: [
+ "libart",
+ ],
+}
+
+art_cc_binary {
+ name: "profmand",
+ defaults: [
+ "profman-defaults",
+ "art_debug_defaults",
+ ],
+ shared_libs: [
+ "libartd",
+ ],
+}
diff --git a/profman/Android.mk b/profman/Android.mk
deleted file mode 100644
index d38d107..0000000
--- a/profman/Android.mk
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# Copyright (C) 2016 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include art/build/Android.executable.mk
-
-PROFMAN_SRC_FILES := \
- profman.cc \
- profile_assistant.cc
-
-# TODO: Remove this when the framework (installd) supports pushing the
-# right instruction-set parameter for the primary architecture.
-ifneq ($(filter ro.zygote=zygote64,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES)),)
- profman_arch := 64
-else
- profman_arch := 32
-endif
-
-ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
- $(eval $(call build-art-executable,profman,$(PROFMAN_SRC_FILES),libcutils,art/profman,target,ndebug,$(profman_arch)))
-endif
-ifeq ($(ART_BUILD_TARGET_DEBUG),true)
- $(eval $(call build-art-executable,profman,$(PROFMAN_SRC_FILES),libcutils,art/profman,target,debug,$(profman_arch)))
-endif
-
-ifeq ($(ART_BUILD_HOST_NDEBUG),true)
- $(eval $(call build-art-executable,profman,$(PROFMAN_SRC_FILES),libcutils,art/profman,host,ndebug))
-endif
-ifeq ($(ART_BUILD_HOST_DEBUG),true)
- $(eval $(call build-art-executable,profman,$(PROFMAN_SRC_FILES),libcutils,art/profman,host,debug))
-endif