Skip to content

Commit 15fe406

Browse files
jiangxingitster
authored andcommitted
Makefile: remove duplicate and unwanted files in FOUND_SOURCE_FILES
We get source files saved in "$(FOUND_SOURCE_FILES)" by running the command "git ls-files" or the command "find". We tried to have the both commands return the same list of files, but apparently the "find" command will return more files, such as the generated headers. We can filter out these generated headers to get closer results. In addition to this, "$(FOUND_SOURCE_FILES)" may contain duplicate files. E.g. "git-ls-files" may have duplicate entries for the same file in different staging areas if there are unresolved conflicts in the working tree. For this case, we can reduce duplicate entries by passing the option "--deduplicate" to git-ls-files. Junio reported that when running "make" in a working tree with unresolved conflicts, "make" may report warnings like below: Makefile:xxxx: target '.build/pot/po/FOO.c.po' given more than once in the same rule The duplicate targets are introduced by the following pattern rule we added in the preceding commit for incremental build of "po/git.pot". $(LOCALIZED_C_GEN_PO): .build/pot/po/%.po: % Although we have resolved this issue by sorting to create a unique $(LOCALIZED_C), other targets may benefit from this. Such as: tags, cscope.out, etc. Reported-by: Junio C Hamano <[email protected]> Signed-off-by: Jiang Xin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6dd9a91 commit 15fe406

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ generated-hdrs: $(GENERATED_H)
845845
## Exhaustive lists of our source files, either dynamically generated,
846846
## or hardcoded.
847847
SOURCES_CMD = ( \
848-
git ls-files \
848+
git ls-files --deduplicate \
849849
'*.[hcS]' \
850850
'*.sh' \
851851
':!*[tp][0-9][0-9][0-9][0-9]*' \
@@ -862,7 +862,7 @@ SOURCES_CMD = ( \
862862
-o \( -name '*.sh' -type f -print \) \
863863
| sed -e 's|^\./||' \
864864
)
865-
FOUND_SOURCE_FILES := $(shell $(SOURCES_CMD))
865+
FOUND_SOURCE_FILES := $(filter-out $(GENERATED_H),$(shell $(SOURCES_CMD)))
866866

867867
FOUND_C_SOURCES = $(filter %.c,$(FOUND_SOURCE_FILES))
868868
FOUND_H_SOURCES = $(filter %.h,$(FOUND_SOURCE_FILES))

0 commit comments

Comments
 (0)