|
1 | 1 | #!/usr/bin/env bash
|
2 |
| -# |
3 |
| -# |
| 2 | + |
4 | 3 | set -ex
|
5 | 4 |
|
6 |
| -DESTDIR="stdlib-fpm" |
| 5 | +# Target directory to deploy stdlib to |
| 6 | +destdir="${DESTDIR:-stdlib-fpm}" |
| 7 | + |
| 8 | +# Get fypp preprocessor |
| 9 | +fypp="${FYPP:-$(which fypp)}" |
| 10 | + |
| 11 | +# Arguments for the fypp preprocessor |
| 12 | +fyflags="${FYFLAGS:--DMAXRANK=4}" |
7 | 13 |
|
8 |
| -FYFLAGS="-DMAXRANK=4" |
| 14 | +# Number of parallel jobs for preprocessing |
| 15 | +njob="$(nproc)" |
9 | 16 |
|
10 |
| -mkdir -p $DESTDIR/src |
11 |
| -mkdir -p $DESTDIR/test |
| 17 | +# Additional files to include |
| 18 | +include=( |
| 19 | + "ci/fpm.toml" |
| 20 | + "LICENSE" |
| 21 | +) |
| 22 | + |
| 23 | +# Files to remove from collection |
| 24 | +prune=( |
| 25 | + "$destdir/test/test_always_fail.f90" |
| 26 | + "$destdir/test/test_always_skip.f90" |
| 27 | + "$destdir/test/test_mean_f03.f90" |
| 28 | + "$destdir/src/common.f90" |
| 29 | + "$destdir/src/f18estop.f90" |
| 30 | +) |
| 31 | + |
| 32 | +mkdir -p "$destdir/src" "$destdir/test" |
12 | 33 |
|
13 | 34 | # Preprocess stdlib sources
|
14 |
| -ls src/*.fypp | cut -f1 -d. | xargs -i{} fypp {}.fypp {}.f90 $FYFLAGS |
| 35 | +find src -maxdepth 1 -iname "*.fypp" \ |
| 36 | + | cut -f1 -d. | xargs -P "$njob" -I{} "$fypp" "{}.fypp" "$destdir/{}.f90" $fyflags |
| 37 | + |
| 38 | +# Collect stdlib source files |
| 39 | +find src -maxdepth 1 -iname "*.f90" -exec cp {} "$destdir/src/" \; |
| 40 | +find src/tests -name "test_*.f90" -exec cp {} "$destdir/test/" \; |
| 41 | +find src/tests -name "*.dat" -exec cp {} "$destdir/" \; |
15 | 42 |
|
16 |
| -# Collect stdlib files |
17 |
| -find src -maxdepth 1 -iname "*.f90" -exec cp {} $DESTDIR/src/ \; |
18 |
| -find src/tests -name "test_*.f90" -exec cp {} $DESTDIR/test/ \; |
19 |
| -find src/tests -name "*.dat" -exec cp {} $DESTDIR/ \; |
20 |
| -cp LICENSE $DESTDIR/ |
21 |
| -cp ci/fpm.toml $DESTDIR/ |
| 43 | +# Include additional files |
| 44 | +cp "${include[@]}" "$destdir/" |
22 | 45 |
|
23 | 46 | # Source file workarounds for fpm
|
24 |
| -rm $DESTDIR/test/test_always_fail.f90 |
25 |
| -rm $DESTDIR/test/test_always_skip.f90 |
26 |
| -rm $DESTDIR/test/test_mean_f03.f90 |
27 |
| -rm $DESTDIR/src/common.f90 |
28 |
| -rm $DESTDIR/src/f18estop.f90 |
| 47 | +rm "${prune[@]}" |
29 | 48 |
|
30 | 49 | # List stdlib-fpm package contents
|
31 |
| -ls -R $DESTDIR |
| 50 | +ls -R "$destdir" |
0 commit comments