#!/bin/sh # description # * compiles the sc source code to c # dependencies # * sph-sc # * clang-format root="$PWD" source_sc="$root/source/sc" source_c="$root/source/c-precompiled" export SC_LOAD_PATH="$root/$source_sc" copy_submodules() { # copy files from submodules. # to not have the whole submodule repository in the source directory source=submodules/sph-sc-lib/source/sc/main target="$source_sc/foreign" mkdir -p "$source_sc/foreign/sph" && cp --update --target-directory="$target/sph" "$source/sph.sc" "$source/guile.sc" "$source/mi-list.sc" \ "$source/helper.sc" "$source/memreg.sc" "$source/memreg-heap.sc" } compile_sc() { # create the c source code copy_submodules && cd "$source_sc" && find -type f -name "*.sc" -exec sc --parents '{}' "$source_c" \; && cd "$root" && find "$source_c" -type f -exec ./exe/format-c -i '{}' \; } mkdir -p "$source_c" && compile_sc