Skip to content

Add SPDX license id and copyright banners to source files needing them#545

Merged
jafingerhut merged 7 commits intop4lang:mainfrom
jafingerhut:add-license-id-and-copyright-banners-to-source-files
Apr 11, 2026
Merged

Add SPDX license id and copyright banners to source files needing them#545
jafingerhut merged 7 commits intop4lang:mainfrom
jafingerhut:add-license-id-and-copyright-banners-to-source-files

Conversation

@jafingerhut
Copy link
Copy Markdown
Contributor

@jafingerhut jafingerhut commented Feb 11, 2025

Status of this PR as of 2026-Apr-11:

I think it is reasonable to review this as it is now, and merge it if approved. The copyright names I have added to a few of the files match the name of the person who added the file to this repository, and the year they added it.

If later we learn from advice from someone at the Linux Foundation that some other name/year should be used (which seems unlikely to me), we can change it then.

Older status of this PR as of 2025-Mar-05:

Waiting on Andy finding someone that can give legal advice to P4.org as a whole on what the Copyright author and year should be across p4lang repositories.

What is their recommendation on who the copyright author should be? Should we use individual authors or a group ("The P4Runtime authors")? Should we have a CONTRIBUTORS file?

Signed-off-by: Andy Fingerhut <andy_fingerhut@alum.wustl.edu>
@jafingerhut
Copy link
Copy Markdown
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

Signed-off-by: Andy Fingerhut <andy_fingerhut@alum.wustl.edu>
@jafingerhut
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

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

@jafingerhut
Copy link
Copy Markdown
Contributor Author

jafingerhut commented Feb 14, 2025

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 the copyright author should be? Should we use individual authors or a group ("The P4Runtime authors")? Should we have a CONTRIBUTORS file?

@smolkaj
Copy link
Copy Markdown
Member

smolkaj commented Feb 12, 2026

This has been stale for a while. Do we want to pick it back up? Should we mark it obsolete?

@smolkaj
Copy link
Copy Markdown
Member

smolkaj commented Apr 10, 2026

WG update: currently not a priority, but Andy may pick this back up in a coupel of months.

…ght-banners-to-source-files

Signed-off-by: Andy Fingerhut <andy_fingerhut@alum.wustl.edu>
Signed-off-by: Andy Fingerhut <andy_fingerhut@alum.wustl.edu>
Signed-off-by: Andy Fingerhut <andy_fingerhut@alum.wustl.edu>
@jafingerhut
Copy link
Copy Markdown
Contributor Author

@chrispsommers @smolkaj I fixed the conflicts that had arisen between this PR and latest main branch version since last year, but made no other changes. I think it is reasonable to review it as it is now, and merge if approved.

If later we learn that the Linux Foundation has specific recommendations on what name to use on the copyright of files, we can make appropriate modifications at that time. This PR adds a name for the copyright of several files that did not already have a name. In all cases, I used the name of the person who first added the file to this repository, and the year that they added it, which seems legally safe.

Signed-off-by: Andy Fingerhut <andy_fingerhut@alum.wustl.edu>
Copy link
Copy Markdown
Member

@smolkaj smolkaj left a comment

Choose a reason for hiding this comment

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

Thanks!

@jafingerhut jafingerhut merged commit 593e1f6 into p4lang:main Apr 11, 2026
10 checks passed
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.

3 participants