33 lines
830 B
Bash
33 lines
830 B
Bash
#!/bin/sh
|
|||
|
|
# Regenerates Sources/mdview/Assets.swift from the files in assets/, embedding
|
||
|
|
# them as Swift raw string literals so the binary is fully self-contained.
|
||
|
|
set -eu
|
||
|
|
cd "$(dirname "$0")/.."
|
||
|
|
|
||
|
|
out=Sources/mdview/Assets.swift
|
||
|
|
|
||
|
|
emit() {
|
||
|
|
name=$1
|
||
|
|
file=$2
|
||
|
|
if grep -q '"""##' "$file"; then
|
||
|
|
echo "error: $file contains the raw string delimiter" >&2
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
printf ' static let %s = ##"""\n' "$name"
|
||
|
|
cat "$file"
|
||
|
|
printf '\n"""##\n\n'
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
echo '// Generated by scripts/gen-assets.sh -- do not edit by hand.'
|
||
|
|
echo
|
||
|
|
echo 'enum Assets {'
|
||
|
|
emit markdownCSS assets/github-markdown.css
|
||
|
|
emit highlightLightCSS assets/hljs-github.css
|
||
|
|
emit highlightDarkCSS assets/hljs-github-dark.css
|
||
|
|
emit highlightJS assets/highlight.min.js
|
||
|
|
echo '}'
|
||
|
|
} > "$out"
|
||
|
|
|
||
|
|
echo "wrote $out"
|