Easier way to specify how files are generated.
This commit is contained in:
parent
27db6e1992
commit
f613853328
1 changed files with 20 additions and 7 deletions
|
|
@ -1,9 +1,22 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
if [ "$1" ]; then
|
||||
# Print the content of the generated source named $1 here.
|
||||
true
|
||||
else
|
||||
# Print a list of names of the files that should be generated using this script here.
|
||||
true
|
||||
fi
|
||||
set -e -o pipefail
|
||||
|
||||
current_file_name=$1
|
||||
|
||||
# This function should be called for each generated file with the file's name as the first argument and the command to call to produce the file's content as the remaining arguments.
|
||||
function generate_file() {
|
||||
file_name=$1
|
||||
shift
|
||||
generate_command=("$@")
|
||||
|
||||
if ! [ "$current_file_name" ]; then
|
||||
echo "$file_name"
|
||||
elif [ "$current_file_name" == "$file_name" ]; then
|
||||
"${generate_command[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Call generate_file for each file to be generated.
|
||||
# E.g.:
|
||||
# generate_file src/test.scad echo "cube();"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue