Meson already takes care of passing the proper absolute or relative
paths to commands. There is no need do more path manipulation.
So simplify the script by using the paths as-is. This also fixes the
path manipulation issue that prevented libcamera from building as a
subproject.
Fixes: 19371dee41 ("utils: gen-shader-headers: Add a utility to generate headers from shaders")
Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
54 lines
1.2 KiB
Bash
Executable File
54 lines
1.2 KiB
Bash
Executable File
#!/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
|