1
1
module fpm_model
2
-
3
2
! Definition and validation of the backend model
4
-
5
- use fpm_command_line, only: fpm_build_settings
6
- use fpm_filesystem, only: exists, join_path
7
- use fpm_manifest, only: package_t, default_library, default_executable
8
- use fpm_manifest_executable, only: executable_t
9
- use fpm_sources, only: resolve_module_dependencies, add_sources_from_dir, &
10
- add_executable_sources, srcfile_t
11
3
use fpm_strings, only: string_t
12
-
13
4
implicit none
14
5
15
6
private
16
- public :: build_model, fpm_model_t
7
+ public :: srcfile_ptr, srcfile_t, fpm_model_t
8
+
9
+ public :: FPM_UNIT_UNKNOWN, FPM_UNIT_PROGRAM, FPM_UNIT_MODULE, &
10
+ FPM_UNIT_SUBMODULE, FPM_UNIT_SUBPROGRAM, FPM_UNIT_CSOURCE, &
11
+ FPM_UNIT_CHEADER
12
+
13
+ integer , parameter :: FPM_UNIT_UNKNOWN = - 1
14
+ integer , parameter :: FPM_UNIT_PROGRAM = 1
15
+ integer , parameter :: FPM_UNIT_MODULE = 2
16
+ integer , parameter :: FPM_UNIT_SUBMODULE = 3
17
+ integer , parameter :: FPM_UNIT_SUBPROGRAM = 4
18
+ integer , parameter :: FPM_UNIT_CSOURCE = 5
19
+ integer , parameter :: FPM_UNIT_CHEADER = 6
20
+
21
+ type srcfile_ptr
22
+ ! For constructing arrays of src_file pointers
23
+ type (srcfile_t), pointer :: ptr = > null ()
24
+ end type srcfile_ptr
25
+
26
+ type srcfile_t
27
+ ! Type for encapsulating a source file
28
+ ! and it's metadata
29
+ character (:), allocatable :: file_name
30
+ ! File path relative to cwd
31
+ character (:), allocatable :: exe_name
32
+ ! Name of executable for FPM_UNIT_PROGRAM
33
+ logical :: is_test = .false.
34
+ ! Is executable a test?
35
+ type (string_t), allocatable :: modules_provided(:)
36
+ ! Modules provided by this source file (lowerstring)
37
+ integer :: unit_type = FPM_UNIT_UNKNOWN
38
+ ! Type of program unit
39
+ type (string_t), allocatable :: modules_used(:)
40
+ ! Modules USEd by this source file (lowerstring)
41
+ type (string_t), allocatable :: include_dependencies(:)
42
+ ! Files INCLUDEd by this source file
43
+ type (srcfile_ptr), allocatable :: file_dependencies(:)
44
+ ! Resolved source file dependencies
45
+
46
+ logical :: built = .false.
47
+ logical :: touched = .false.
48
+ end type srcfile_t
17
49
18
50
type :: fpm_model_t
19
51
character (:), allocatable :: package_name
@@ -30,39 +62,4 @@ module fpm_model
30
62
! Base directory for build
31
63
end type fpm_model_t
32
64
33
- contains
34
-
35
- subroutine build_model (model , settings , package )
36
- ! Constructs a valid fpm model from command line settings and toml manifest
37
- !
38
- type (fpm_model_t), intent (out ) :: model
39
- type (fpm_build_settings), intent (in ) :: settings
40
- type (package_t), intent (in ) :: package
41
-
42
- model% package_name = package% name
43
-
44
- ! #TODO: Choose flags and output directory based on cli settings & manifest inputs
45
- model% fortran_compiler = ' gfortran'
46
- model% output_directory = ' build/gfortran_debug'
47
- model% fortran_compile_flags = ' -Wall -Wextra -Wimplicit-interface -fPIC -fmax-errors=1 -g ' // &
48
- ' -fbounds-check -fcheck-array-temporaries -fbacktrace ' // &
49
- ' -J' // join_path(model% output_directory,model% package_name)
50
- model% link_flags = ' '
51
-
52
- ! Add sources from executable directories
53
- if (allocated (package% executable)) then
54
- call add_executable_sources(model% sources, package% executable,is_test= .false. )
55
- end if
56
- if (allocated (package% test)) then
57
- call add_executable_sources(model% sources, package% test,is_test= .true. )
58
- end if
59
-
60
- if (allocated (package% library)) then
61
- call add_sources_from_dir(model% sources,package% library% source_dir)
62
- end if
63
-
64
- call resolve_module_dependencies(model% sources)
65
-
66
- end subroutine build_model
67
-
68
65
end module fpm_model
0 commit comments