Re: [pacman-dev] [PATCH 2/4] Create a convenience library for reused functionality

2018-09-19 Thread Allan McRae
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


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

2018-07-05 Thread Dave Reisner
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(-)

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
-- 
2.18.0