Commit 86b3d60f authored by David Boddie's avatar David Boddie
Browse files

Merge branch 'generalize-image-copying' into 'master'

Include a manifest of extra files and a tool to copy them

See merge request Librem5/!349
parents bf2e9d14 124ce0bf
Pipeline #48428 passed with stages
in 1 minute and 39 seconds
......@@ -54,10 +54,9 @@ clean:
.PHONY: html
html: check
# Copy images referenced as image links to suitable destinations.
@mkdir -p $(BUILDDIR)/html/Hardware_Reference/images/Birch
@cp Hardware_Reference/images/Birch/large/* $(BUILDDIR)/html/Hardware_Reference/images/Birch/
# Copy images referenced as image links to suitable destinations.
python3 _extensions/ extra-files.txt $(BUILDDIR)/html
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
#!/usr/bin/env python3
import glob
import os
import shutil
import sys
def process_manifest(manifest, html_dir):
src = None
lineno = 1
for line in open(manifest).readlines():
if line.startswith('#'):
line = line.strip()
if not line:
if src is None:
src = line.strip()
dest = line.strip()
copy_files(src, dest, html_dir)
src = None
lineno += 1
except IOError:
sys.stderr.write('Failed to process manifest "%s" at line %i.\n' % (
manifest, lineno))
except OSError:
sys.stderr.write('Failed to create directory given in manifest "%s" '
'at line %i.\n' % (manifest, lineno))
def copy_files(src, dest, html_dir):
pieces = dest.split(os.sep)
new_dir = html_dir
for piece in pieces:
new_dir = os.path.join(new_dir, piece)
if not os.path.exists(new_dir):
print('Creating', new_dir)
for path in glob.glob(src):
file_name = os.path.split(path)[1]
dest_path = os.path.join(new_dir, file_name)
print('Copying', path, 'to', dest_path)
shutil.copy2(path, dest_path)
if __name__ == '__main__':
if len(sys.argv) != 3:
sys.stderr.write('Usage: %s <manifest> <HTML output directory>\n' % sys.argv[0])
manifest = sys.argv[1]
html_dir = sys.argv[2]
process_manifest(manifest, html_dir)
# Pairs of lines separated by blank lines. The first line in a pair is the
# source files to copy, the second the destination directory in the output HTML
# file structure. Relative paths from the root of the project are used.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment