forked from fortran-lang/fpm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request fortran-lang#743 from LKedward/fix-exe-linking
Fix executables linking
- Loading branch information
Showing
15 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <sys/stat.h> | ||
/* | ||
* Decides whether a given file name is a directory. | ||
* return 1 if file exists and is a directory | ||
* Source (Public domain): https://github.com/urbanjost/M_system | ||
*/ | ||
int my_isdir(const char *path) | ||
{ | ||
struct stat sb; | ||
return stat(path, &sb) == 0 && S_ISDIR(sb.st_mode); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module with_c | ||
use iso_c_binding, only: c_char, c_int, c_null_char | ||
implicit none | ||
|
||
contains | ||
|
||
function system_isdir(dirname) | ||
! Source (Public domain): https://github.com/urbanjost/M_system | ||
! | ||
implicit none | ||
character(len=*), intent(in) :: dirname | ||
logical :: system_isdir | ||
|
||
interface | ||
function c_isdir(dirname) bind(C, name="my_isdir") result(c_ierr) | ||
import c_char, c_int | ||
character(kind=c_char, len=1), intent(in) :: dirname(*) | ||
integer(kind=c_int) :: c_ierr | ||
end function c_isdir | ||
end interface | ||
|
||
system_isdir = c_isdir(trim(dirname)//c_null_char) == 1 | ||
|
||
end function system_isdir | ||
|
||
end module with_c | ||
|
||
program with_c_app | ||
use with_c | ||
implicit none | ||
|
||
write (*, *) "isdir('app') = ", system_isdir('app') | ||
write (*, *) "isdir('src') = ", system_isdir('src') | ||
write (*, *) "isdir('test') = ", system_isdir('test') | ||
write (*, *) "isdir('bench') = ", system_isdir('bench') | ||
|
||
end program with_c_app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
name = "with_c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
submodule(parent) child1 | ||
implicit none | ||
|
||
interface | ||
module function my_fun() result (b) | ||
integer :: b | ||
end function my_fun | ||
end interface | ||
|
||
contains | ||
|
||
module procedure my_sub1 | ||
a = my_fun() | ||
end procedure my_sub1 | ||
|
||
end submodule child1 |
10 changes: 10 additions & 0 deletions
10
example_packages/app_with_submodule/app/app1/grandchild.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
submodule(parent:child1) grandchild | ||
implicit none | ||
|
||
contains | ||
|
||
module procedure my_fun | ||
b = 1 | ||
end procedure my_fun | ||
|
||
end submodule grandchild |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
program test | ||
use parent | ||
implicit none | ||
|
||
integer :: a | ||
|
||
call my_sub1(a) | ||
|
||
if (a /= 1) then | ||
write(*,*) 'FAILED: Unexpected value of a' | ||
stop 1 | ||
end if | ||
|
||
end program test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
submodule(parent) child2 | ||
implicit none | ||
|
||
contains | ||
|
||
module procedure my_sub1 | ||
a = 2 | ||
end procedure my_sub1 | ||
|
||
end submodule child2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
program test | ||
use parent | ||
implicit none | ||
|
||
integer :: a | ||
|
||
call my_sub1(a) | ||
|
||
if (a /= 2) then | ||
write(*,*) 'FAILED: Unexpected value of a' | ||
stop 1 | ||
end if | ||
|
||
end program test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
name = "app_with_submodule" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module parent | ||
implicit none | ||
|
||
interface | ||
|
||
module subroutine my_sub1(a) | ||
integer, intent(out) :: a | ||
end subroutine my_sub1 | ||
end interface | ||
|
||
end module parent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters