Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Third-party crates support: proc-macro2, quote, syn, serde and serde_derive #1007

Open
wants to merge 16 commits into
base: rust-next
Choose a base branch
from

Commits on May 8, 2023

  1. rust: proc-macro2: import crate

    This is a subset of the Rust `proc-macro2` crate,
    version 1.0.46, licensed under "Apache-2.0 OR MIT", from:
    
        https://github.com/dtolnay/proc-macro2/raw/1.0.46/src
    
    The files are copied as-is, with no modifications whatsoever
    (not even adding the SPDX identifiers).
    
    For copyright details, please see:
    
        https://github.com/dtolnay/proc-macro2/blob/1.0.46/README.md#license
        https://github.com/dtolnay/proc-macro2/blob/1.0.46/LICENSE-APACHE
        https://github.com/dtolnay/proc-macro2/blob/1.0.46/LICENSE-MIT
    
    The next two patches modify these files as needed for use within
    the kernel. This patch split allows reviewers to double-check
    the import and to clearly see the differences introduced.
    
    The following script may be used to verify the contents:
    
        for path in $(cd rust/proc-macro2/ && find . -type f -name '*.rs'); do
            curl --silent --show-error --location \
                https://github.com/dtolnay/proc-macro2/raw/1.0.46/src/$path \
                | diff --unified rust/proc-macro2/$path - && echo $path: OK
        done
    
    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    4d28d13 View commit details
    Browse the repository at this point in the history
  2. rust: proc-macro2: add SPDX License Identifiers

    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    ff8917c View commit details
    Browse the repository at this point in the history
  3. rust: proc-macro2: remove unicode_ident dependency

    The `proc-macro2` crate depends on the `unicode-ident` crate
    to determine whether characters have the XID_Start or XID_Continue
    properties according to Unicode Standard Annex torvalds#31.
    
    However, we only need ASCII identifiers in the kernel, thus we can
    simplify the check and remove completely that dependency.
    
    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    bb40745 View commit details
    Browse the repository at this point in the history
  4. rust: quote: import crate

    This is a subset of the Rust `quote` crate,
    version 1.0.21, licensed under "Apache-2.0 OR MIT", from:
    
        https://github.com/dtolnay/quote/raw/1.0.21/src
    
    The files are copied as-is, with no modifications whatsoever
    (not even adding the SPDX identifiers).
    
    For copyright details, please see:
    
        https://github.com/dtolnay/quote/blob/1.0.21/README.md#license
        https://github.com/dtolnay/quote/blob/1.0.21/LICENSE-APACHE
        https://github.com/dtolnay/quote/blob/1.0.21/LICENSE-MIT
    
    The next patch modifies these files as needed for use within
    the kernel. This patch split allows reviewers to double-check
    the import and to clearly see the differences introduced.
    
    The following script may be used to verify the contents:
    
        for path in $(cd rust/quote/ && find . -type f -name '*.rs'); do
            curl --silent --show-error --location \
                https://github.com/dtolnay/quote/raw/1.0.21/src/$path \
                | diff --unified rust/quote/$path - && echo $path: OK
        done
    
    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    90523af View commit details
    Browse the repository at this point in the history
  5. rust: quote: add SPDX License Identifiers

    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    d7f4b0d View commit details
    Browse the repository at this point in the history
  6. rust: syn: import crate

    This is a subset of the Rust `syn` crate,
    version 1.0.104, licensed under "Apache-2.0 OR MIT", from:
    
        https://github.com/dtolnay/syn/raw/1.0.104/src
    
    The files are copied as-is, with no modifications whatsoever
    (not even adding the SPDX identifiers).
    
    For copyright details, please see:
    
        https://github.com/dtolnay/syn/blob/1.0.104/README.md#license
        https://github.com/dtolnay/syn/blob/1.0.104/LICENSE-APACHE
        https://github.com/dtolnay/syn/blob/1.0.104/LICENSE-MIT
    
    The next two patches modify these files as needed for use within
    the kernel. This patch split allows reviewers to double-check
    the import and to clearly see the differences introduced.
    
    The following script may be used to verify the contents:
    
        for path in $(cd rust/syn/ && find . -type f -name '*.rs'); do
            curl --silent --show-error --location \
                https://github.com/dtolnay/syn/raw/1.0.104/src/$path \
                | diff --unified rust/syn/$path - && echo $path: OK
        done
    
    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    313e6c9 View commit details
    Browse the repository at this point in the history
  7. rust: syn: add SPDX License Identifiers

    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    f9bcfd0 View commit details
    Browse the repository at this point in the history
  8. rust: syn: remove unicode-ident dependency

    The `syn` crate depends on the `unicode-ident` crate
    to determine whether characters have the XID_Start or XID_Continue
    properties according to Unicode Standard Annex torvalds#31.
    
    However, we only need ASCII identifiers in the kernel, thus we can
    simplify the check and remove completely that dependency.
    
    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    3916aa6 View commit details
    Browse the repository at this point in the history
  9. rust: serde: import crate

    This is a subset of the Rust `serde` crate,
    version v1.0.156, licensed under "Apache-2.0 OR MIT", from:
    
        https://github.com/serde-rs/serde/tree/v1.0.156/serde/src
    
    The files are copied as-is, with no modifications whatsoever
    (not even adding the SPDX identifiers).
    
    For copyright details, please see:
    
        https://github.com/serde-rs/serde/blob/v1.0.156/README.md#license
        https://github.com/serde-rs/serde/blob/v1.0.156/LICENSE-APACHE
        https://github.com/serde-rs/serde/blob/v1.0.156/LICENSE-MIT
    
    The next three patches modify these files as needed for use within
    the kernel. This patch split allows reviewers to double-check
    the import and to clearly see the differences introduced.
    
    The following script may be used to verify the contents:
    
        for path in $(cd rust/serde/ && find . -type f -name '*.rs'); do
            curl --silent --show-error --location \
                https://github.com/serde-rs/serde/raw/v1.0.156/serde/src/$path \
                | diff --unified rust/serde/$path - && echo $path: OK
        done
    
    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    2e4b1b4 View commit details
    Browse the repository at this point in the history
  10. rust: serde: add no_fp_fmt_parse support

    We do not have formatting for floating point in the kernel,
    thus simple compile out all that.
    
    Probably we should name it differently, more similar to `integer128`.
    
    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    7fcbf51 View commit details
    Browse the repository at this point in the history
  11. rust: serde: enable the core_c_str feature

    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    22605b8 View commit details
    Browse the repository at this point in the history
  12. rust: serde: add SPDX License Identifiers

    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    b56a317 View commit details
    Browse the repository at this point in the history
  13. rust: serde_derive: import crate

    This is a subset of the Rust `serde_derive` crate,
    version v1.0.156, licensed under "Apache-2.0 OR MIT", from:
    
        https://github.com/serde-rs/serde/tree/v1.0.156/serde_derive/src
    
    The files are copied as-is, with no modifications whatsoever
    (not even adding the SPDX identifiers).
    
    For copyright details, please see:
    
        https://github.com/serde-rs/serde/blob/v1.0.156/README.md#license
        https://github.com/serde-rs/serde/blob/v1.0.156/LICENSE-APACHE
        https://github.com/serde-rs/serde/blob/v1.0.156/LICENSE-MIT
    
    The next patch modifies these files as needed for use within
    the kernel. This patch split allows reviewers to double-check
    the import and to clearly see the differences introduced.
    
    The following script may be used to verify the contents:
    
        for path in $(cd rust/serde_derive/ && find . -type f -name '*.rs'); do
            curl --silent --show-error --location \
                https://github.com/serde-rs/serde/raw/v1.0.156/serde_derive/src/$path \
                | diff --unified rust/serde_derive/$path - && echo $path: OK
        done
    
    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    6f37f9b View commit details
    Browse the repository at this point in the history
  14. rust: serde_derive: add SPDX License Identifiers

    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    16bebcf View commit details
    Browse the repository at this point in the history
  15. rust: Kbuild: enable proc-macro2, quote, syn, serde and `serd…

    …e_derive`
    
    With all the new files in place from the new crates, this patch
    adds support for them in the build system.
    
    Note that, if we decide to add third-party crates support to upstream, we would
    probably want to do it in a different way. But this is useful for playing around
    with these crates, experimenting, etc.
    
    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    9121b11 View commit details
    Browse the repository at this point in the history
  16. rust: test serde support

    A trivial example based on `serde`'s `example-format' [1].
    
    It contains both a in-`kernel` data format later used by
    the kernel module, as well as a local data format in
    the module.
    
    The kernel module gives an output such as:
    
        [    0.801425] rust_serde: Rust serde sample (init)
        [    0.801634] rust_serde:             original = S { a: (), b: false, c: true, d: () }
        [    0.802079] rust_serde:           serialized = [2, 0, 1, 0, 1, 1, 0, 3]
        [    0.802506] rust_serde:         deserialized = S { a: (), b: false, c: true, d: () }
        [    0.802718] rust_serde:   serialized (local) = [2, 0, 1, 42, 1, 43, 0, 3]
        [    0.802895] rust_serde: deserialized (local) = S { a: (), b: false, c: true, d: () }
        [    0.808954] rust_serde: Rust serde sample (exit)
    
    Note that this is just a quick draft/hack to check the previous
    commits work. It is not intended to be merged at all.
    
    Link: https://github.com/serde-rs/example-format [1]
    Signed-off-by: Miguel Ojeda <[email protected]>
    ojeda committed May 8, 2023
    Configuration menu
    Copy the full SHA
    7d2ea51 View commit details
    Browse the repository at this point in the history