Patchwork [2,of,2] infra: remove usage of pkgparentdir in favor of pkgdir

login
register
mail settings
Submitter Thomas De Schampheleire
Date Nov. 11, 2013, 11:53 a.m.
Message ID <8953db252a5816d2e988.1384170792@argentina>
Download mbox | patch
Permalink /patch/290254/
State Superseded
Headers show

Comments

Thomas De Schampheleire - Nov. 11, 2013, 11:53 a.m.
As Arnout suggested, pkgparentdir is no longer really needed. Its usage can
be replaced with pkgdir. This patch makes that change, and removes the
definition of pkgparentdir.

Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>

---
Note: as a consequence of this change, the definition of FOO_DIR_PREFIX
slightly changed. I could have renamed the variable, but FOO_DIR was already
taken, and it's still more or less a prefix.

 package/pkg-autotools.mk |   6 +++---
 package/pkg-cmake.mk     |   6 +++---
 package/pkg-generic.mk   |  10 +++++-----
 package/pkg-utils.mk     |   1 -
 4 files changed, 11 insertions(+), 12 deletions(-)
Arnout Vandecappelle - Nov. 11, 2013, 11:15 p.m.
On 11/11/13 12:53, Thomas De Schampheleire wrote:
> As Arnout suggested, pkgparentdir is no longer really needed. Its usage can
> be replaced with pkgdir. This patch makes that change, and removes the
> definition of pkgparentdir.
>
> Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
>
> ---
> Note: as a consequence of this change, the definition of FOO_DIR_PREFIX
> slightly changed. I could have renamed the variable, but FOO_DIR was already
> taken, and it's still more or less a prefix.

  I think it's a better idea to choose a new name - if only to help 
people who are using this variable in custom packages. Or better yet, 
remove it completely - it's anyway not used anymore.


>
>   package/pkg-autotools.mk |   6 +++---
>   package/pkg-cmake.mk     |   6 +++---
>   package/pkg-generic.mk   |  10 +++++-----
>   package/pkg-utils.mk     |   1 -
>   4 files changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk
> --- a/package/pkg-autotools.mk
> +++ b/package/pkg-autotools.mk
> @@ -48,7 +48,7 @@ endef
>   #             for host packages
>   #  argument 3 is the uppercase package name, without the HOST_ prefix
>   #             for host packages
> -#  argument 4 is the package directory prefix
> +#  argument 4 is the package directory
>   #  argument 5 is the type (target or host)
>   ################################################################################
>
> @@ -311,5 +311,5 @@ endef
>   # autotools-package -- the target generator macro for autotools packages
>   ################################################################################
>
> -autotools-package = $(call inner-autotools-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target)
> -host-autotools-package = $(call inner-autotools-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
> +autotools-package = $(call inner-autotools-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgdir),target)
> +host-autotools-package = $(call inner-autotools-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgdir),host)
> diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
> --- a/package/pkg-cmake.mk
> +++ b/package/pkg-cmake.mk
> @@ -31,7 +31,7 @@
>   #             for host packages
>   #  argument 3 is the uppercase package name, without the HOST_ prefix
>   #             for host packages
> -#  argument 4 is the package directory prefix
> +#  argument 4 is the package directory
>   #  argument 5 is the type (target or host)
>   ################################################################################
>
> @@ -179,8 +179,8 @@ endef
>   # cmake-package -- the target generator macro for CMake packages
>   ################################################################################
>
> -cmake-package = $(call inner-cmake-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target)
> -host-cmake-package = $(call inner-cmake-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
> +cmake-package = $(call inner-cmake-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgdir),target)
> +host-cmake-package = $(call inner-cmake-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgdir),host)
>
>   ################################################################################
>   # Generation of the CMake toolchain file
> diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
> --- a/package/pkg-generic.mk
> +++ b/package/pkg-generic.mk
> @@ -89,7 +89,7 @@ endif
>   # find the package directory (typically package/<pkgname>) and the
>   # prefix of the patches
>   $(BUILD_DIR)/%/.stamp_patched: NAMEVER = $(RAWNAME)-$($(PKG)_VERSION)
> -$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(call qstrip,$(BR2_GLOBAL_PATCH_DIR))/$(RAWNAME)
> +$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $($(PKG)_DIR_PREFIX) $(call qstrip,$(BR2_GLOBAL_PATCH_DIR))/$(RAWNAME)
>   $(BUILD_DIR)/%/.stamp_patched:
>   	@$(call MESSAGE,"Patching")
>   	$(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
> @@ -197,7 +197,7 @@ endif
>   #             for host packages
>   #  argument 3 is the uppercase package name, without the HOST_ prefix
>   #             for host packages
> -#  argument 4 is the package directory prefix
> +#  argument 4 is the package directory
>   #  argument 5 is the type (target or host)
>   ################################################################################
>
> @@ -475,7 +475,7 @@ endif
>   # kernel case, the bootloaders case, and the normal packages case.
>   ifeq ($(1),linux)
>   $(2)_KCONFIG_VAR = BR2_LINUX_KERNEL
> -else ifeq ($(4),boot/)
> +else ifneq ($(filter boot/%,$(4)),)

  Since this is the only place where $(4) is used, we could use $(pkgdir) 
directly and drop the 4th parameter. (I just tested and it seems to work.)


  Regards,
  Arnout

>   $(2)_KCONFIG_VAR = BR2_TARGET_$(2)
>   else
>   $(2)_KCONFIG_VAR = BR2_PACKAGE_$(2)
> @@ -565,8 +565,8 @@ endef # inner-generic-package
>   ################################################################################
>
>   # In the case of target packages, keep the package name "pkg"
> -generic-package = $(call inner-generic-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target)
> +generic-package = $(call inner-generic-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgdir),target)
>   # In the case of host packages, turn the package name "pkg" into "host-pkg"
> -host-generic-package = $(call inner-generic-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
> +host-generic-package = $(call inner-generic-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgdir),host)
>
>   # :mode=makefile:
> diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
> --- a/package/pkg-utils.mk
> +++ b/package/pkg-utils.mk
> @@ -60,7 +60,6 @@ endef
>   # package, for which the package directory is an empty string.
>   pkgdir       = $(dir $(lastword $(MAKEFILE_LIST)))
>   pkgname      = $(lastword $(subst /, ,$(call pkgdir)))
> -pkgparentdir = $(patsubst %$(call pkgname)/,%,$(call pkgdir))
>
>   # Define extractors for different archive suffixes
>   INFLATE.bz2  = $(BZCAT)
>
Thomas De Schampheleire - Nov. 12, 2013, 8:56 a.m.
On Tue, Nov 12, 2013 at 12:15 AM, Arnout Vandecappelle <arnout@mind.be> wrote:
> On 11/11/13 12:53, Thomas De Schampheleire wrote:
>>
>> As Arnout suggested, pkgparentdir is no longer really needed. Its usage
>> can
>> be replaced with pkgdir. This patch makes that change, and removes the
>> definition of pkgparentdir.
>>
>> Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
>>
>> ---
>> Note: as a consequence of this change, the definition of FOO_DIR_PREFIX
>> slightly changed. I could have renamed the variable, but FOO_DIR was
>> already
>> taken, and it's still more or less a prefix.
>
>
>  I think it's a better idea to choose a new name - if only to help people
> who are using this variable in custom packages. Or better yet, remove it
> completely - it's anyway not used anymore.

The only remaining place is in the foo-patch block, to get the
location of patches for that package.
That is outside the inner-generic-package, so we cannot use $(4)
anymore. How do you propose to solve that?

>
>
>
>>
>>   package/pkg-autotools.mk |   6 +++---
>>   package/pkg-cmake.mk     |   6 +++---
>>   package/pkg-generic.mk   |  10 +++++-----
>>   package/pkg-utils.mk     |   1 -
>>   4 files changed, 11 insertions(+), 12 deletions(-)
>>
>> diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk
>> --- a/package/pkg-autotools.mk
>> +++ b/package/pkg-autotools.mk
>> @@ -48,7 +48,7 @@ endef
>>   #             for host packages
>>   #  argument 3 is the uppercase package name, without the HOST_ prefix
>>   #             for host packages
>> -#  argument 4 is the package directory prefix
>> +#  argument 4 is the package directory
>>   #  argument 5 is the type (target or host)
>>
>> ################################################################################
>>
>> @@ -311,5 +311,5 @@ endef
>>   # autotools-package -- the target generator macro for autotools packages
>>
>> ################################################################################
>>
>> -autotools-package = $(call inner-autotools-package,$(call pkgname),$(call
>> UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call
>> pkgparentdir),target)
>> -host-autotools-package = $(call inner-autotools-package,host-$(call
>> pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call
>> pkgname)),$(call pkgparentdir),host)
>> +autotools-package = $(call inner-autotools-package,$(call pkgname),$(call
>> UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call
>> pkgdir),target)
>> +host-autotools-package = $(call inner-autotools-package,host-$(call
>> pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call
>> pkgname)),$(call pkgdir),host)
>> diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
>> --- a/package/pkg-cmake.mk
>> +++ b/package/pkg-cmake.mk
>> @@ -31,7 +31,7 @@
>>   #             for host packages
>>   #  argument 3 is the uppercase package name, without the HOST_ prefix
>>   #             for host packages
>> -#  argument 4 is the package directory prefix
>> +#  argument 4 is the package directory
>>   #  argument 5 is the type (target or host)
>>
>> ################################################################################
>>
>> @@ -179,8 +179,8 @@ endef
>>   # cmake-package -- the target generator macro for CMake packages
>>
>> ################################################################################
>>
>> -cmake-package = $(call inner-cmake-package,$(call pkgname),$(call
>> UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call
>> pkgparentdir),target)
>> -host-cmake-package = $(call inner-cmake-package,host-$(call
>> pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call
>> pkgname)),$(call pkgparentdir),host)
>> +cmake-package = $(call inner-cmake-package,$(call pkgname),$(call
>> UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call
>> pkgdir),target)
>> +host-cmake-package = $(call inner-cmake-package,host-$(call
>> pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call
>> pkgname)),$(call pkgdir),host)
>>
>>
>> ################################################################################
>>   # Generation of the CMake toolchain file
>> diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
>> --- a/package/pkg-generic.mk
>> +++ b/package/pkg-generic.mk
>> @@ -89,7 +89,7 @@ endif
>>   # find the package directory (typically package/<pkgname>) and the
>>   # prefix of the patches
>>   $(BUILD_DIR)/%/.stamp_patched: NAMEVER = $(RAWNAME)-$($(PKG)_VERSION)
>> -$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS =
>> $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(call
>> qstrip,$(BR2_GLOBAL_PATCH_DIR))/$(RAWNAME)
>> +$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $($(PKG)_DIR_PREFIX)
>> $(call qstrip,$(BR2_GLOBAL_PATCH_DIR))/$(RAWNAME)
>>   $(BUILD_DIR)/%/.stamp_patched:
>>         @$(call MESSAGE,"Patching")
>>         $(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
>> @@ -197,7 +197,7 @@ endif
>>   #             for host packages
>>   #  argument 3 is the uppercase package name, without the HOST_ prefix
>>   #             for host packages
>> -#  argument 4 is the package directory prefix
>> +#  argument 4 is the package directory
>>   #  argument 5 is the type (target or host)
>>
>> ################################################################################
>>
>> @@ -475,7 +475,7 @@ endif
>>   # kernel case, the bootloaders case, and the normal packages case.
>>   ifeq ($(1),linux)
>>   $(2)_KCONFIG_VAR = BR2_LINUX_KERNEL
>> -else ifeq ($(4),boot/)
>> +else ifneq ($(filter boot/%,$(4)),)
>
>
>  Since this is the only place where $(4) is used, we could use $(pkgdir)
> directly and drop the 4th parameter. (I just tested and it seems to work.)

If we can find a solution for the patching commands, then it's
probably possible...

Best regards,
Thomas
Thomas Petazzoni - Nov. 12, 2013, 11:09 a.m.
Dear Thomas De Schampheleire,

On Tue, 12 Nov 2013 09:56:37 +0100, Thomas De Schampheleire wrote:

> >  I think it's a better idea to choose a new name - if only to help
> > people who are using this variable in custom packages. Or better
> > yet, remove it completely - it's anyway not used anymore.
> 
> The only remaining place is in the foo-patch block, to get the
> location of patches for that package.
> That is outside the inner-generic-package, so we cannot use $(4)
> anymore. How do you propose to solve that?

Currently:

 <foo>_DIR => build directory

 <foo>_DIR_PREFIX => prefix of the package directory in Buildroot
                     sources

 <foo>_DL_DIR => location of the package download directory, for
                 git/cvs downloads (apparently not used consistently)

I think it would make a lot more sense to have:

 <foo>_DIR => points to the package directory in Buildroot sources, e.g
              package/busybox/ for Busybox. This would allow packages
              to easily reference their own directory, to get access to
              configuration files and others, instead of having to know
              they are located in package/busybox/. This could also be
              used in the patching step instead of the DIR_PREFIX thing.

 <foo>_BUILDDIR => points to the package build directory in $(BUILD_DIR)

 <foo>_SRCDIR => points to the package source directory (currently
                 identical to <foo>_BUILDDIR, would change when we
                 introduce OOT build for packages). Actually, more than
                 half of the patch set I have to introduce OOT is about
                 using <foo>_SRCDIR vs <foo>_BUILDDIR in the right
                 places.

 <foo>_DL_DIR => same as before.

Best regards,

Thomas
Thomas De Schampheleire - Nov. 12, 2013, 11:32 a.m.
Hi Thomas,

On Tue, Nov 12, 2013 at 12:09 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Dear Thomas De Schampheleire,
>
> On Tue, 12 Nov 2013 09:56:37 +0100, Thomas De Schampheleire wrote:
>
>> >  I think it's a better idea to choose a new name - if only to help
>> > people who are using this variable in custom packages. Or better
>> > yet, remove it completely - it's anyway not used anymore.
>>
>> The only remaining place is in the foo-patch block, to get the
>> location of patches for that package.
>> That is outside the inner-generic-package, so we cannot use $(4)
>> anymore. How do you propose to solve that?
>
> Currently:
>
>  <foo>_DIR => build directory
>
>  <foo>_DIR_PREFIX => prefix of the package directory in Buildroot
>                      sources
>
>  <foo>_DL_DIR => location of the package download directory, for
>                  git/cvs downloads (apparently not used consistently)
>
> I think it would make a lot more sense to have:
>
>  <foo>_DIR => points to the package directory in Buildroot sources, e.g
>               package/busybox/ for Busybox. This would allow packages
>               to easily reference their own directory, to get access to
>               configuration files and others, instead of having to know
>               they are located in package/busybox/. This could also be
>               used in the patching step instead of the DIR_PREFIX thing.

Suppose we change this definition, do you suggest to change all .mk
files that currently reference package/foo to use FOO_DIR instead?
While FOO_DIR is useful for the infrastructure, like in the patching
case, I don't think it is necessary to change a file
package/foo/foo.mk to remove the hardcoded package/foo inside the
file. The likelihood of files being moved is very small, plus it will
be very hard to enforce consistent usage of FOO_DIR in favor of
package/foo in this case.

>
>  <foo>_BUILDDIR => points to the package build directory in $(BUILD_DIR)
>
>  <foo>_SRCDIR => points to the package source directory (currently
>                  identical to <foo>_BUILDDIR, would change when we
>                  introduce OOT build for packages). Actually, more than
>                  half of the patch set I have to introduce OOT is about
>                  using <foo>_SRCDIR vs <foo>_BUILDDIR in the right
>                  places.
>
>  <foo>_DL_DIR => same as before.

In general, I think the new variable names make sense.

Best regards,
Thomas
Arnout Vandecappelle - Nov. 12, 2013, 1:42 p.m.
On 12/11/13 12:32, Thomas De Schampheleire wrote:
> Hi Thomas,
>
> On Tue, Nov 12, 2013 at 12:09 PM, Thomas Petazzoni
> <thomas.petazzoni@free-electrons.com> wrote:
>> Dear Thomas De Schampheleire,
>>
>> On Tue, 12 Nov 2013 09:56:37 +0100, Thomas De Schampheleire wrote:
>>
>>>>   I think it's a better idea to choose a new name - if only to help
>>>> people who are using this variable in custom packages. Or better
>>>> yet, remove it completely - it's anyway not used anymore.
>>>
>>> The only remaining place is in the foo-patch block, to get the
>>> location of patches for that package.
>>> That is outside the inner-generic-package, so we cannot use $(4)
>>> anymore. How do you propose to solve that?
>>
>> Currently:
>>
>>   <foo>_DIR => build directory
>>
>>   <foo>_DIR_PREFIX => prefix of the package directory in Buildroot
>>                       sources
>>
>>   <foo>_DL_DIR => location of the package download directory, for
>>                   git/cvs downloads (apparently not used consistently)
>>
>> I think it would make a lot more sense to have:
>>
>>   <foo>_DIR => points to the package directory in Buildroot sources, e.g
>>                package/busybox/ for Busybox. This would allow packages
>>                to easily reference their own directory, to get access to
>>                configuration files and others, instead of having to know
>>                they are located in package/busybox/. This could also be
>>                used in the patching step instead of the DIR_PREFIX thing.

  As I mentioned before, I would prefer to not reuse the same name with a 
different meaning, because it may confuse users who have custom 
modifications that rely on that variable. So instead I'd remove the 
<foo>_DIR completely (so that it's pretty clear that this variable is 
empty if anybody still uses it), and instead use e.g. <foo>_BR_DIR for 
this purpose.

>
> Suppose we change this definition, do you suggest to change all .mk
> files that currently reference package/foo to use FOO_DIR instead?
> While FOO_DIR is useful for the infrastructure, like in the patching
> case, I don't think it is necessary to change a file
> package/foo/foo.mk to remove the hardcoded package/foo inside the
> file. The likelihood of files being moved is very small, plus it will
> be very hard to enforce consistent usage of FOO_DIR in favor of
> package/foo in this case.

  How is that hard?

  I would do what we usually do for new policy: enforce it for new 
packages, but leave it alone for existing packages until someone grows 
tired of the inconsistency and sends a global fixup patch. That also has 
the advantage that we can still change our mind on the short term without 
needing to change things all over the place again.

  That said, I think that using package/foo in the .mk file is a lot 
clearer than $(FOO_XXXDIR).

>
>>
>>   <foo>_BUILDDIR => points to the package build directory in $(BUILD_DIR)
>>
>>   <foo>_SRCDIR => points to the package source directory (currently
>>                   identical to <foo>_BUILDDIR, would change when we
>>                   introduce OOT build for packages). Actually, more than
>>                   half of the patch set I have to introduce OOT is about
>>                   using <foo>_SRCDIR vs <foo>_BUILDDIR in the right
>>                   places.
>>
>>   <foo>_DL_DIR => same as before.
>
> In general, I think the new variable names make sense.

  +1.

  ThomasP, perhaps you can resubmit the patches for <foo>_SRCDIR vs 
<foo>_BUILDDIR, since they can be applied independently of OOT.

  Regards,
  Arnout

>
> Best regards,
> Thomas
>
Arnout Vandecappelle - Nov. 12, 2013, 1:46 p.m.
On 12/11/13 09:56, Thomas De Schampheleire wrote:
> On Tue, Nov 12, 2013 at 12:15 AM, Arnout Vandecappelle<arnout@mind.be>  wrote:
>> >On 11/11/13 12:53, Thomas De Schampheleire wrote:
>>> >>
>>> >>As Arnout suggested, pkgparentdir is no longer really needed. Its usage
>>> >>can
>>> >>be replaced with pkgdir. This patch makes that change, and removes the
>>> >>definition of pkgparentdir.
>>> >>
>>> >>Signed-off-by: Thomas De Schampheleire<thomas.de.schampheleire@gmail.com>
>>> >>
>>> >>---
>>> >>Note: as a consequence of this change, the definition of FOO_DIR_PREFIX
>>> >>slightly changed. I could have renamed the variable, but FOO_DIR was
>>> >>already
>>> >>taken, and it's still more or less a prefix.
>> >
>> >
>> >  I think it's a better idea to choose a new name - if only to help people
>> >who are using this variable in custom packages. Or better yet, remove it
>> >completely - it's anyway not used anymore.
> The only remaining place is in the foo-patch block, to get the
> location of patches for that package.
> That is outside the inner-generic-package, so we cannot use $(4)
> anymore. How do you propose to solve that?

  Oops, I forgot about that.

  It would be possible to move the definition of PATCH_BASE_DIRS to 
inner-generic-package (i.e. call it $(2)_PATCH_BASE_DIRS and expand 
$($(PKG)_PATCH_BASE_DIRS) in the pattern rule). However, it's a lot 
clearer to define something like $(2)_BRDIR in inner-generic-package.

  Regards,
  Arnout
Thomas De Schampheleire - Nov. 12, 2013, 1:49 p.m.
On Tue, Nov 12, 2013 at 2:42 PM, Arnout Vandecappelle <arnout@mind.be> wrote:
> On 12/11/13 12:32, Thomas De Schampheleire wrote:
>>
>> Hi Thomas,
>>
>> On Tue, Nov 12, 2013 at 12:09 PM, Thomas Petazzoni
>> <thomas.petazzoni@free-electrons.com> wrote:
>>>
>>> Dear Thomas De Schampheleire,
>>>
>>> On Tue, 12 Nov 2013 09:56:37 +0100, Thomas De Schampheleire wrote:
>>>
>>>>>   I think it's a better idea to choose a new name - if only to help
>>>>> people who are using this variable in custom packages. Or better
>>>>> yet, remove it completely - it's anyway not used anymore.
>>>>
>>>>
>>>> The only remaining place is in the foo-patch block, to get the
>>>> location of patches for that package.
>>>> That is outside the inner-generic-package, so we cannot use $(4)
>>>> anymore. How do you propose to solve that?
>>>
>>>
>>> Currently:
>>>
>>>   <foo>_DIR => build directory
>>>
>>>   <foo>_DIR_PREFIX => prefix of the package directory in Buildroot
>>>                       sources
>>>
>>>   <foo>_DL_DIR => location of the package download directory, for
>>>                   git/cvs downloads (apparently not used consistently)
>>>
>>> I think it would make a lot more sense to have:
>>>
>>>   <foo>_DIR => points to the package directory in Buildroot sources, e.g
>>>                package/busybox/ for Busybox. This would allow packages
>>>                to easily reference their own directory, to get access to
>>>                configuration files and others, instead of having to know
>>>                they are located in package/busybox/. This could also be
>>>                used in the patching step instead of the DIR_PREFIX thing.
>
>
>  As I mentioned before, I would prefer to not reuse the same name with a
> different meaning, because it may confuse users who have custom
> modifications that rely on that variable. So instead I'd remove the
> <foo>_DIR completely (so that it's pretty clear that this variable is empty
> if anybody still uses it), and instead use e.g. <foo>_BR_DIR for this
> purpose.

In that case I would prefer something like <foo>_PKG_DIR, instead of BR.

Best regards,
Thomas
Arnout Vandecappelle - Nov. 12, 2013, 3:35 p.m.
On 12/11/13 14:49, Thomas De Schampheleire wrote:
> On Tue, Nov 12, 2013 at 2:42 PM, Arnout Vandecappelle <arnout@mind.be> wrote:
>> On 12/11/13 12:32, Thomas De Schampheleire wrote:
>>>
>>> Hi Thomas,
>>>
>>> On Tue, Nov 12, 2013 at 12:09 PM, Thomas Petazzoni
>>> <thomas.petazzoni@free-electrons.com> wrote:
>>>>
>>>> Dear Thomas De Schampheleire,
>>>>
>>>> On Tue, 12 Nov 2013 09:56:37 +0100, Thomas De Schampheleire wrote:
>>>>
>>>>>>    I think it's a better idea to choose a new name - if only to help
>>>>>> people who are using this variable in custom packages. Or better
>>>>>> yet, remove it completely - it's anyway not used anymore.
>>>>>
>>>>>
>>>>> The only remaining place is in the foo-patch block, to get the
>>>>> location of patches for that package.
>>>>> That is outside the inner-generic-package, so we cannot use $(4)
>>>>> anymore. How do you propose to solve that?
>>>>
>>>>
>>>> Currently:
>>>>
>>>>    <foo>_DIR => build directory
>>>>
>>>>    <foo>_DIR_PREFIX => prefix of the package directory in Buildroot
>>>>                        sources
>>>>
>>>>    <foo>_DL_DIR => location of the package download directory, for
>>>>                    git/cvs downloads (apparently not used consistently)
>>>>
>>>> I think it would make a lot more sense to have:
>>>>
>>>>    <foo>_DIR => points to the package directory in Buildroot sources, e.g
>>>>                 package/busybox/ for Busybox. This would allow packages
>>>>                 to easily reference their own directory, to get access to
>>>>                 configuration files and others, instead of having to know
>>>>                 they are located in package/busybox/. This could also be
>>>>                 used in the patching step instead of the DIR_PREFIX thing.
>>
>>
>>   As I mentioned before, I would prefer to not reuse the same name with a
>> different meaning, because it may confuse users who have custom
>> modifications that rely on that variable. So instead I'd remove the
>> <foo>_DIR completely (so that it's pretty clear that this variable is empty
>> if anybody still uses it), and instead use e.g. <foo>_BR_DIR for this
>> purpose.
>
> In that case I would prefer something like <foo>_PKG_DIR, instead of BR.

  OK.

  But for consistency with BUILDDIR and SRCDIR, I'd prefer PKGDIR.

  Regards,
  Arnout
Peter Korsgaard - Nov. 12, 2013, 10:05 p.m.
>>>>> "Arnout" == Arnout Vandecappelle <arnout@mind.be> writes:

Hi,

>  How is that hard?

>  I would do what we usually do for new policy: enforce it for new
> packages, but leave it alone for existing packages until someone grows
> tired of the inconsistency and sends a global fixup patch. That also
> has the advantage that we can still change our mind on the short term
> without needing to change things all over the place again.

>  That said, I think that using package/foo in the .mk file is a lot
> clearer than $(FOO_XXXDIR).

Agreed. We already have a bunch of magic variable names in BR, so lets
not enforce more than needed.

>>> <foo>_DL_DIR => same as before.
>> 
>> In general, I think the new variable names make sense.

>  +1.

+1
Peter Korsgaard - Nov. 12, 2013, 10:06 p.m.
>>>>> "Arnout" == Arnout Vandecappelle <arnout@mind.be> writes:

>>> As I mentioned before, I would prefer to not reuse the same name with a
>>> different meaning, because it may confuse users who have custom
>>> modifications that rely on that variable. So instead I'd remove the
>>> <foo>_DIR completely (so that it's pretty clear that this variable is empty
>>> if anybody still uses it), and instead use e.g. <foo>_BR_DIR for this
>>> purpose.
>> 
>> In that case I would prefer something like <foo>_PKG_DIR, instead of BR.

>  OK.

>  But for consistency with BUILDDIR and SRCDIR, I'd prefer PKGDIR.

Or <foo>_BUILD_DIR / _SRC_DIR.

</bikeshed>
Thomas De Schampheleire - Dec. 5, 2013, 2:53 p.m.
Thomas,

On Tue, Nov 12, 2013 at 2:42 PM, Arnout Vandecappelle <arnout@mind.be> wrote:
[..]
>>
>>>
>>>   <foo>_BUILDDIR => points to the package build directory in $(BUILD_DIR)
>>>
>>>   <foo>_SRCDIR => points to the package source directory (currently
>>>                   identical to <foo>_BUILDDIR, would change when we
>>>                   introduce OOT build for packages). Actually, more than
>>>                   half of the patch set I have to introduce OOT is about
>>>                   using <foo>_SRCDIR vs <foo>_BUILDDIR in the right
>>>                   places.
>>>
>>>   <foo>_DL_DIR => same as before.
>>
>>
>> In general, I think the new variable names make sense.
>
>
>  +1.
>
>  ThomasP, perhaps you can resubmit the patches for <foo>_SRCDIR vs
> <foo>_BUILDDIR, since they can be applied independently of OOT.
>

Thomas, could you resubmit or point me to these patches? Is it work in
progress or pretty much ready?

I'm going to take up this patch series during this release cycle...

Thanks,
Thomas
Thomas De Schampheleire - Dec. 15, 2013, 1:14 p.m.
All,

On Thu, Dec 5, 2013 at 3:53 PM, Thomas De Schampheleire
<patrickdepinguin@gmail.com> wrote:
> Thomas,
>
> On Tue, Nov 12, 2013 at 2:42 PM, Arnout Vandecappelle <arnout@mind.be> wrote:
> [..]
>>>
>>>>
>>>>   <foo>_BUILDDIR => points to the package build directory in $(BUILD_DIR)
>>>>
>>>>   <foo>_SRCDIR => points to the package source directory (currently
>>>>                   identical to <foo>_BUILDDIR, would change when we
>>>>                   introduce OOT build for packages). Actually, more than
>>>>                   half of the patch set I have to introduce OOT is about
>>>>                   using <foo>_SRCDIR vs <foo>_BUILDDIR in the right
>>>>                   places.
>>>>
>>>>   <foo>_DL_DIR => same as before.
>>>
>>>
>>> In general, I think the new variable names make sense.
>>
>>
>>  +1.
>>
>>  ThomasP, perhaps you can resubmit the patches for <foo>_SRCDIR vs
>> <foo>_BUILDDIR, since they can be applied independently of OOT.
>>
>
> Thomas, could you resubmit or point me to these patches? Is it work in
> progress or pretty much ready?
>
> I'm going to take up this patch series during this release cycle...

Looking again to this, there already is a FOO_SRCDIR and FOO_BUILDDIR:

$(2)_DL_DIR     =  $$(DL_DIR)/$$($(2)_BASE_NAME)
$(2)_DIR        =  $$(BUILD_DIR)/$$($(2)_BASE_NAME)
$(2)_SRCDIR     = $$($(2)_DIR)/$$($(2)_SUBDIR)
$(2)_BUILDDIR   ?= $$($(2)_SRCDIR)

There may be some overlay between FOO_DIR and FOO_SRCDIR, which is
identical for many packages (those that do not have FOO_SUBDIR set).

Additionally, the naming policy is not uniform now (underscores). We
could either keep it as it is, or rename SRCDIR to SRC_DIR and
BUILDDIR to BUILD_DIR. There are only very few occurrences of these
variables, so it is certainly doable. However, there is also
FOO_OVERRIDE_SRCDIR which is something visible externally and may be
more difficult to change (from a usability perspective).
Inputs?

However, to meet the comments on this particular patch, I think we can simply:
- introduce $(2)_PKGDIR (or $(2)_PKG_DIR, depending on the above discussion)
- remove the fourth parameter to inner-generic package ($(pkgdir)), as
suggested by Arnout

What do you think?

Best regards,
Thomas

Patch

diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk
--- a/package/pkg-autotools.mk
+++ b/package/pkg-autotools.mk
@@ -48,7 +48,7 @@  endef
 #             for host packages
 #  argument 3 is the uppercase package name, without the HOST_ prefix
 #             for host packages
-#  argument 4 is the package directory prefix
+#  argument 4 is the package directory
 #  argument 5 is the type (target or host)
 ################################################################################
 
@@ -311,5 +311,5 @@  endef
 # autotools-package -- the target generator macro for autotools packages
 ################################################################################
 
-autotools-package = $(call inner-autotools-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target)
-host-autotools-package = $(call inner-autotools-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
+autotools-package = $(call inner-autotools-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgdir),target)
+host-autotools-package = $(call inner-autotools-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgdir),host)
diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -31,7 +31,7 @@ 
 #             for host packages
 #  argument 3 is the uppercase package name, without the HOST_ prefix
 #             for host packages
-#  argument 4 is the package directory prefix
+#  argument 4 is the package directory
 #  argument 5 is the type (target or host)
 ################################################################################
 
@@ -179,8 +179,8 @@  endef
 # cmake-package -- the target generator macro for CMake packages
 ################################################################################
 
-cmake-package = $(call inner-cmake-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target)
-host-cmake-package = $(call inner-cmake-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
+cmake-package = $(call inner-cmake-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgdir),target)
+host-cmake-package = $(call inner-cmake-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgdir),host)
 
 ################################################################################
 # Generation of the CMake toolchain file
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -89,7 +89,7 @@  endif
 # find the package directory (typically package/<pkgname>) and the
 # prefix of the patches
 $(BUILD_DIR)/%/.stamp_patched: NAMEVER = $(RAWNAME)-$($(PKG)_VERSION)
-$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(call qstrip,$(BR2_GLOBAL_PATCH_DIR))/$(RAWNAME)
+$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $($(PKG)_DIR_PREFIX) $(call qstrip,$(BR2_GLOBAL_PATCH_DIR))/$(RAWNAME)
 $(BUILD_DIR)/%/.stamp_patched:
 	@$(call MESSAGE,"Patching")
 	$(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
@@ -197,7 +197,7 @@  endif
 #             for host packages
 #  argument 3 is the uppercase package name, without the HOST_ prefix
 #             for host packages
-#  argument 4 is the package directory prefix
+#  argument 4 is the package directory
 #  argument 5 is the type (target or host)
 ################################################################################
 
@@ -475,7 +475,7 @@  endif
 # kernel case, the bootloaders case, and the normal packages case.
 ifeq ($(1),linux)
 $(2)_KCONFIG_VAR = BR2_LINUX_KERNEL
-else ifeq ($(4),boot/)
+else ifneq ($(filter boot/%,$(4)),)
 $(2)_KCONFIG_VAR = BR2_TARGET_$(2)
 else
 $(2)_KCONFIG_VAR = BR2_PACKAGE_$(2)
@@ -565,8 +565,8 @@  endef # inner-generic-package
 ################################################################################
 
 # In the case of target packages, keep the package name "pkg"
-generic-package = $(call inner-generic-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target)
+generic-package = $(call inner-generic-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgdir),target)
 # In the case of host packages, turn the package name "pkg" into "host-pkg"
-host-generic-package = $(call inner-generic-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
+host-generic-package = $(call inner-generic-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgdir),host)
 
 # :mode=makefile:
diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
--- a/package/pkg-utils.mk
+++ b/package/pkg-utils.mk
@@ -60,7 +60,6 @@  endef
 # package, for which the package directory is an empty string.
 pkgdir       = $(dir $(lastword $(MAKEFILE_LIST)))
 pkgname      = $(lastword $(subst /, ,$(call pkgdir)))
-pkgparentdir = $(patsubst %$(call pkgname)/,%,$(call pkgdir))
 
 # Define extractors for different archive suffixes
 INFLATE.bz2  = $(BZCAT)