[Kimchi-devel] [PATCH V4 6/7] add an optional to toggle the sample plugin

Zhou Zheng Sheng zhshzhou at linux.vnet.ibm.com
Mon Jun 9 08:16:25 UTC 2014


on 2014/06/09 16:02, shaohef at linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> 
> sample plugin is used to test as a plugin demo.
> 
> we disable it by default.
> 
> use this command to enable sample plugin
> $ ./autogen.sh --enable-plugins
> 
> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> ---
>  configure.ac                                   | 10 ++++++++++
>  plugins/sample/Makefile.am                     | 17 ++++++++++++++++-
>  plugins/sample/{sample.conf => sample.conf.in} |  2 +-
>  3 files changed, 27 insertions(+), 2 deletions(-)
>  rename plugins/sample/{sample.conf => sample.conf.in} (91%)
> 
> diff --git a/configure.ac b/configure.ac
> index cc971e8..047cf9d 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -48,6 +48,16 @@ if test "x$PYFLAKES" = "x"; then
>    AC_MSG_WARN([pyflakes not found])
>  fi
> 
> +AC_ARG_ENABLE(
> +    [sample],
> +    [AS_HELP_STRING(
> +        [--enable-sample],
> +        [build sample plugin package @<:@default=no@:>@]
> +    )],
> +    ,
> +    [enable_sample="no"]
> +)
> +AM_CONDITIONAL([SAMPLE], [test "${enable_sample}" = "yes"])
> 
>  AC_CONFIG_FILES([
>      po/Makefile.in
> diff --git a/plugins/sample/Makefile.am b/plugins/sample/Makefile.am
> index e03a4c0..7835c3f 100644
> --- a/plugins/sample/Makefile.am
> +++ b/plugins/sample/Makefile.am
> @@ -19,4 +19,19 @@
> 
>  SUBDIRS = ui
> 
> -EXTRA_DIST = API.json sample.conf $(wildcard *.py)
> +EXTRA_DIST = API.json sample.conf.in $(wildcard *.py)
> +
> +if SAMPLE
> +ENABLE_SAMPLE =  True
> +else
> +ENABLE_SAMPLE =  False
> +endif
> +
> +do_substitution = \
> +	sed -e 's,[@]ENABLE_SAMPLE[@],$(ENABLE_SAMPLE),g'

This is a little too magical. If it's possible, I suggest adding
sample.conf.in into configure.ac substitution list.

> +
> +sample.conf: sample.conf.in Makefile
> +	$(do_substitution) < $< > $@
> +
> +BUILT_SOURCES = sample.conf
> +CLEANFILES = sample.conf
> diff --git a/plugins/sample/sample.conf b/plugins/sample/sample.conf.in
> similarity index 91%
> rename from plugins/sample/sample.conf
> rename to plugins/sample/sample.conf.in
> index 78a9f4e..f890983 100644
> --- a/plugins/sample/sample.conf
> +++ b/plugins/sample/sample.conf.in
> @@ -1,5 +1,5 @@
>  [kimchi]
> -enable = True
> +enable = @ENABLE_SAMPLE@
>  plugin_class = "Drawings"
>  uri = "/plugins/sample"
> 


-- 
Zhou Zheng Sheng / 周征晟
E-mail: zhshzhou at linux.vnet.ibm.com
Telephone: 86-10-82454397




More information about the Kimchi-devel mailing list