Skip to content

Commit f508dba

Browse files
Merge branch 'main' into enable_profiles_in_toml
2 parents 0c6c3a4 + 07a725b commit f508dba

File tree

102 files changed

+3619
-959
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+3619
-959
lines changed

.github/workflows/CI.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,20 @@ jobs:
5959
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
6060
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
6161
62+
- name: Install GFortran Windows
63+
if: contains(matrix.os, 'windows')
64+
run: |
65+
Invoke-WebRequest -Uri $Env:GCC_DOWNLOAD -OutFile mingw-w64.zip
66+
Expand-Archive mingw-w64.zip
67+
echo "$pwd\mingw-w64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
68+
env:
69+
GCC_DOWNLOAD: "https://github.com/brechtsanders/winlibs_mingw/releases/download/9.4.0-9.0.0-msvcrt-r2/winlibs-x86_64-posix-seh-gcc-9.4.0-mingw-w64-9.0.0-r2.zip"
70+
6271
# Phase 1: Bootstrap fpm with existing version
6372
- name: Install fpm
6473
uses: fortran-lang/setup-fpm@v3
6574
with:
66-
fpm-version: 'v0.2.0'
75+
fpm-version: 'v0.3.0'
6776

6877
- name: Remove fpm from path
6978
shell: bash

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Binaries for the latest stable release are available [to download](https://githu
3737

3838
__Note:__ On Linux and MacOS, you will need to enable executable permission before you can use the binary.
3939

40-
_e.g._ `$ chmod u+x fpm-0.5.0-linux-x86_64`
40+
_e.g._ `$ chmod u+x fpm-0.6.0-linux-x86_64`
4141

4242
The binaries at the [current tag](https://github.com/fortran-lang/fpm/releases/tag/current) are updated automatically to always provide the current git version from the default branch.
4343

@@ -66,7 +66,8 @@ or from [miniconda](https://docs.conda.io/en/latest/miniconda.html).
6666

6767
#### [MSYS2]
6868

69-
Fpm is available as MinGW package in the MSYS2 package manager.
69+
Fpm is available as MinGW package in the MSYS2 package manager,
70+
which supports parallelization of the target compilation.
7071
To install fpm with pacman use
7172

7273
```
@@ -101,6 +102,21 @@ For more details check the package information [here](https://spack.readthedocs.
101102
[Spack]: https://spack.io
102103

103104

105+
#### Homebrew
106+
107+
The Fortran Package Manager (fpm) is available for the [Homebrew](https://brew.sh/) package manager via an additional tap.
108+
To install fpm via brew, include the new tap and install using
109+
110+
```
111+
brew tap fortran-lang/fortran
112+
brew install fpm
113+
```
114+
115+
Binary distributions are available for MacOS 11 (Catalina) and 12 (Big Sur) for x86_64 architectures. For other platforms fpm will be built locally from source automatically.
116+
117+
Fpm should be available and functional after those steps.
118+
For more details checkout the tap [here](https://github.com/fortran-lang/homebrew-fortran).
119+
104120
#### Github Actions
105121

106122
To setup *fpm* within Github actions for automated testing, you can use the [fortran-lang/setup-fpm](https://github.com/marketplace/actions/setup-fpm) action.

app/main.f90

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ program main
88
fpm_test_settings, &
99
fpm_install_settings, &
1010
fpm_update_settings, &
11+
fpm_clean_settings, &
1112
get_command_line_settings
1213
use fpm_error, only: error_t
1314
use fpm_filesystem, only: exists, parent_dir, join_path
14-
use fpm, only: cmd_build, cmd_run
15+
use fpm, only: cmd_build, cmd_run, cmd_clean
1516
use fpm_cmd_install, only: cmd_install
1617
use fpm_cmd_new, only: cmd_new
1718
use fpm_cmd_update, only : cmd_update
@@ -45,20 +46,24 @@ program main
4546
pwd_working = pwd_start
4647
end if
4748

48-
if (.not.has_manifest(pwd_working)) then
49-
project_root = pwd_working
50-
do while(.not.has_manifest(project_root))
51-
working_dir = parent_dir(project_root)
52-
if (len(working_dir) == 0) exit
53-
project_root = working_dir
54-
end do
55-
56-
if (has_manifest(project_root)) then
57-
call change_directory(project_root, error)
58-
call handle_error(error)
59-
write(output_unit, '(*(a))') "fpm: Entering directory '"//project_root//"'"
49+
select type (settings => cmd_settings)
50+
type is (fpm_new_settings)
51+
class default
52+
if (.not.has_manifest(pwd_working)) then
53+
project_root = pwd_working
54+
do while(.not.has_manifest(project_root))
55+
working_dir = parent_dir(project_root)
56+
if (len(working_dir) == 0) exit
57+
project_root = working_dir
58+
end do
59+
60+
if (has_manifest(project_root)) then
61+
call change_directory(project_root, error)
62+
call handle_error(error)
63+
write(output_unit, '(*(a))') "fpm: Entering directory '"//project_root//"'"
64+
end if
6065
end if
61-
end if
66+
end select
6267

6368
select type(settings=>cmd_settings)
6469
type is (fpm_new_settings)
@@ -73,6 +78,8 @@ program main
7378
call cmd_install(settings)
7479
type is (fpm_update_settings)
7580
call cmd_update(settings)
81+
type is (fpm_clean_settings)
82+
call cmd_clean(settings)
7683
end select
7784

7885
if (allocated(project_root)) then

ci/run_tests.sh

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
set -ex
33

44
cd "$(dirname $0)/.."
@@ -62,6 +62,22 @@ test ! -x ./build/gfortran_*/app/unused
6262
test ! -x ./build/gfortran_*/test/unused_test
6363
popd
6464

65+
pushd tree_shake
66+
"$fpm" build
67+
"$fpm" run
68+
"$fpm" test
69+
test ! -e ./build/gfortran_*/tree_shake/src_farewell_m.f90.o
70+
test ! -e ./build/gfortran_*/tree_shake/src_farewell_m.f90.o.log
71+
popd
72+
73+
pushd submodule_tree_shake
74+
"$fpm" run
75+
test ! -e ./build/gfortran_*/submodule_tree_shake/src_parent_unused.f90.o
76+
test ! -e ./build/gfortran_*/submodule_tree_shake/src_parent_unused.f90.o.log
77+
test ! -e ./build/gfortran_*/submodule_tree_shake/src_child_unused.f90.o
78+
test ! -e ./build/gfortran_*/submodule_tree_shake/src_child_unused.f90.o.log
79+
popd
80+
6581
pushd version_file
6682
"$fpm" build
6783
"$fpm" run
@@ -76,6 +92,10 @@ pushd submodules
7692
"$fpm" build
7793
popd
7894

95+
pushd app_with_submodule
96+
"$fpm" run --all
97+
popd
98+
7999
pushd program_with_module
80100
"$fpm" build
81101
"$fpm" run --target Program_with_module
@@ -102,5 +122,29 @@ pushd c_main
102122
"$fpm" run
103123
popd
104124

125+
pushd app_with_c
126+
"$fpm" run
127+
popd
128+
129+
pushd hello_fpm_path
130+
"$fpm" run
131+
popd
132+
133+
pushd preprocess_cpp
134+
"$fpm" build
135+
popd
136+
137+
pushd preprocess_hello
138+
"$fpm" build
139+
popd
140+
141+
pushd fpm_test_exe_issues
142+
"$fpm" build
143+
popd
144+
145+
pushd cpp_files
146+
"$fpm" test
147+
popd
148+
105149
# Cleanup
106150
rm -rf ./*/build

example_packages/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ the features demonstrated in each package and which versions of fpm are supporte
66

77
| Name | Features | Bootstrap (Haskell) fpm | fpm |
88
|---------------------|---------------------------------------------------------------|:-----------------------:|:---:|
9+
| app_with_c | C files located in app directory (not src) | N | Y |
10+
| app_with_submodule | Submodules located in app directory (not src) | N | Y |
911
| auto_discovery_off | Default layout with auto-discovery disabled | N | Y |
1012
| c_header_only | C header-only library | N | Y |
1113
| c_includes | C library with c include directory and dependency includes | N | Y |
@@ -20,8 +22,14 @@ the features demonstrated in each package and which versions of fpm are supporte
2022
| makefile_complex | External build command (makefile); local path dependency | Y | N |
2123
| program_with_module | App-only; module+program in single source file | Y | Y |
2224
| submodules | Lib-only; submodules (3 levels) | N | Y |
25+
| tree_shake | Test tree-shaking/pruning of unused module dependencies | N | Y |
26+
| submodule_tree_shake| Test tree-shaking/pruning with submodules dependencies | N | Y |
2327
| link_external | Link external library | N | Y |
2428
| link_executable | Link external library to a single executable | N | Y |
2529
| version_file | Read version number from a file in the project root | N | Y |
2630
| with_c | Compile with `c` source files | N | Y |
2731
| with_makefile | External build command (makefile) | Y | N |
32+
| preprocess_cpp | Lib only; C preprocessing; Macro parsing | N | Y |
33+
| preprocess_hello | App only; Macros remain local to the package | N | Y |
34+
| preprocess_hello_dependency | Lib only; Macros not getting passed here from root | N | Y |
35+
| cpp_files | C++ files get compiled using fpm | N | Y |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/*
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <sys/stat.h>
2+
/*
3+
* Decides whether a given file name is a directory.
4+
* return 1 if file exists and is a directory
5+
* Source (Public domain): https://github.com/urbanjost/M_system
6+
*/
7+
int my_isdir(const char *path)
8+
{
9+
struct stat sb;
10+
return stat(path, &sb) == 0 && S_ISDIR(sb.st_mode);
11+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module with_c
2+
use iso_c_binding, only: c_char, c_int, c_null_char
3+
implicit none
4+
5+
contains
6+
7+
function system_isdir(dirname)
8+
! Source (Public domain): https://github.com/urbanjost/M_system
9+
!
10+
implicit none
11+
character(len=*), intent(in) :: dirname
12+
logical :: system_isdir
13+
14+
interface
15+
function c_isdir(dirname) bind(C, name="my_isdir") result(c_ierr)
16+
import c_char, c_int
17+
character(kind=c_char, len=1), intent(in) :: dirname(*)
18+
integer(kind=c_int) :: c_ierr
19+
end function c_isdir
20+
end interface
21+
22+
system_isdir = c_isdir(trim(dirname)//c_null_char) == 1
23+
24+
end function system_isdir
25+
26+
end module with_c
27+
28+
program with_c_app
29+
use with_c
30+
implicit none
31+
32+
write (*, *) "isdir('app') = ", system_isdir('app')
33+
write (*, *) "isdir('src') = ", system_isdir('src')
34+
write (*, *) "isdir('test') = ", system_isdir('test')
35+
write (*, *) "isdir('bench') = ", system_isdir('bench')
36+
37+
end program with_c_app

example_packages/app_with_c/fpm.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name = "with_c"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/*

0 commit comments

Comments
 (0)