-
Notifications
You must be signed in to change notification settings - Fork 111
feat: shared
and static
library targets
#1138
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
Merged
Merged
Changes from 55 commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
7918b56
add `shared` option to the [library] manifest
perazz a3dfe13
generalize library name
perazz c71301c
on shared library, add per-project library files
perazz 64257f6
build target: `info` pretty print
perazz d5a1314
fix library targets
perazz 3e83987
exclude empty library files
perazz 0064295
dependency: add dependency graph to `dependency_node_t`
perazz 7623c4e
return all dependencies in a manifest
perazz cedcf3b
build dependency graph from the manifest
perazz faa01a4
remove `package_tmp`
perazz b92687b
recurse package dependencies
perazz 9cf5c7d
localized topological sort for determining the linking order
perazz 7e78d08
move `library_filename` to fpm_environment
perazz 7fc19bf
fix order of the link dependencies
perazz b374bcb
enumerate shared libraries
perazz 2ddf082
shared library target linking command
perazz 5446a2c
compile all libraries separately
perazz 113ec21
install all lirbary targets
perazz fa63aed
[cli] add comments to `fpm new`
perazz dd5526b
test: shared lib dependencies
perazz fde74e5
test: shared library installer
perazz 7e7ad82
cleanup
perazz 32f2aa5
BUGFIX: dev_dependency
perazz c27c282
[BUGFIX] ensure target libraries have dependencies among them to ensu…
perazz cffc325
add example: shared library with dependencies
perazz 5beebcd
add shared library examples
perazz 8c4bfe7
[run] cleanup runner command
perazz e6217ed
split get_library_dirs
perazz 4f4d970
[run] add local library paths to the local environment to ruyn with d…
perazz 8579677
always run position independent code
perazz 8bffd89
fix
perazz 414f448
`requires` (int) -> `package_dep` (string_t)
perazz d5f1ecf
do not prune source files when building shared libraries
perazz 5bf09ea
more shared library tests
perazz 6e4ff09
Delete .fpm_model.toml.swp
perazz 49f3710
remove unused variables
perazz 58f3185
remove `shared`, implement `lib_type` string
perazz 3b66dc7
replace `library.shared` with `library.type`
perazz e57c5da
implement static library linking
perazz 4ebe231
add static library test
perazz 7950b0b
line too long
perazz c03ceaa
create import library and definition file
perazz 01fb0b5
export `.def` and import library on Windows
perazz db42238
targets: always initialize an output_dir
perazz 5486d45
ifx bug fix
perazz 886d609
robust `monolithic` evaluation
perazz b0b6d63
fix monolithic source pruning
perazz f434cb0
ifx: allocatable string checks
perazz 9ef7a9e
always prune empty libraries
perazz 33da9ea
new test: package depends on empty library
perazz 494564a
new test: package depends on empty library
perazz d00e314
add test: enforce dependency ID on pruned empty targets
perazz 05d09dc
Merge branch 'dynamic_library' of https://github.com/perazz/fpm into …
perazz 3cd7732
Update fpm_model.f90
perazz 7d76083
fix failed merge
perazz 2a47835
do not install `.def` files
perazz 523c670
Remove accidentally committed binary (bin/fpm)
perazz 3b5efe5
update CLI help
perazz 5a795f6
update upstream comment
perazz f95cc34
CLI: mention environment variables
perazz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -6,3 +6,6 @@ build/* | |
# CodeBlocks | ||
project/ | ||
|
||
# Temporary files | ||
*.swp | ||
|
This file contains hidden or 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 hidden or 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,4 @@ | ||
program main | ||
use testdrive | ||
print *, 'Hello, world!' | ||
end program main |
This file contains hidden or 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,8 @@ | ||
# App only, use shared lib from other folder | ||
name = "shared_app_only" | ||
library.type="shared" | ||
install.library=true | ||
[dependencies] | ||
shared_lib_extra = { path = "../shared_lib_extra" } | ||
[dev-dependencies] | ||
test-drive = { git = "https://github.com/fortran-lang/test-drive", tag="v0.5.0" } |
This file contains hidden or 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,50 @@ | ||
module test_shared_lib | ||
use testdrive, only : new_unittest, unittest_type, error_type, check | ||
use shared_lib, only: test_something | ||
|
||
implicit none | ||
|
||
public :: collect | ||
|
||
|
||
contains | ||
|
||
!> Collect all exported unit tests | ||
subroutine collect(testsuite) | ||
!> Collection of tests | ||
type(unittest_type), allocatable, intent(out) :: testsuite(:) | ||
|
||
testsuite = [ new_unittest("shared_lib", test_shared) ] | ||
|
||
end subroutine collect | ||
|
||
subroutine test_shared(error) | ||
type(error_type), allocatable, intent(out) :: error | ||
|
||
call check(error, test_something(), 123, "Should be test_something==123") | ||
|
||
end subroutine test_shared | ||
|
||
end module test_shared_lib | ||
|
||
program tester | ||
use, intrinsic :: iso_fortran_env, only : error_unit | ||
use testdrive, only : run_testsuite, new_testsuite, testsuite_type | ||
use test_shared_lib, only : collect | ||
implicit none | ||
integer :: stat | ||
type(testsuite_type), allocatable :: testsuite | ||
character(len=*), parameter :: fmt = '("#", *(1x, a))' | ||
|
||
stat = 0 | ||
|
||
testsuite = new_testsuite("shared_lib", collect) | ||
|
||
write(error_unit, fmt) "Testing:", testsuite%name | ||
call run_testsuite(testsuite%collect, error_unit, stat) | ||
|
||
if (stat > 0) then | ||
write(error_unit, '(i0, 1x, a)') stat, "test(s) failed!" | ||
error stop | ||
end if | ||
end program tester |
This file contains hidden or 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,3 @@ | ||
# Shared library with no executables | ||
name = "shared_lib" | ||
library.type="shared" |
This file contains hidden or 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 @@ | ||
module shared_lib | ||
implicit none | ||
private | ||
|
||
public :: say_hello | ||
public :: test_something | ||
contains | ||
subroutine say_hello | ||
print *, "Hello, shared_lib!" | ||
end subroutine say_hello | ||
integer function test_something() | ||
test_something = 123 | ||
end function test_something | ||
end module shared_lib |
This file contains hidden or 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,5 @@ | ||
name = "shared_lib_empty" | ||
library.type="shared" | ||
[dependencies] | ||
shared_lib = { path = "../shared_lib" } | ||
shared_app_only = { path = "../shared_app_only" } |
This file contains hidden or 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,4 @@ | ||
name = "shared_lib_extra" | ||
library.type="shared" | ||
[dependencies] | ||
shared_lib = { path = "../shared_lib" } |
10 changes: 10 additions & 0 deletions
10
example_packages/shared_lib_extra/src/shared_lib_extra.f90
This file contains hidden or 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 @@ | ||
module shared_lib_extra | ||
implicit none | ||
private | ||
|
||
public :: say_extra_hello | ||
contains | ||
subroutine say_extra_hello | ||
print *, "Hello, shared_lib_extra!" | ||
end subroutine say_extra_hello | ||
end module shared_lib_extra |
This file contains hidden or 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,4 @@ | ||
program main | ||
use testdrive | ||
print *, 'Hello, world!' | ||
end program main |
This file contains hidden or 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,8 @@ | ||
# App only, use shared libs from other folder, no provided sources | ||
name = "static_app_only" | ||
library.type="static" | ||
install.library=true | ||
[dependencies] | ||
shared_lib_extra = { path = "../shared_lib_extra" } | ||
[dev-dependencies] | ||
test-drive = { git = "https://github.com/fortran-lang/test-drive", tag="v0.5.0" } |
This file contains hidden or 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,50 @@ | ||
module test_shared_lib | ||
use testdrive, only : new_unittest, unittest_type, error_type, check | ||
use shared_lib, only: test_something | ||
|
||
implicit none | ||
|
||
public :: collect | ||
|
||
|
||
contains | ||
|
||
!> Collect all exported unit tests | ||
subroutine collect(testsuite) | ||
!> Collection of tests | ||
type(unittest_type), allocatable, intent(out) :: testsuite(:) | ||
|
||
testsuite = [ new_unittest("shared_lib", test_shared) ] | ||
|
||
end subroutine collect | ||
|
||
subroutine test_shared(error) | ||
type(error_type), allocatable, intent(out) :: error | ||
|
||
call check(error, test_something(), 123, "Should be test_something==123") | ||
|
||
end subroutine test_shared | ||
|
||
end module test_shared_lib | ||
|
||
program tester | ||
use, intrinsic :: iso_fortran_env, only : error_unit | ||
use testdrive, only : run_testsuite, new_testsuite, testsuite_type | ||
use test_shared_lib, only : collect | ||
implicit none | ||
integer :: stat | ||
type(testsuite_type), allocatable :: testsuite | ||
character(len=*), parameter :: fmt = '("#", *(1x, a))' | ||
|
||
stat = 0 | ||
|
||
testsuite = new_testsuite("shared_lib", collect) | ||
|
||
write(error_unit, fmt) "Testing:", testsuite%name | ||
call run_testsuite(testsuite%collect, error_unit, stat) | ||
|
||
if (stat > 0) then | ||
write(error_unit, '(i0, 1x, a)') stat, "test(s) failed!" | ||
error stop | ||
end if | ||
end program tester |
This file contains hidden or 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,5 @@ | ||
name = "static_lib_empty" | ||
library.type="static" | ||
[dependencies] | ||
shared_lib = { path = "../shared_lib" } | ||
shared_app_only = { path = "../shared_app_only" } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.