cola-cli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cola_cli/__init__.py +3 -0
- cola_cli/__main__.py +3 -0
- cola_cli/builders.py +347 -0
- cola_cli/cli.py +177 -0
- cola_cli/common.py +98 -0
- cola_cli/environment.py +245 -0
- cola_cli/runtime.py +25 -0
- cola_cli/scripts/install.jl +10 -0
- cola_cli/scripts/locking.gradle +9 -0
- cola_cli/setup.py +163 -0
- cola_cli/sources.py +256 -0
- cola_cli/templates/common/.editorconfig.j2 +15 -0
- cola_cli/templates/common/.gitignore.j2 +20 -0
- cola_cli/templates/common/cola.toml.j2 +8 -0
- cola_cli/templates/cpp/.clang-format.j2 +6 -0
- cola_cli/templates/cpp/.clang-tidy.j2 +4 -0
- cola_cli/templates/cpp/CMakeLists.txt.j2 +51 -0
- cola_cli/templates/cpp/include/{{ name }}.hh.j2 +23 -0
- cola_cli/templates/cpp/src/{{ name }}.cc.j2 +3 -0
- cola_cli/templates/fortran/.fprettify.rc.j2 +2 -0
- cola_cli/templates/fortran/CMakeLists.txt.j2 +63 -0
- cola_cli/templates/fortran/src/{{ name }}.f90.j2 +73 -0
- cola_cli/templates/java/CMakeLists.txt.j2 +33 -0
- cola_cli/templates/java/build.gradle.kts.j2 +35 -0
- cola_cli/templates/java/config/checkstyle/checkstyle.xml.j2 +19 -0
- cola_cli/templates/java/settings.gradle.kts.j2 +1 -0
- cola_cli/templates/java/src/main/java/org/cola/generated/{{ package }}/{{ name }}Converter.java.j2 +9 -0
- cola_cli/templates/java/src/main/java/org/cola/generated/{{ package }}/{{ name }}Generator.java.j2 +9 -0
- cola_cli/templates/java/src/main/java/org/cola/generated/{{ package }}/{{ name }}Writer.java.j2 +9 -0
- cola_cli/templates/julia/.JuliaFormatter.toml.j2 +2 -0
- cola_cli/templates/julia/Project.toml.j2 +10 -0
- cola_cli/templates/julia/src/{{ name }}.jl.j2 +17 -0
- cola_cli/templates/python/pyproject.toml.j2 +23 -0
- cola_cli/templates/python/src/{{ package }}/__init__.py.j2 +1 -0
- cola_cli/templates/python/src/{{ package }}/filters.py.j2 +18 -0
- cola_cli/templates/quality/.cmake-format.yaml.j2 +13 -0
- cola_cli/templates/quality/CMakePresets.json.j2 +22 -0
- cola_cli-0.1.0.dist-info/METADATA +272 -0
- cola_cli-0.1.0.dist-info/RECORD +43 -0
- cola_cli-0.1.0.dist-info/WHEEL +5 -0
- cola_cli-0.1.0.dist-info/entry_points.txt +2 -0
- cola_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
- cola_cli-0.1.0.dist-info/top_level.txt +1 -0
cola_cli/sources.py
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"""Source identity and snapshots. Language dependency solving belongs to their tools."""
|
|
2
|
+
|
|
3
|
+
import fnmatch
|
|
4
|
+
import hashlib
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
import shutil
|
|
8
|
+
import tempfile
|
|
9
|
+
import tomllib
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from urllib.parse import urlparse
|
|
12
|
+
|
|
13
|
+
from .common import ColaError, execute
|
|
14
|
+
|
|
15
|
+
BUILTINS = {
|
|
16
|
+
"core": "https://github.com/Spectator-matter-group-INR-RAS/COLA.git",
|
|
17
|
+
"python": "https://github.com/ZakayZ/COLA-PY.git",
|
|
18
|
+
"julia": "https://github.com/ZakayZ/COLA_Julia.git",
|
|
19
|
+
"java": "https://github.com/ZakayZ/COLA_JVM.git",
|
|
20
|
+
"fortran": "https://github.com/ZakayZ/COLA_Fortran.git",
|
|
21
|
+
}
|
|
22
|
+
IGNORED = (
|
|
23
|
+
".git",
|
|
24
|
+
".venv",
|
|
25
|
+
".gradle",
|
|
26
|
+
".pytest_cache",
|
|
27
|
+
".ruff_cache",
|
|
28
|
+
"__pycache__",
|
|
29
|
+
"*.egg-info",
|
|
30
|
+
"build",
|
|
31
|
+
"dist",
|
|
32
|
+
".DS_Store",
|
|
33
|
+
)
|
|
34
|
+
IDENTIFIER = re.compile(r"[a-z][a-z0-9_-]{0,63}\Z")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def name_check(name):
|
|
38
|
+
if not isinstance(name, str) or not IDENTIFIER.fullmatch(name):
|
|
39
|
+
raise ColaError(f"Invalid module name {name!r}; use lowercase letters, digits, '-' or '_'.")
|
|
40
|
+
return name
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def child(root, relative):
|
|
44
|
+
relative = Path(relative)
|
|
45
|
+
if relative.is_absolute() or ".." in relative.parts:
|
|
46
|
+
raise ColaError(f"Expected a relative subdirectory inside the repository: {relative}")
|
|
47
|
+
result = (root / relative).resolve()
|
|
48
|
+
if not result.is_relative_to(root.resolve()) or not result.is_dir():
|
|
49
|
+
raise ColaError(f"Source subdirectory does not exist inside {root}: {relative}")
|
|
50
|
+
return result
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def ignored(directory, names):
|
|
54
|
+
result = []
|
|
55
|
+
for name in names:
|
|
56
|
+
path = Path(directory) / name
|
|
57
|
+
generated_cmake = (
|
|
58
|
+
path.is_dir()
|
|
59
|
+
and any(fnmatch.fnmatch(name, pattern) for pattern in ("build-*", "build_*", "cmake-build-*"))
|
|
60
|
+
and ((path / "CMakeCache.txt").exists() or (path / "CMakeFiles").is_dir())
|
|
61
|
+
)
|
|
62
|
+
if generated_cmake or any(fnmatch.fnmatch(name, pattern) for pattern in IGNORED):
|
|
63
|
+
result.append(name)
|
|
64
|
+
return result
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def copy_source(source, destination):
|
|
68
|
+
"""Copy build inputs, including untracked files, without modifying the checkout."""
|
|
69
|
+
for directory, dirs, files in os.walk(source, followlinks=False):
|
|
70
|
+
excluded = set(ignored(directory, dirs + files))
|
|
71
|
+
dirs[:] = [entry for entry in dirs if entry not in excluded]
|
|
72
|
+
for name in [*dirs, *(entry for entry in files if entry not in excluded)]:
|
|
73
|
+
path = Path(directory) / name
|
|
74
|
+
if path.is_symlink():
|
|
75
|
+
if path.is_dir() or not path.resolve().is_relative_to(source.resolve()):
|
|
76
|
+
raise ColaError(f"Snapshot cannot include a directory or external symlink: {path}")
|
|
77
|
+
shutil.copytree(source, destination, ignore=ignored)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def tree_hash(root):
|
|
81
|
+
digest = hashlib.sha256()
|
|
82
|
+
for path in sorted(root.rglob("*")):
|
|
83
|
+
if path.is_symlink():
|
|
84
|
+
raise ColaError(f"Unexpected symlink in stored source snapshot: {path}")
|
|
85
|
+
if path.is_file():
|
|
86
|
+
digest.update(path.relative_to(root).as_posix().encode())
|
|
87
|
+
digest.update(b"\0x\0" if path.stat().st_mode & 0o111 else b"\0-\0")
|
|
88
|
+
with path.open("rb") as stream:
|
|
89
|
+
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
|
|
90
|
+
digest.update(chunk)
|
|
91
|
+
digest.update(b"\0")
|
|
92
|
+
return digest.hexdigest()
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def source_spec(value, ref=None, subdirectory="."):
|
|
96
|
+
if value.startswith("github:"):
|
|
97
|
+
value = "https://github.com/" + value.removeprefix("github:").removesuffix(".git") + ".git"
|
|
98
|
+
if value.startswith(("https://", "ssh://", "git@", "file://")):
|
|
99
|
+
if value.startswith("https://") and urlparse(value).username:
|
|
100
|
+
raise ColaError("Use SSH or a Git credential helper; do not put credentials in the source URL.")
|
|
101
|
+
result = {"kind": "git", "url": value, "ref": ref or "HEAD"}
|
|
102
|
+
else:
|
|
103
|
+
path = Path(value).expanduser().resolve()
|
|
104
|
+
if not path.is_dir():
|
|
105
|
+
raise ColaError(f"No local source directory: {path}")
|
|
106
|
+
if ref:
|
|
107
|
+
# A local Git repository can also be used at an exact revision.
|
|
108
|
+
result = {"kind": "git", "url": path.as_uri(), "ref": ref}
|
|
109
|
+
else:
|
|
110
|
+
result = {"kind": "path", "path": str(path)}
|
|
111
|
+
if Path(subdirectory).is_absolute() or ".." in Path(subdirectory).parts:
|
|
112
|
+
raise ColaError("--subdirectory must stay inside the source repository.")
|
|
113
|
+
result["subdirectory"] = subdirectory
|
|
114
|
+
return result
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def snapshot(root, spec, *, commit=None):
|
|
118
|
+
(root / "tmp").mkdir(parents=True, exist_ok=True)
|
|
119
|
+
with tempfile.TemporaryDirectory(dir=root / "tmp") as temporary:
|
|
120
|
+
temporary = Path(temporary)
|
|
121
|
+
revision = None
|
|
122
|
+
if spec["kind"] == "git":
|
|
123
|
+
checkout = temporary / "checkout"
|
|
124
|
+
execute(["git", "clone", "--no-checkout", "--", spec["url"], checkout], capture=True)
|
|
125
|
+
ref = commit or spec["ref"]
|
|
126
|
+
command = ["git", "-C", checkout, "rev-parse", "--verify", "--end-of-options"]
|
|
127
|
+
try:
|
|
128
|
+
revision = execute([*command, ref + "^{commit}"], capture=True).strip()
|
|
129
|
+
except ColaError:
|
|
130
|
+
# clone creates only the default local branch; other branches are remote refs.
|
|
131
|
+
branch = ref.removeprefix("refs/heads/")
|
|
132
|
+
revision = execute([*command, f"refs/remotes/origin/{branch}^{{commit}}"], capture=True).strip()
|
|
133
|
+
execute(["git", "-C", checkout, "checkout", "--detach", revision], capture=True)
|
|
134
|
+
if (checkout / ".gitmodules").exists():
|
|
135
|
+
execute(["git", "-C", checkout, "submodule", "update", "--init", "--recursive"], capture=True)
|
|
136
|
+
origin = checkout
|
|
137
|
+
else:
|
|
138
|
+
origin = Path(spec["path"])
|
|
139
|
+
source = child(origin, spec["subdirectory"])
|
|
140
|
+
copied = temporary / "snapshot"
|
|
141
|
+
copy_source(source, copied)
|
|
142
|
+
identity = tree_hash(copied)
|
|
143
|
+
target = root / "sources" / identity
|
|
144
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
145
|
+
if target.exists():
|
|
146
|
+
if tree_hash(target) != identity:
|
|
147
|
+
raise ColaError(f"Source snapshot was modified: {target}")
|
|
148
|
+
else:
|
|
149
|
+
shutil.move(copied, target)
|
|
150
|
+
return {"sha256": identity, "commit": revision}
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def toml(path):
|
|
154
|
+
try:
|
|
155
|
+
return tomllib.loads(path.read_text(encoding="utf-8"))
|
|
156
|
+
except (OSError, ValueError) as error:
|
|
157
|
+
raise ColaError(f"Cannot read {path}: {error}") from error
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def describe(source, *, name=None, backend=None, libraries=(), depends=(), cmake_args=()):
|
|
161
|
+
descriptor = toml(source / "cola.toml").get("module", {}) if (source / "cola.toml").exists() else {}
|
|
162
|
+
if not isinstance(descriptor, dict):
|
|
163
|
+
raise ColaError("cola.toml must define a [module] table.")
|
|
164
|
+
for field in ("depends", "libraries", "cmake_args"):
|
|
165
|
+
value = descriptor.get(field, [])
|
|
166
|
+
if not isinstance(value, list) or not all(isinstance(item, str) for item in value):
|
|
167
|
+
raise ColaError(f"module.{field} must be an array of strings in cola.toml.")
|
|
168
|
+
py = toml(source / "pyproject.toml").get("project", {}) if (source / "pyproject.toml").exists() else {}
|
|
169
|
+
jl = toml(source / "Project.toml") if (source / "Project.toml").exists() else {}
|
|
170
|
+
cmake = (source / "CMakeLists.txt").read_text() if (source / "CMakeLists.txt").exists() else ""
|
|
171
|
+
project = re.search(r"\bproject\s*\(\s*([A-Za-z][A-Za-z0-9_-]*)", cmake, re.IGNORECASE)
|
|
172
|
+
project = project[1] if project else None
|
|
173
|
+
role = None
|
|
174
|
+
if py.get("name") == "colapy":
|
|
175
|
+
role, selected = "python", "python"
|
|
176
|
+
elif jl.get("uuid") == "e8fb5d31-b8d4-4e67-9fe8-a5a2e74aa831":
|
|
177
|
+
role, selected = "julia", "julia"
|
|
178
|
+
elif project in {"COLA", "COLA_Fortran", "COLA_JVM"}:
|
|
179
|
+
role = {"COLA": "core", "COLA_Fortran": "fortran", "COLA_JVM": "java"}[project]
|
|
180
|
+
selected = "cmake"
|
|
181
|
+
else:
|
|
182
|
+
selected = "python" if py else "julia" if jl else "cmake" if cmake else None
|
|
183
|
+
selected = backend or descriptor.get("backend") or selected
|
|
184
|
+
if selected not in {"python", "julia", "cmake"}:
|
|
185
|
+
raise ColaError("Cannot infer the build backend; provide cola.toml or --backend cmake/python/julia.")
|
|
186
|
+
inferred = py.get("name") if selected == "python" else jl.get("name") if selected == "julia" else project
|
|
187
|
+
identifier = name or descriptor.get("name") or role or (inferred or source.name).lower().replace(".", "-")
|
|
188
|
+
name_check(identifier)
|
|
189
|
+
if (role and identifier != role) or (identifier in BUILTINS and identifier != role):
|
|
190
|
+
raise ColaError(f"The names {', '.join(BUILTINS)} are reserved for the COLA core and bridges.")
|
|
191
|
+
requirements = list(depends or descriptor.get("depends", []))
|
|
192
|
+
if role != "core":
|
|
193
|
+
requirements.append("core")
|
|
194
|
+
if selected == "python" and role != "python":
|
|
195
|
+
requirements.append("python")
|
|
196
|
+
if selected == "julia" and role != "julia":
|
|
197
|
+
requirements.append("julia")
|
|
198
|
+
if "COLA_Fortran" in cmake and role != "fortran":
|
|
199
|
+
requirements.append("fortran")
|
|
200
|
+
if "COLA_JVM" in cmake and role != "java":
|
|
201
|
+
requirements.append("java")
|
|
202
|
+
requirements = sorted({name_check(entry) for entry in requirements})
|
|
203
|
+
if identifier in requirements:
|
|
204
|
+
raise ColaError(f"Module {identifier} depends on itself.")
|
|
205
|
+
default_libraries = {
|
|
206
|
+
"core": [],
|
|
207
|
+
"python": ["COLA-Py"],
|
|
208
|
+
"julia": ["COLA_Julia"],
|
|
209
|
+
"java": ["COLA_JVM"],
|
|
210
|
+
"fortran": [],
|
|
211
|
+
}
|
|
212
|
+
exported = list(libraries or descriptor.get("libraries", default_libraries.get(role, [project] if project else [])))
|
|
213
|
+
for library in exported:
|
|
214
|
+
if not isinstance(library, str) or not re.fullmatch(r"[A-Za-z][A-Za-z0-9_.-]*", library):
|
|
215
|
+
raise ColaError(f"Invalid COLA library name: {library!r}")
|
|
216
|
+
options = list(cmake_args or descriptor.get("cmake_args", []))
|
|
217
|
+
for option in options:
|
|
218
|
+
if (
|
|
219
|
+
not isinstance(option, str)
|
|
220
|
+
or not option.startswith("-D")
|
|
221
|
+
or any(key in option for key in ("CMAKE_INSTALL_PREFIX", "COLA_DIR", "COLA_INSTALL_PREFIX"))
|
|
222
|
+
):
|
|
223
|
+
raise ColaError("cmake_args must be -D definitions and cannot override the managed installation prefix.")
|
|
224
|
+
return {
|
|
225
|
+
"name": identifier,
|
|
226
|
+
"backend": selected,
|
|
227
|
+
"role": role,
|
|
228
|
+
"depends": requirements,
|
|
229
|
+
"libraries": exported,
|
|
230
|
+
"cmake_args": options,
|
|
231
|
+
"package": py.get("name") if selected == "python" else jl.get("name") if selected == "julia" else None,
|
|
232
|
+
"version": py.get("version") if selected == "python" else jl.get("version"),
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def ordered(modules):
|
|
237
|
+
"""Only order explicitly selected modules; do not implement a version solver."""
|
|
238
|
+
result, visiting, visited = [], set(), set()
|
|
239
|
+
|
|
240
|
+
def visit(name):
|
|
241
|
+
if name not in modules:
|
|
242
|
+
raise ColaError(f"Required module {name!r} is missing; add it before building.")
|
|
243
|
+
if name in visiting:
|
|
244
|
+
raise ColaError(f"Dependency cycle involving {name}.")
|
|
245
|
+
if name in visited:
|
|
246
|
+
return
|
|
247
|
+
visiting.add(name)
|
|
248
|
+
for requirement in modules[name]["depends"]:
|
|
249
|
+
visit(requirement)
|
|
250
|
+
visiting.remove(name)
|
|
251
|
+
visited.add(name)
|
|
252
|
+
result.append(name)
|
|
253
|
+
|
|
254
|
+
for name in modules:
|
|
255
|
+
visit(name)
|
|
256
|
+
return result
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/build/
|
|
2
|
+
/dist/
|
|
3
|
+
/.venv/
|
|
4
|
+
/.gradle/
|
|
5
|
+
/.idea/
|
|
6
|
+
/.vscode/
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
*.egg-info/
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
*.mod
|
|
12
|
+
*.smod
|
|
13
|
+
*.o
|
|
14
|
+
*.so
|
|
15
|
+
*.dylib
|
|
16
|
+
*.class
|
|
17
|
+
*.jar
|
|
18
|
+
CMakeUserPresets.json
|
|
19
|
+
compile_commands.json
|
|
20
|
+
.DS_Store
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
cmake_minimum_required(
|
|
2
|
+
VERSION
|
|
3
|
+
3.20
|
|
4
|
+
)
|
|
5
|
+
project(
|
|
6
|
+
{{ name }}
|
|
7
|
+
VERSION
|
|
8
|
+
{{ version }}
|
|
9
|
+
LANGUAGES
|
|
10
|
+
CXX
|
|
11
|
+
)
|
|
12
|
+
find_package(
|
|
13
|
+
COLA
|
|
14
|
+
CONFIG
|
|
15
|
+
REQUIRED
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
# Compile the declarations. Switch OBJECT to SHARED after implementing the module.
|
|
19
|
+
add_library(
|
|
20
|
+
{{ name }}
|
|
21
|
+
OBJECT
|
|
22
|
+
src/{{ name }}.cc
|
|
23
|
+
)
|
|
24
|
+
target_compile_features(
|
|
25
|
+
{{ name }}
|
|
26
|
+
PUBLIC
|
|
27
|
+
cxx_std_17
|
|
28
|
+
)
|
|
29
|
+
target_include_directories(
|
|
30
|
+
{{ name }}
|
|
31
|
+
PUBLIC
|
|
32
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
|
33
|
+
)
|
|
34
|
+
target_link_libraries(
|
|
35
|
+
{{ name }}
|
|
36
|
+
PUBLIC
|
|
37
|
+
COLA
|
|
38
|
+
)
|
|
39
|
+
target_compile_options(
|
|
40
|
+
{{ name }}
|
|
41
|
+
PRIVATE
|
|
42
|
+
"$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wall;-Wextra;-Wpedantic>"
|
|
43
|
+
)
|
|
44
|
+
set_target_properties(
|
|
45
|
+
{{ name }}
|
|
46
|
+
PROPERTIES
|
|
47
|
+
POSITION_INDEPENDENT_CODE
|
|
48
|
+
TRUE
|
|
49
|
+
)
|
|
50
|
+
# Once the target is SHARED and LoadCOLAModule is defined:
|
|
51
|
+
# install(TARGETS {{ name }} LIBRARY DESTINATION lib/{{ name }})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <COLA.hh>
|
|
4
|
+
#include <memory>
|
|
5
|
+
|
|
6
|
+
namespace {{ package }} {
|
|
7
|
+
class Generator : public cola::VGenerator {
|
|
8
|
+
public:
|
|
9
|
+
std::unique_ptr<cola::EventData> operator()() override;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
class Converter : public cola::VConverter {
|
|
13
|
+
public:
|
|
14
|
+
std::unique_ptr<cola::EventData> operator()(std::unique_ptr<cola::EventData>&& data) override;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
class Writer : public cola::VWriter {
|
|
18
|
+
public:
|
|
19
|
+
void operator()(std::unique_ptr<cola::EventData>&& data) override;
|
|
20
|
+
};
|
|
21
|
+
} // namespace {{ package }}
|
|
22
|
+
|
|
23
|
+
extern "C" cola::VModule* LoadCOLAModule();
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
cmake_minimum_required(
|
|
2
|
+
VERSION
|
|
3
|
+
3.20
|
|
4
|
+
)
|
|
5
|
+
project(
|
|
6
|
+
{{ name }}
|
|
7
|
+
VERSION
|
|
8
|
+
{{ version }}
|
|
9
|
+
LANGUAGES
|
|
10
|
+
CXX
|
|
11
|
+
Fortran
|
|
12
|
+
)
|
|
13
|
+
find_package(
|
|
14
|
+
COLA_Fortran
|
|
15
|
+
CONFIG
|
|
16
|
+
REQUIRED
|
|
17
|
+
)
|
|
18
|
+
include(
|
|
19
|
+
GNUInstallDirs
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# Fill in the filter procedure bodies before running the module.
|
|
23
|
+
add_cola_fortran_library(
|
|
24
|
+
{{ name }}
|
|
25
|
+
SOURCES
|
|
26
|
+
src/{{ name }}.f90
|
|
27
|
+
)
|
|
28
|
+
target_include_directories(
|
|
29
|
+
{{ name }}
|
|
30
|
+
PRIVATE
|
|
31
|
+
"${CMAKE_CURRENT_BINARY_DIR}/generated"
|
|
32
|
+
"${CMAKE_CURRENT_BINARY_DIR}/modules"
|
|
33
|
+
)
|
|
34
|
+
set_target_properties(
|
|
35
|
+
{{ name }}
|
|
36
|
+
PROPERTIES
|
|
37
|
+
VERSION
|
|
38
|
+
"${PROJECT_VERSION}"
|
|
39
|
+
SOVERSION
|
|
40
|
+
"${PROJECT_VERSION_MAJOR}"
|
|
41
|
+
INSTALL_RPATH_USE_LINK_PATH
|
|
42
|
+
TRUE
|
|
43
|
+
)
|
|
44
|
+
if (CMAKE_Fortran_COMPILER_ID
|
|
45
|
+
STREQUAL
|
|
46
|
+
"GNU"
|
|
47
|
+
)
|
|
48
|
+
target_compile_options(
|
|
49
|
+
{{ name }}
|
|
50
|
+
PRIVATE
|
|
51
|
+
"$<$<COMPILE_LANGUAGE:Fortran>:-Wall;-Wextra;-Wimplicit-interface>"
|
|
52
|
+
"$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:Debug>>:-fcheck=all;-fbacktrace>"
|
|
53
|
+
)
|
|
54
|
+
endif (
|
|
55
|
+
|
|
56
|
+
)
|
|
57
|
+
install(
|
|
58
|
+
TARGETS
|
|
59
|
+
{{ name }}
|
|
60
|
+
LIBRARY
|
|
61
|
+
DESTINATION
|
|
62
|
+
${CMAKE_INSTALL_LIBDIR}/{{ name }}
|
|
63
|
+
)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
module {{ package }}
|
|
2
|
+
use cola, only: AbstractFortranGenerator, AbstractFortranConverter, AbstractFortranWriter, &
|
|
3
|
+
EventData, ParametersMap
|
|
4
|
+
implicit none
|
|
5
|
+
private
|
|
6
|
+
|
|
7
|
+
type, public, extends(AbstractFortranGenerator) :: Generator
|
|
8
|
+
contains
|
|
9
|
+
procedure :: init => generator_init
|
|
10
|
+
procedure :: run => generator_run
|
|
11
|
+
end type Generator
|
|
12
|
+
|
|
13
|
+
type, public, extends(AbstractFortranConverter) :: Converter
|
|
14
|
+
contains
|
|
15
|
+
procedure :: init => converter_init
|
|
16
|
+
procedure :: run => converter_run
|
|
17
|
+
end type Converter
|
|
18
|
+
|
|
19
|
+
type, public, extends(AbstractFortranWriter) :: Writer
|
|
20
|
+
contains
|
|
21
|
+
procedure :: init => writer_init
|
|
22
|
+
procedure :: run => writer_run
|
|
23
|
+
end type Writer
|
|
24
|
+
|
|
25
|
+
contains
|
|
26
|
+
subroutine generator_init(self, pmap, err)
|
|
27
|
+
class(Generator), intent(inout) :: self
|
|
28
|
+
type(ParametersMap), intent(in) :: pmap
|
|
29
|
+
character(len=:), allocatable, intent(out) :: err
|
|
30
|
+
|
|
31
|
+
! TODO: Implement this procedure and assign its output arguments.
|
|
32
|
+
end subroutine generator_init
|
|
33
|
+
|
|
34
|
+
function generator_run(self, err) result(ed)
|
|
35
|
+
class(Generator), intent(in) :: self
|
|
36
|
+
character(len=:), allocatable, intent(out) :: err
|
|
37
|
+
type(EventData) :: ed
|
|
38
|
+
|
|
39
|
+
! TODO: Implement this procedure and assign its output arguments.
|
|
40
|
+
end function generator_run
|
|
41
|
+
|
|
42
|
+
subroutine converter_init(self, pmap, err)
|
|
43
|
+
class(Converter), intent(inout) :: self
|
|
44
|
+
type(ParametersMap), intent(in) :: pmap
|
|
45
|
+
character(len=:), allocatable, intent(out) :: err
|
|
46
|
+
|
|
47
|
+
! TODO: Implement this procedure and assign its output arguments.
|
|
48
|
+
end subroutine converter_init
|
|
49
|
+
|
|
50
|
+
subroutine converter_run(self, ed, err)
|
|
51
|
+
class(Converter), intent(in) :: self
|
|
52
|
+
type(EventData), intent(inout) :: ed
|
|
53
|
+
character(len=:), allocatable, intent(out) :: err
|
|
54
|
+
|
|
55
|
+
! TODO: Implement this procedure and assign its output arguments.
|
|
56
|
+
end subroutine converter_run
|
|
57
|
+
|
|
58
|
+
subroutine writer_init(self, pmap, err)
|
|
59
|
+
class(Writer), intent(inout) :: self
|
|
60
|
+
type(ParametersMap), intent(in) :: pmap
|
|
61
|
+
character(len=:), allocatable, intent(out) :: err
|
|
62
|
+
|
|
63
|
+
! TODO: Implement this procedure and assign its output arguments.
|
|
64
|
+
end subroutine writer_init
|
|
65
|
+
|
|
66
|
+
subroutine writer_run(self, ed, err)
|
|
67
|
+
class(Writer), intent(in) :: self
|
|
68
|
+
type(EventData), intent(in) :: ed
|
|
69
|
+
character(len=:), allocatable, intent(out) :: err
|
|
70
|
+
|
|
71
|
+
! TODO: Implement this procedure and assign its output arguments.
|
|
72
|
+
end subroutine writer_run
|
|
73
|
+
end module {{ package }}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
cmake_minimum_required(
|
|
2
|
+
VERSION
|
|
3
|
+
3.20
|
|
4
|
+
)
|
|
5
|
+
project(
|
|
6
|
+
{{ name }}
|
|
7
|
+
VERSION
|
|
8
|
+
{{ version }}
|
|
9
|
+
LANGUAGES
|
|
10
|
+
CXX
|
|
11
|
+
)
|
|
12
|
+
find_package(
|
|
13
|
+
COLA_JVM
|
|
14
|
+
CONFIG
|
|
15
|
+
REQUIRED
|
|
16
|
+
)
|
|
17
|
+
include(
|
|
18
|
+
GNUInstallDirs
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# Implement the methods and make the registered classes concrete before running.
|
|
22
|
+
# This helper builds and installs both the native module and its JAR.
|
|
23
|
+
add_cola_gradle_library(
|
|
24
|
+
{{ name }}
|
|
25
|
+
JAR
|
|
26
|
+
"build/libs/{{ name }}-all.jar"
|
|
27
|
+
GENERATORS
|
|
28
|
+
"{{ name }}Generator=org.cola.generated.{{ package }}.{{ name }}Generator"
|
|
29
|
+
CONVERTERS
|
|
30
|
+
"{{ name }}Converter=org.cola.generated.{{ package }}.{{ name }}Converter"
|
|
31
|
+
WRITERS
|
|
32
|
+
"{{ name }}Writer=org.cola.generated.{{ package }}.{{ name }}Writer"
|
|
33
|
+
)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
plugins {
|
|
2
|
+
java
|
|
3
|
+
checkstyle
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
version = "{{ version }}"
|
|
7
|
+
repositories { mavenCentral() }
|
|
8
|
+
val colaJvmApi = providers.gradleProperty("colaJvmApi")
|
|
9
|
+
dependencies {
|
|
10
|
+
if (colaJvmApi.isPresent) {
|
|
11
|
+
compileOnly(files(colaJvmApi.get()))
|
|
12
|
+
} else {
|
|
13
|
+
compileOnly("io.github.zakayz:cola-jvm-api:0.1.0")
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
tasks.withType<JavaCompile>().configureEach {
|
|
18
|
+
options.release.set(17)
|
|
19
|
+
options.encoding = "UTF-8"
|
|
20
|
+
options.compilerArgs.addAll(listOf("-Xlint:all", "-Werror"))
|
|
21
|
+
}
|
|
22
|
+
checkstyle {
|
|
23
|
+
toolVersion = "10.26.1"
|
|
24
|
+
configFile = file("config/checkstyle/checkstyle.xml")
|
|
25
|
+
isIgnoreFailures = false
|
|
26
|
+
maxWarnings = 0
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
tasks.register<Jar>("colaJar") {
|
|
30
|
+
archiveFileName.set("{{ name }}-all.jar")
|
|
31
|
+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
32
|
+
from(sourceSets.main.get().output)
|
|
33
|
+
dependsOn(configurations.runtimeClasspath)
|
|
34
|
+
from({ configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) } })
|
|
35
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
|
3
|
+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
|
4
|
+
<module name="Checker">
|
|
5
|
+
<property name="charset" value="UTF-8"/>
|
|
6
|
+
<module name="FileTabCharacter"/>
|
|
7
|
+
<module name="NewlineAtEndOfFile"/>
|
|
8
|
+
<module name="LineLength">
|
|
9
|
+
<property name="max" value="100"/>
|
|
10
|
+
</module>
|
|
11
|
+
<module name="TreeWalker">
|
|
12
|
+
<module name="UnusedImports"/>
|
|
13
|
+
<module name="AvoidStarImport"/>
|
|
14
|
+
<module name="NeedBraces"/>
|
|
15
|
+
<module name="TypeName"/>
|
|
16
|
+
<module name="MethodName"/>
|
|
17
|
+
<module name="ModifierOrder"/>
|
|
18
|
+
</module>
|
|
19
|
+
</module>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rootProject.name = "{{ name }}"
|