record-finalized-flags: convert to Rust
Bug: 377676163
Test: m record-finalized-flags
Test: atest record-finalized-flags-test
Merged-In: Id6cc4dea2e0bf13858d4f698fecffe2537161bb2
Change-Id: Id6cc4dea2e0bf13858d4f698fecffe2537161bb2
diff --git a/tools/record-finalized-flags/.gitignore b/tools/record-finalized-flags/.gitignore
new file mode 100644
index 0000000..1e7caa9
--- /dev/null
+++ b/tools/record-finalized-flags/.gitignore
@@ -0,0 +1,2 @@
+Cargo.lock
+target/
diff --git a/tools/record-finalized-flags/Android.bp b/tools/record-finalized-flags/Android.bp
index 63bcc2d..45065e4 100644
--- a/tools/record-finalized-flags/Android.bp
+++ b/tools/record-finalized-flags/Android.bp
@@ -1,4 +1,25 @@
-sh_binary_host {
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+rust_defaults {
+ name: "record-finalized-flags-defaults",
+ edition: "2021",
+ clippy_lints: "android",
+ lints: "android",
+ srcs: ["src/main.rs"],
+ rustlibs: [
+ "libanyhow",
+ ],
+}
+
+rust_binary_host {
name: "record-finalized-flags",
- src: "record-finalized-flags.sh",
+ defaults: ["record-finalized-flags-defaults"],
+}
+
+rust_test_host {
+ name: "record-finalized-flags-test",
+ defaults: ["record-finalized-flags-defaults"],
+ test_suites: ["general-tests"],
}
diff --git a/tools/record-finalized-flags/Cargo.toml b/tools/record-finalized-flags/Cargo.toml
new file mode 100644
index 0000000..ae895a4
--- /dev/null
+++ b/tools/record-finalized-flags/Cargo.toml
@@ -0,0 +1,12 @@
+# Cargo.toml file to allow rapid development of record-finalized-flags using
+# cargo. Soong is the official Android build system, and the only system
+# guaranteed to support record-finalized-flags. If there is ever any issue with
+# the cargo setup, support for cargo will be dropped and this file removed.
+
+[package]
+name = "record-finalized-flags"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+anyhow = { path = "../../../../external/rust/android-crates-io/crates/anyhow" }
diff --git a/tools/record-finalized-flags/record-finalized-flags.sh b/tools/record-finalized-flags/record-finalized-flags.sh
deleted file mode 100644
index 1d85ae9..0000000
--- a/tools/record-finalized-flags/record-finalized-flags.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash -e
-#
-# Copyright 2024 Google Inc. All rights reserved.
-#
-# 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.
-
-# TODO: implement this tool
-echo "record-finalized-flags.sh $*"
diff --git a/tools/record-finalized-flags/src/main.rs b/tools/record-finalized-flags/src/main.rs
new file mode 100644
index 0000000..ceb975e
--- /dev/null
+++ b/tools/record-finalized-flags/src/main.rs
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2025 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.
+ */
+
+//! `record-finalized-flags` is a tool to create a snapshot (intended to be stored in
+//! prebuilts/sdk) of the flags used with @FlaggedApi APIs
+use anyhow::Result;
+
+fn main() -> Result<()> {
+ println!("{:?}", std::env::args());
+ Ok(())
+}
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn test() {}
+}