#!/bin/sh format_c() { clang-format -i "$@" } copy_submodules() { # copy code files from submodules. # to not have the whole submodule in the source directory a=submodules/sph-sc-lib/source/sc b="$a/sph" f="source/sc/foreign" mkdir -p "$f/sph" && cp --update --target-directory="$f" "$a/sph.sc" && cp --update --target-directory="$f/sph" \ "$b/guile.sc" "$b/mi-list.sc" "$b/one.sc" } export SC_LOAD_PATH="$PWD/source/sc/foreign" dir=source/c-precompiled file="$dir/main.c" copy_submodules && mkdir -p "$dir" && sc source/sc/main.sc "$file" && format_c "$file" && chmod 755 "$dir" && chmod 644 "$file"