Skip to content

Commit

Permalink
Merge branch 'main' into serialize_fpm_model
Browse files Browse the repository at this point in the history
  • Loading branch information
henilp105 authored Jan 27, 2024
2 parents a1e71e9 + a0cb608 commit 230eeef
Show file tree
Hide file tree
Showing 22 changed files with 442 additions and 98 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-11, windows-latest]
gcc_v: [10] # Version of GFortran we want to use.
gcc_v: [10,11,12,13] # Version of GFortran we want to use.
include:
- os: ubuntu-latest
os-arch: linux-x86_64
Expand All @@ -43,7 +43,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Install GFortran macOS
if: contains(matrix.os, 'macos')
Expand Down Expand Up @@ -194,7 +194,7 @@ jobs:
- build

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Download Artifacts
uses: actions/download-artifact@v2
Expand Down Expand Up @@ -277,7 +277,7 @@ jobs:
env:
DEPLOY_BRANCH: ${{ secrets.DEPLOY_BRANCH && contains(github.ref, secrets.DEPLOY_BRANCH) && 1 || 0 }}

- uses: actions/checkout@v2
- uses: actions/checkout@v4
if: ${{ github.event_name == 'push' }}

- name: Download Artifacts
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ jobs:
mpi: openmpi
- os: ubuntu-latest
mpi: mpich
- os: windows-latest
mpi: msmpi
- os: macos-latest
mpi: openmpi
- os: macos-latest
Expand All @@ -45,7 +43,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: (Ubuntu) setup gcc version
if: contains(matrix.os,'ubuntu')
Expand Down Expand Up @@ -106,16 +104,14 @@ jobs:
if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'intel')
timeout-minutes: 1
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
- name: (Ubuntu) Install Intel oneAPI
if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'intel')
timeout-minutes: 5
run: sudo apt-get install intel-oneapi-compiler-fortran intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic intel-oneapi-mpi intel-oneapi-mpi-devel intel-oneapi-mkl ninja-build
timeout-minutes: 15
run: sudo apt-get install intel-oneapi-compiler-dpcpp-cpp-2023.1.0 intel-oneapi-compiler-fortran-2023.1.0 intel-oneapi-mpi-devel ninja-build

- name: (Ubuntu) Setup Intel oneAPI environment
if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'intel')
Expand Down Expand Up @@ -152,6 +148,7 @@ jobs:
if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi')
run: |
echo "C:\Program Files\Microsoft MPI\Bin\" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "/c/Program Files/Microsoft MPI/Bin/" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "MSMPI_BIN=C:\Program Files\Microsoft MPI\Bin\" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: (Windows) load OneAPI environment variables
Expand Down Expand Up @@ -216,9 +213,9 @@ jobs:
if: contains(matrix.mpi,'intel')
shell: bash
run: |
echo "FPM_FC=ifort" >> $GITHUB_ENV
echo "FPM_CC=icc" >> $GITHUB_ENV
echo "FPM_CXX=icpc" >> $GITHUB_ENV
echo "FPM_FC=ifx" >> $GITHUB_ENV
echo "FPM_CC=icx" >> $GITHUB_ENV
echo "FPM_CXX=icpx" >> $GITHUB_ENV
- name: (macOS) Use gcc/g++ instead of Clang for C/C++
if: contains(matrix.os,'macOS')
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
FORMAT: ${{ matrix.format }}
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -44,7 +44,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
env:
DEPLOY_BRANCH: ${{ secrets.DEPLOY_BRANCH && contains(github.ref, secrets.DEPLOY_BRANCH) && 1 || 0 }}

- uses: actions/checkout@v2
- uses: actions/checkout@v4
if: ${{ github.event_name == 'push' }}

- name: Download Artifacts
Expand Down
4 changes: 4 additions & 0 deletions ci/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ pushd preprocess_cpp_deps
"$fpm" build
popd

pushd preprocess_cpp_suffix
"$fpm" run
popd

pushd preprocess_per_dependency
"$fpm" run
popd
Expand Down
1 change: 1 addition & 0 deletions example_packages/preprocess_cpp_suffix/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/*
8 changes: 8 additions & 0 deletions example_packages/preprocess_cpp_suffix/app/main.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
program test_preprocess_suffix
use preprocess_cpp
#ifndef TESTMACRO
stop -1
#else
stop 0
#endif
end program test_preprocess_suffix
7 changes: 7 additions & 0 deletions example_packages/preprocess_cpp_suffix/fpm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name = "preprocess_cpp_suffix"
version = "1"

[preprocess]
[preprocess.cpp]
macros = ["TESTMACRO", "TESTMACRO2=3", "TESTMACRO3={version}"]
suffixes = ["fpp"]
22 changes: 22 additions & 0 deletions example_packages/preprocess_cpp_suffix/src/preprocess_cpp.fpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module preprocess_cpp
implicit none
private

public :: say_hello
contains
subroutine say_hello
print *, "Hello, preprocess_cpp!"
#ifndef TESTMACRO
This breaks the build.
#endif

#if TESTMACRO2 != 3
This breaks the build.
#endif

#if TESTMACRO3 != 1
This breaks the build.
#endif

end subroutine say_hello
end module preprocess_cpp
4 changes: 3 additions & 1 deletion fpm.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "fpm"
version = "0.9.0"
version = "0.10.0"
license = "MIT"
author = "fpm maintainers"
maintainer = ""
Expand All @@ -18,6 +18,8 @@ fortran-regex.git = "https://github.com/perazz/fortran-regex"
fortran-regex.tag = "1.1.2"
jonquil.git = "https://github.com/toml-f/jonquil"
jonquil.rev = "4fbd4cf34d577c0fd25e32667ee9e41bf231ece8"
fortran-shlex.git = "https://github.com/perazz/fortran-shlex"
fortran-shlex.tag = "1.0.1"

[[test]]
name = "cli-test"
Expand Down
38 changes: 15 additions & 23 deletions src/fpm.f90
Original file line number Diff line number Diff line change
Expand Up @@ -111,37 +111,23 @@ subroutine build_model(model, settings, package, error)
model%packages(i)%version = package%version%s()

!> Add this dependency's manifest macros
allocate(model%packages(i)%macros(0))
call model%packages(i)%preprocess%destroy()

if (allocated(dependency%preprocess)) then
do j = 1, size(dependency%preprocess)
if (dependency%preprocess(j)%name == "cpp") then
if (.not. has_cpp) has_cpp = .true.
if (allocated(dependency%preprocess(j)%macros)) then
model%packages(i)%macros = [model%packages(i)%macros, dependency%preprocess(j)%macros]
end if
else
write(stderr, '(a)') 'Warning: Preprocessor ' // package%preprocess(i)%name // &
' is not supported; will ignore it'
end if
call model%packages(i)%preprocess%add_config(dependency%preprocess(j))
end do
end if

!> Add this dependency's package-level macros
if (allocated(dep%preprocess)) then
do j = 1, size(dep%preprocess)
if (dep%preprocess(j)%name == "cpp") then
if (.not. has_cpp) has_cpp = .true.
if (allocated(dep%preprocess(j)%macros)) then
model%packages(i)%macros = [model%packages(i)%macros, dep%preprocess(j)%macros]
end if
else
write(stderr, '(a)') 'Warning: Preprocessor ' // package%preprocess(i)%name // &
' is not supported; will ignore it'
end if
call model%packages(i)%preprocess%add_config(dep%preprocess(j))
end do
end if

if (model%packages(i)%preprocess%is_cpp()) has_cpp = .true.

if (.not.allocated(model%packages(i)%sources)) allocate(model%packages(i)%sources(0))

if (allocated(dependency%library)) then
Expand All @@ -150,7 +136,7 @@ subroutine build_model(model, settings, package, error)
lib_dir = join_path(dep%proj_dir, dependency%library%source_dir)
if (is_dir(lib_dir)) then
call add_sources_from_dir(model%packages(i)%sources, lib_dir, FPM_SCOPE_LIB, &
error=error)
with_f_ext=model%packages(i)%preprocess%suffixes, error=error)
if (allocated(error)) exit
end if
end if
Expand Down Expand Up @@ -188,7 +174,8 @@ subroutine build_model(model, settings, package, error)
! Add sources from executable directories
if (is_dir('app') .and. package%build%auto_executables) then
call add_sources_from_dir(model%packages(1)%sources,'app', FPM_SCOPE_APP, &
with_executables=.true., error=error)
with_executables=.true., with_f_ext=model%packages(1)%preprocess%suffixes,&
error=error)

if (allocated(error)) then
return
Expand All @@ -197,7 +184,8 @@ subroutine build_model(model, settings, package, error)
end if
if (is_dir('example') .and. package%build%auto_examples) then
call add_sources_from_dir(model%packages(1)%sources,'example', FPM_SCOPE_EXAMPLE, &
with_executables=.true., error=error)
with_executables=.true., &
with_f_ext=model%packages(1)%preprocess%suffixes,error=error)

if (allocated(error)) then
return
Expand All @@ -206,7 +194,8 @@ subroutine build_model(model, settings, package, error)
end if
if (is_dir('test') .and. package%build%auto_tests) then
call add_sources_from_dir(model%packages(1)%sources,'test', FPM_SCOPE_TEST, &
with_executables=.true., error=error)
with_executables=.true., &
with_f_ext=model%packages(1)%preprocess%suffixes,error=error)

if (allocated(error)) then
return
Expand All @@ -216,6 +205,7 @@ subroutine build_model(model, settings, package, error)
if (allocated(package%executable)) then
call add_executable_sources(model%packages(1)%sources, package%executable, FPM_SCOPE_APP, &
auto_discover=package%build%auto_executables, &
with_f_ext=model%packages(1)%preprocess%suffixes, &
error=error)

if (allocated(error)) then
Expand All @@ -226,6 +216,7 @@ subroutine build_model(model, settings, package, error)
if (allocated(package%example)) then
call add_executable_sources(model%packages(1)%sources, package%example, FPM_SCOPE_EXAMPLE, &
auto_discover=package%build%auto_examples, &
with_f_ext=model%packages(1)%preprocess%suffixes, &
error=error)

if (allocated(error)) then
Expand All @@ -236,6 +227,7 @@ subroutine build_model(model, settings, package, error)
if (allocated(package%test)) then
call add_executable_sources(model%packages(1)%sources, package%test, FPM_SCOPE_TEST, &
auto_discover=package%build%auto_tests, &
with_f_ext=model%packages(1)%preprocess%suffixes, &
error=error)

if (allocated(error)) then
Expand Down
2 changes: 1 addition & 1 deletion src/fpm/fpm_release.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type(version_t) function fpm_version()

! Fallback to last known version in case of undefined macro
#ifndef FPM_RELEASE_VERSION
# define FPM_RELEASE_VERSION 0.8.0
# define FPM_RELEASE_VERSION 0.10.0
#endif

! Accept solution from https://stackoverflow.com/questions/31649691/stringify-macro-with-gnu-gfortran
Expand Down
Loading

0 comments on commit 230eeef

Please sign in to comment.