Skip to content
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

Compiler flags profiles #498

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ee0d46c
Initial branch commit - new_package subroutine parses TOML and loads …
kubajj May 31, 2021
a978be3
Add support for profiles defined with missing values
kubajj Jun 1, 2021
648764c
Add first implementation of find_profile subroutine
kubajj Jun 3, 2021
e8ea449
Temporary solution of adding compiler flags from profile to model
kubajj Jun 3, 2021
020c34a
Added built in profiles support, updated find_profile decision making
kubajj Jun 4, 2021
1caa897
Add error handling and basic testing for profiles
kubajj Jun 8, 2021
97085c6
Fix merge conflict
kubajj Jun 10, 2021
507d634
Simplify profiles handling before implementing package scope
kubajj Jun 11, 2021
5550bf7
Initial implementation of package scope compiler profiles
kubajj Jun 15, 2021
941c23b
Add file scope flags and representation of profiles as string for sho…
kubajj Jun 18, 2021
a1a503c
Change _ to - in toml fields names, minor changes in get_flags subrou…
kubajj Jun 21, 2021
f81132a
Merge pull requests
kubajj Jun 24, 2021
2989997
Add example pacakges with compiler profiles, remove c_flags from srcf…
kubajj Jun 28, 2021
709ad3a
Add an example project with c flags
kubajj Jun 28, 2021
0997172
Stop modifying model outside of build_model
kubajj Jun 30, 2021
cb06c00
Fix src/fpm_targets.f90 to run with no source files
kubajj Jul 22, 2021
cab4181
Fix merge conflicts
kubajj Jul 22, 2021
286ac9c
Remove failing line from fpm_targets.f90
kubajj Jul 22, 2021
98badd6
Update error handling in profiles parser and introduce is_built_in bo…
kubajj Jul 26, 2021
7d8ca4c
Add profiles hierarchy and propagation to dependencies
kubajj Jul 31, 2021
999c3a6
Implement suggested changes
kubajj Jul 31, 2021
981df56
Update ci test for windows
kubajj Jul 31, 2021
1e82f4e
Update profiles priorities test to use proprocessor
kubajj Jul 31, 2021
20084fe
Apply suggestions from code review
kubajj Jul 31, 2021
91323bf
Change stop to stop 1 in profiles_priorities example package
kubajj Jul 31, 2021
269416a
Prevent main package in profiles priorities from failing due to not b…
kubajj Jul 31, 2021
ba2c812
Fix merge conflict
kubajj Aug 9, 2021
ce59082
Add comments detailing the functions
kubajj Aug 9, 2021
789d823
Fox merge conflict with PR #533
kubajj Aug 9, 2021
794cd85
Apply suggestions from code review
kubajj Aug 9, 2021
a3978b8
Make new_dependency_node pure
kubajj Aug 9, 2021
e642a14
Make get_default_profiles neater
kubajj Aug 9, 2021
09e5b97
Apply some suggestions from code review
kubajj Aug 10, 2021
7d09b4f
Extend subroutine get_object_name
kubajj Aug 10, 2021
789175f
Merge branch 'Load_compiler_profiles' of github.com:kubajj/fpm into L…
kubajj Aug 10, 2021
d708b94
Close code fence and propagate error while reading manifest
kubajj Aug 10, 2021
fa52c0a
Cover invalid toml - only supported tables and fields are valid
kubajj Aug 12, 2021
1edf2f1
Last GSoC commit - Separate validation and reading when parsing toml …
kubajj Aug 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify profiles handling before implementing package scope
  • Loading branch information
kubajj committed Jun 11, 2021
commit 507d634a84b32cabc5606075b861aa9ce387a248
65 changes: 34 additions & 31 deletions src/fpm.f90
Original file line number Diff line number Diff line change
Expand Up @@ -65,37 +65,6 @@ subroutine build_model(model, settings, package, error)
model%fortran_compiler = settings%compiler
endif

if(settings%profile.eq.'')then
if (trim(settings%flag).eq.'') then
profile = 'debug'
end if
else
profile = settings%profile
endif
if (allocated(package%profiles).and.allocated(profile)) then
call find_profile(package%profiles, profile, model%fortran_compiler, get_os_type(), compiler_flags)
print *,"found profile has the following flags: "//compiler_flags
end if
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)

if (is_unknown_compiler(model%fortran_compiler)) then
write(*, '(*(a:,1x))') &
"<WARN>", "Unknown compiler", model%fortran_compiler, "requested!", &
"Defaults for this compiler might be incorrect"
end if
model%output_directory = join_path('build',basename(model%fortran_compiler)//'_'//settings%build_name)

call get_module_flags(model%fortran_compiler, &
& join_path(model%output_directory,model%package_name), &
& model%fortran_compile_flags)
if (allocated(compiler_flags)) then
model%fortran_compile_flags = " "//compiler_flags // settings%flag // model%fortran_compile_flags
else
model%fortran_compile_flags = settings%flag // model%fortran_compile_flags
end if

allocate(model%packages(model%deps%ndep))

! Add sources from executable directories
Expand Down Expand Up @@ -166,6 +135,7 @@ subroutine build_model(model, settings, package, error)
if (allocated(error)) exit

model%packages(i)%name = dependency%name
model%packages(i)%profiles = dependency%profiles
if (.not.allocated(model%packages(i)%sources)) allocate(model%packages(i)%sources(0))

if (allocated(dependency%library)) then
Expand Down Expand Up @@ -214,6 +184,39 @@ subroutine build_model(model, settings, package, error)
if (duplicates_found) then
error stop 'Error: One or more duplicate module names found.'
end if

! Compiler flags logic
if(settings%profile.eq.'')then
if (trim(settings%flag).eq.'') then
profile = 'debug'
end if
else
profile = settings%profile
endif
if (allocated(package%profiles).and.allocated(profile)) then
call find_profile(package%profiles, profile, model%fortran_compiler, get_os_type(), compiler_flags)
print *,"Matching profile has the following flags: "//compiler_flags
end if
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)

if (is_unknown_compiler(model%fortran_compiler)) then
write(*, '(*(a:,1x))') &
"<WARN>", "Unknown compiler", model%fortran_compiler, "requested!", &
"Defaults for this compiler might be incorrect"
end if
model%output_directory = join_path('build',basename(model%fortran_compiler)//'_'//settings%build_name)

call get_module_flags(model%fortran_compiler, &
& join_path(model%output_directory,model%package_name), &
& model%fortran_compile_flags)
if (allocated(compiler_flags)) then
model%fortran_compile_flags = " "//compiler_flags // settings%flag // model%fortran_compile_flags
else
model%fortran_compile_flags = settings%flag // model%fortran_compile_flags
end if

end subroutine build_model

! Check for duplicate modules
Expand Down
6 changes: 3 additions & 3 deletions src/fpm/manifest/package.f90
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
module fpm_manifest_package
use fpm_manifest_build, only: build_config_t, new_build_config
use fpm_manifest_dependency, only : dependency_config_t, new_dependencies
use fpm_manifest_profile, only : profile_config_t, new_profiles, NO_DEF_PROF, get_default_profiles
use fpm_manifest_profile, only : profile_config_t, new_profiles, get_default_profiles
use fpm_manifest_example, only : example_config_t, new_example
use fpm_manifest_executable, only : executable_config_t, new_executable
use fpm_manifest_library, only : library_config_t, new_library
Expand Down Expand Up @@ -187,8 +187,8 @@ subroutine new_package(self, table, error)
call new_profiles(self%profiles, child, error)
if (allocated(error)) return
else
allocate(self%profiles(NO_DEF_PROF))
call get_default_profiles(self%profiles)
self%profiles = get_default_profiles(error)
if (allocated(error)) return
end if

call get_value(table, "executable", children, requested=.false.)
Expand Down
Loading