diff mbox

[20/23,v5] docs/asciidoc: call $(pkgname) and $(pkgdir) in a single place

Message ID b0636122e2367750eece267d01b569286603652d.1410692671.git.yann.morin.1998@free.fr
State Changes Requested
Headers show

Commit Message

Yann E. MORIN Sept. 14, 2014, 11:07 a.m. UTC
Like for all the package infrastructures, retrieve the package name and
directory in the front-end macro-variable, rather than everywhere in the
backend macro.

This allows us to clean up the ASCIIDOC macro, by removing all the calls
to $(pkgname) and $(pkgdir), and to UPPERCASE (which made the macro a
bit difficult to read.)

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Samuel Martin <s.martin49@gmail.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
---
 package/doc-asciidoc.mk | 39 ++++++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 17 deletions(-)

Comments

Samuel Martin Sept. 22, 2014, 8:42 p.m. UTC | #1
On Sun, Sep 14, 2014 at 1:07 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> Like for all the package infrastructures, retrieve the package name and
> directory in the front-end macro-variable, rather than everywhere in the
> backend macro.
>
> This allows us to clean up the ASCIIDOC macro, by removing all the calls
> to $(pkgname) and $(pkgdir), and to UPPERCASE (which made the macro a
> bit difficult to read.)
>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Samuel Martin <s.martin49@gmail.com>
> Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>

Reviewed-by: Samuel Martin <s.martin49@gmail.com>
Thomas De Schampheleire Sept. 24, 2014, 7:44 p.m. UTC | #2
On Sun, Sep 14, 2014 at 1:07 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> Like for all the package infrastructures, retrieve the package name and
> directory in the front-end macro-variable, rather than everywhere in the
> backend macro.
>
> This allows us to clean up the ASCIIDOC macro, by removing all the calls
> to $(pkgname) and $(pkgdir), and to UPPERCASE (which made the macro a
> bit difficult to read.)
>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Samuel Martin <s.martin49@gmail.com>
> Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
> ---
>  package/doc-asciidoc.mk | 39 ++++++++++++++++++++++-----------------
>  1 file changed, 22 insertions(+), 17 deletions(-)
>
> diff --git a/package/doc-asciidoc.mk b/package/doc-asciidoc.mk
> index 4366f8a..38c9ced 100644
> --- a/package/doc-asciidoc.mk
> +++ b/package/doc-asciidoc.mk
> @@ -104,6 +104,11 @@ endef
>  ################################################################################
>  # ASCIIDOC -- generates the make targets needed to build asciidoc documentation.
>  #
> +# argument 1 is the lowercase name of the document; the document's main file
> +#            must have the same name, with the .txt extension
> +# argument 2 is the uppercase name of the document
> +# argument 3 is the directory containing the document's sources
> +#
>  # The variable <DOCUMENT_NAME>_SOURCES defines the dependencies.
>  # The variable <DOCUMENT_NAME>_RESSOURCES defines where the document's
>  # resources, such as images, are located; must be an absolute path.
> @@ -111,43 +116,43 @@ endef
>  define ASCIIDOC
>  # Single line, because splitting a foreach is not easy...
>  $(pkgname)-check-dependencies: asciidoc-check-dependencies

Any reason why you did not change this occurrence of $(pkgname) ?

Other than that, I like the simplification brought by this patch!

Note that the order strikes me as odd. If you'd have made this change
somewhere in the beginning of the series, the rest of the patches
would have been simpler to read too. (no need to change this though,
just an observation).

Best regards,
Thomas
Yann E. MORIN Sept. 24, 2014, 9:16 p.m. UTC | #3
Thomas, All,

On 2014-09-24 21:44 +0200, Thomas De Schampheleire spake thusly:
> On Sun, Sep 14, 2014 at 1:07 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > Like for all the package infrastructures, retrieve the package name and
> > directory in the front-end macro-variable, rather than everywhere in the
> > backend macro.
> >
> > This allows us to clean up the ASCIIDOC macro, by removing all the calls
> > to $(pkgname) and $(pkgdir), and to UPPERCASE (which made the macro a
> > bit difficult to read.)
> >
> > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> > Cc: Samuel Martin <s.martin49@gmail.com>
> > Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
> > ---
> >  package/doc-asciidoc.mk | 39 ++++++++++++++++++++++-----------------
> >  1 file changed, 22 insertions(+), 17 deletions(-)
> >
> > diff --git a/package/doc-asciidoc.mk b/package/doc-asciidoc.mk
> > index 4366f8a..38c9ced 100644
> > --- a/package/doc-asciidoc.mk
> > +++ b/package/doc-asciidoc.mk
> > @@ -104,6 +104,11 @@ endef
> >  ################################################################################
> >  # ASCIIDOC -- generates the make targets needed to build asciidoc documentation.
> >  #
> > +# argument 1 is the lowercase name of the document; the document's main file
> > +#            must have the same name, with the .txt extension
> > +# argument 2 is the uppercase name of the document
> > +# argument 3 is the directory containing the document's sources
> > +#
> >  # The variable <DOCUMENT_NAME>_SOURCES defines the dependencies.
> >  # The variable <DOCUMENT_NAME>_RESSOURCES defines where the document's
> >  # resources, such as images, are located; must be an absolute path.
> > @@ -111,43 +116,43 @@ endef
> >  define ASCIIDOC
> >  # Single line, because splitting a foreach is not easy...
> >  $(pkgname)-check-dependencies: asciidoc-check-dependencies
> 
> Any reason why you did not change this occurrence of $(pkgname) ?

Gee... Drools... Yes, I missed that one.

> Other than that, I like the simplification brought by this patch!

So do I, so do I! ;-)

> Note that the order strikes me as odd. If you'd have made this change
> somewhere in the beginning of the series, the rest of the patches
> would have been simpler to read too. (no need to change this though,
> just an observation).

Yes, I wanted to re-order the series so it was more logical, and bring
cleanups before actual changes.

However, as we discussed on IRC, this series is a real rebase-and-merge
nightmare...

I'll try to see what I can do, but I'm afraid I'll keep this series in
the current order. :-(

At one point, I even considered trashing it and redoing it all from
scratch, but that's just as insane. :-]

Regards,
Yann E. MORIN.
diff mbox

Patch

diff --git a/package/doc-asciidoc.mk b/package/doc-asciidoc.mk
index 4366f8a..38c9ced 100644
--- a/package/doc-asciidoc.mk
+++ b/package/doc-asciidoc.mk
@@ -104,6 +104,11 @@  endef
 ################################################################################
 # ASCIIDOC -- generates the make targets needed to build asciidoc documentation.
 #
+# argument 1 is the lowercase name of the document; the document's main file
+#            must have the same name, with the .txt extension
+# argument 2 is the uppercase name of the document
+# argument 3 is the directory containing the document's sources
+#
 # The variable <DOCUMENT_NAME>_SOURCES defines the dependencies.
 # The variable <DOCUMENT_NAME>_RESSOURCES defines where the document's
 # resources, such as images, are located; must be an absolute path.
@@ -111,43 +116,43 @@  endef
 define ASCIIDOC
 # Single line, because splitting a foreach is not easy...
 $(pkgname)-check-dependencies: asciidoc-check-dependencies
-	$$(Q)$$(foreach hook,$$($$(call UPPERCASE,$(pkgname))_CHECK_EXTRA_DEPENDENCIES_HOOKS),$$(call $$(hook))$$(sep))
+	$$(Q)$$(foreach hook,$$($(2)_CHECK_EXTRA_DEPENDENCIES_HOOKS),$$(call $$(hook))$$(sep))
 
-$$(BUILD_DIR)/$(pkgname):
+$$(BUILD_DIR)/$(1):
 	$$(Q)mkdir -p $$@
 
 # Single line, because splitting a foreach is not easy...
-$(pkgname)-rsync: $$(BUILD_DIR)/$(pkgname)
-	$$(Q)$$(call MESSAGE,"Preparing the $(pkgname) sources...")
-	$$(Q)rsync -a $(pkgdir) $$^
-	$$(Q)$$(foreach hook,$$($$(call UPPERCASE,$(pkgname))_POST_EXTRACT_HOOKS),$$(call $$(hook))$$(sep))
+$(1)-rsync: $$(BUILD_DIR)/$(1)
+	$$(Q)$$(call MESSAGE,"Preparing the $(1) sources...")
+	$$(Q)rsync -a $(3) $$^
+	$$(Q)$$(foreach hook,$$($(2)_POST_EXTRACT_HOOKS),$$(call $$(hook))$$(sep))
 
-$(pkgname)-prepare-sources: $(pkgname)-rsync
+$(1)-prepare-sources: $(1)-rsync
 
-$(call ASCIIDOC_INNER,$(pkgname),$$(call UPPERCASE,$(pkgname)),$(pkgdir),xhtml,html,html,HTML,\
+$(call ASCIIDOC_INNER,$(1),$(2),$(3),xhtml,html,html,HTML,\
 	--xsltproc-opts "--stringparam toc.section.depth 1")
 
-$(call ASCIIDOC_INNER,$(pkgname),$$(call UPPERCASE,$(pkgname)),$(pkgdir),chunked,split-html,chunked,split HTML,\
+$(call ASCIIDOC_INNER,$(1),$(2),$(3),chunked,split-html,chunked,split HTML,\
 	--xsltproc-opts "--stringparam toc.section.depth 1")
 
 # dblatex needs to pass the '--maxvars ...' option to xsltproc to prevent it
 # from reaching the template recursion limit when processing the (long) target
 # package table and bailing out.
-$(call ASCIIDOC_INNER,$(pkgname),$$(call UPPERCASE,$(pkgname)),$(pkgdir),pdf,pdf,pdf,PDF,\
+$(call ASCIIDOC_INNER,$(1),$(2),$(3),pdf,pdf,pdf,PDF,\
 	--dblatex-opts "-P latex.output.revhistory=0 -x '--maxvars 100000'")
 
-$(call ASCIIDOC_INNER,$(pkgname),$$(call UPPERCASE,$(pkgname)),$(pkgdir),text,text,text,text)
+$(call ASCIIDOC_INNER,$(1),$(2),$(3),text,text,text,text)
 
-$(call ASCIIDOC_INNER,$(pkgname),$$(call UPPERCASE,$(pkgname)),$(pkgdir),epub,epub,epub,ePUB)
+$(call ASCIIDOC_INNER,$(1),$(2),$(3),epub,epub,epub,ePUB)
 
-clean: $(pkgname)-clean
-$(pkgname)-clean:
-	$$(Q)$$(RM) -rf $$(BUILD_DIR)/$(pkgname)
-.PHONY: $(pkgname) $(pkgname)-clean
+clean: $(1)-clean
+$(1)-clean:
+	$$(Q)$$(RM) -rf $$(BUILD_DIR)/$(1)
+.PHONY: $(1) $(1)-clean
 endef
 
 ################################################################################
 # asciidoc-document -- the target generator macro for asiciidoc documents
 ################################################################################
 
-asciidoc-document = $(call ASCIIDOC)
+asciidoc-document = $(call ASCIIDOC,$(pkgname),$(call UPPERCASE,$(pkgname)),$(pkgdir))