Add the artd binary to the ART APEX
Test: none
Bug: 177273468
Change-Id: I443c49fe08400236bc16ba2d8c7768e6265392f5
diff --git a/artd/Android.bp b/artd/Android.bp
new file mode 100644
index 0000000..558b1ce
--- /dev/null
+++ b/artd/Android.bp
@@ -0,0 +1,50 @@
+//
+// Copyright (C) 2021 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.
+//
+
+art_cc_binary {
+ name: "artd",
+ defaults: ["art_defaults"],
+ min_sdk_version: "S",
+ host_supported: true,
+
+ srcs: [
+ "artd.cc",
+ ],
+
+ shared_libs: [
+ "libartbase",
+ "libarttools",
+ "libbase",
+ ],
+
+ target: {
+ host: {
+ stl: "c++_static",
+ },
+ },
+
+ apex_available: [
+ "com.android.art",
+ "com.android.art.debug",
+ ],
+}
+
+prebuilt_etc {
+ name: "com.android.art.artd.init.rc",
+ src: "artd.rc",
+ filename: "init.rc",
+ installable: false,
+}
diff --git a/artd/artd.cc b/artd/artd.cc
new file mode 100644
index 0000000..614a2f1
--- /dev/null
+++ b/artd/artd.cc
@@ -0,0 +1,53 @@
+/*
+** Copyright 2021, 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.
+*/
+
+#define LOG_TAG "artd"
+
+#include <unistd.h>
+
+#include "base/logging.h"
+#include "base/macros.h"
+#include "tools/tools.h"
+
+namespace {
+
+class Artd {
+ public:
+ Artd(ATTRIBUTE_UNUSED const int argc, ATTRIBUTE_UNUSED char* argv[]) {}
+
+ NO_RETURN
+ void Run() {
+ LOG(DEBUG) << "Starting artd";
+
+ while (true) {
+ // This is a scaffolding CL. This sleep is intended to keep the process
+ // alive for testing without it using too many system resources. This
+ // will be removed and replaced with a server loop in a followup CL.
+ sleep(5);
+ }
+ }
+};
+
+} // namespace
+
+int main(const int argc, char* argv[]) {
+ setenv("ANDROID_LOG_TAGS", "*:v", 1);
+ android::base::InitLogging(argv);
+
+ Artd artd(argc, argv);
+
+ artd.Run();
+}
diff --git a/artd/artd.rc b/artd/artd.rc
new file mode 100644
index 0000000..554cc1e
--- /dev/null
+++ b/artd/artd.rc
@@ -0,0 +1,17 @@
+# Copyright (C) 2021 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.
+
+service artd /apex/com.android.art/bin/artd
+ class core
+ user artd
\ No newline at end of file
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index 0f9a87f..a50bacd 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -251,6 +251,9 @@
native_shared_libs: art_runtime_base_native_shared_libs +
art_runtime_base_native_device_only_shared_libs +
libcore_native_shared_libs,
+ binaries: [
+ "artd",
+ ],
multilib: {
both: {
binaries: art_runtime_base_binaries_both +
@@ -270,6 +273,7 @@
],
prebuilts: [
"art-linker-config",
+ "com.android.art.artd.init.rc",
],
// ART APEXes depend on bouncycastle which is disabled for PDK builds.
// Since the dependency is disabled, ART APEXes can't be built either.
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py
index 3eeb7fc..9044fc7 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -519,6 +519,7 @@
self._checker.check_file('apex_manifest.pb')
# Check binaries for ART.
+ self._checker.check_executable('artd')
self._checker.check_first_executable('dex2oat')
self._checker.check_executable('dexdump')
self._checker.check_executable('dexlist')