Skip to contentSkip to conversation

master - commands: move command def parsing into lvm binary

PATCH David Teigland 1 participant 1 message Feb 13, 2017

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c3faa5816d223b0a77a248aed9a88e73461268ce
Commit:        c3faa5816d223b0a77a248aed9a88e73461268ce
Parent:        942dc07402747d00946c5e80d890d535c0cbd125
Author:        David Teigland <[email protected]>
AuthorDate:    Fri Feb 10 11:36:11 2017 -0600
Committer:     David Teigland <[email protected]>
CommitterDate: Mon Feb 13 08:20:10 2017 -0600

commands: move command def parsing into lvm binary

It was previously done at build time by the ccmd binary.

---
 tools/Makefile.in      |   47 +-
 tools/ccmd-main.c      | 1130 --------------------
 tools/ccmd-man.c       |  997 ------------------
 tools/ccmd-util.c      |  936 -----------------
 tools/ccmd.h           |  144 ---
 tools/command-lines.in |   17 +-
 tools/command.c        | 2694 ++++++++++++++++++++++++++++++++++++++++++++++++
 tools/command.h        |   36 +-
 tools/lvchange.c       |   20 +-
 tools/lvconvert.c      |   38 +-
 tools/lvmcmdline.c     |  303 +-----
 tools/toollib.c        |   12 +-
 tools/tools.h          |    8 +
 13 files changed, 2847 insertions(+), 3535 deletions(-)
tools/Makefile.in +26 -21
index 8f53851..1761be4 100644
@@ -18,6 +18,7 @@ top_srcdir = @top_srcdir@
 top_builddir = @top_builddir@
 
 SOURCES =\
+	command.c \
 	dumpconfig.c \
 	formats.c \
 	lvchange.c \
@@ -77,7 +78,6 @@ SOURCES2 =\
 
 TARGETS =\
 	.commands \
-	command-lines.h \
 	liblvm2cmd.a \
 	lvm
 
@@ -102,7 +102,7 @@ CLEAN_TARGETS = liblvm2cmd.$(LIB_SUFFIX) $(TARGETS_DM) \
 	liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION) lvm-static.o \
 	liblvm2cmd-static.a dmsetup.static lvm.static \
 	$(LDDEPS) .exported_symbols_generated \
-	ccmd command-lines.h command-lines-count.h
+	cmds.h command-lines-input.h command-count.h
 
 ifeq ("@CMDLIB@", "yes")
 	TARGETS += liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION)
@@ -176,35 +176,40 @@ liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION): liblvm2cmd.$(LIB_SUFFIX)
 	$(CC) -E -P $(srcdir)/cmdnames.h 2> /dev/null | \
 		egrep -v '^ *(|#.*|config|devtypes|dumpconfig|formats|fullreport|help|lastlog|lvpoll|pvdata|segtypes|systemid|tags|version) *$$' > .commands
 
-ccmd: $(srcdir)/ccmd-main.c $(srcdir)/ccmd-util.c $(srcdir)/ccmd-man.c
-	$(CC) $(srcdir)/ccmd-main.c $(srcdir)/ccmd-util.c $(srcdir)/ccmd-man.c -o ccmd
-
 .DELETE_ON_ERROR:
 
-command-lines.h: $(srcdir)/command-lines.in ccmd
-	$(top_builddir)/tools/ccmd --output struct $(srcdir)/command-lines.in > $@
-
-command-lines-count.h: $(srcdir)/command-lines.in ccmd
-	$(top_builddir)/tools/ccmd --output count $(srcdir)/command-lines.in > $@
-
 # move properly to configure
 WC = /usr/bin/wc
 GREP = /bin/grep
 SORT = /bin/sort
-CUT = /bin/cut
-SED = /bin/sed
 
-# FIXME Add licence text from template file
-command-lines-count-new.h: $(srcdir)/command-lines.in ccmd Makefile
+command-count.h: $(srcdir)/command-lines.in Makefile
+	set -o pipefail && \
+	( cat $(top_srcdir)/doc/license.txt && \
+	  echo "/* Do not edit. This file is generated by the Makefile. */" && \
+	  echo -n "#define COMMAND_COUNT " && \
+	  $(GREP) '^ID:' $(srcdir)/command-lines.in | $(WC) -l \
+	) > $@
+
+cmds.h: $(srcdir)/command-lines.in Makefile
+	set -o pipefail && \
+	( cat $(top_srcdir)/doc/license.txt && \
+	  echo "/* Do not edit. This file is generated by the Makefile. */" && \
+	  echo "cmd(CMD_NONE, none)" && \
+	  $(GREP) '^ID:' $(srcdir)/command-lines.in | $(SORT) -u | $(AWK) '{print "cmd(" $$2 "_CMD, " $$2 ")"}' && \
+	  echo "cmd(CMD_COUNT, count)" \
+	) > $@
+
+command-lines-input.h: $(srcdir)/command-lines.in Makefile
 	set -o pipefail && \
-	(echo -n "#define COMMAND_COUNT " && \
-	$(GREP) '^ID:' $(srcdir)/command-lines.in | $(WC) -l && \
-	echo -e "enum {\n\tno_CMD," && \
-	$(GREP) '^ID:' $(srcdir)/command-lines.in | $(CUT) -d\  -f2 | $(SORT) -u | $(SED) 's/\(.*\)/\t&_CMD,/' && \
-	echo -e "\tCOMMAND_ID_COUNT,\n};" \
+	( cat $(top_srcdir)/doc/license.txt && \
+	  echo "/* Do not edit. This file is generated by the Makefile. */" && \
+	  echo -en "const char _command_input[] =\n\n\"" && \
+	  $(GREP) -Ev '^#|\-\-\-|^$$' $(srcdir)/command-lines.in | $(AWK) 'BEGIN {ORS = "\\n\"\n\""} //' && \
+	  echo "\\n\";" \
 	) > $@
 
-$(SOURCES:%.c=%.d): command-lines.h command-lines-count.h
+$(SOURCES:%.c=%.d) $(SOURCES2:%.c=%.d): command-lines-input.h command-count.h cmds.h
 
 ifneq ("$(CFLOW_CMD)", "")
 CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES))
tools/ccmd-main.c deleted +0 -1130

1,130 lines not on this page · raw message

tools/ccmd-man.c deleted +0 -997

997 lines not on this page · raw message

tools/ccmd-util.c deleted +0 -936

792 lines not on this page · raw message

tools/ccmd.h deleted +0 -144

144 lines not on this page · raw message

tools/command-lines.in +10 -7
index 4cc51fe..30573f4 100644

Lines of this file are not shown. View the raw message.

tools/command.c new file +2694 -0

2,694 lines not on this page · raw message

tools/command.h +26 -10
index c9be260..b3fae03 100644

Lines of this file are not shown. View the raw message.

tools/lvchange.c +6 -14
index b75d058..1c00b76 100644

Lines of this file are not shown. View the raw message.

tools/lvconvert.c +16 -22
index 2ccf264..75bdcb9 100644

Lines of this file are not shown. View the raw message.

tools/lvmcmdline.c +57 -246

303 lines not on this page · raw message

tools/toollib.c +4 -8
index 2c0096f..3b47989 100644

Lines of this file are not shown. View the raw message.

tools/tools.h +8 -0
index 392490f..4e1d87f 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.