aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLKedward <laurence.kedward@bristol.ac.uk>2020-12-12 10:37:22 +0000
committerLKedward <laurence.kedward@bristol.ac.uk>2020-12-12 10:39:53 +0000
commit33ad2ce196eb70d56e0150c153c7931727226095 (patch)
tree39a938a74b6bfecac8991059e2dd0d42a39600b3
parent9121c4ee97a23d6a7b2becf0de15d2738a84b1a4 (diff)
downloadfpm-33ad2ce196eb70d56e0150c153c7931727226095.tar.gz
fpm-33ad2ce196eb70d56e0150c153c7931727226095.zip
Fix: Ignore empty source files
Targets not generated for empty source files
-rw-r--r--fpm/src/fpm_source_parsing.f9011
1 files changed, 10 insertions, 1 deletions
diff --git a/fpm/src/fpm_source_parsing.f90 b/fpm/src/fpm_source_parsing.f90
index 80b21fb..f81555d 100644
--- a/fpm/src/fpm_source_parsing.f90
+++ b/fpm/src/fpm_source_parsing.f90
@@ -16,7 +16,7 @@
!>
module fpm_source_parsing
use fpm_error, only: error_t, file_parse_error, fatal_error
-use fpm_strings, only: string_t, split, lower, str_ends_with, fnv_1a
+use fpm_strings, only: string_t, string_cat, split, lower, str_ends_with, fnv_1a
use fpm_model, only: srcfile_t, &
FPM_UNIT_UNKNOWN, FPM_UNIT_PROGRAM, FPM_UNIT_MODULE, &
FPM_UNIT_SUBMODULE, FPM_UNIT_SUBPROGRAM, &
@@ -86,6 +86,9 @@ function parse_f_source(f_filename,error) result(f_source)
file_lines = read_lines(fh)
close(fh)
+ ! Ignore empty files, returned as FPM_UNIT_UNKNOW
+ if (len_trim(string_cat(file_lines,' ')) < 1) return
+
f_source%digest = fnv_1a(file_lines)
do pass = 1,2
@@ -388,6 +391,12 @@ function parse_c_source(c_filename,error) result(c_source)
file_lines = read_lines(fh)
close(fh)
+ ! Ignore empty files, returned as FPM_UNIT_UNKNOW
+ if (len_trim(string_cat(file_lines,' ')) < 1) then
+ c_source%unit_type = FPM_UNIT_UNKNOWN
+ return
+ end if
+
c_source%digest = fnv_1a(file_lines)
do pass = 1,2