Skip to content

Commit 7c144a9

Browse files
committed
feat: added basic script for preprocessing and saving generated files
1 parent 2570975 commit 7c144a9

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

fypp-gfortran.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
# Target directory for saving preprocessed project.
6+
destdir="${DESTDIR:-build}"
7+
8+
# Get fypp preprocessor
9+
fypp="${FYPP:-$(which fypp)}"
10+
11+
# Number of parallel jobs for preprocessing
12+
if [ $(uname) = "Darwin" ]; then
13+
njob="$(sysctl -n hw.ncpu)"
14+
else
15+
njob="$(nproc)"
16+
fi
17+
18+
# Create directories for the fpm project.
19+
mkdir -p "$destdir/preprocessed_files"
20+
21+
# Preprocess all files with .fypp extension in source directory.
22+
# Save generated files in build directory.
23+
find src -iname "*.fypp" \
24+
-exec basename {} .fypp ';' \
25+
| cut -f1 -d. | xargs -P "$njob" -I{} "$fypp" "src/{}.fypp" "$destdir/preprocessed_files/{}.f90" \
26+
27+
args=("$@")
28+
29+
file=$(printf "%s\n" "${args[@]}" | grep -P '^.+\.[fF]90')
30+
31+
exec gfortran "${args[@]}"
32+
33+

0 commit comments

Comments
 (0)