From 33ad2ce196eb70d56e0150c153c7931727226095 Mon Sep 17 00:00:00 2001 From: LKedward Date: Sat, 12 Dec 2020 10:37:22 +0000 Subject: Fix: Ignore empty source files Targets not generated for empty source files --- fpm/src/fpm_source_parsing.f90 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3