Skip to content

Commit b8ba629

Browse files
peffgitster
authored andcommitted
Makefile: fold MISC_H into LIB_H
We keep a list of most of the header files in LIB_H, but some are split out into MISC_H. The original point of LIB_H was that it would force recompilation of C files when any of the library headers changed. It was over-encompassing, since not all C files included all of the library headers; this made it simple to maintain, but meant that we sometimes recompiled when it was not necessary. Over time, some new headers were omitted from LIB_H, and rules were added to the Makefile for a few specific targets to explicitly depend on them. This avoided some unnecessary recompilation at the cost of having to maintain the dependency list of those targets manually (e.g., d349a03). Later, we needed a complete list of headers from which we should extract strings to localized. Thus 1b8b2e4 introduced MISC_H to mention all header files not included in LIB_H, and the concatenation of the two lists is fed to xgettext. Headers mentioned as dependencies must also be manually added to MISC_H to receive the benefits of localization. Having to update multiple locations manually is a pain and has led to errors. For example, see "git log -Swt-status.h Makefile" for some back-and-forth between the two locations. Or the fact that column.h was never added to MISC_H, and therefore was not localized (which is fixed by this patch). Moreover, the benefits of keeping these few headers out of LIB_H is not that great, for two reasons: 1. The better way to do this is by auto-computing the dependencies, which is more accurate and less work to maintain. If your compiler supports it, we turn on computed header dependencies by default these days. So these manual dependencies are used only for people who do not have gcc at all (which increases the chance of them becoming stale, as many developers will never even use them). 2. Even if you do not have gcc, the manual header dependencies do not help all that much. They obviously cannot help with an initial compilation (since their purpose is to avoid unnecessary recompilation when a header changes), which means they are only useful when building a new version of git in the working tree that held an existing build (e.g., after checkout or during a bisection). But since a change of a header in LIB_H will force recompilation, and given that the vast majority of headers are in LIB_H, most version changes will result in a full rebuild anyway. Let's just fold MISC_H into LIB_H and get rid of these manual rules. The worst case is some extra compilation, but even that is unlikely to matter due to the reasons above. The one exception is that we should keep common-cmds.h separate. Because it is generated, the computed dependencies do not handle it properly, and we must keep separate individual dependencies on it. Let's therefore rename MISC_H to GENERATED_H to make it more clear what should go in it. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fc89003 commit b8ba629

File tree

1 file changed

+16
-29
lines changed

1 file changed

+16
-29
lines changed

Makefile

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ XDIFF_OBJS =
397397
VCSSVN_H =
398398
VCSSVN_OBJS =
399399
VCSSVN_TEST_OBJS =
400-
MISC_H =
400+
GENERATED_H =
401401
EXTRA_CPPFLAGS =
402402
LIB_H =
403403
LIB_OBJS =
@@ -574,30 +574,22 @@ VCSSVN_H += vcs-svn/fast_export.h
574574
VCSSVN_H += vcs-svn/svndiff.h
575575
VCSSVN_H += vcs-svn/svndump.h
576576

577-
MISC_H += bisect.h
578-
MISC_H += branch.h
579-
MISC_H += bundle.h
580-
MISC_H += common-cmds.h
581-
MISC_H += fetch-pack.h
582-
MISC_H += reachable.h
583-
MISC_H += send-pack.h
584-
MISC_H += shortlog.h
585-
MISC_H += tar.h
586-
MISC_H += thread-utils.h
587-
MISC_H += url.h
588-
MISC_H += walker.h
589-
MISC_H += wt-status.h
577+
GENERATED_H += common-cmds.h
590578

591579
LIB_H += advice.h
592580
LIB_H += archive.h
593581
LIB_H += argv-array.h
594582
LIB_H += attr.h
583+
LIB_H += bisect.h
595584
LIB_H += blob.h
585+
LIB_H += branch.h
596586
LIB_H += builtin.h
597587
LIB_H += bulk-checkin.h
588+
LIB_H += bundle.h
598589
LIB_H += cache-tree.h
599590
LIB_H += cache.h
600591
LIB_H += color.h
592+
LIB_H += column.h
601593
LIB_H += commit.h
602594
LIB_H += compat/bswap.h
603595
LIB_H += compat/cygwin.h
@@ -618,6 +610,7 @@ LIB_H += diff.h
618610
LIB_H += diffcore.h
619611
LIB_H += dir.h
620612
LIB_H += exec_cmd.h
613+
LIB_H += fetch-pack.h
621614
LIB_H += fmt-merge-msg.h
622615
LIB_H += fsck.h
623616
LIB_H += gettext.h
@@ -627,6 +620,7 @@ LIB_H += graph.h
627620
LIB_H += grep.h
628621
LIB_H += hash.h
629622
LIB_H += help.h
623+
LIB_H += http.h
630624
LIB_H += kwset.h
631625
LIB_H += levenshtein.h
632626
LIB_H += list-objects.h
@@ -649,31 +643,38 @@ LIB_H += pkt-line.h
649643
LIB_H += progress.h
650644
LIB_H += prompt.h
651645
LIB_H += quote.h
646+
LIB_H += reachable.h
652647
LIB_H += reflog-walk.h
653648
LIB_H += refs.h
654649
LIB_H += remote.h
655650
LIB_H += rerere.h
656651
LIB_H += resolve-undo.h
657652
LIB_H += revision.h
658653
LIB_H += run-command.h
654+
LIB_H += send-pack.h
659655
LIB_H += sequencer.h
660656
LIB_H += sha1-array.h
661657
LIB_H += sha1-lookup.h
658+
LIB_H += shortlog.h
662659
LIB_H += sideband.h
663660
LIB_H += sigchain.h
664661
LIB_H += strbuf.h
665662
LIB_H += streaming.h
666663
LIB_H += string-list.h
667664
LIB_H += submodule.h
668665
LIB_H += tag.h
666+
LIB_H += tar.h
669667
LIB_H += thread-utils.h
670668
LIB_H += transport.h
671669
LIB_H += tree-walk.h
672670
LIB_H += tree.h
673671
LIB_H += unpack-trees.h
672+
LIB_H += url.h
674673
LIB_H += userdiff.h
675674
LIB_H += utf8.h
676675
LIB_H += varint.h
676+
LIB_H += walker.h
677+
LIB_H += wt-status.h
677678
LIB_H += xdiff-interface.h
678679
LIB_H += xdiff/xdiff.h
679680

@@ -2237,20 +2238,6 @@ else
22372238
# gcc detects!
22382239

22392240
$(GIT_OBJS): $(LIB_H)
2240-
builtin/branch.o builtin/checkout.o builtin/clone.o builtin/reset.o branch.o transport.o: branch.h
2241-
builtin/bundle.o bundle.o transport.o: bundle.h
2242-
builtin/bisect--helper.o builtin/rev-list.o bisect.o: bisect.h
2243-
builtin/clone.o builtin/fetch-pack.o transport.o: fetch-pack.h
2244-
builtin/index-pack.o builtin/grep.o builtin/pack-objects.o transport-helper.o thread-utils.o: thread-utils.h
2245-
builtin/send-pack.o transport.o: send-pack.h
2246-
builtin/log.o builtin/shortlog.o: shortlog.h
2247-
builtin/prune.o builtin/reflog.o reachable.o: reachable.h
2248-
builtin/commit.o builtin/revert.o wt-status.o: wt-status.h
2249-
builtin/tar-tree.o archive-tar.o: tar.h
2250-
connect.o transport.o url.o http-backend.o: url.h
2251-
builtin/branch.o builtin/commit.o builtin/tag.o column.o help.o pager.o: column.h
2252-
http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h
2253-
http.o http-walker.o http-push.o http-fetch.o remote-curl.o: http.h url.h
22542241

22552242
xdiff-interface.o $(XDIFF_OBJS): $(XDIFF_H)
22562243

@@ -2347,7 +2334,7 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \
23472334
--keyword=_ --keyword=N_ --keyword="Q_:1,2"
23482335
XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell
23492336
XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl
2350-
LOCALIZED_C := $(C_OBJ:o=c) $(LIB_H) $(XDIFF_H) $(VCSSVN_H) $(MISC_H)
2337+
LOCALIZED_C := $(C_OBJ:o=c) $(LIB_H) $(XDIFF_H) $(VCSSVN_H) $(GENERATED_H)
23512338
LOCALIZED_SH := $(SCRIPT_SH)
23522339
LOCALIZED_PERL := $(SCRIPT_PERL)
23532340

0 commit comments

Comments
 (0)