Patchwork [PATCHv2,1/4] core: introduce the BR2_EXTERNAL variable

login
register
mail settings
Submitter Thomas Petazzoni
Date Sept. 14, 2013, 7:03 p.m.
Message ID <1379185433-8770-2-git-send-email-thomas.petazzoni@free-electrons.com>
Download mbox | patch
Permalink /patch/274930/
State Superseded
Headers show

Comments

Thomas Petazzoni - Sept. 14, 2013, 7:03 p.m.
This commit introduces the BR2_EXTERNAL environment variable, which
will allow to keep Buildroot customization (board-specific
configuration files or root filesystem overlays, package Config.in and
makefiles, as well as defconfigs) outside of the Buildroot tree.

This commit only introduces the variable itself, and ensures that it
is available within Config.in options, so that string options used to
specify paths to directories or files can use $BR2_EXTERNAL as a
reference. For example, one can use
$BR2_EXTERNAL/board/<someboard>/kernel.config as the
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE value.

Following patches extend the usage of BR2_EXTERNAL to other areas
(packages and defconfigs).

In details, this commit:

 * Introduces the BR2_EXTERNAL Kconfig option. This option has no
   prompt, and is therefore not visible to the user and also not
   stored in the .config file. It is automatically set to the value of
   the BR2_EXTERNAL environment variable. The only purpose of this
   BR2_EXTERNAL Kconfig option is to allow $BR2_EXTERNAL to be
   properly expanded when used inside Kconfig option values.

 * Ensures that the path given in BR2_EXTERNAL is an absolute path, or
   if not path is given, ensures that BR2_EXTERNAL points to a dummy
   implementation in $(TOPDIR)/support/dummy-external/. This last part
   is not directly useful in this commit, but is needed to properly
   support Config.in options declared in BR2_EXTERNAL (next commit).

 * Passes the BR2_EXTERNAL into the *config environment, so that its
   value is found when parsing/evaluating Config.in files and .config
   values.

 * Encodes the BR2_EXTERNAL value into the Makefile wrapper (only if
   BR2_EXTERNAL is specified by the user, not if the dummy internal
   value is used).

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 Config.in                  |  4 ++++
 Makefile                   | 13 +++++++++++--
 support/scripts/mkmakefile |  3 ++-
 3 files changed, 17 insertions(+), 3 deletions(-)
Ryan Barnett - Sept. 16, 2013, 4:34 p.m.
Thomas,

Per our chat on IRC, putting BR2_EXTERNAL into the generated makefile
isn't quite working out like I expected. I'm losing the BR2_EXTERNAL
variable definition.

Here are the steps I'm taking after applying your v2 of this patch to
a git clone of the mainline of buildroot. The buildroot clone is not
in the directory of ~/tmp but elsewhere.

make O=~/tmp/build_xm BR2_EXTERNAL=~/tmp/buildroot 
rc_beagle_xm_min_defconfig
cd ~/tmp/build_xm
make

Here is the output from the make:

make -C /home/rjbarnet/projects/buildroot/buildroot-git 
O=/home/rjbarnet/projects/muos/build_xm/. 
BR2_EXTERNAL=/home/rjbarnet/projects/muos/muos-svn/buildroot
/usr/bin/make -j8 O=/home/rjbarnet/projects/muos/build_xm/. 
HOSTCC="/usr/bin/gcc" HOSTCXX="/usr/bin/g++" silentoldconfig
  GEN     /home/rjbarnet/projects/muos/build_xm/./Makefile
BR2_DEFCONFIG='' 
KCONFIG_AUTOCONFIG=/home/rjbarnet/projects/muos/build_xm/build/buildroot-config/auto.conf 
KCONFIG_AUTOHEADER=/home/rjbarnet/projects/muos/build_xm/build/buildroot-config/autoconf.h 
KCONFIG_TRISTATE=/home/rjbarnet/projects/muos/build_xm/build/buildroot-config/tristate.config 
BUILDROOT_CONFIG=/home/rjbarnet/projects/muos/build_xm/./.config 
BR2_EXTERNAL=/home/rjbarnet/projects/buildroot/buildroot-git/support/dummy-external/ 
/home/rjbarnet/projects/muos/build_xm/build/buildroot-config/conf 
--silentoldconfig Config.in
mkdir -p /home/rjbarnet/projects/muos/build_xm/target
rsync -a \
                --exclude .empty --exclude .svn --exclude .git \
                --exclude .hg --exclude=CVS --exclude '*~' \
 /home/rjbarnet/projects/buildroot/buildroot-git/system/skeleton/ 
/home/rjbarnet/projects/muos/build_xm/target/
cp support/misc/target-dir-warning.txt 
/home/rjbarnet/projects/muos/build_xm/target/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
touch /home/rjbarnet/projects/muos/build_xm/build/.root
--2013-09-16 10:50:52-- 
<Stuff saying unable to downloading toolchain...>
--2013-09-16 10:50:55--  
http://sources.buildroot.net//gcc-linaro-arm-linux-gnueabihf-4.8-2013.08_linux.tar.xz
<Stuff saying can't download toolcahin....>
make[1]: *** 
[/home/apps/opt/buildroot-2011.05/dl/gcc-linaro-arm-linux-gnueabihf-4.8-2013.08_linux.tar.xz] 
Error 1
make: *** [all] Error 2

Note: I know the toolchain can't be downloaded, but the point is that 
I'm losing BR2_EXTERNAL path.

Here is the config that I'm using:

BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_EABIHF=y
BR2_DL_DIR="/home/apps/opt/buildroot-2011.05/dl"
BR2_JLEVEL=8
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_LINARO_2013_04=y
BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY=y
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyO2"
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL)/board/common-omap/local-skeleton"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="3.8.13"
BR2_LINUX_KERNEL_PATCH="$(BR2_EXTERNAL)/board/common-omap/kernel-patches-3.8.13"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL)/board/common-omap/linux-3.8.13.config"
BR2_LINUX_KERNEL_ZIMAGE=y
BR2_TARGET_ROOTFS_TAR_BZIP2=y
BR2_TARGET_UBOOT=y
BR2_TARGET_UBOOT_BOARDNAME="omap3_beagle"
BR2_TARGET_UBOOT_CUSTOM_PATCH_DIR="$(BR2_EXTERNAL)/board/common-omap/uboot-patches-2013.07"
BR2_TARGET_UBOOT_FORMAT_IMG=y
BR2_TARGET_UBOOT_SPL=y
BR2_TARGET_UBOOT_SPL_NAME="MLO"
BR2_PACKAGE_HOST_E2FSPROGS=y
BR2_PACKAGE_HOST_GENEXT2FS=y

Thanks,
-Ryan

-----------------------------------------------------------------
Ryan J Barnett / Software Engineer / Platform SW
MS 137-157, 855 35th St NE, Cedar Rapids, IA, 52498-3161, US
Phone: 319-263-3880 / VPN: 263-3880 
rjbarnet@rockwellcollins.com
www.rockwellcollins.com
Arnout Vandecappelle - Sept. 16, 2013, 9:30 p.m.
On 14/09/13 21:03, Thomas Petazzoni wrote:
> This commit introduces the BR2_EXTERNAL environment variable, which
> will allow to keep Buildroot customization (board-specific
> configuration files or root filesystem overlays, package Config.in and
> makefiles, as well as defconfigs) outside of the Buildroot tree.
>
> This commit only introduces the variable itself, and ensures that it
> is available within Config.in options, so that string options used to
> specify paths to directories or files can use $BR2_EXTERNAL as a

  $(BR2_EXTERNAL). The $ is expanded by make. Same comment applies to 
other places in the commit message as well. You did put it correctly in 
the manual.

> reference. For example, one can use
> $BR2_EXTERNAL/board/<someboard>/kernel.config as the
> BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE value.
>
> Following patches extend the usage of BR2_EXTERNAL to other areas
> (packages and defconfigs).
>
> In details, this commit:
>
>   * Introduces the BR2_EXTERNAL Kconfig option. This option has no
>     prompt, and is therefore not visible to the user and also not
>     stored in the .config file. It is automatically set to the value of
>     the BR2_EXTERNAL environment variable. The only purpose of this
>     BR2_EXTERNAL Kconfig option is to allow $BR2_EXTERNAL to be
>     properly expanded when used inside Kconfig option values.
>
>   * Ensures that the path given in BR2_EXTERNAL is an absolute path, or
>     if not path is given, ensures that BR2_EXTERNAL points to a dummy
>     implementation in $(TOPDIR)/support/dummy-external/. This last part
>     is not directly useful in this commit, but is needed to properly
>     support Config.in options declared in BR2_EXTERNAL (next commit).

  It would make more sense to do it in that commit then, but that's just 
nitpicking.

>
>   * Passes the BR2_EXTERNAL into the *config environment, so that its
>     value is found when parsing/evaluating Config.in files and .config
>     values.

  That's pretty useless in this commit, since it anyway doesn't end up in 
.config and isn't used in Config.in.

>
>   * Encodes the BR2_EXTERNAL value into the Makefile wrapper (only if
>     BR2_EXTERNAL is specified by the user, not if the dummy internal
>     value is used).
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
>   Config.in                  |  4 ++++
>   Makefile                   | 13 +++++++++++--
>   support/scripts/mkmakefile |  3 ++-
>   3 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/Config.in b/Config.in
> index 65c29b4..522eaf8 100644
> --- a/Config.in
> +++ b/Config.in
> @@ -14,6 +14,10 @@ config BR2_HOSTARCH
>   	string
>   	option env="HOSTARCH"
>
> +config BR2_EXTERNAL
> +	string
> +	option env="BR2_EXTERNAL"
> +

  If you agree to store the value in the .config file, it could look 
something like this.

-------

config BR2_EXTERNAL_FROM_ENV
         string
         option env="BR2_EXTERNAL"

# This condition forces the user to set BR2_EXTERNAL from the
# command line the first time.
if BR2_EXTERNAL_FROM_ENV != ""
config BR2_EXTERNAL
         string "External buildroot add-ons"
         default BR2_EXTERNAL_FROM_ENV
         help
           List of directories with buildroot add-ons. ...
endif

if BR2_EXTERNAL != BR2_EXTERNAL_FROM_ENV
comment "You need to re-run the config to see the new packages"
endif


-------

  It doesn't really work, though, because currently the .config is not 
read in when doing 'make menuconfig', so that BR2_EXTERNAL_FROM_ENV will 
always be "". But I'm sure we'll be able to find something that works 
with a little more effort.


>   # Hidden boolean selected by pre-built packages for x86, when they
>   # need to run on x86-64 machines (example: pre-built external
>   # toolchains, binary tools like SAM-BA, etc.).
> diff --git a/Makefile b/Makefile
> index 8610592..13ad342 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -51,6 +51,14 @@ CONFIG_CONFIG_IN=Config.in
>   CONFIG=support/kconfig
>   DATE:=$(shell date +%Y%m%d)
>
> +# Turn BR2_EXTERNAL into an absolute path
> +ifneq ($(BR2_EXTERNAL),)
> +override BR2_EXTERNAL := $(realpath $(BR2_EXTERNAL))
> +BR2_EXTERNAL_USED = y
> +else
> +BR2_EXTERNAL = $(TOPDIR)/support/dummy-external/
> +endif
> +
>   # Compute the full local version string so packages can use it as-is
>   # Need to export it, so it can be got from environment in children (eg. mconf)
>   export BR2_VERSION_FULL:=$(BR2_VERSION)$(shell $(TOPDIR)/support/scripts/setlocalversion)
> @@ -632,7 +640,8 @@ COMMON_CONFIG_ENV = \
>   	KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
>   	KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
>   	KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
> -	BUILDROOT_CONFIG=$(BUILDROOT_CONFIG)
> +	BUILDROOT_CONFIG=$(BUILDROOT_CONFIG) \
> +	BR2_EXTERNAL=$(BR2_EXTERNAL)
>
>   xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
>   	@mkdir -p $(BUILD_DIR)/buildroot-config
> @@ -739,7 +748,7 @@ source-check:
>   # output directory.
>   outputmakefile:
>   ifeq ($(NEED_WRAPPER),y)
> -	$(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
> +	$(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O) $(if $(BR2_EXTERNAL_USED),$(BR2_EXTERNAL))
>   endif
>
>   # printvars prints all the variables currently defined in our Makefiles
> diff --git a/support/scripts/mkmakefile b/support/scripts/mkmakefile
> index cef2ec7..e7c1bd0 100755
> --- a/support/scripts/mkmakefile
> +++ b/support/scripts/mkmakefile
> @@ -6,7 +6,7 @@
>   # Usage
>   # $1 - Kernel src directory
>   # $2 - Output directory
> -
> +# $3 - BR2_EXTERNAL directory
>
>   test ! -r $2/Makefile -o -O $2/Makefile || exit 0
>   # Only overwrite automatically generated Makefiles
> @@ -27,6 +27,7 @@ makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST)))
>
>   MAKEARGS := -C $1
>   MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir))
> +MAKEARGS += BR2_EXTERNAL=$3

  Obviously, this won't be needed anymore if the EXTERNAL is stored in 
the .config.


  Regards,
  Arnout

>
>   MAKEFLAGS += --no-print-directory
>
>
Thomas Petazzoni - Sept. 17, 2013, 4:26 a.m.
Dear Arnout Vandecappelle,

On Mon, 16 Sep 2013 23:30:49 +0200, Arnout Vandecappelle wrote:
> On 14/09/13 21:03, Thomas Petazzoni wrote:
> > This commit introduces the BR2_EXTERNAL environment variable, which
> > will allow to keep Buildroot customization (board-specific
> > configuration files or root filesystem overlays, package Config.in
> > and makefiles, as well as defconfigs) outside of the Buildroot tree.
> >
> > This commit only introduces the variable itself, and ensures that it
> > is available within Config.in options, so that string options used
> > to specify paths to directories or files can use $BR2_EXTERNAL as a
> 
>   $(BR2_EXTERNAL). The $ is expanded by make. Same comment applies to 
> other places in the commit message as well. You did put it correctly
> in the manual.

Right, true.

> >   * Ensures that the path given in BR2_EXTERNAL is an absolute
> > path, or if not path is given, ensures that BR2_EXTERNAL points to
> > a dummy implementation in $(TOPDIR)/support/dummy-external/. This
> > last part is not directly useful in this commit, but is needed to
> > properly support Config.in options declared in BR2_EXTERNAL (next
> > commit).
> 
>   It would make more sense to do it in that commit then, but that's
> just nitpicking.

Yeah, but since it was really part of the same chunk of code, it was
annoying to split further. But I can certainly split that up further.

> >   * Passes the BR2_EXTERNAL into the *config environment, so that
> > its value is found when parsing/evaluating Config.in files
> > and .config values.
> 
>   That's pretty useless in this commit, since it anyway doesn't end
> up in .config and isn't used in Config.in.

Right, could be moved to the next commit then (but to me the separation
of the commits is relatively artificial, since the patch set really
only makes sense if everything is applied).

>   If you agree to store the value in the .config file, it could look 
> something like this.
> 
> -------
> 
> config BR2_EXTERNAL_FROM_ENV
>          string
>          option env="BR2_EXTERNAL"
> 
> # This condition forces the user to set BR2_EXTERNAL from the
> # command line the first time.
> if BR2_EXTERNAL_FROM_ENV != ""
> config BR2_EXTERNAL
>          string "External buildroot add-ons"
>          default BR2_EXTERNAL_FROM_ENV
>          help
>            List of directories with buildroot add-ons. ...
> endif
> 
> if BR2_EXTERNAL != BR2_EXTERNAL_FROM_ENV
> comment "You need to re-run the config to see the new packages"
> endif
> 
> 
> -------

I don't know. Do we really want to do that? Isn't it simpler to always
pass it as an environment variable?

I mean, if an user changes the value of BR2_EXTERNAL in menuconfig, he
has to exit / re-run menuconfig to anyway see the updated set of
configuration options after the BR2_EXTERNAL value change. Does it
really makes sense to set in menuconfig a configuration option that by
itself changes the available configuration options, but which requires
exiting/re-runnning menuconfig?

>   It doesn't really work, though, because currently the .config is
> not read in when doing 'make menuconfig', so that
> BR2_EXTERNAL_FROM_ENV will always be "". But I'm sure we'll be able
> to find something that works with a little more effort.

Hum, the .config is not read when doing 'make menuconfig'? Then how can
'make menuconfig' show the current state of enabled options?

Best regards,

Thomas
Arnout Vandecappelle - Sept. 17, 2013, 6:10 a.m.
On 17/09/13 06:26, Thomas Petazzoni wrote:
> Dear Arnout Vandecappelle,
>
> On Mon, 16 Sep 2013 23:30:49 +0200, Arnout Vandecappelle wrote:
>> On 14/09/13 21:03, Thomas Petazzoni wrote:
>>> This commit introduces the BR2_EXTERNAL environment variable, which
>>> will allow to keep Buildroot customization (board-specific
>>> configuration files or root filesystem overlays, package Config.in
>>> and makefiles, as well as defconfigs) outside of the Buildroot tree.
>>>
>>> This commit only introduces the variable itself, and ensures that it
>>> is available within Config.in options, so that string options used
>>> to specify paths to directories or files can use $BR2_EXTERNAL as a
>>
>>    $(BR2_EXTERNAL). The $ is expanded by make. Same comment applies to
>> other places in the commit message as well. You did put it correctly
>> in the manual.
>
> Right, true.
>
>>>    * Ensures that the path given in BR2_EXTERNAL is an absolute
>>> path, or if not path is given, ensures that BR2_EXTERNAL points to
>>> a dummy implementation in $(TOPDIR)/support/dummy-external/. This
>>> last part is not directly useful in this commit, but is needed to
>>> properly support Config.in options declared in BR2_EXTERNAL (next
>>> commit).
>>
>>    It would make more sense to do it in that commit then, but that's
>> just nitpicking.
>
> Yeah, but since it was really part of the same chunk of code, it was
> annoying to split further. But I can certainly split that up further.
>
>>>    * Passes the BR2_EXTERNAL into the *config environment, so that
>>> its value is found when parsing/evaluating Config.in files
>>> and .config values.
>>
>>    That's pretty useless in this commit, since it anyway doesn't end
>> up in .config and isn't used in Config.in.
>
> Right, could be moved to the next commit then (but to me the separation
> of the commits is relatively artificial, since the patch set really
> only makes sense if everything is applied).

  Fair enough.


>>    If you agree to store the value in the .config file, it could look
>> something like this.
>>
>> -------
>>
>> config BR2_EXTERNAL_FROM_ENV
>>           string
>>           option env="BR2_EXTERNAL"
>>
>> # This condition forces the user to set BR2_EXTERNAL from the
>> # command line the first time.
>> if BR2_EXTERNAL_FROM_ENV != ""
>> config BR2_EXTERNAL
>>           string "External buildroot add-ons"
>>           default BR2_EXTERNAL_FROM_ENV
>>           help
>>             List of directories with buildroot add-ons. ...
>> endif
>>
>> if BR2_EXTERNAL != BR2_EXTERNAL_FROM_ENV
>> comment "You need to re-run the config to see the new packages"
>> endif
>>
>>
>> -------
>
> I don't know. Do we really want to do that? Isn't it simpler to always
> pass it as an environment variable?
>
> I mean, if an user changes the value of BR2_EXTERNAL in menuconfig, he
> has to exit / re-run menuconfig to anyway see the updated set of
> configuration options after the BR2_EXTERNAL value change. Does it
> really makes sense to set in menuconfig a configuration option that by
> itself changes the available configuration options, but which requires
> exiting/re-runnning menuconfig?

  The primary way of setting BR2_EXTERNAL would still be through the 
environment - in fact, the code above forces you to set it through the 
environment the first time, otherwise the option won't be visible.


>>    It doesn't really work, though, because currently the .config is
>> not read in when doing 'make menuconfig', so that
>> BR2_EXTERNAL_FROM_ENV will always be "". But I'm sure we'll be able
>> to find something that works with a little more effort.
>
> Hum, the .config is not read when doing 'make menuconfig'? Then how can
> 'make menuconfig' show the current state of enabled options?

  I mena that it isn't read by the Makefile.

  Regards,
  Arnout
Thomas Petazzoni - Sept. 17, 2013, 6:47 p.m.
Dear Arnout Vandecappelle,

On Tue, 17 Sep 2013 08:10:11 +0200, Arnout Vandecappelle wrote:

> > I mean, if an user changes the value of BR2_EXTERNAL in menuconfig, he
> > has to exit / re-run menuconfig to anyway see the updated set of
> > configuration options after the BR2_EXTERNAL value change. Does it
> > really makes sense to set in menuconfig a configuration option that by
> > itself changes the available configuration options, but which requires
> > exiting/re-runnning menuconfig?
> 
>   The primary way of setting BR2_EXTERNAL would still be through the 
> environment - in fact, the code above forces you to set it through the 
> environment the first time, otherwise the option won't be visible.
> 
> 
> >>    It doesn't really work, though, because currently the .config is
> >> not read in when doing 'make menuconfig', so that
> >> BR2_EXTERNAL_FROM_ENV will always be "". But I'm sure we'll be able
> >> to find something that works with a little more effort.
> >
> > Hum, the .config is not read when doing 'make menuconfig'? Then how can
> > 'make menuconfig' show the current state of enabled options?
> 
>   I mena that it isn't read by the Makefile.

Ok, so what do you suggest exactly? Because you proposed an
implementation, but concluded with 'it doesn't work'. So I'm a little
bit confused here :-)

Thanks!

Thomas
Ryan Barnett - Sept. 23, 2013, 8:39 p.m.
Thomas,

I've been using this patch for around a week now and today I tired to
generate the manual with this patch applied. However, "make manual"
fails pretty bad with this patch set applied. Have you tired 
generating the manual at all?

Here is what I've done:
 * Applied all four patches for v2 of BR2_EXTERNAL
 * make clean
 * make manual

I'm not exactly sure the root cause of the problem but my guess is
the top-level Config.in. To fix the problem, I just revert the 4 
patches and I can build the manual fine. When I do make manual I 
get the following error output:

/home/rjbarnet/projects/buildroot/buildroot-git/Config.in:19:warning:
The symbol BR2_EXTERNAL references the non-existent environment variable 
BR2_EXTERNAL and will
get the empty string as its value.

If you're using kconfiglib via 'make (i)scriptconfig' it should have set 
up the
environment correctly for you. If you still got this message, that might 
be an
error, and you should e-mail kconfiglib@gmail.com.
.
Traceback (most recent call last):
  File 
"/home/rjbarnet/projects/buildroot/buildroot-git/support/scripts/gen-manual-lists.py", 
line 376, in <module>
    buildroot = Buildroot()
  File 
"/home/rjbarnet/projects/buildroot/buildroot-git/support/scripts/gen-manual-lists.py", 
line 217, in __init__
    self.root_config))
  File 
"/home/rjbarnet/projects/buildroot/buildroot-git/support/scripts/kconfiglib.py", 
line 214, in __init__
    self.top_block = self._parse_file(filename, None, None, None)
  File 
"/home/rjbarnet/projects/buildroot/buildroot-git/support/scripts/kconfiglib.py", 
line 919, in _parse_file
    return self._parse_block(line_feeder, None, parent, deps, 
visible_if_deps, res)
  File 
"/home/rjbarnet/projects/buildroot/buildroot-git/support/scripts/kconfiglib.py", 
line 1114, in _parse_block
    self.base_dir))
IOError: /home/rjbarnet/projects/buildroot/buildroot-git/Config.in:490: 
sourced file "$BR2_EXTERNAL/Config.in" (expands to
"2_EXTERNAL/Config.in") not found. Perhaps base_dir
(argument to Config.__init__(), currently
"/home/rjbarnet/projects/buildroot/buildroot-git") is set to the wrong 
value.
make: *** [manual-update-lists] Error 1


Thanks,
-Ryan

Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote on 
09/14/2013 02:03:50 PM:
 
> This commit introduces the BR2_EXTERNAL environment variable, which
> will allow to keep Buildroot customization (board-specific
> configuration files or root filesystem overlays, package Config.in and
> makefiles, as well as defconfigs) outside of the Buildroot tree.
> 
> This commit only introduces the variable itself, and ensures that it
> is available within Config.in options, so that string options used to
> specify paths to directories or files can use $BR2_EXTERNAL as a
> reference. For example, one can use
> $BR2_EXTERNAL/board/<someboard>/kernel.config as the
> BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE value.
> 
> Following patches extend the usage of BR2_EXTERNAL to other areas
> (packages and defconfigs).
> 
> In details, this commit:
> 
>  * Introduces the BR2_EXTERNAL Kconfig option. This option has no
>    prompt, and is therefore not visible to the user and also not
>    stored in the .config file. It is automatically set to the value of
>    the BR2_EXTERNAL environment variable. The only purpose of this
>    BR2_EXTERNAL Kconfig option is to allow $BR2_EXTERNAL to be
>    properly expanded when used inside Kconfig option values.
> 
>  * Ensures that the path given in BR2_EXTERNAL is an absolute path, or
>    if not path is given, ensures that BR2_EXTERNAL points to a dummy
>    implementation in $(TOPDIR)/support/dummy-external/. This last part
>    is not directly useful in this commit, but is needed to properly
>    support Config.in options declared in BR2_EXTERNAL (next commit).
> 
>  * Passes the BR2_EXTERNAL into the *config environment, so that its
>    value is found when parsing/evaluating Config.in files and .config
>    values.
> 
>  * Encodes the BR2_EXTERNAL value into the Makefile wrapper (only if
>    BR2_EXTERNAL is specified by the user, not if the dummy internal
>    value is used).
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
>  Config.in                  |  4 ++++
>  Makefile                   | 13 +++++++++++--
>  support/scripts/mkmakefile |  3 ++-
>  3 files changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/Config.in b/Config.in
> index 65c29b4..522eaf8 100644
> --- a/Config.in
> +++ b/Config.in
> @@ -14,6 +14,10 @@ config BR2_HOSTARCH
>     string
>     option env="HOSTARCH"
> 
> +config BR2_EXTERNAL
> +   string
> +   option env="BR2_EXTERNAL"
> +
>  # Hidden boolean selected by pre-built packages for x86, when they
>  # need to run on x86-64 machines (example: pre-built external
>  # toolchains, binary tools like SAM-BA, etc.).
> diff --git a/Makefile b/Makefile
> index 8610592..13ad342 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -51,6 +51,14 @@ CONFIG_CONFIG_IN=Config.in
>  CONFIG=support/kconfig
>  DATE:=$(shell date +%Y%m%d)
> 
> +# Turn BR2_EXTERNAL into an absolute path
> +ifneq ($(BR2_EXTERNAL),)
> +override BR2_EXTERNAL := $(realpath $(BR2_EXTERNAL))
> +BR2_EXTERNAL_USED = y
> +else
> +BR2_EXTERNAL = $(TOPDIR)/support/dummy-external/
> +endif
> +
>  # Compute the full local version string so packages can use it as-is
>  # Need to export it, so it can be got from environment in children (eg. 
mconf)
>  export BR2_VERSION_FULL:=$(BR2_VERSION)$(shell $(TOPDIR)/support/
> scripts/setlocalversion)
> @@ -632,7 +640,8 @@ COMMON_CONFIG_ENV = \
>     KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
>     KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
>     KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
> -   BUILDROOT_CONFIG=$(BUILDROOT_CONFIG)
> +   BUILDROOT_CONFIG=$(BUILDROOT_CONFIG) \
> +   BR2_EXTERNAL=$(BR2_EXTERNAL)
> 
>  xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
>     @mkdir -p $(BUILD_DIR)/buildroot-config
> @@ -739,7 +748,7 @@ source-check:
>  # output directory.
>  outputmakefile:
>  ifeq ($(NEED_WRAPPER),y)
> -   $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
> +   $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O) $(if $
> (BR2_EXTERNAL_USED),$(BR2_EXTERNAL))
>  endif
> 
>  # printvars prints all the variables currently defined in our Makefiles
> diff --git a/support/scripts/mkmakefile b/support/scripts/mkmakefile
> index cef2ec7..e7c1bd0 100755
> --- a/support/scripts/mkmakefile
> +++ b/support/scripts/mkmakefile
> @@ -6,7 +6,7 @@
>  # Usage
>  # $1 - Kernel src directory
>  # $2 - Output directory
> -
> +# $3 - BR2_EXTERNAL directory
> 
>  test ! -r $2/Makefile -o -O $2/Makefile || exit 0
>  # Only overwrite automatically generated Makefiles
> @@ -27,6 +27,7 @@ makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST)))
> 
>  MAKEARGS := -C $1
>  MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$
> (patsubst %/,%,\$(makedir))
> +MAKEARGS += BR2_EXTERNAL=$3
> 
>  MAKEFLAGS += --no-print-directory
> 
> -- 
> 1.8.1.2
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Samuel Martin - Sept. 23, 2013, 10:17 p.m.
Hi Ryan, Thomas,


2013/9/23 Ryan Barnett <rjbarnet@rockwellcollins.com>
>
> Thomas,
>
> I've been using this patch for around a week now and today I tired to
> generate the manual with this patch applied. However, "make manual"
> fails pretty bad with this patch set applied. Have you tired
> generating the manual at all?
>
> Here is what I've done:
>  * Applied all four patches for v2 of BR2_EXTERNAL
>  * make clean
>  * make manual
>
> I'm not exactly sure the root cause of the problem but my guess is
> the top-level Config.in. To fix the problem, I just revert the 4
> patches and I can build the manual fine. When I do make manual I
> get the following error output:
>
> /home/rjbarnet/projects/buildroot/buildroot-git/Config.in:19:warning:
> The symbol BR2_EXTERNAL references the non-existent environment variable
BR2_EXTERNAL and will
> get the empty string as its value.
>
> If you're using kconfiglib via 'make (i)scriptconfig' it should have set
up the
> environment correctly for you. If you still got this message, that might
be an
> error, and you should e-mail kconfiglib@gmail.com.
> .
> Traceback (most recent call last):
>   File
"/home/rjbarnet/projects/buildroot/buildroot-git/support/scripts/gen-manual-lists.py",
line 376, in <module>
>     buildroot = Buildroot()
>   File
"/home/rjbarnet/projects/buildroot/buildroot-git/support/scripts/gen-manual-lists.py",
line 217, in __init__
>     self.root_config))
>   File
"/home/rjbarnet/projects/buildroot/buildroot-git/support/scripts/kconfiglib.py",
line 214, in __init__
>     self.top_block = self._parse_file(filename, None, None, None)
>   File
"/home/rjbarnet/projects/buildroot/buildroot-git/support/scripts/kconfiglib.py",
line 919, in _parse_file
>     return self._parse_block(line_feeder, None, parent, deps,
visible_if_deps, res)
>   File
"/home/rjbarnet/projects/buildroot/buildroot-git/support/scripts/kconfiglib.py",
line 1114, in _parse_block
>     self.base_dir))
> IOError: /home/rjbarnet/projects/buildroot/buildroot-git/Config.in:490:
sourced file "$BR2_EXTERNAL/Config.in" (expands to
> "2_EXTERNAL/Config.in") not found. Perhaps base_dir
> (argument to Config.__init__(), currently
> "/home/rjbarnet/projects/buildroot/buildroot-git") is set to the wrong
value.
> make: *** [manual-update-lists] Error 1

Good catch!
I missed it...

Could you try this patch: http://code.bulix.org/y27qmv-84542

Regards,


--
Samuel
Ryan Barnett - Sept. 23, 2013, 10:30 p.m.
Samuel,

Samuel Martin <s.martin49@gmail.com> wrote on 
09/23/2013 05:17:08 PM:

> Hi Ryan, Thomas,
> 

[...]

> 
> Good catch!
> I missed it...
> 
> Could you try this patch: http://code.bulix.org/y27qmv-84542

Could you send this in an email? I can't get to any pastebin type 
website from behind my work's firewall.

> 
> Regards,
> 
> 
> --
> Samuel

Thanks,
-Ryan

Patch

diff --git a/Config.in b/Config.in
index 65c29b4..522eaf8 100644
--- a/Config.in
+++ b/Config.in
@@ -14,6 +14,10 @@  config BR2_HOSTARCH
 	string
 	option env="HOSTARCH"
 
+config BR2_EXTERNAL
+	string
+	option env="BR2_EXTERNAL"
+
 # Hidden boolean selected by pre-built packages for x86, when they
 # need to run on x86-64 machines (example: pre-built external
 # toolchains, binary tools like SAM-BA, etc.).
diff --git a/Makefile b/Makefile
index 8610592..13ad342 100644
--- a/Makefile
+++ b/Makefile
@@ -51,6 +51,14 @@  CONFIG_CONFIG_IN=Config.in
 CONFIG=support/kconfig
 DATE:=$(shell date +%Y%m%d)
 
+# Turn BR2_EXTERNAL into an absolute path
+ifneq ($(BR2_EXTERNAL),)
+override BR2_EXTERNAL := $(realpath $(BR2_EXTERNAL))
+BR2_EXTERNAL_USED = y
+else
+BR2_EXTERNAL = $(TOPDIR)/support/dummy-external/
+endif
+
 # Compute the full local version string so packages can use it as-is
 # Need to export it, so it can be got from environment in children (eg. mconf)
 export BR2_VERSION_FULL:=$(BR2_VERSION)$(shell $(TOPDIR)/support/scripts/setlocalversion)
@@ -632,7 +640,8 @@  COMMON_CONFIG_ENV = \
 	KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
 	KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
 	KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
-	BUILDROOT_CONFIG=$(BUILDROOT_CONFIG)
+	BUILDROOT_CONFIG=$(BUILDROOT_CONFIG) \
+	BR2_EXTERNAL=$(BR2_EXTERNAL)
 
 xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
 	@mkdir -p $(BUILD_DIR)/buildroot-config
@@ -739,7 +748,7 @@  source-check:
 # output directory.
 outputmakefile:
 ifeq ($(NEED_WRAPPER),y)
-	$(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
+	$(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O) $(if $(BR2_EXTERNAL_USED),$(BR2_EXTERNAL))
 endif
 
 # printvars prints all the variables currently defined in our Makefiles
diff --git a/support/scripts/mkmakefile b/support/scripts/mkmakefile
index cef2ec7..e7c1bd0 100755
--- a/support/scripts/mkmakefile
+++ b/support/scripts/mkmakefile
@@ -6,7 +6,7 @@ 
 # Usage
 # $1 - Kernel src directory
 # $2 - Output directory
-
+# $3 - BR2_EXTERNAL directory
 
 test ! -r $2/Makefile -o -O $2/Makefile || exit 0
 # Only overwrite automatically generated Makefiles
@@ -27,6 +27,7 @@  makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST)))
 
 MAKEARGS := -C $1
 MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir))
+MAKEARGS += BR2_EXTERNAL=$3
 
 MAKEFLAGS += --no-print-directory