mirror of https://github.com/wolfSSL/wolfssl.git
40 lines
1.4 KiB
Python
Executable File
40 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Entry point for the vendored wolfssl-compliance-tooling generator.
|
|
|
|
The customer command stays `python3 scripts/gen-sbom`.
|
|
The implementation is tools/sbom/gen-sbom. A release tarball carries both.
|
|
Importing this module loads that implementation.
|
|
Copying this file without tools/sbom/gen-sbom does not work.
|
|
"""
|
|
import importlib.util
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
from importlib.machinery import SourceFileLoader
|
|
|
|
_here = os.path.dirname(os.path.abspath(__file__))
|
|
_target = os.path.abspath(os.path.join(_here, os.pardir, "tools", "sbom", "gen-sbom"))
|
|
_MISSING = (
|
|
"ERROR: wolfssl-compliance-tooling generator not found at "
|
|
f"{_target}. scripts/gen-sbom is the entry point. "
|
|
"tools/sbom/gen-sbom is the program. Keep both files."
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
if not os.path.isfile(_target):
|
|
sys.exit(_MISSING)
|
|
# On Windows, os.execv returns to the shell at once with status 0 and
|
|
# does not quote arguments that contain spaces.
|
|
sys.exit(subprocess.call([sys.executable, _target, *sys.argv[1:]]))
|
|
|
|
if not os.path.isfile(_target):
|
|
raise ImportError(_MISSING)
|
|
|
|
# The importer gets the generator module itself, so a patch of a name in it
|
|
# changes what the generator uses.
|
|
_loader = SourceFileLoader(__name__, _target)
|
|
_module = importlib.util.module_from_spec(
|
|
importlib.util.spec_from_loader(__name__, _loader))
|
|
sys.modules[__name__] = _module
|
|
_loader.exec_module(_module)
|