Publish VCC Plus OSS source distribution for 3.6.2 build 60
This commit is contained in:
commit
c652a5276d
1192 files changed
+272368
No files matched your search
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Bundle authored project templates from their single repository source."""
|
||||
import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
# Deliberately enumerate source files: a developer's command-line make products,
|
||||
# local settings, ROMs or disk images must never enter a distributed template.
|
||||
HELLO_DISK_FILES = (
|
||||
'main.c', 'include/hello.h', 'src/display.c', 'src/disk.c',
|
||||
'assets/words.txt', 'tools/build-data.pl', 'Makefile',
|
||||
'vccplus-project.json', 'README.md', '.gitignore',
|
||||
)
|
||||
|
||||
|
||||
def stage(source: Path, destination: Path, lander=None):
|
||||
if (destination.name != 'DevelopmentTemplates'
|
||||
or destination.parent.name != 'Resources'
|
||||
or destination.parent.parent.name != 'Contents'
|
||||
or destination.parent.parent.parent.suffix != '.app'):
|
||||
raise ValueError('Destination must be APP.app/Contents/Resources/DevelopmentTemplates')
|
||||
payload = []
|
||||
templates = [(source, "HelloDisk", HELLO_DISK_FILES)]
|
||||
if lander is not None:
|
||||
templates.append((lander, "TalkingPlanetLander", ("main.c", "Makefile", "vccplus-project.json", "README.md", ".gitignore")))
|
||||
for base, name, filenames in templates:
|
||||
for relative in filenames:
|
||||
path = base / relative
|
||||
if not path.is_file() or any(part.is_symlink() for part in (path, *path.parents)):
|
||||
raise ValueError('Template source must be a regular, unlinked file: ' + relative)
|
||||
payload.append((Path(name) / relative, path.read_bytes()))
|
||||
if destination.is_symlink():
|
||||
raise ValueError('Template destination must not be a symbolic link')
|
||||
if destination.exists():
|
||||
shutil.rmtree(destination)
|
||||
for relative, data in payload:
|
||||
target = destination / relative
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_bytes(data)
|
||||
print('Included authored C project templates (source only).')
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--source', type=Path)
|
||||
parser.add_argument('--destination', type=Path)
|
||||
args = parser.parse_args()
|
||||
source = args.source or Path(os.environ['SRCROOT']).parent.parent / 'examples/cmoc/HelloDisk'
|
||||
destination = args.destination or (Path(os.environ['TARGET_BUILD_DIR']) /
|
||||
os.environ['UNLOCALIZED_RESOURCES_FOLDER_PATH'] / 'DevelopmentTemplates')
|
||||
stage(source.resolve(), destination, None if args.source else (source.parent / "TalkingPlanetLander").resolve())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user