[pacman-dev,2/4] Create a convenience library for reused functionality

Message ID 20180705144244.15619-2-dreisner@archlinux.org
State New
Headers show
Series
  • [pacman-dev,1/4] pacman/conf: Remove unused include
Related show

Commit Message

Dave Reisner July 5, 2018, 2:42 p.m. UTC
This is shared between pacman and pacman-conf (and might be used by
other binaries in the future) -- no need to compile it once for each
consumer.
---
 src/pacman/.gitignore  |  3 ++-
 src/pacman/Makefile.am | 37 +++++++++++++++++++------------------
 2 files changed, 21 insertions(+), 19 deletions(-)

Comments

Allan McRae Sept. 19, 2018, 7:47 a.m. UTC | #1
On 6/7/18 12:42 am, Dave Reisner wrote:
> This is shared between pacman and pacman-conf (and might be used by
> other binaries in the future) -- no need to compile it once for each
> consumer.
> ---

I don't understand this patch...

(before)
Making all in src/pacman
  CC       check.o
  CC       conf.o
  CC       database.o
  CC       deptest.o
  CC       files.o
  CC       ini.o
  CC       package.o
  CC       pacman.o
  CC       query.o
  CC       remove.o
  CC       sighandler.o
  CC       sync.o
  CC       callback.o
  CC       upgrade.o
  CC       util.o
  CC       util-common.o
  CCLD     pacman
  CC       pacman-conf.o
  CCLD     pacman-conf

(after)
Making all in src/pacman
  CC       conf.lo
  CC       ini.lo
  CC       callback.lo
  CC       util.lo
  CC       util-common.lo
  CCLD     libbasic.la
  CC       check.o
  CC       database.o
  CC       deptest.o
  CC       files.o
  CC       package.o
  CC       pacman.o
  CC       query.o
  CC       remove.o
  CC       sighandler.o
  CC       sync.o
  CC       upgrade.o
  CCLD     pacman
  CC       pacman-conf.o
  CCLD     pacman-conf

Nothing is compiled twice there.  ini.c and util-common.c are still
compiled twice - once in lib/libalpm and once in src/pacman.

How is the library helping?  Some gain in linking time?

A

Patch

diff --git a/src/pacman/.gitignore b/src/pacman/.gitignore
index 24e11ed3..9889c35e 100644
--- a/src/pacman/.gitignore
+++ b/src/pacman/.gitignore
@@ -1,6 +1,7 @@ 
 .deps
 .libs
+*.l[ao]
 pacman
 pacman.exe
 pacman-conf
-pacman-conf.exe
\ No newline at end of file
+pacman-conf.exe
diff --git a/src/pacman/Makefile.am b/src/pacman/Makefile.am
index 2344daff..15cf20ce 100644
--- a/src/pacman/Makefile.am
+++ b/src/pacman/Makefile.am
@@ -8,6 +8,19 @@  hookdir   = ${sysconfdir}/pacman.d/hooks/
 cachedir  = ${localstatedir}/cache/pacman/pkg/
 logfile   = ${localstatedir}/log/pacman.log
 
+noinst_LTLIBRARIES = \
+	libbasic.la
+
+libbasic_la_SOURCES = \
+	conf.h conf.c \
+	ini.h ini.c \
+	callback.h callback.c \
+	util.h util.c \
+	util-common.h util-common.c
+
+libbasic_la_LIBADD = \
+	$(top_builddir)/lib/libalpm/.libs/libalpm.la
+
 bin_PROGRAMS = pacman pacman-conf
 
 AM_CPPFLAGS = \
@@ -31,37 +44,25 @@  endif
 
 pacman_SOURCES = \
 	check.h check.c \
-	conf.h conf.c \
 	database.c \
 	deptest.c \
 	files.c \
-	ini.h ini.c \
 	package.h package.c \
 	pacman.h pacman.c \
 	query.c \
 	remove.c \
 	sighandler.h sighandler.c \
 	sync.c \
-	callback.h callback.c \
-	upgrade.c \
-	util.h util.c \
-	util-common.h util-common.c
+	upgrade.c
 
 pacman_LDADD = \
 	$(LTLIBINTL) \
+	libbasic.la \
 	$(top_builddir)/lib/libalpm/.libs/libalpm.la \
 	$(LIBARCHIVE_LIBS)
 
-pacman_conf_SOURCES = pacman-conf.c \
-	util.h \
-	util.c \
-	ini.h \
-	ini.c \
-	util-common.h \
-	util-common.c \
-	callback.h \
-	callback.c \
-	conf.h \
-	conf.c
+pacman_conf_SOURCES = pacman-conf.c
 
-pacman_conf_LDADD = $(top_builddir)/lib/libalpm/.libs/libalpm.la
+pacman_conf_LDADD = \
+	libbasic.la \
+	$(top_builddir)/lib/libalpm/.libs/libalpm.la