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 license id and copyright banners to source files needing them #545

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

Conversation

jafingerhut
Copy link
Contributor

No description provided.

@jafingerhut
Copy link
Contributor Author

Assuming PR #546 enables the CI checks to pass for this PR in the near future, my intent is that this PR will be preferred over the earlier #543 for two reasons:

  • It uses a more automated flow for adding software license information to the files, in particular this new Python program I'm hacking up spdx-check.py [1] analyzes all files in a repo, and generates a Bash script that invokes addlicense [2], which you can then run to add full copyright banners, plus an SPDX license id line, for you (unless that program fails to add one, typically because there is a partial copyright notice already in the file, which requires hand-editing). I'm using the p4runtime repo as a guinea-pig for this couple of scripts, to see if they need enhancements.

  • This PR adds Apache copyright banners as well as SPDX license id lines.

[1] https://github.com/jafingerhut/test-spdx-checker
[2] https://github.com/google/addlicense

@jafingerhut
Copy link
Contributor Author

@chrispsommers @smolkaj I would like to talk about this PR at the next P4Runtime API meeting, in hopes of merging it, or deciding how to change it before it is merged.

@chrispsommers
Copy link
Collaborator

@chrispsommers @smolkaj I would like to talk about this PR at the next P4Runtime API meeting, in hopes of merging it, or deciding how to change it before it is merged.

For sure, it'll be on the agenda. Thanks!

@chrispsommers
Copy link
Collaborator

From addlicense:

The program ensures source code files have copyright license headers by scanning directory patterns recursively.
It modifies all source files in place and avoids adding a license header to any file that already has one.

So why are your scripts required, why can't addlicense be called directly?

@jafingerhut
Copy link
Contributor Author

jafingerhut commented Feb 14, 2025

From addlicense:

The program ensures source code files have copyright license headers by scanning directory patterns recursively.
It modifies all source files in place and avoids adding a license header to any file that already has one.

So why are your scripts required, why can't addlicense be called directly?

My spdx-check.py script is not required. You can call addlicense directly if you wish.

In a repo with 50 files that already have SPDX-License-Identifier lines, and 200 that do not, where you want to put a reasonable copyright author and year that differs across those 200 files, writing all of the addlicense commands with those different authors/years can be very tedious. spdx-check.py can create a Bash script with those different addlicense invocations, independent for each source file, for you.

Also, addlicense will not tell you if a file has a copyright notice, but lacks an SPDX-License-Identifier line, as far as I know. My spdx-check.py program will.

@chrispsommers
Copy link
Collaborator

Got it, I didn't realize you needed arguments to addlicense. Your script seems very helpful!

@jafingerhut
Copy link
Contributor Author

Copying this comment from Steffen, accidentally added to a different PR:

Question for Linux foundation from the P4 API WG discussion:

What is their recommendation on who to attribute the license to? Should we use individual authors or a group ("The P4Runtime authors")? Should we have a CONTRIBUTORS file?

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.

2 participants