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

Add SPDX headers #1532

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

nicholasbishop
Copy link
Member

  • The first commit adds SPDX headers to the two generated source files.
  • The second commit adds xtask code for checking/adding SPDX headers.
  • The next five commits add the SPDX headers to uefi-macros, uefi-raw, uefi-test-runner, uefi, and xtask directories
  • The final commit makes the xtask header check fatal if any headers are missing.

Closes #1511

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
  • Update the changelog (if necessary)

This will be used to verify that source files (just *.rs for now) all have an
SPDX license header. In non-check mode, the license header will be added.

For now, in check mode an error is shown but it's not treated as fatal. Once all
files have been fixed, the error will be made fatal.
let paths = std::str::from_utf8(&output.stdout)?.lines();

// Path prefixes that should not be checked/formatted.
let exclude_path_prefixes = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This could be a more prominent constant

"uefi-macros/tests/ui/",
];

let expected_header = "// SPDX-License-Identifier: MIT OR Apache-2.0\n\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also make this a constant; close to the new constant mentioned above?

// Paths that are missing the file header (only used in check mode).
let mut missing = Vec::new();

for path in paths {
Copy link
Contributor

@phip1611 phip1611 Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this could be written more nice

paths.into_iter()
  .filter(|path| !exclude_path_prefixes.any(|e| e.startsWith(path)))
  .filter(|path| {
    let text = fs_err::read_to_string(path)?;
    !text.startsWith(expected_header)
  })
  .forEach(|missing| /* ... */)

Copy link
Contributor

@phip1611 phip1611 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for working on this! Left a few remarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SPDX IDs
2 participants