From 5d22f5aac698c4b8f135a226e944be9ded9475b0 Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Fri, 30 Jul 2021 18:25:46 +0200 Subject: Add objects for handling compiler and archiver --- src/fpm.f90 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/fpm.f90') diff --git a/src/fpm.f90 b/src/fpm.f90 index 89eca1a..465d16e 100644 --- a/src/fpm.f90 +++ b/src/fpm.f90 @@ -10,7 +10,7 @@ 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, & - get_archiver + archiver_t use fpm_sources, only: add_executable_sources, add_sources_from_dir @@ -59,23 +59,23 @@ subroutine build_model(model, settings, package, error) if (allocated(error)) return if(settings%compiler.eq.'')then - model%fortran_compiler = 'gfortran' + model%compiler%fc = "gfortran" else - model%fortran_compiler = settings%compiler + model%compiler%fc = settings%compiler endif - model%archiver = get_archiver() - call get_default_c_compiler(model%fortran_compiler, model%c_compiler) - model%c_compiler = get_env('FPM_C_COMPILER',model%c_compiler) + 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) - if (is_unknown_compiler(model%fortran_compiler)) then + if (is_unknown_compiler(model%compiler%fc)) then write(*, '(*(a:,1x))') & - "", "Unknown compiler", model%fortran_compiler, "requested!", & + "", "Unknown compiler", model%compiler%fc, "requested!", & "Defaults for this compiler might be incorrect" end if - model%output_directory = join_path('build',basename(model%fortran_compiler)//'_'//settings%build_name) + model%output_directory = join_path('build',basename(model%compiler%fc)//'_'//settings%build_name) - call get_module_flags(model%fortran_compiler, & + 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 @@ -187,8 +187,8 @@ subroutine build_model(model, settings, package, error) if (settings%verbose) then write(*,*)' BUILD_NAME: ',settings%build_name - write(*,*)' COMPILER: ',settings%compiler - write(*,*)' C COMPILER: ',model%c_compiler + write(*,*)' COMPILER: ',model%compiler%fc + write(*,*)' C COMPILER: ',model%compiler%cc write(*,*)' COMPILER OPTIONS: ', model%fortran_compile_flags write(*,*)' INCLUDE DIRECTORIES: [', string_cat(model%include_dirs,','),']' end if -- cgit v1.2.3 From c6f0ec64b8060523beaf828ceae32fa3827f65fb Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Fri, 30 Jul 2021 19:59:26 +0200 Subject: Move default flags fetching and build name generation to model --- src/fpm.f90 | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'src/fpm.f90') 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))') & "", "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(*,*)' BUILD_NAME: ',settings%build_name + write(*,*)' BUILD_NAME: ',build_name write(*,*)' COMPILER: ',model%compiler%fc write(*,*)' C COMPILER: ',model%compiler%cc write(*,*)' COMPILER OPTIONS: ', model%fortran_compile_flags -- cgit v1.2.3 From 41d6c7b40aaf59cc6d403add22167a81c2f8b494 Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Sat, 31 Jul 2021 01:07:50 +0200 Subject: Allow detection of underlying compiler in mpiwrapper - cleanup compiler flags a bit --- src/fpm.f90 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/fpm.f90') diff --git a/src/fpm.f90 b/src/fpm.f90 index 53c5767..36f63d8 100644 --- a/src/fpm.f90 +++ b/src/fpm.f90 @@ -18,12 +18,9 @@ use fpm_targets, only: targets_from_sources, resolve_module_dependencies, & FPM_TARGET_EXECUTABLE, FPM_TARGET_ARCHIVE use fpm_manifest, only : get_package_data, package_config_t use fpm_error, only : error_t, fatal_error, fpm_stop -use fpm_manifest_test, only : test_config_t use,intrinsic :: iso_fortran_env, only : stdin=>input_unit, & & stdout=>output_unit, & & stderr=>error_unit -use fpm_manifest_dependency, only: dependency_config_t -use, intrinsic :: iso_fortran_env, only: error_unit implicit none private public :: cmd_build, cmd_run @@ -234,7 +231,7 @@ subroutine check_modules_for_duplicates(model, duplicates_found) if (allocated(model%packages(k)%sources(l)%modules_provided)) then do m=1,size(model%packages(k)%sources(l)%modules_provided) if (model%packages(k)%sources(l)%modules_provided(m)%s.in.modules(:modi-1)) then - write(error_unit, *) "Warning: Module ",model%packages(k)%sources(l)%modules_provided(m)%s, & + write(stderr, *) "Warning: Module ",model%packages(k)%sources(l)%modules_provided(m)%s, & " in ",model%packages(k)%sources(l)%file_name," is a duplicate" duplicates_found = .true. else -- cgit v1.2.3