Skip to content

github-ci: add fpm support #508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/fpm-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: fpm-deployment

on: [push, pull_request]
env:
GCC_V: "10"

jobs:
Build:
runs-on: ubuntu-latest

steps:
- name: Checkout 🛎️
uses: actions/[email protected]

- name: Set up Python 3.x
uses: actions/setup-python@v1
with:
python-version: 3.x

- name: Install fypp
run: pip install --upgrade fypp

- name: Generate stdlib-fpm package 🔧
run: |
sh ./ci/fpm-deployment.sh

- name: Install GFortran
run: |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GCC_V }} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ env.GCC_V }} \
--slave /usr/bingcov gcov /usr/bin/gcov-${{ env.GCC_V }}

- name: Install fpm latest release
uses: fortran-lang/setup-fpm@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Run fpm test ⚙
run: |
cp -r stdlib-fpm stdlib-fpm-test
cd stdlib-fpm-test
fpm test
fpm test --profile release

# Update and deploy the f90 files generated by github-ci to the `stdlib-fpm` branch.
- name: Deploy 🚀
uses: JamesIves/[email protected]
if: github.event_name != 'pull_request'
with:
BRANCH: stdlib-fpm
FOLDER: stdlib-fpm
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [Supported compilers](#supported-compilers)
- [Build with CMake](#build-with-cmake)
- [Build with make](#build-with-make)
- [Build with fortran-lang/fpm](#build-with-fortran-langfpm)
* [Using stdlib in your project](#using-stdlib-in-your-project)
* [Documentation](#documentation)
* [Contributing](#contributing)
Expand Down Expand Up @@ -176,7 +177,21 @@ You can limit the maximum rank by setting ``-DMAXRANK=<num>`` in the ``FYPPFLAGS
make -f Makefile.manual FYPPFLAGS=-DMAXRANK=4
```

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

Fortran Package Manager (fpm) is a great package manager and build system for Fortran.
You can build using provided `fpm.toml`:

```sh
git checkout stdlib-fpm
fpm build --profile release
```

To use `stdlib` within your `fpm` project, add the following to your `fpm.toml` file:
```toml
[dependencies]
stdlib = { git="https://github.com/fortran-lang/stdlib", branch="stdlib-fpm" }
```

## Using stdlib in your project

Expand Down
31 changes: 31 additions & 0 deletions ci/fpm-deployment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
#
#
set -ex

DESTDIR="stdlib-fpm"

FYFLAGS="-DMAXRANK=4"

mkdir -p $DESTDIR/src
mkdir -p $DESTDIR/test

# Preprocess stdlib sources
ls src/*.fypp | cut -f1 -d. | xargs -i{} fypp {}.fypp {}.f90 $FYFLAGS

# Collect stdlib files
find src -maxdepth 1 -iname "*.f90" -exec cp {} $DESTDIR/src/ \;
find src/tests -name "test_*.f90" -exec cp {} $DESTDIR/test/ \;
find src/tests -name "*.dat" -exec cp {} $DESTDIR/ \;
cp LICENSE $DESTDIR/
cp ci/fpm.toml $DESTDIR/

# Source file workarounds for fpm
rm $DESTDIR/test/test_always_fail.f90
rm $DESTDIR/test/test_always_skip.f90
rm $DESTDIR/test/test_mean_f03.f90
rm $DESTDIR/src/common.f90
rm $DESTDIR/src/f18estop.f90

# List stdlib-fpm package contents
ls -R $DESTDIR
5 changes: 5 additions & 0 deletions ci/fpm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name = "stdlib"
version = "0.0.0"
license = "MIT"
author = "stdlib contributors"
copyright = "2019-2021 stdlib contributors"