[PATCH] lib: add new libgit-builtin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since its creation in 0a02ce72d9 (Clean up the Makefile a bit.,
2005-04-18), libgit.a has been used as dumping ground for everything all
git commands use.

When the code was split between `*.c` and `builtin/*.c` it was never
clarified what belongs in what category.

The code in `*.c` can be shared by all builtins, but so can the code in
`builtin/*.c`.

There's no practical difference.

In order to attempt to start decoupling libgit.a from the `git` binary,
let's create a new libgit-builtin.a library meant only for the code in
`builtin/*.c`.

Ideally eventually libgit.a would not contain code that is specific to
`git`, only code that is generic and could be used by projects outside
git.git.

This is an essential step that has to be done if there's any hope of
ever having a public libgit.so library.

The choice of notes-utils.c is mostly arbitrary, but its functions had
been discussed before as a roadblock for a proper libgit. In particular
something like `init_copy_notes_for_rewrite("am")` does not seem like
something anyone outside `git` would want to call.

Cc: Emily Shaffer <nasamuffin@xxxxxxxxxx>
Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---

After re-reading a previous thread about the lbification of git [1], I
realized `init_copy_notes_for_rewrite()` and others which now belong in
notes-utils.c are good candidates to start splitting away from what
eventually should be a public libgit.so library.

[1] https://lore.kernel.org/git/1370712574-27688-1-git-send-email-felipe.contreras@xxxxxxxxx/

 Makefile | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index e440728c24..84cbb35828 100644
--- a/Makefile
+++ b/Makefile
@@ -668,6 +668,7 @@ FUZZ_OBJS =
 FUZZ_PROGRAMS =
 GIT_OBJS =
 LIB_OBJS =
+BUILTIN_LIB_OBJS =
 SCALAR_OBJS =
 OBJECTS =
 OTHER_PROGRAMS =
@@ -916,6 +917,7 @@ export PYTHON_PATH
 TEST_SHELL_PATH = $(SHELL_PATH)
 
 LIB_FILE = libgit.a
+BUILTIN_LIB_FILE = libgit-builtin.a
 XDIFF_LIB = xdiff/lib.a
 REFTABLE_LIB = reftable/libreftable.a
 REFTABLE_TEST_LIB = reftable/libreftable_test.a
@@ -1071,7 +1073,6 @@ LIB_OBJS += negotiator/noop.o
 LIB_OBJS += negotiator/skipping.o
 LIB_OBJS += notes-cache.o
 LIB_OBJS += notes-merge.o
-LIB_OBJS += notes-utils.o
 LIB_OBJS += notes.o
 LIB_OBJS += object-file.o
 LIB_OBJS += object-name.o
@@ -1194,6 +1195,8 @@ LIB_OBJS += ws.o
 LIB_OBJS += wt-status.o
 LIB_OBJS += xdiff-interface.o
 
+BUILTIN_LIB_OBJS += notes-utils.o
+
 BUILTIN_OBJS += builtin/add.o
 BUILTIN_OBJS += builtin/am.o
 BUILTIN_OBJS += builtin/annotate.o
@@ -1332,7 +1335,7 @@ THIRD_PARTY_SOURCES += sha1collisiondetection/%
 THIRD_PARTY_SOURCES += sha1dc/%
 
 # xdiff and reftable libs may in turn depend on what is in libgit.a
-GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(LIB_FILE)
+GITLIBS = common-main.o $(LIB_FILE) $(BUILTIN_LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(LIB_FILE)
 EXTLIBS =
 
 GIT_USER_AGENT = git/$(GIT_VERSION)
@@ -2655,6 +2658,7 @@ TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST
 test-objs: $(TEST_OBJS)
 
 GIT_OBJS += $(LIB_OBJS)
+GIT_OBJS += $(BUILTIN_LIB_OBJS)
 GIT_OBJS += $(BUILTIN_OBJS)
 GIT_OBJS += common-main.o
 GIT_OBJS += git.o
@@ -2809,6 +2813,9 @@ scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS)
 $(LIB_FILE): $(LIB_OBJS)
 	$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
 
+$(BUILTIN_LIB_FILE): $(BUILTIN_LIB_OBJS)
+	$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
+
 $(XDIFF_LIB): $(XDIFF_OBJS)
 	$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
 
@@ -3651,7 +3658,7 @@ clean: profile-clean coverage-clean cocciclean
 	$(RM) po/git.pot po/git-core.pot
 	$(RM) git.res
 	$(RM) $(OBJECTS)
-	$(RM) $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(REFTABLE_TEST_LIB)
+	$(RM) $(LIB_FILE) $(BUILTIN_LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(REFTABLE_TEST_LIB)
 	$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS)
 	$(RM) $(TEST_PROGRAMS)
 	$(RM) $(FUZZ_PROGRAMS)
-- 
2.40.0+fc1




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux