[Buildroot] [PATCHv3 13/18] pkg-generic: introduce a <pkg>_ALL_DOWNLOADS variable and factorize code

Yann E. MORIN yann.morin.1998 at free.fr
Sat Apr 25 17:58:42 UTC 2015


Thomas, All,

On 2015-04-25 16:42 +0200, Thomas Petazzoni spake thusly:
> Now, both the download and source-check code are iterating over
> <pkg>_SOURCE, <pkg>_PATCH and <pkg>_EXTRA_DOWNLOADS elements, figuring
> out whether they contain full URLs or not. Instead of doing this
> repeatdly, this patch introduces an internal <pkg>_ALL_DOWNLOADS
> variable, which contains the list of everything that needs to be
> downloaded, with URLs already expanded to take into account <pkg>_SITE
> if needed.
> 
> This allows to simplify quite significantly the .stamp_download and
> source-check implementation.
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>

Reviewed-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>

Note that adding $(2)_FINAL_ALL_DEPENDENCIES would not be much more
intrusive than this one patch.

Regards,
Yann E. MORIN.

> ---
>  package/pkg-generic.mk | 26 ++++++++------------------
>  1 file changed, 8 insertions(+), 18 deletions(-)
> 
> diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
> index cb901ae..517c02f 100644
> --- a/package/pkg-generic.mk
> +++ b/package/pkg-generic.mk
> @@ -72,25 +72,13 @@ endif
>  $(BUILD_DIR)/%/.stamp_downloaded:
>  	$(foreach hook,$($(PKG)_PRE_DOWNLOAD_HOOKS),$(call $(hook))$(sep))
>  # Only show the download message if it isn't already downloaded
> -	$(Q)for p in $($(PKG)_SOURCE) $($(PKG)_PATCH) $($(PKG)_EXTRA_DOWNLOADS) ; do \
> +	$(Q)for p in $($(PKG)_ALL_DOWNLOADS); do \
>  		if test ! -e $(DL_DIR)/`basename $$p` ; then \
>  			$(call MESSAGE,"Downloading") ; \
>  			break ; \
>  		fi ; \
>  	done
> -	$(if $($(PKG)_SOURCE),$(call DOWNLOAD,$($(PKG)_SITE:/=)/$($(PKG)_SOURCE)))
> -	$(foreach p,$($(PKG)_EXTRA_DOWNLOADS),\
> -		$(if $(findstring ://,$(p)),\
> -			$(call DOWNLOAD,$(p)),\
> -			$(call DOWNLOAD,$($(PKG)_SITE:/=)/$(p))\
> -		)\
> -	$(sep))
> -	$(foreach p,$($(PKG)_PATCH),\
> -		$(if $(findstring ://,$(p)),\
> -			$(call DOWNLOAD,$(p)),\
> -			$(call DOWNLOAD,$($(PKG)_SITE:/=)/$(p))\
> -		)\
> -	$(sep))
> +	$(foreach p,$($(PKG)_ALL_DOWNLOADS),$(call DOWNLOAD,$(p))$(sep))
>  	$(foreach hook,$($(PKG)_POST_DOWNLOAD_HOOKS),$(call $(hook))$(sep))
>  	$(Q)mkdir -p $(@D)
>  	$(Q)touch $@
> @@ -355,6 +343,11 @@ ifndef $(2)_PATCH
>   endif
>  endif
>  
> +$(2)_ALL_DOWNLOADS = \
> +	$$(foreach p,$$($(2)_SOURCE) $$($(2)_PATCH) $$($(2)_EXTRA_DOWNLOADS),\
> +		$$(if $$(findstring ://,$$(p)),$$(p),\
> +			$$($(2)_SITE:/=)/$$(p)))
> +
>  ifndef $(2)_SITE
>   ifdef $(3)_SITE
>    $(2)_SITE = $$($(3)_SITE)
> @@ -568,10 +561,7 @@ $(1)-show-version:
>  
>  $(1)-source-check:
>  ifeq ($$($(2)_OVERRIDE_SRCDIR),)
> -	$$(foreach p,$$($(2)_SOURCE) $$($(2)_EXTRA_DOWNLOADS) $$($(2)_PATCH),\
> -		$$(if $$(findstring ://,$$(p)),\
> -			$$(call SOURCE_CHECK,$$(p)),\
> -			$$(call SOURCE_CHECK,$$($(2)_SITE:/=)/$$(p)))$$(sep))
> +	$$(foreach p,$$($(2)_ALL_DOWNLOADS),$$(call SOURCE_CHECK,$$(p))$$(sep))
>  else
>  	test -d $$($(2)_OVERRIDE_SRCDIR)
>  endif
> -- 
> 2.1.0
> 

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'


More information about the buildroot mailing list