Skip to content
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

fpm deployment enhancement #802

Merged
merged 19 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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
81 changes: 39 additions & 42 deletions .github/workflows/fpm-deployment.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,48 @@
name: fpm-deployment

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

jobs:
Build:
runs-on: ubuntu-latest
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
toolchain: {compiler: gcc, version: 13}

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: |
bash ./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/bin/gcov gcov /usr/bin/gcov-${{ env.GCC_V }}

- name: Install fpm latest release
uses: fortran-lang/setup-fpm@v5
with:
fpm-version: 'v0.10.0'

- name: Run fpm test ⚙
run: |
cp -r stdlib-fpm stdlib-fpm-test
cd stdlib-fpm-test
fpm test
fpm test --profile release
- name: Checkout code
uses: actions/[email protected]

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

- name: Install requirements
run: pip install --upgrade -r config/requirements.txt

- uses: fortran-lang/setup-fortran@main
id: setup-fortran
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

- name: Setup Fortran Package Manager
uses: fortran-lang/setup-fpm@v5
with:
fpm-version: 'v0.10.0'

- run: |
python config/fypp_deployment.py --deploy_stdlib_fpm 1
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
- name: Deploy 🚀
uses: JamesIves/[email protected]
if: github.event_name != 'pull_request'
with:
BRANCH: stdlib-fpm
FOLDER: stdlib-fpm
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build/

**/temp/
# FORD generated documentation
# !WARNING! This folder gets deleted and overwritten
API-doc/
Expand Down
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,38 @@ earlier builds do not affect the new build.
Fortran Package Manager (fpm) is a package manager and build system for Fortran.
You can build `stdlib` using provided `fpm.toml`:

**Option 1**: From root folder

As `fpm` does not currently support `fypp` natively, `stdlib` now proposes a python script to preprocess and build. This script enables modification of the different `fypp` macros available in `stdlib`. The preprocessed files will be dumped at `<current_folder>/temp/*.f90` or `*.F90`. You can use the following command line:
jalvesz marked this conversation as resolved.
Show resolved Hide resolved

```sh
git checkout stdlib-fpm
python config/fypp_deployment.py
fpm build --profile release
```

**Alternative**: as `fpm` does not currently support `fypp` natively, building `stdlib` with `fpm` can be done in two steps: a) launch the preprocessor through the `fpm-deployment.sh` script, which creates a subfolder `stdlib-fpm` and b) build the project using the processed files within the latter subfolder. This process can be done with the following commands:
or the short-cut

```sh
source ./ci/fpm-deployment.sh
cd stdlib-fpm/
fpm build --profile release
python config/fypp_deployment.py --build 1
jalvesz marked this conversation as resolved.
Show resolved Hide resolved
```

To modify the `maxrank` macro for instance:
```sh
python config/fypp_deployment.py --maxrank 7 --build 1
```

To see all the options:
```sh
python config/fypp_deployment.py --help
```
**Note**: If you use a compiler different than GNU compilers, the script will try to catch it from the environment variables `FPM_FC`, `FPM_CC`, `FPM_CXX`.

**Option 2**: From the `stdlib-fpm` branch which has already been preprocessed with default macros:
```sh
git checkout stdlib-fpm
fpm build --profile release
```
#### Runing the examples
You can run the examples with `fpm` as:

```sh
Expand Down
7 changes: 0 additions & 7 deletions ci/.gitignore

This file was deleted.

99 changes: 0 additions & 99 deletions ci/fpm-deployment.sh

This file was deleted.

Loading
Loading