Skip to content

Commit 608d5a2

Browse files
authored
Merge pull request #508 from fortran-fans/add_fpm_ci2
github-ci: add fpm support
2 parents ff0756d + 7abb413 commit 608d5a2

File tree

5 files changed

+122
-0
lines changed

5 files changed

+122
-0
lines changed

.github/workflows/fpm-deployment.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: fpm-deployment
2+
3+
on: [push, pull_request]
4+
env:
5+
GCC_V: "10"
6+
7+
jobs:
8+
Build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout 🛎️
13+
uses: actions/[email protected]
14+
15+
- name: Set up Python 3.x
16+
uses: actions/setup-python@v1
17+
with:
18+
python-version: 3.x
19+
20+
- name: Install fypp
21+
run: pip install --upgrade fypp
22+
23+
- name: Generate stdlib-fpm package 🔧
24+
run: |
25+
bash ./ci/fpm-deployment.sh
26+
27+
- name: Install GFortran
28+
run: |
29+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GCC_V }} 100 \
30+
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ env.GCC_V }} \
31+
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ env.GCC_V }}
32+
33+
- name: Install fpm latest release
34+
uses: fortran-lang/setup-fpm@v3
35+
with:
36+
github-token: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Run fpm test ⚙
39+
run: |
40+
cp -r stdlib-fpm stdlib-fpm-test
41+
cd stdlib-fpm-test
42+
fpm test
43+
fpm test --profile release
44+
45+
# Update and deploy the f90 files generated by github-ci to the `stdlib-fpm` branch.
46+
- name: Deploy 🚀
47+
uses: JamesIves/[email protected]
48+
if: github.event_name != 'pull_request'
49+
with:
50+
BRANCH: stdlib-fpm
51+
FOLDER: stdlib-fpm

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ API-doc/
3939

4040
# Build directory for out-of-tree builds
4141
/build
42+
/stdlib-fpm
4243

4344
# Emacs backup files
4445
*~

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [Supported compilers](#supported-compilers)
1212
- [Build with CMake](#build-with-cmake)
1313
- [Build with make](#build-with-make)
14+
- [Build with fortran-lang/fpm](#build-with-fortran-langfpm)
1415
* [Using stdlib in your project](#using-stdlib-in-your-project)
1516
* [Documentation](#documentation)
1617
* [Contributing](#contributing)
@@ -176,7 +177,21 @@ You can limit the maximum rank by setting ``-DMAXRANK=<num>`` in the ``FYPPFLAGS
176177
make -f Makefile.manual FYPPFLAGS=-DMAXRANK=4
177178
```
178179

180+
### Build with [fortran-lang/fpm](https://github.com/fortran-lang/fpm)
179181

182+
Fortran Package Manager (fpm) is a package manager and build system for Fortran.
183+
You can build `stdlib` using provided `fpm.toml`:
184+
185+
```sh
186+
git checkout stdlib-fpm
187+
fpm build --profile release
188+
```
189+
190+
To use `stdlib` within your `fpm` project, add the following lines to your `fpm.toml` file:
191+
```toml
192+
[dependencies]
193+
stdlib = { git="https://github.com/fortran-lang/stdlib", branch="stdlib-fpm" }
194+
```
180195

181196
## Using stdlib in your project
182197

ci/fpm-deployment.sh

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
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}"
13+
14+
# Number of parallel jobs for preprocessing
15+
njob="$(nproc)"
16+
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"
33+
34+
# Preprocess stdlib sources
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/" \;
42+
43+
# Include additional files
44+
cp "${include[@]}" "$destdir/"
45+
46+
# Source file workarounds for fpm
47+
rm "${prune[@]}"
48+
49+
# List stdlib-fpm package contents
50+
ls -R "$destdir"

ci/fpm.toml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name = "stdlib"
2+
version = "0.0.0"
3+
license = "MIT"
4+
author = "stdlib contributors"
5+
copyright = "2019-2021 stdlib contributors"

0 commit comments

Comments
 (0)