diff mbox

[08/16,v3] core: do not hard-code inclusion of br2-external in Kconfig

Message ID 326c5c4a0a2b9cb4d4cb430791ce5aaf21185e95.1468750623.git.yann.morin.1998@free.fr
State Changes Requested
Headers show

Commit Message

Yann E. MORIN July 17, 2016, 10:34 a.m. UTC
Move the inclusion of br2-external's Config.in to the generated kconfig
snippet.

This will ultimately allow us to use more than one br2-external tree.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Peter Korsgaard <jacmet@uclibc.org>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
---
 Config.in | 7 -------
 Makefile  | 8 +++++++-
 2 files changed, 7 insertions(+), 8 deletions(-)

Comments

Romain Naour Aug. 6, 2016, 3:21 p.m. UTC | #1
Hi Yann,

Le 17/07/2016 à 12:34, Yann E. MORIN a écrit :
> Move the inclusion of br2-external's Config.in to the generated kconfig
> snippet.
> 
> This will ultimately allow us to use more than one br2-external tree.

Reviewed-by: Romain Naour <romain.naour@gmail.com>

Best regards,
Romain

> 
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Cc: Peter Korsgaard <jacmet@uclibc.org>
> Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
> Cc: Arnout Vandecappelle <arnout@mind.be>
> ---
>  Config.in | 7 -------
>  Makefile  | 8 +++++++-
>  2 files changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/Config.in b/Config.in
> index 7f533ce..7810bf8 100644
> --- a/Config.in
> +++ b/Config.in
> @@ -761,11 +761,4 @@ source "package/Config.in.host"
>  
>  source "Config.in.legacy"
>  
> -menu "User-provided options"
> -	depends on BR2_EXTERNAL != "support/dummy-external"
> -
> -source "$BR2_EXTERNAL/Config.in"
> -
> -endmenu
> -
>  source "$BR2_BUILD_DIR/.br2-external.in"
> diff --git a/Makefile b/Makefile
> index 39a1507..86c532e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -882,7 +882,13 @@ endif
>  
>  .PHONY: $(BUILD_DIR)/.br2-external.in
>  $(BUILD_DIR)/.br2-external.in: $(BUILD_DIR)
> -	@touch $@
> +	$(Q)( \
> +		printf "#\n# Automatically generated file; DO NOT EDIT.\n#\n\n"; \
> +		printf 'menu "User-provided options"\n'; \
> +		printf '\tdepends on BR2_EXTERNAL != "support/dummy-external"\n\n'; \
> +		printf 'source "%s/Config.in"\n\n' $$(cd $(BR2_EXTERNAL) >/dev/null 2>&1 && pwd); \
> +		printf 'endmenu # User-provided options\n'; \
> +	) >$@
>  
>  # printvars prints all the variables currently defined in our
>  # Makefiles. Alternatively, if a non-empty VARS variable is passed,
>
Thomas Petazzoni Aug. 27, 2016, 8 p.m. UTC | #2
Hello,

On Sun, 17 Jul 2016 12:34:28 +0200, Yann E. MORIN wrote:

>  .PHONY: $(BUILD_DIR)/.br2-external.in
>  $(BUILD_DIR)/.br2-external.in: $(BUILD_DIR)
> -	@touch $@
> +	$(Q)( \
> +		printf "#\n# Automatically generated file; DO NOT EDIT.\n#\n\n"; \
> +		printf 'menu "User-provided options"\n'; \
> +		printf '\tdepends on BR2_EXTERNAL != "support/dummy-external"\n\n'; \
> +		printf 'source "%s/Config.in"\n\n' $$(cd $(BR2_EXTERNAL) >/dev/null 2>&1 && pwd); \
> +		printf 'endmenu # User-provided options\n'; \
> +	) >$@

Shouldn't the logic that generates the .br2-external.in be moved to a
shell script?

I'm generally in favor of having most of the logic in make, but here,
it is really ugly. Did you try having this in a shell script?

Also, what about using readlink or realpath to convert the path to an
absolute path?

Best regards,

Thomas
Yann E. MORIN Aug. 27, 2016, 10:14 p.m. UTC | #3
Thomas, All,

On 2016-08-27 22:00 +0200, Thomas Petazzoni spake thusly:
> On Sun, 17 Jul 2016 12:34:28 +0200, Yann E. MORIN wrote:
> >  .PHONY: $(BUILD_DIR)/.br2-external.in
> >  $(BUILD_DIR)/.br2-external.in: $(BUILD_DIR)
> > -	@touch $@
> > +	$(Q)( \
> > +		printf "#\n# Automatically generated file; DO NOT EDIT.\n#\n\n"; \
> > +		printf 'menu "User-provided options"\n'; \
> > +		printf '\tdepends on BR2_EXTERNAL != "support/dummy-external"\n\n'; \
> > +		printf 'source "%s/Config.in"\n\n' $$(cd $(BR2_EXTERNAL) >/dev/null 2>&1 && pwd); \
> > +		printf 'endmenu # User-provided options\n'; \
> > +	) >$@
> 
> Shouldn't the logic that generates the .br2-external.in be moved to a
> shell script?
> 
> I'm generally in favor of having most of the logic in make, but here,
> it is really ugly. Did you try having this in a shell script?

Well, for the above, it's OK to move to a shell script, indeed.

But once we have multiple br2-external trees, we need, for each of them:
  - the path to the br2-external tree,
  - the name of that tree.

So, if offloading this to a script, we'd need to either:

  - construct a list of tuples of {name,path} to the script, maybe
    something like:

        MY_NAME:/path/to/my-name-ext/ FOO:/path/to/foo-ext/ ...
or
  - rescann and re-extract the names from each br2-external tree.

Not very nice in either cases... :-/

> Also, what about using readlink or realpath to convert the path to an
> absolute path?

You meant the "cd blabla && pwd" trick?

I kept it because that's the way it is done today...

Regards,
Yann E. MORIN.
diff mbox

Patch

diff --git a/Config.in b/Config.in
index 7f533ce..7810bf8 100644
--- a/Config.in
+++ b/Config.in
@@ -761,11 +761,4 @@  source "package/Config.in.host"
 
 source "Config.in.legacy"
 
-menu "User-provided options"
-	depends on BR2_EXTERNAL != "support/dummy-external"
-
-source "$BR2_EXTERNAL/Config.in"
-
-endmenu
-
 source "$BR2_BUILD_DIR/.br2-external.in"
diff --git a/Makefile b/Makefile
index 39a1507..86c532e 100644
--- a/Makefile
+++ b/Makefile
@@ -882,7 +882,13 @@  endif
 
 .PHONY: $(BUILD_DIR)/.br2-external.in
 $(BUILD_DIR)/.br2-external.in: $(BUILD_DIR)
-	@touch $@
+	$(Q)( \
+		printf "#\n# Automatically generated file; DO NOT EDIT.\n#\n\n"; \
+		printf 'menu "User-provided options"\n'; \
+		printf '\tdepends on BR2_EXTERNAL != "support/dummy-external"\n\n'; \
+		printf 'source "%s/Config.in"\n\n' $$(cd $(BR2_EXTERNAL) >/dev/null 2>&1 && pwd); \
+		printf 'endmenu # User-provided options\n'; \
+	) >$@
 
 # printvars prints all the variables currently defined in our
 # Makefiles. Alternatively, if a non-empty VARS variable is passed,