summaryrefslogtreecommitdiff
path: root/generate_sources.sh
diff options
context:
space:
mode:
authorMichael Schwarz <michi.schwarz@gmail.com>2014-12-04 10:19:29 +0100
committerMichael Schwarz <michi.schwarz@gmail.com>2014-12-04 10:19:29 +0100
commitbf0c5f26a96de9e82681f658856929e73022f9bf (patch)
tree76b009c3e4cbd20e7d474a66d864fe7be8cc3aa5 /generate_sources.sh
parentb8c479c1983d3b2efb2f64633082ebc5af8e26e0 (diff)
parent9da7f66feec3ec222760e5d34ff83e43ab41af39 (diff)
downloadpogojig-bf0c5f26a96de9e82681f658856929e73022f9bf.tar.gz
pogojig-bf0c5f26a96de9e82681f658856929e73022f9bf.tar.bz2
pogojig-bf0c5f26a96de9e82681f658856929e73022f9bf.zip
Merge commit '9da7f66feec3ec222760e5d34ff83e43ab41af39' into no-examples
Diffstat (limited to 'generate_sources.sh')
-rwxr-xr-xgenerate_sources.sh30
1 files changed, 23 insertions, 7 deletions
diff --git a/generate_sources.sh b/generate_sources.sh
index 687f91a..4a05760 100755
--- a/generate_sources.sh
+++ b/generate_sources.sh
@@ -1,9 +1,25 @@
#! /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
+ mkdir -p "$(dirname "$file_name")"
+ "${generate_command[@]}" > "$file_name"
+ fi
+}
+
+# Call generate_file for each file to be generated.
+for i in {1..5}; do
+ size=$[ $i * 10 ]
+ generate_file "src/generated/cube_$size.scad" echo "cube($size);"
+done