Skip to content

Commit

Permalink
Prepare to update copyrights (#1559)
Browse files Browse the repository at this point in the history
* Remove year from template
* Add originating year and organizations
* Make copyright contribution more explicit
* Improve and genericise copyright text for script generation
* Update modeline
* Reindent PR template for consistency
  • Loading branch information
sethrj authored Jan 2, 2025
1 parent f7eba01 commit 2cce92e
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 70 deletions.
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ c93d9582552e2d7ad4e18d9d74b7e9e62de53c0e
7a0f476ae128025a8843ba2b1e6e6284efb7d0dd
c06d0a263847884aff7aefc9280c758860ea5fc2
f27dc24aac631ebfea4f487a0d122a0e69d3c083
f7eba0148dcc1b8f284aaa63643658dbe11a9507
# clang-format and IWYU
0e14b341e12eb750b627e7d61602e50c68db2551
954cd07322312b43eb7dc926abd0054f630a8eff
Expand Down
17 changes: 15 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,30 @@ If you're a core developer, add one of each label:
- Change type: {bug, documentation, enhancement, minor}
- Category: {app, core, external, field, orange, performance, physics, user}

Some examples of labels are:
Some examples of labels corresponding to titles are:
- *Implement the FooBar model*: enhancement, physics
- *Handle errors in track initialization*: enhancement, orange
- *Fix sampling of low-energy Celeritons*: bug, physics
- *Refactor code in preparation for new tracker type*: minor, orange
- *Add CI support for multiple Geant4 versions*: enhancement, documentation

See [review process](https://github.com/celeritas-project/celeritas/blob/develop/doc/appendix/administration.rst#code-review) for descriptions of the labels and requirements.
See [review process](https://celeritas-project.github.io/celeritas/user/appendix/administration.html#code-review) for descriptions of the labels and requirements.

# Draft status

The final button to push, "Create pull request", has an drop-down menu arrow
next to it that lets you change to "Draft pull request". Select this option if
you want to run further testing before beginning the review process.

# Copyright

Copyrights and patents in the Celeritas project are retained by contributors.
No copyright assignment is required to contribute to Celeritas, but by
submitting content in this pull request, *you are confirming that you have the
right to make your contribution to Celeritas, and that if you are making your
contribution in the course of your employment, that such contributions are
authorized by your employer.*

See [the top-level COPYRIGHT file](https://github.com/celeritas-project/celeritas/blob/develop/COPYRIGHT)
for details on code copyright, or [the documentation COPYRIGHT file](https://github.com/celeritas-project/celeritas/blob/develop/doc/COPYRIGHT)
for the documentation license.
12 changes: 11 additions & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ or http://www.apache.org/licenses/LICENSE-2.0) or the MIT license,
(LICENSE-MIT or http://opensource.org/licenses/MIT), at your option.

Copyrights and patents in the Celeritas project are retained by contributors.
No copyright assignment is required to contribute to Celeritas.
No copyright assignment is required to contribute to Celeritas, but by
submitting content in a pull request, you are confirming that you have the
right to make your contribution to Celeritas, and that if you are making your
contribution in the course of your employment, that such contributions are
authorized by your employer.

Celeritas was originally developed in 2020 by developers at Oak Ridge National
Laboratory (UT-Battelle, LLC), Fermi National Accelerator Laboratory
(Fermi Research Alliance, LLC), Argonne National Laboratory
(UChicago Argonne, LLC), and Lawrence Berkeley National Laboratory (University
of California).


SPDX usage
Expand Down
134 changes: 67 additions & 67 deletions scripts/dev/celeritas-gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,29 @@

###############################################################################

CXX_TOP = '''\
//{modeline:-^75s}//
// Copyright {year} UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \\file {dirname}{basename}
//---------------------------------------------------------------------------//
'''
def _make_top(comment_prefix, preamble=None, postamble=None):
lines = []
def _append_lines(s):
if s:
if isinstance(s, str):
lines.append(s)
else:
lines.extend(s)
_append_lines(preamble)
lines.extend(comment_prefix + " " + line for line in [
"Copyright Celeritas contributors: see top-level COPYRIGHT file for details",
"SPDX-License-Identifier: (Apache-2.0 OR MIT)",
])
_append_lines(postamble)
lines.append("")
return "\n".join(lines)

_C_SEP = "".join(["//", "-" * 75, "//"]) # //-----...---//
CXX_TOP = _make_top(
"//",
"//{modeline:-^75s}//",
[_C_SEP, "//! \\file {dirname}{basename}", _C_SEP]
)

HEADER_FILE = '''\
#pragma once
Expand Down Expand Up @@ -75,6 +89,18 @@ class {name}
{namespace_end}
'''

C_HEADER_FILE = '''\
#pragma once
//---------------------------------------------------------------------------//
'''

C_CODE_FILE = '''\
#include "{name}.{hext}"
//---------------------------------------------------------------------------//
'''

TEST_HARNESS_FILE = '''\
#include "{dirname}{name}.{hext}"
Expand Down Expand Up @@ -286,21 +312,7 @@ class {name}Test : public ::celeritas::test::Test
'''


SWIG_FILE = '''\
%{{
#include "{name}.{hext}"
%}}
%include "{name}.{hext}"
'''


CMAKE_TOP = '''\
#{modeline:-^77s}#
# Copyright {year} UT-Battelle, LLC, and other Celeritas developers.
# See the top-level COPYRIGHT file for details.
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
'''
CMAKE_TOP = _make_top("#", "#{modeline:-^77s}#")

CMAKELISTS_FILE = '''\
#-----------------------------------------------------------------------------#
Expand Down Expand Up @@ -341,35 +353,25 @@ class {name}Test : public ::celeritas::test::Test
#-----------------------------------------------------------------------------#
'''

PYTHON_TOP = '''\
#!/usr/bin/env python3
# Copyright {year} UT-Battelle, LLC, and other Celeritas developers.
# See the top-level COPYRIGHT file for details.
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
'''
PYTHON_TOP = _make_top("#", "#!/usr/bin/env python")

PYTHON_FILE = '''\
"""
"""
'''

SHELL_TOP = '''\
#!/bin/sh -ex
# Copyright {year} UT-Battelle, LLC, and other Celeritas developers.
# See the top-level COPYRIGHT file for details.
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
'''
SHELL_TOP = _make_top(
"#",
["#!/bin/sh -ex", "#{modeline:-^77s}#"],
"#{:-^77s}#".format("")
)

SHELL_FILE = '''\
'''

OMN_TOP = '''\
! Copyright {year} UT-Battelle, LLC, and other Celeritas developers.
! See the top-level COPYRIGHT file for details.
! SPDX-License-Identifier: (Apache-2.0 OR MIT)
'''
OMN_TOP = _make_top("!")

ORANGE_FILE = '''
[GEOMETRY]
Expand Down Expand Up @@ -402,11 +404,7 @@ class {name}Test : public ::celeritas::test::Test
shapes world_box ~mycyl
'''

RST_TOP = '''\
.. Copyright {year} UT-Battelle, LLC, and other Celeritas developers.
.. See the doc/COPYRIGHT file for details.
.. SPDX-License-Identifier: CC-BY-4.0
'''
RST_TOP = _make_top("..")

RST_FILE = '''
.. _{name}:
Expand Down Expand Up @@ -437,16 +435,15 @@ class {name}Test : public ::celeritas::test::Test
int i = 0;
'''

YEAR = datetime.today().year

TEMPLATES = {
'hh': HEADER_FILE,
'c': C_CODE_FILE,
'h': C_HEADER_FILE,
'cc': CODE_FILE,
'cu': CODE_FILE,
'test.cc': TEST_HARNESS_FILE,
'test.cu': TEST_CODE_FILE,
'test.hh': TEST_HEADER_FILE,
'i': SWIG_FILE,
'cmake': CMAKE_FILE,
'CMakeLists.txt': CMAKELISTS_FILE,
'py': PYTHON_FILE,
Expand All @@ -457,32 +454,33 @@ class {name}Test : public ::celeritas::test::Test

LANG = {
'h': "C",
'c': "C",
'hh': "C++",
'cc': "C++",
'cu': "CUDA",
'cmake': "CMake",
'CMakeLists.txt': "CMake",
'py': "Python",
'sh': "Shell",
'omn': "Omnibus",
'rst': "RST",
'cu': "cuda",
'cmake': "cmake",
'CMakeLists.txt': "cmake",
'py': "python",
'sh': "sh",
'omn': "omnibus",
'rst': "rst",
}

TOPS = {
'C': CXX_TOP,
'C++': CXX_TOP,
'CUDA': CXX_TOP,
'CMake': CMAKE_TOP,
'Python': PYTHON_TOP,
'Shell': SHELL_TOP,
'Omnibus': OMN_TOP,
'RST': RST_TOP,
'cuda': CXX_TOP,
'cmake': CMAKE_TOP,
'python': PYTHON_TOP,
'sh': SHELL_TOP,
'omnibus': OMN_TOP,
'rst': RST_TOP,
}

HEXT = {
'C': "h",
'C++': "hh",
'CUDA': "hh",
'cuda': "hh",
}


Expand All @@ -493,6 +491,9 @@ def generate(repodir, filename, namespace):

dirname = os.path.relpath(filename, start=repodir)
all_dirs = dirname.split(os.sep)[:-1]
if not all_dirs:
print("Cannot generate files in the top level of the repository")
sys.exit(1)

if namespace is None:
namespace = 'celeritas'
Expand Down Expand Up @@ -537,8 +538,8 @@ def generate(repodir, filename, namespace):
variables = {
'longext': longext,
'ext': ext,
'hext': "hh",
'modeline': "-*-{}-*-".format(lang),
'hext': "hh" if lang != "C" else "h",
'modeline': f" -*- {lang} -*- ",
'name': name,
'namespace': namespace,
'namespace_begin': "\n".join(nsbeg),
Expand All @@ -547,8 +548,7 @@ def generate(repodir, filename, namespace):
'dirname': dirname,
'capabbr': capabbr,
'lowabbr': capabbr.lower(),
'year': YEAR,
'corecel_ns': "", # or "celeritas::" or someday "corecel::"
'corecel_ns': "", # or "celeritas::" or someday(?) "corecel::"
'celeritas_ns': "",
}
with open(filename, 'w') as f:
Expand Down

0 comments on commit 2cce92e

Please sign in to comment.