Skip to content

Commit 8791593

Browse files
committed
Add: test package for app with c files
1 parent 9b480d2 commit 8791593

File tree

6 files changed

+56
-1
lines changed

6 files changed

+56
-1
lines changed

ci/run_tests.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ pushd c_main
122122
"$fpm" run
123123
popd
124124

125+
pushd app_with_c
126+
"$fpm" run
127+
popd
128+
125129
pushd hello_fpm_path
126130
"$fpm" run
127131
popd

example_packages/README.md

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

77
| Name | Features | Bootstrap (Haskell) fpm | fpm |
88
|---------------------|---------------------------------------------------------------|:-----------------------:|:---:|
9-
| auto_discovery_off | Default layout with auto-discovery disabled | N | Y |
9+
| app_with_c | C files located in app directory (not src) | N | Y |
1010
| app_with_submodule | Submodules located in app directory (not src) | N | Y |
11+
| auto_discovery_off | Default layout with auto-discovery disabled | N | Y |
1112
| c_header_only | C header-only library | N | Y |
1213
| c_includes | C library with c include directory and dependency includes | N | Y |
1314
| circular_example | Local path dependency; circular dependency | Y | 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"

0 commit comments

Comments
 (0)