diff mbox

[4/4] tools: moveconfig: add --spl option to move options for SPL build

Message ID 1471871902-5361-5-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit 07913d1e42c1db77acd653fb4aa671b664c59db2
Headers show

Commit Message

Masahiro Yamada Aug. 22, 2016, 1:18 p.m. UTC
Prior to this commit, the tool could not move options guarded by
CONFIG_SPL_BUILD ifdef conditionals because they do not show up in
include/autoconf.mk.  This new option, if given, makes the tool
parse spl/include/autoconf.mk instead of include/autoconf.mk,
which is probably preferred behavior when moving options for SPL.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

 tools/moveconfig.py | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

-- 
1.9.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Comments

Andrew Davis Aug. 22, 2016, 2:57 p.m. UTC | #1
On 08/22/2016 09:43 AM, Tom Rini wrote:
> On Mon, Aug 22, 2016 at 10:18:22PM +0900, Masahiro Yamada wrote:

> 

>> Prior to this commit, the tool could not move options guarded by

>> CONFIG_SPL_BUILD ifdef conditionals because they do not show up in

>> include/autoconf.mk.  This new option, if given, makes the tool

>> parse spl/include/autoconf.mk instead of include/autoconf.mk,

>> which is probably preferred behavior when moving options for SPL.

>>

>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> 

> Reviewed-by: Tom Rini <trini@konsulko.com>

> 


I think we are still missing the case of some option being defined one
way in the SPL build case but another the regular case, which one should
be added to the defconfig?

In a set of slides[0] I found on the subject it looks like there was
going to be a system where we could conditionally define options in
defconfig based on whether we were building SPL or not. So we could run
moveconfig in multiple passes and find what kind of tag we need.

S:CONFIG_FOO=200
T:CONFIG_FOO=300
ST:CONFIG_BAR=y
+S:CONFIG_BAZ=y
+T:CONFIG_QUX=y
+ST:CONFIG_QUUX=y
etc..

Did this ever get implemented?

[0]
http://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2014/uboot2014_kconfig.pdf

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Masahiro Yamada Aug. 23, 2016, 12:41 a.m. UTC | #2
Hi Andrew,


2016-08-22 23:57 GMT+09:00 Andrew F. Davis <afd@ti.com>:

> I think we are still missing the case of some option being defined one

> way in the SPL build case but another the regular case, which one should

> be added to the defconfig?



  #ifdef CONFIG_SPL_BUILD
     #define CONFIG_FOO   100
  #else
     #define CONFIG_FOO   200
  #endif

is a case where we can not migrate as is.



Generally, it will be changed as follows:

config  FOO
        int "foo"

config  SPL_FOO
        int "foo for SPL"


It is too much to have regular/SPL variants
for all cases, so we need to draw a line somewhere, though.




> In a set of slides[0] I found on the subject it looks like there was

> going to be a system where we could conditionally define options in

> defconfig based on whether we were building SPL or not. So we could run

> moveconfig in multiple passes and find what kind of tag we need.

>

> S:CONFIG_FOO=200

> T:CONFIG_FOO=300

> ST:CONFIG_BAR=y

> +S:CONFIG_BAZ=y

> +T:CONFIG_QUX=y

> +ST:CONFIG_QUUX=y

> etc..

>

> Did this ever get implemented?

>

> [0]

> http://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2014/uboot2014_kconfig.pdf

>


At first, I implemented like that,
but I realized it was tedious to use.

So, commit e02ee2548 switched to single .config
like Linux has.  Instead, this requires
separate CONFIGs for U-Boot proper and SPL
as mentioned above.

-- 
Best Regards
Masahiro Yamada
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
diff mbox

Patch

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 98e8608..5576b57 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -138,6 +138,12 @@  Available options
    If not specified, "make savedefconfig" only occurs for cases
    where at least one CONFIG was moved.
 
+ -S, --spl
+   Look for moved config options in spl/include/autoconf.mk instead of
+   include/autoconf.mk.  This is useful for moving options for SPL build
+   because SPL related options (mostly prefixed with CONFIG_SPL_) are
+   sometimes blocked by CONFIG_SPL_BUILD ifdef conditionals.
+
  -H, --headers-only
    Only cleanup the headers; skip the defconfig processing
 
@@ -614,6 +620,8 @@  class KconfigParser:
         self.options = options
         self.dotconfig = os.path.join(build_dir, '.config')
         self.autoconf = os.path.join(build_dir, 'include', 'autoconf.mk')
+        self.spl_autoconf = os.path.join(build_dir, 'spl', 'include',
+                                         'autoconf.mk')
         self.config_autoconf = os.path.join(build_dir, 'include', 'config',
                                             'auto.conf')
         self.defconfig = os.path.join(build_dir, 'defconfig')
@@ -715,11 +723,25 @@  class KconfigParser:
         results = []
         updated = False
         suspicious = False
+        rm_files = [self.config_autoconf, self.autoconf]
+
+        if self.options.spl:
+            if os.path.exists(self.spl_autoconf):
+                autoconf_path = self.spl_autoconf
+                rm_files.append(self.spl_autoconf)
+            else:
+                for f in rm_files:
+                    os.remove(f)
+                return (updated, suspicious,
+                        color_text(self.options.color, COLOR_BROWN,
+                                   "SPL is not enabled.  Skipped.") + '\n')
+        else:
+            autoconf_path = self.autoconf
 
         with open(self.dotconfig) as f:
             dotconfig_lines = f.readlines()
 
-        with open(self.autoconf) as f:
+        with open(autoconf_path) as f:
             autoconf_lines = f.readlines()
 
         for config in self.configs:
@@ -744,6 +766,9 @@  class KconfigParser:
                 actlog = "'%s' is the same as the define in Kconfig.  Do nothing." \
                          % value
                 log_color = COLOR_LIGHT_PURPLE
+            elif action == ACTION_SPL_NOT_EXIST:
+                actlog = "SPL is not enabled for this defconfig.  Skip."
+                log_color = COLOR_PURPLE
             else:
                 sys.exit("Internal Error. This should not happen.")
 
@@ -756,8 +781,8 @@  class KconfigParser:
                     updated = True
 
         self.results = results
-        os.remove(self.config_autoconf)
-        os.remove(self.autoconf)
+        for f in rm_files:
+            os.remove(f)
 
         return (updated, suspicious, log)
 
@@ -1217,6 +1242,8 @@  def main():
                       help='exit immediately on any error')
     parser.add_option('-s', '--force-sync', action='store_true', default=False,
                       help='force sync by savedefconfig')
+    parser.add_option('-S', '--spl', action='store_true', default=False,
+                      help='parse config options defined for SPL build')
     parser.add_option('-H', '--headers-only', dest='cleanup_headers_only',
                       action='store_true', default=False,
                       help='only cleanup the headers')