File: gen-shader-headers.sh

package info (click to toggle)
libcamera 0.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,488 kB
  • sloc: cpp: 85,656; python: 18,099; ansic: 12,763; sh: 1,309; makefile: 60
file content (53 lines) | stat: -rwxr-xr-x 1,180 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh

set -e

usage() {
	echo "Usage: $0 <src_dir> <output_header> <shader_file1> [shader_file2 ...]"
	echo
	echo "Generates a C header file containing hex-encoded shader data."
	echo
	echo "Arguments:"
	echo "  src_dir             Path to the base of the source directory"
	echo "  output_header       Path to the generated header file"
	echo "  shader_file(s)      One or more shader files to embed in the header"
	exit 1
}

if [ $# -lt 4 ]; then
	echo "Error: Invalid argument count."
	usage
fi

src_dir="$1"; shift
build_path="$1"; shift

cat <<EOF > "$build_path"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* This file is auto-generated, do not edit! */

#pragma once

EOF

cat <<EOF >> "$build_path"
/*
 * List the names of the shaders at the top of
 * header for readability's sake
 *
EOF

for file in "$@"; do
	name=$(basename "$file" | tr '.' '_')
	echo "[SHADER-GEN] $name"
	echo " * unsigned char $name;" >> "$build_path"
done

echo "*/" >> "$build_path"

echo "/* Hex encoded shader data */" >> "$build_path"
for file in "$@"; do
	name=$(basename "$file")
	"$src_dir/utils/gen-shader-header.py" "$name" "$file" >> "$build_path"
	echo >> "$build_path"
done