aboutsummaryrefslogtreecommitdiff
path: root/src/fpm.f90
diff options
context:
space:
mode:
authorSebastian Ehlert <28669218+awvwgk@users.noreply.github.com>2021-07-30 19:59:26 +0200
committerSebastian Ehlert <28669218+awvwgk@users.noreply.github.com>2021-07-30 23:41:34 +0200
commitc6f0ec64b8060523beaf828ceae32fa3827f65fb (patch)
tree0aeb9c87496fd09e8d6b9596cacd5355d53c10ee /src/fpm.f90
parent5d22f5aac698c4b8f135a226e944be9ded9475b0 (diff)
downloadfpm-c6f0ec64b8060523beaf828ceae32fa3827f65fb.tar.gz
fpm-c6f0ec64b8060523beaf828ceae32fa3827f65fb.zip
Move default flags fetching and build name generation to model
Diffstat (limited to 'src/fpm.f90')
-rw-r--r--src/fpm.f9039
1 files changed, 21 insertions, 18 deletions
diff --git a/src/fpm.f90 b/src/fpm.f90
index 465d16e..53c5767 100644
--- a/src/fpm.f90
+++ b/src/fpm.f90
@@ -1,5 +1,5 @@
module fpm
-use fpm_strings, only: string_t, operator(.in.), glob, join, string_cat
+use fpm_strings, only: string_t, operator(.in.), glob, join, string_cat, fnv_1a
use fpm_backend, only: build_package
use fpm_command_line, only: fpm_build_settings, fpm_new_settings, &
fpm_run_settings, fpm_install_settings, fpm_test_settings
@@ -9,8 +9,7 @@ use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists,
use fpm_model, only: fpm_model_t, srcfile_t, show_model, &
FPM_SCOPE_UNKNOWN, FPM_SCOPE_LIB, FPM_SCOPE_DEP, &
FPM_SCOPE_APP, FPM_SCOPE_EXAMPLE, FPM_SCOPE_TEST
-use fpm_compiler, only: get_module_flags, is_unknown_compiler, get_default_c_compiler, &
- archiver_t
+use fpm_compiler, only: new_compiler, new_archiver
use fpm_sources, only: add_executable_sources, add_sources_from_dir
@@ -43,10 +42,11 @@ subroutine build_model(model, settings, package, error)
integer :: i, j
type(package_config_t) :: dependency
- character(len=:), allocatable :: manifest, lib_dir
+ character(len=:), allocatable :: manifest, lib_dir, flags
logical :: duplicates_found = .false.
type(string_t) :: include_dir
+ character(len=16) :: build_name
model%package_name = package%name
@@ -58,27 +58,30 @@ subroutine build_model(model, settings, package, error)
call model%deps%add(package, error)
if (allocated(error)) return
- if(settings%compiler.eq.'')then
- model%compiler%fc = "gfortran"
+ call new_compiler(model%compiler, settings%compiler)
+ call new_archiver(model%archiver)
+
+ if (settings%flag == '') then
+ flags = model%compiler%get_default_flags(settings%profile == "release")
else
- model%compiler%fc = settings%compiler
- endif
+ flags = settings%flag
+ select case(settings%profile)
+ case("release", "debug")
+ flags = flags // model%compiler%get_default_flags(settings%profile == "release")
+ end select
+ end if
- model%archiver = archiver_t()
- call get_default_c_compiler(model%compiler%fc, model%compiler%cc)
- model%compiler%cc = get_env('FPM_C_COMPILER',model%compiler%cc)
+ write(build_name, '(z16.16)') fnv_1a(flags)
- if (is_unknown_compiler(model%compiler%fc)) then
+ if (model%compiler%is_unknown()) then
write(*, '(*(a:,1x))') &
"<WARN>", "Unknown compiler", model%compiler%fc, "requested!", &
"Defaults for this compiler might be incorrect"
end if
- model%output_directory = join_path('build',basename(model%compiler%fc)//'_'//settings%build_name)
+ model%output_directory = join_path('build',basename(model%compiler%fc)//'_'//build_name)
- call get_module_flags(model%compiler%fc, &
- & join_path(model%output_directory,model%package_name), &
- & model%fortran_compile_flags)
- model%fortran_compile_flags = settings%flag // model%fortran_compile_flags
+ model%fortran_compile_flags = flags // " " // &
+ & model%compiler%get_module_flag(join_path(model%output_directory, model%package_name))
allocate(model%packages(model%deps%ndep))
@@ -186,7 +189,7 @@ subroutine build_model(model, settings, package, error)
if (allocated(error)) return
if (settings%verbose) then
- write(*,*)'<INFO> BUILD_NAME: ',settings%build_name
+ write(*,*)'<INFO> BUILD_NAME: ',build_name
write(*,*)'<INFO> COMPILER: ',model%compiler%fc
write(*,*)'<INFO> C COMPILER: ',model%compiler%cc
write(*,*)'<INFO> COMPILER OPTIONS: ', model%fortran_compile_flags