aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLKedward <laurence.kedward@bristol.ac.uk>2020-11-01 12:34:44 +0000
committerLKedward <laurence.kedward@bristol.ac.uk>2020-11-01 12:57:01 +0000
commit11bebfcbbd114655b38ee0dd7e47ade9a15252d6 (patch)
tree5abffc045ea766eba59e1e4a39134e94bebc6c7a
parent8096ba728f770fb0eb9fcea863d5177bb294770f (diff)
downloadfpm-11bebfcbbd114655b38ee0dd7e47ade9a15252d6.tar.gz
fpm-11bebfcbbd114655b38ee0dd7e47ade9a15252d6.zip
Get backend working with new model targets structure
-rw-r--r--fpm/src/fpm.f906
-rw-r--r--fpm/src/fpm_backend.f90143
-rw-r--r--fpm/src/fpm_targets.f90120
-rw-r--r--fpm/test/fpm_test/test_module_dependencies.f90126
4 files changed, 206 insertions, 189 deletions
diff --git a/fpm/src/fpm.f90 b/fpm/src/fpm.f90
index 571eb10..402a1e4 100644
--- a/fpm/src/fpm.f90
+++ b/fpm/src/fpm.f90
@@ -170,12 +170,12 @@ subroutine build_model(model, settings, package, error)
& -fmax-errors=1 &
& -ffast-math &
& -funroll-loops ' // &
- & '-J'//join_path(model%output_directory,model%package_name)
+ & '-J'//join_path(model%output_directory,'lib')
else
model%output_directory = 'build/gfortran_debug'
model%fortran_compile_flags = ' -Wall -Wextra -Wimplicit-interface -fPIC -fmax-errors=1 -g '// &
'-fbounds-check -fcheck-array-temporaries -fbacktrace '// &
- '-J'//join_path(model%output_directory,model%package_name)
+ '-J'//join_path(model%output_directory,'lib')
endif
model%link_flags = ''
@@ -234,7 +234,7 @@ subroutine build_model(model, settings, package, error)
stop
else
- call targets_from_sources(model%targets,sources,model%package_name)
+ call targets_from_sources(model,sources)
call resolve_module_dependencies(model%targets,error)
endif
diff --git a/fpm/src/fpm_backend.f90 b/fpm/src/fpm_backend.f90
index 2706b79..88f3317 100644
--- a/fpm/src/fpm_backend.f90
+++ b/fpm/src/fpm_backend.f90
@@ -4,10 +4,10 @@ module fpm_backend
use fpm_environment, only: run, get_os_type, OS_WINDOWS
use fpm_filesystem, only: basename, dirname, join_path, exists, mkdir
-use fpm_model, only: fpm_model_t, srcfile_t, FPM_UNIT_MODULE, &
+use fpm_model, only: fpm_model_t, srcfile_t, build_target_t, FPM_UNIT_MODULE, &
FPM_UNIT_SUBMODULE, FPM_UNIT_SUBPROGRAM, &
FPM_UNIT_CSOURCE, FPM_UNIT_PROGRAM, &
- FPM_SCOPE_TEST, build_target_t
+ FPM_SCOPE_TEST, FPM_TARGET_OBJECT, FPM_TARGET_ARCHIVE, FPM_TARGET_EXECUTABLE
use fpm_strings, only: split
@@ -22,61 +22,28 @@ contains
subroutine build_package(model)
type(fpm_model_t), intent(inout) :: model
- ! integer :: i
- ! character(:), allocatable :: base, linking, subdir
+ integer :: i
+ character(:), allocatable :: base, linking, subdir
- ! if (.not.exists(model%output_directory)) then
- ! call mkdir(model%output_directory)
- ! end if
- ! if (.not.exists(join_path(model%output_directory,model%package_name))) then
- ! call mkdir(join_path(model%output_directory,model%package_name))
- ! end if
+ if (.not.exists(model%output_directory)) then
+ call mkdir(model%output_directory)
+ end if
- ! linking = ""
- ! do i=1,size(model%targets)
+ if (.not.exists(join_path(model%output_directory,'lib'))) then
+ call mkdir(join_path(model%output_directory,'lib'))
+ end if
- ! ! if (model%sources(i)%unit_type == FPM_UNIT_MODULE .or. &
- ! ! model%sources(i)%unit_type == FPM_UNIT_SUBMODULE .or. &
- ! ! model%sources(i)%unit_type == FPM_UNIT_SUBPROGRAM .or. &
- ! ! model%sources(i)%unit_type == FPM_UNIT_CSOURCE) then
-
- ! call build_source(model,model%sources(i),linking)
+ if (model%targets(1)%ptr%target_type == FPM_TARGET_ARCHIVE) then
+ linking = ' -l'//model%package_name//" -L"//join_path(model%output_directory,'lib')
+ else
+ linking = " "
+ end if
- ! ! end if
+ do i=1,size(model%targets)
+
+ call build_target(model,model%targets(i)%ptr,linking)
- ! end do
-
- ! if (any([(model%sources(i)%unit_type == FPM_UNIT_PROGRAM,i=1,size(model%sources))])) then
- ! if (.not.exists(join_path(model%output_directory,'test'))) then
- ! call mkdir(join_path(model%output_directory,'test'))
- ! end if
- ! if (.not.exists(join_path(model%output_directory,'app'))) then
- ! call mkdir(join_path(model%output_directory,'app'))
- ! end if
- ! end if
-
- ! do i=1,size(model%sources)
-
- ! if (model%sources(i)%unit_type == FPM_UNIT_PROGRAM) then
-
- ! base = basename(model%sources(i)%file_name,suffix=.false.)
-
- ! if (model%sources(i)%unit_scope == FPM_SCOPE_TEST) then
- ! subdir = 'test'
- ! else
- ! subdir = 'app'
- ! end if
-
- ! call run("gfortran -c " // model%sources(i)%file_name // ' '//model%fortran_compile_flags &
- ! // " -o " // join_path(model%output_directory,subdir,base) // ".o")
-
- ! call run("gfortran " // join_path(model%output_directory, subdir, base) // ".o "// &
- ! linking //" " //model%link_flags // " -o " // &
- ! join_path(model%output_directory,subdir,model%sources(i)%exe_name) )
-
- ! end if
-
- ! end do
+ end do
end subroutine build_package
@@ -87,41 +54,63 @@ recursive subroutine build_target(model,target,linking)
!
type(fpm_model_t), intent(in) :: model
type(build_target_t), intent(inout) :: target
- character(:), allocatable, intent(inout) :: linking
+ character(:), allocatable, intent(in) :: linking
+
+ integer :: i
+ character(:), allocatable :: objs
+
+ if (target%built) then
+ return
+ end if
+
+ if (target%touched) then
+ write(*,*) '(!) Circular dependency found with: ',target%output_file
+ stop
+ else
+ target%touched = .true.
+ end if
+
+ objs = " "
- ! integer :: i
- ! character(:), allocatable :: object_file
+ do i=1,size(target%dependencies)
- ! if (source_file%built) then
- ! return
- ! end if
+ if (associated(target%dependencies(i)%ptr)) then
+ call build_target(model,target%dependencies(i)%ptr,linking)
+ end if
- ! if (source_file%touched) then
- ! write(*,*) '(!) Circular dependency found with: ',source_file%file_name
- ! stop
- ! else
- ! source_file%touched = .true.
- ! end if
+ if (target%target_type == FPM_TARGET_ARCHIVE ) then
- ! do i=1,size(source_file%file_dependencies)
+ objs = objs//" "//target%dependencies(i)%ptr%output_file
- ! if (associated(source_file%file_dependencies(i)%ptr)) then
- ! call build_source(model,source_file%file_dependencies(i)%ptr,linking)
- ! end if
+ else if (target%target_type == FPM_TARGET_EXECUTABLE .and. &
+ target%dependencies(i)%ptr%target_type == FPM_TARGET_OBJECT) then
- ! end do
+ objs = " "//target%dependencies(i)%ptr%output_file
- ! object_file = get_object_name(model,source_file%file_name)
+ end if
+
+ end do
- ! if (.not.exists(dirname(object_file))) then
- ! call mkdir(dirname(object_file))
- ! end if
+ if (.not.exists(dirname(target%output_file))) then
+ call mkdir(dirname(target%output_file))
+ end if
+
+ select case(target%target_type)
+
+ case (FPM_TARGET_OBJECT)
+ call run("gfortran -c " // target%source%file_name // model%fortran_compile_flags &
+ // " -o " // target%output_file)
+
+ case (FPM_TARGET_EXECUTABLE)
+ call run("gfortran " // objs // model%fortran_compile_flags &
+ //linking// " -o " // target%output_file)
+
+ case (FPM_TARGET_ARCHIVE)
+ call run("ar -rs " // target%output_file // objs)
- ! call run("gfortran -c " // source_file%file_name // model%fortran_compile_flags &
- ! // " -o " // object_file)
- ! linking = linking // " " // object_file
+ end select
- ! source_file%built = .true.
+ target%built = .true.
end subroutine build_target
diff --git a/fpm/src/fpm_targets.f90 b/fpm/src/fpm_targets.f90
index dfdc9af..0c46aac 100644
--- a/fpm/src/fpm_targets.f90
+++ b/fpm/src/fpm_targets.f90
@@ -1,18 +1,16 @@
module fpm_targets
use fpm_error, only: error_t, fatal_error
-use fpm_model!, only: srcfile_t, build_target_t, FPM_UNIT_PROGRAM, &
- ! FPM_TARGET_EXECUTABLE, FPM_TARGET_ARCHIVE, FPM_TARGET_OBJECT
+use fpm_model
use fpm_environment, only: get_os_type, OS_WINDOWS
-use fpm_filesystem, only: dirname, join_path
+use fpm_filesystem, only: dirname, join_path, canon_path
use fpm_strings, only: operator(.in.)
implicit none
contains
-subroutine targets_from_sources(targets,sources,package_name)
- type(build_target_ptr), allocatable, intent(out), target :: targets(:)
+subroutine targets_from_sources(model,sources)
+ type(fpm_model_t), intent(inout), target :: model
type(srcfile_t), intent(in) :: sources(:)
- character(*), intent(in) :: package_name
integer :: i
type(build_target_t), pointer :: dep
@@ -20,49 +18,96 @@ subroutine targets_from_sources(targets,sources,package_name)
with_lib = any([(sources(i)%unit_scope == FPM_SCOPE_LIB,i=1,size(sources))])
- if (with_lib) call add_target(targets,type = FPM_TARGET_ARCHIVE,&
- output_file = package_name//'.a')
+ if (with_lib) call add_target(model%targets,type = FPM_TARGET_ARCHIVE,&
+ output_file = join_path(model%output_directory,&
+ 'lib','lib'//model%package_name//'.a'))
do i=1,size(sources)
select case (sources(i)%unit_type)
case (FPM_UNIT_MODULE,FPM_UNIT_SUBMODULE,FPM_UNIT_SUBPROGRAM,FPM_UNIT_CSOURCE)
- call add_target(targets,source = sources(i), &
+ call add_target(model%targets,source = sources(i), &
type = FPM_TARGET_OBJECT,&
- output_file = get_object_name(sources(i)%file_name))
+ output_file = get_object_name(sources(i)))
if (with_lib .and. sources(i)%unit_scope == FPM_SCOPE_LIB) then
! Archive depends on object
- call add_dependency(targets(1)%ptr, targets(size(targets))%ptr)
+ call add_dependency(model%targets(1)%ptr, model%targets(size(model%targets))%ptr)
end if
case (FPM_UNIT_PROGRAM)
- call add_target(targets,type = FPM_TARGET_OBJECT,&
- output_file = get_object_name(sources(i)%file_name), &
+ call add_target(model%targets,type = FPM_TARGET_OBJECT,&
+ output_file = get_object_name(sources(i)), &
source = sources(i) &
)
-
- call add_target(targets,type = FPM_TARGET_EXECUTABLE,&
- output_file = join_path('app',sources(i)%exe_name))
-
+
+ if (sources(i)%unit_scope == FPM_SCOPE_APP) then
+ call add_target(model%targets,type = FPM_TARGET_EXECUTABLE,&
+ output_file = join_path(model%output_directory,'app',sources(i)%exe_name))
+ else
+ call add_target(model%targets,type = FPM_TARGET_EXECUTABLE,&
+ output_file = join_path(model%output_directory,'test',sources(i)%exe_name))
+
+ end if
! Executable depends on object
- call add_dependency(targets(size(targets))%ptr, targets(size(targets)-1)%ptr)
+ call add_dependency(model%targets(size(model%targets))%ptr, model%targets(size(model%targets)-1)%ptr)
if (with_lib) then
! Executable depends on library
- call add_dependency(targets(size(targets))%ptr, targets(1)%ptr)
+ call add_dependency(model%targets(size(model%targets))%ptr, model%targets(1)%ptr)
end if
end select
end do
+ contains
+
+ function get_object_name(source) result(object_file)
+ ! Generate object target path from source name and model params
+ !
+ !
+ type(srcfile_t), intent(in) :: source
+ character(:), allocatable :: object_file
+
+ integer :: i
+ character(1), parameter :: filesep = '/'
+ character(:), allocatable :: dir
+
+ object_file = canon_path(source%file_name)
+
+ ! Ignore first directory level
+ object_file = object_file(index(object_file,filesep)+1:)
+
+ ! Convert any remaining directory separators to underscores
+ i = index(object_file,filesep)
+ do while(i > 0)
+ object_file(i:i) = '_'
+ i = index(object_file,filesep)
+ end do
+
+ select case(source%unit_scope)
+
+ case (FPM_SCOPE_APP)
+ object_file = join_path(model%output_directory,'app',object_file)//'.o'
+
+ case (FPM_SCOPE_TEST)
+ object_file = join_path(model%output_directory,'test',object_file)//'.o'
+
+ case default
+ object_file = join_path(model%output_directory,'lib',object_file)//'.o'
+
+ end select
+
+ end function get_object_name
+
end subroutine targets_from_sources
+!> Add new target to target list
subroutine add_target(targets,type,output_file,source)
type(build_target_ptr), allocatable, intent(inout) :: targets(:)
integer, intent(in) :: type
@@ -84,49 +129,16 @@ subroutine add_target(targets,type,output_file,source)
end subroutine add_target
+!> Add pointer to dependeny in target%dependencies
subroutine add_dependency(target, dependency)
type(build_target_t), intent(inout) :: target
type(build_target_t) , intent(in), target :: dependency
- type(build_target_ptr) :: depend
-
- depend%ptr => dependency
-
- ! if (.not.allocated(target%dependencies)) then
- ! allocate(target%dependencies(0))
- ! end if
-
- target%dependencies = [target%dependencies, depend]
- ! target%dependencies(size(target%dependencies))%ptr => dependency
+ target%dependencies = [target%dependencies, build_target_ptr(dependency)]
end subroutine add_dependency
-function get_object_name(source_file_name) result(object_file)
- ! Generate object target path from source name and model params
- !
- ! src/test.f90 -> <output-dir>/<package-name>/test.o
- ! src/subdir/test.f90 -> <output-dir>/<package-name>/subdir_test.o
- !
- character(*), intent(in) :: source_file_name
- character(:), allocatable :: object_file
-
- integer :: i
- character(1) :: filesep
-
- select case(get_os_type())
- case (OS_WINDOWS)
- filesep = '\'
- case default
- filesep = '/'
- end select
-
- ! Exclude first directory level from path
- object_file = source_file_name(index(source_file_name,filesep)+1:)//'.o'
-
-end function get_object_name
-
-
subroutine resolve_module_dependencies(targets,error)
! After enumerating all source files: resolve file dependencies
! by searching on module names
diff --git a/fpm/test/fpm_test/test_module_dependencies.f90 b/fpm/test/fpm_test/test_module_dependencies.f90
index 1292a39..c73db30 100644
--- a/fpm/test/fpm_test/test_module_dependencies.f90
+++ b/fpm/test/fpm_test/test_module_dependencies.f90
@@ -2,7 +2,7 @@
module test_module_dependencies
use testsuite, only : new_unittest, unittest_t, error_t, test_failed
use fpm_targets, only: targets_from_sources, resolve_module_dependencies
- use fpm_model, only: srcfile_t, build_target_t, build_target_ptr, &
+ use fpm_model, only: fpm_model_t, srcfile_t, build_target_t, build_target_ptr, &
FPM_UNIT_UNKNOWN, FPM_UNIT_PROGRAM, FPM_UNIT_MODULE, &
FPM_UNIT_SUBMODULE, FPM_UNIT_SUBPROGRAM, FPM_UNIT_CSOURCE, &
FPM_UNIT_CHEADER, FPM_SCOPE_UNKNOWN, FPM_SCOPE_LIB, &
@@ -52,7 +52,9 @@ contains
type(error_t), allocatable, intent(out) :: error
type(srcfile_t) :: sources(2)
- type(build_target_ptr), allocatable :: targets(:)
+ type(fpm_model_t) :: model
+
+ model%output_directory = ''
sources(1) = new_test_source(FPM_UNIT_MODULE,file_name="src/my_mod_1.f90", &
scope = FPM_SCOPE_LIB, &
@@ -63,32 +65,32 @@ contains
provides=[string_t('my_mod_2')], &
uses=[string_t('my_mod_1')])
- call targets_from_sources(targets,sources,'test_package')
- call resolve_module_dependencies(targets,error)
+ call targets_from_sources(model,sources)
+ call resolve_module_dependencies(model%targets,error)
if (allocated(error)) then
return
end if
- if (size(targets) /= 3) then
- call test_failed(error,'Incorrect number of targets - expecting three')
+ if (size(model%targets) /= 3) then
+ call test_failed(error,'Incorrect number of model%targets - expecting three')
return
end if
- call check_target(targets(1)%ptr,type=FPM_TARGET_ARCHIVE,n_depends=2, &
- deps = [targets(2),targets(3)],error=error)
+ call check_target(model%targets(1)%ptr,type=FPM_TARGET_ARCHIVE,n_depends=2, &
+ deps = [model%targets(2),model%targets(3)],error=error)
if (allocated(error)) return
- call check_target(targets(2)%ptr,type=FPM_TARGET_OBJECT,n_depends=0, &
+ call check_target(model%targets(2)%ptr,type=FPM_TARGET_OBJECT,n_depends=0, &
source=sources(1),error=error)
if (allocated(error)) return
- call check_target(targets(3)%ptr,type=FPM_TARGET_OBJECT,n_depends=1, &
- deps=[targets(2)],source=sources(2),error=error)
+ call check_target(model%targets(3)%ptr,type=FPM_TARGET_OBJECT,n_depends=1, &
+ deps=[model%targets(2)],source=sources(2),error=error)
if (allocated(error)) return
@@ -96,7 +98,7 @@ contains
!> Check a program using a library module
- !> Each program generates two targets: object file and executable
+ !> Each program generates two model%targets: object file and executable
!>
subroutine test_program_module_use(error)
@@ -117,9 +119,11 @@ contains
integer :: i
type(srcfile_t) :: sources(3)
- type(build_target_ptr), allocatable :: targets(:)
+ type(fpm_model_t) :: model
character(:), allocatable :: scope_str
+ model%output_directory = ''
+
scope_str = merge('FPM_SCOPE_APP ','FPM_SCOPE_TEST',exe_scope==FPM_SCOPE_APP)//' - '
sources(1) = new_test_source(FPM_UNIT_MODULE,file_name="src/my_mod_1.f90", &
@@ -130,35 +134,35 @@ contains
scope=exe_scope, &
uses=[string_t('my_mod_1')])
- call targets_from_sources(targets,sources,'')
- call resolve_module_dependencies(targets,error)
+ call targets_from_sources(model,sources)
+ call resolve_module_dependencies(model%targets,error)
if (allocated(error)) then
return
end if
- if (size(targets) /= 4) then
- call test_failed(error,scope_str//'Incorrect number of targets - expecting three')
+ if (size(model%targets) /= 4) then
+ call test_failed(error,scope_str//'Incorrect number of model%targets - expecting three')
return
end if
- call check_target(targets(1)%ptr,type=FPM_TARGET_ARCHIVE,n_depends=1, &
- deps=[targets(2)],error=error)
+ call check_target(model%targets(1)%ptr,type=FPM_TARGET_ARCHIVE,n_depends=1, &
+ deps=[model%targets(2)],error=error)
if (allocated(error)) return
- call check_target(targets(2)%ptr,type=FPM_TARGET_OBJECT,n_depends=0, &
+ call check_target(model%targets(2)%ptr,type=FPM_TARGET_OBJECT,n_depends=0, &
source=sources(1),error=error)
if (allocated(error)) return
- call check_target(targets(3)%ptr,type=FPM_TARGET_OBJECT,n_depends=1, &
- deps=[targets(2)],source=sources(2),error=error)
+ call check_target(model%targets(3)%ptr,type=FPM_TARGET_OBJECT,n_depends=1, &
+ deps=[model%targets(2)],source=sources(2),error=error)
if (allocated(error)) return
- call check_target(targets(4)%ptr,type=FPM_TARGET_EXECUTABLE,n_depends=2, &
- deps=[targets(1),targets(3)],error=error)
+ call check_target(model%targets(4)%ptr,type=FPM_TARGET_EXECUTABLE,n_depends=2, &
+ deps=[model%targets(1),model%targets(3)],error=error)
if (allocated(error)) return
@@ -176,33 +180,35 @@ contains
integer :: i
type(srcfile_t) :: sources(1)
- type(build_target_ptr), allocatable :: targets(:)
+ type(fpm_model_t) :: model
+
+ model%output_directory = ''
sources(1) = new_test_source(FPM_UNIT_PROGRAM,file_name="app/my_program.f90", &
scope = FPM_SCOPE_APP, &
provides=[string_t('app_mod')], &
uses=[string_t('app_mod')])
- call targets_from_sources(targets,sources,'')
- call resolve_module_dependencies(targets,error)
+ call targets_from_sources(model,sources)
+ call resolve_module_dependencies(model%targets,error)
if (allocated(error)) then
return
end if
- if (size(targets) /= 2) then
- write(*,*) size(targets)
- call test_failed(error,'Incorrect number of targets - expecting two')
+ if (size(model%targets) /= 2) then
+ write(*,*) size(model%targets)
+ call test_failed(error,'Incorrect number of model%targets - expecting two')
return
end if
- call check_target(targets(1)%ptr,type=FPM_TARGET_OBJECT,n_depends=0, &
+ call check_target(model%targets(1)%ptr,type=FPM_TARGET_OBJECT,n_depends=0, &
source=sources(1),error=error)
if (allocated(error)) return
- call check_target(targets(2)%ptr,type=FPM_TARGET_EXECUTABLE,n_depends=1, &
- deps=[targets(1)],error=error)
+ call check_target(model%targets(2)%ptr,type=FPM_TARGET_EXECUTABLE,n_depends=1, &
+ deps=[model%targets(1)],error=error)
if (allocated(error)) return
@@ -228,9 +234,11 @@ contains
type(error_t), allocatable, intent(out) :: error
type(srcfile_t) :: sources(2)
- type(build_target_ptr), allocatable :: targets(:)
+ type(fpm_model_t) :: model
character(:), allocatable :: scope_str
+ model%output_directory = ''
+
scope_str = merge('FPM_SCOPE_APP ','FPM_SCOPE_TEST',exe_scope==FPM_SCOPE_APP)//' - '
sources(1) = new_test_source(FPM_UNIT_MODULE,file_name="app/app_mod.f90", &
@@ -241,31 +249,31 @@ contains
scope=exe_scope, &
uses=[string_t('app_mod')])
- call targets_from_sources(targets,sources,'')
- call resolve_module_dependencies(targets,error)
+ call targets_from_sources(model,sources)
+ call resolve_module_dependencies(model%targets,error)
if (allocated(error)) then
return
end if
- if (size(targets) /= 3) then
- call test_failed(error,scope_str//'Incorrect number of targets - expecting three')
+ if (size(model%targets) /= 3) then
+ call test_failed(error,scope_str//'Incorrect number of model%targets - expecting three')
return
end if
- call check_target(targets(1)%ptr,type=FPM_TARGET_OBJECT,n_depends=0, &
+ call check_target(model%targets(1)%ptr,type=FPM_TARGET_OBJECT,n_depends=0, &
source=sources(1),error=error)
if (allocated(error)) return
- call check_target(targets(2)%ptr,type=FPM_TARGET_OBJECT,n_depends=1, &
- source=sources(2),deps=[targets(1)],error=error)
+ call check_target(model%targets(2)%ptr,type=FPM_TARGET_OBJECT,n_depends=1, &
+ source=sources(2),deps=[model%targets(1)],error=error)
if (allocated(error)) return
- call check_target(targets(3)%ptr,type=FPM_TARGET_EXECUTABLE,n_depends=1, &
- deps=[targets(2)],error=error)
+ call check_target(model%targets(3)%ptr,type=FPM_TARGET_EXECUTABLE,n_depends=1, &
+ deps=[model%targets(2)],error=error)
if (allocated(error)) return
@@ -280,7 +288,9 @@ contains
type(error_t), allocatable, intent(out) :: error
type(srcfile_t) :: sources(2)
- type(build_target_ptr), allocatable :: targets(:)
+ type(fpm_model_t) :: model
+
+ model%output_directory = ''
sources(1) = new_test_source(FPM_UNIT_MODULE,file_name="src/my_mod_1.f90", &
scope = FPM_SCOPE_LIB, &
@@ -291,8 +301,8 @@ contains
provides=[string_t('my_mod_2')], &
uses=[string_t('my_mod_3')])
- call targets_from_sources(targets,sources,'')
- call resolve_module_dependencies(targets,error)
+ call targets_from_sources(model,sources)
+ call resolve_module_dependencies(model%targets,error)
end subroutine test_missing_library_use
@@ -304,7 +314,9 @@ contains
type(error_t), allocatable, intent(out) :: error
type(srcfile_t) :: sources(2)
- type(build_target_ptr), allocatable :: targets(:)
+ type(fpm_model_t) :: model
+
+ model%output_directory = ''
sources(1) = new_test_source(FPM_UNIT_MODULE,file_name="src/my_mod_1.f90", &
scope = FPM_SCOPE_LIB, &
@@ -314,8 +326,8 @@ contains
scope=FPM_SCOPE_APP, &
uses=[string_t('my_mod_2')])
- call targets_from_sources(targets,sources,'')
- call resolve_module_dependencies(targets,error)
+ call targets_from_sources(model,sources)
+ call resolve_module_dependencies(model%targets,error)
end subroutine test_missing_program_use
@@ -327,7 +339,9 @@ contains
type(error_t), allocatable, intent(out) :: error
type(srcfile_t) :: sources(2)
- type(build_target_ptr), allocatable :: targets(:)
+ type(fpm_model_t) :: model
+
+ model%output_directory = ''
sources(1) = new_test_source(FPM_UNIT_MODULE,file_name="app/app_mod.f90", &
scope = FPM_SCOPE_APP, &
@@ -338,8 +352,8 @@ contains
provides=[string_t('my_mod')], &
uses=[string_t('app_mod')])
- call targets_from_sources(targets,sources,'')
- call resolve_module_dependencies(targets,error)
+ call targets_from_sources(model,sources)
+ call resolve_module_dependencies(model%targets,error)
end subroutine test_invalid_library_use
@@ -351,7 +365,9 @@ contains
type(error_t), allocatable, intent(out) :: error
type(srcfile_t) :: sources(2)
- type(build_target_ptr), allocatable :: targets(:)
+ type(fpm_model_t) :: model
+
+ model%output_directory = ''
sources(1) = new_test_source(FPM_UNIT_MODULE,file_name="app/subdir/app_mod.f90", &
scope = FPM_SCOPE_APP, &
@@ -361,8 +377,8 @@ contains
scope=FPM_SCOPE_APP, &
uses=[string_t('app_mod')])
- call targets_from_sources(targets,sources,'')
- call resolve_module_dependencies(targets,error)
+ call targets_from_sources(model,sources)
+ call resolve_module_dependencies(model%targets,error)
end subroutine test_invalid_own_module_use