diff options
author | Martin Geisler <mgeisler@google.com> | 2024-03-21 15:40:16 +0100 |
---|---|---|
committer | Martin Geisler <mgeisler@google.com> | 2024-03-26 17:42:39 +0100 |
commit | 52011b19398dbb4eff4663f5788e150c1b9c3bde (patch) | |
tree | a4342efe5f3f31055cb6ec7354e1ea0679f7f223 | |
parent | 56ddb4df65fec2d06b2aaab9b667360509e8a671 (diff) | |
download | darling_macro-52011b19398dbb4eff4663f5788e150c1b9c3bde.tar.gz |
Import 'darling_macro' crateupstream
Request Document: go/android-rust-importing-crates
For CL Reviewers: go/android3p#cl-review
For Build Team: go/ab-third-party-imports
Bug: http://b/328420133
Test: m libdarling_macro
Change-Id: I1bf8aef84b9e50df4fc183313e3a7954de11c5ea
-rw-r--r-- | .cargo_vcs_info.json | 6 | ||||
-rw-r--r-- | Android.bp | 17 | ||||
-rw-r--r-- | Cargo.lock | 72 | ||||
-rw-r--r-- | Cargo.toml | 34 | ||||
-rw-r--r-- | LICENSE | 21 | ||||
-rw-r--r-- | METADATA | 20 | ||||
-rw-r--r-- | MODULE_LICENSE_MIT | 0 | ||||
-rw-r--r-- | OWNERS | 2 | ||||
-rw-r--r-- | cargo_embargo.json | 8 | ||||
-rw-r--r-- | src/lib.rs | 40 |
10 files changed, 220 insertions, 0 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json new file mode 100644 index 0000000..9ae55c8 --- /dev/null +++ b/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "25ce6ecc079c58a18cbecbdcc98bf8d647410edd" + }, + "path_in_vcs": "macro" +}
\ No newline at end of file diff --git a/Android.bp b/Android.bp new file mode 100644 index 0000000..f73ebd8 --- /dev/null +++ b/Android.bp @@ -0,0 +1,17 @@ +// This file is generated by cargo_embargo. +// Do not modify this file as changes will be overridden on upgrade. + +// TODO: Add license. +rust_proc_macro { + name: "libdarling_macro", + crate_name: "darling_macro", + cargo_env_compat: true, + cargo_pkg_version: "0.20.8", + srcs: ["src/lib.rs"], + edition: "2018", + rustlibs: [ + "libdarling_core", + "libquote", + "libsyn", + ], +} diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..f5e2af1 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,72 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "darling_core" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.8" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "2.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..779f3b1 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,34 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +name = "darling_macro" +version = "0.20.8" +authors = ["Ted Driggs <ted.driggs@outlook.com>"] +description = """ +Internal support for a proc-macro library for reading attributes into structs when +implementing custom derives. Use https://crates.io/crates/darling in your code. +""" +license = "MIT" +repository = "https://github.com/TedDriggs/darling" + +[lib] +proc-macro = true + +[dependencies.darling_core] +version = "=0.20.8" + +[dependencies.quote] +version = "1.0.18" + +[dependencies.syn] +version = "2.0.15" @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Ted Driggs + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/METADATA b/METADATA new file mode 100644 index 0000000..94e6da0 --- /dev/null +++ b/METADATA @@ -0,0 +1,20 @@ +name: "darling_macro" +description: "()" +third_party { + identifier { + type: "crates.io" + value: "darling_macro" + } + identifier { + type: "Archive" + value: "https://static.crates.io/crates/darling_macro/darling_macro-0.20.8.crate" + primary_source: true + } + version: "0.20.8" + license_type: NOTICE + last_upgrade_date { + year: 2024 + month: 3 + day: 6 + } +} diff --git a/MODULE_LICENSE_MIT b/MODULE_LICENSE_MIT new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/MODULE_LICENSE_MIT @@ -0,0 +1,2 @@ +# Bug component: 688011 +include platform/prebuilts/rust:main:/OWNERS diff --git a/cargo_embargo.json b/cargo_embargo.json new file mode 100644 index 0000000..65331e6 --- /dev/null +++ b/cargo_embargo.json @@ -0,0 +1,8 @@ +{ + "run_cargo": false, + "package": { + "darling_macro": { + "device_supported": false + } + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..8da0272 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,40 @@ +use darling_core::{derive, Error}; +use proc_macro::TokenStream; +use syn::parse_macro_input; + +#[proc_macro_derive(FromMeta, attributes(darling))] +pub fn derive_from_meta(input: TokenStream) -> TokenStream { + derive::from_meta(&parse_macro_input!(input)).into() +} + +#[proc_macro_derive(FromMetaItem, attributes(darling))] +pub fn derive_from_meta_item(_input: TokenStream) -> TokenStream { + Error::custom("darling::FromMetaItem has been replaced by darling::FromMeta") + .write_errors() + .into() +} + +#[proc_macro_derive(FromAttributes, attributes(darling))] +pub fn derive_from_attributes(input: TokenStream) -> TokenStream { + derive::from_attributes(&parse_macro_input!(input)).into() +} + +#[proc_macro_derive(FromDeriveInput, attributes(darling))] +pub fn derive_from_input(input: TokenStream) -> TokenStream { + derive::from_derive_input(&parse_macro_input!(input)).into() +} + +#[proc_macro_derive(FromField, attributes(darling))] +pub fn derive_field(input: TokenStream) -> TokenStream { + derive::from_field(&parse_macro_input!(input)).into() +} + +#[proc_macro_derive(FromTypeParam, attributes(darling))] +pub fn derive_type_param(input: TokenStream) -> TokenStream { + derive::from_type_param(&parse_macro_input!(input)).into() +} + +#[proc_macro_derive(FromVariant, attributes(darling))] +pub fn derive_variant(input: TokenStream) -> TokenStream { + derive::from_variant(&parse_macro_input!(input)).into() +} |