Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e2fc024b authored by Martin Geisler's avatar Martin Geisler Committed by Cherrypicker Worker
Browse files

pdl: Remove module-level allow(…) attribute

This is in preparation for integration into rootcanal. The rootcanal
code includes the generated code via ‘include!’. This breaks because
of the module-level allow attribute.

Tag: #feature
Bug: 228306436
Test: atest pdl_tests pdl_rust_generator_tests_{le,be}
(cherry picked from https://android-review.googlesource.com/q/commit:e90589bf7ce3b0d21e400bc76dd4bf7d5cf366e6)
Merged-In: Ib47eac26c94ede4f51297b096edeee6b43da693d
Change-Id: Ib47eac26c94ede4f51297b096edeee6b43da693d
parent 1f3cd3bc
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -159,6 +159,8 @@ rust_library_host {
    crate_name: "pdl_le_backend",
    srcs: [":pdl_le_backend"],
    defaults: ["pdl_backend_defaults"],
    clippy_lints: "none",
    lints: "none",
}

rust_library_host {
@@ -166,6 +168,8 @@ rust_library_host {
    crate_name: "pdl_be_backend",
    srcs: [":pdl_be_backend"],
    defaults: ["pdl_backend_defaults"],
    clippy_lints: "none",
    lints: "none",
}

rust_binary_host {
@@ -218,6 +222,8 @@ rust_test_host {
        "libpdl_le_backend",
        "libserde_json",
    ],
    clippy_lints: "none",
    lints: "none",
}

rust_test_host {
@@ -229,6 +235,8 @@ rust_test_host {
        "libpdl_be_backend",
        "libserde_json",
    ],
    clippy_lints: "none",
    lints: "none",
}

// Defaults for PDL python backend generation.
+14 −3
Original line number Diff line number Diff line
@@ -6,11 +6,22 @@ use crate::quote_block;
pub fn generate(path: &Path) -> String {
    let mut code = String::new();
    let filename = path.file_name().unwrap().to_str().expect("non UTF-8 filename");
    // TODO(mgeisler): Make the  generated code free from warnings.
    //
    // The code either needs
    //
    // clippy_lints: "none",
    // lints: "none",
    //
    // in the Android.bp file, or we need to add
    //
    // #![allow(warnings, missing_docs)]
    //
    // to the generated code. We cannot add the module-level attribute
    // here because of how the generated code is used with include! in
    // lmp/src/packets.rs.
    code.push_str(&format!("// @generated rust packets from {filename}\n\n"));

    // TODO(mgeisler): make the generated code clean from warnings.
    code.push_str("#![allow(warnings, missing_docs)]\n\n");

    code.push_str(&quote_block! {
        use bytes::{Buf, BufMut, Bytes, BytesMut};
        use num_derive::{FromPrimitive, ToPrimitive};
+0 −2
Original line number Diff line number Diff line
// @generated rust packets from test

#![allow(warnings, missing_docs)]

use bytes::{Buf, BufMut, Bytes, BytesMut};
use num_derive::{FromPrimitive, ToPrimitive};
use num_traits::{FromPrimitive, ToPrimitive};
+0 −2
Original line number Diff line number Diff line
// @generated rust packets from test

#![allow(warnings, missing_docs)]

use bytes::{Buf, BufMut, Bytes, BytesMut};
use num_derive::{FromPrimitive, ToPrimitive};
use num_traits::{FromPrimitive, ToPrimitive};
+0 −2
Original line number Diff line number Diff line
// @generated rust packets from test

#![allow(warnings, missing_docs)]

use bytes::{Buf, BufMut, Bytes, BytesMut};
use num_derive::{FromPrimitive, ToPrimitive};
use num_traits::{FromPrimitive, ToPrimitive};
Loading