All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [[RFC Patch] 1/2] tools: buildmand: Remove duplicated code
@ 2016-09-29 21:12 York Sun
  2016-09-29 21:12 ` [U-Boot] [[RFC Patch] 2/2] tools: buildman: Add compiler wrapper York Sun
  2016-10-03 21:49 ` [U-Boot] [[RFC Patch] 1/2] tools: buildmand: Remove duplicated code Simon Glass
  0 siblings, 2 replies; 4+ messages in thread
From: York Sun @ 2016-09-29 21:12 UTC (permalink / raw)
  To: u-boot

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
---
The duplicated code seems to exist since the beginning of buildman.

 tools/buildman/builderthread.py | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index c512d3b..16e87f3 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -304,10 +304,6 @@ class BuilderThread(threading.Thread):
                 print >>fd, 'arch', result.toolchain.arch
                 fd.write('%s' % result.return_code)
 
-            with open(os.path.join(build_dir, 'toolchain'), 'w') as fd:
-                print >>fd, 'gcc', result.toolchain.gcc
-                print >>fd, 'path', result.toolchain.path
-
             # Write out the image and function size information and an objdump
             env = result.toolchain.MakeEnvironment(self.builder.full_path)
             lines = []
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [[RFC Patch] 2/2] tools: buildman: Add compiler wrapper
  2016-09-29 21:12 [U-Boot] [[RFC Patch] 1/2] tools: buildmand: Remove duplicated code York Sun
@ 2016-09-29 21:12 ` York Sun
  2016-10-03 21:49   ` Simon Glass
  2016-10-03 21:49 ` [U-Boot] [[RFC Patch] 1/2] tools: buildmand: Remove duplicated code Simon Glass
  1 sibling, 1 reply; 4+ messages in thread
From: York Sun @ 2016-09-29 21:12 UTC (permalink / raw)
  To: u-boot

Now we can use compiler wrapper such as ccache or distcc for buildman.

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
---
This is not perfect and may need some improvement. Something I didn't figure
out is how to drop the name under [toolchain-wrapper]. I intended to have this
format but bsettings.GetItems doesn't like it.

[toolchain-wrapper]
ccache

It doesn't deal with more than one line for this setting. For now, the last
setting is taken.

 tools/buildman/README       |  9 +++++++++
 tools/buildman/toolchain.py | 17 +++++++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/tools/buildman/README b/tools/buildman/README
index 8c5f861..514bebc 100644
--- a/tools/buildman/README
+++ b/tools/buildman/README
@@ -211,6 +211,15 @@ arm: arm-none-eabi-
 
 and buildman will find arm-none-eabi-gcc in /usr/bin if you have it installed.
 
+[toolchain-wrapper]
+wrapper: ccache
+
+This tells buildman to use a compiler wrapper in front of CROSS_COMPILE. In
+this example, ccache. It doesn't affect the toolchain scan. The wrapper is
+added when CROSS_COMPILE environtal variable is set. The name in this
+section is ignored. If more than one line is provided, only the last one
+is taken.
+
 3. Make sure you have the require Python pre-requisites
 
 Buildman uses multiprocessing, Queue, shutil, StringIO, ConfigParser and
diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py
index 41e4e4c..01cdb03 100644
--- a/tools/buildman/toolchain.py
+++ b/tools/buildman/toolchain.py
@@ -127,6 +127,15 @@ class Toolchain:
                 return PRIORITY_CALC + prio
         return PRIORITY_CALC + prio
 
+    def GetWrapper(self, show_warning=True):
+        """Get toolchain wrapper from the setting file.
+        """
+	value = ''
+	for name, value in bsettings.GetItems('toolchain-wrapper'):
+            if not value:
+                print "Warning: Wrapper not found"
+        return value
+
     def MakeEnvironment(self, full_path):
         """Returns an environment for using the toolchain.
 
@@ -138,10 +147,14 @@ class Toolchain:
                 PATH
         """
         env = dict(os.environ)
+        wrapper = self.GetWrapper()
+        if wrapper:
+            wrapper = wrapper + ' '
+
         if full_path:
-            env['CROSS_COMPILE'] = os.path.join(self.path, self.cross)
+            env['CROSS_COMPILE'] = wrapper + os.path.join(self.path, self.cross)
         else:
-            env['CROSS_COMPILE'] = self.cross
+            env['CROSS_COMPILE'] = wrapper + self.cross
             env['PATH'] = self.path + ':' + env['PATH']
 
         return env
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [[RFC Patch] 2/2] tools: buildman: Add compiler wrapper
  2016-09-29 21:12 ` [U-Boot] [[RFC Patch] 2/2] tools: buildman: Add compiler wrapper York Sun
@ 2016-10-03 21:49   ` Simon Glass
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2016-10-03 21:49 UTC (permalink / raw)
  To: u-boot

Hi York,

On 29 September 2016 at 15:12, York Sun <york.sun@nxp.com> wrote:
>
> Now we can use compiler wrapper such as ccache or distcc for buildman.
>
> Signed-off-by: York Sun <york.sun@nxp.com>
> CC: Simon Glass <sjg@chromium.org>
> ---
> This is not perfect and may need some improvement. Something I didn't figure
> out is how to drop the name under [toolchain-wrapper]. I intended to have this
> format but bsettings.GetItems doesn't like it.
>
> [toolchain-wrapper]
> ccache
>
> It doesn't deal with more than one line for this setting. For now, the last
> setting is taken.
>
>  tools/buildman/README       |  9 +++++++++
>  tools/buildman/toolchain.py | 17 +++++++++++++++--
>  2 files changed, 24 insertions(+), 2 deletions(-)

Looks good, a few nits below.

Acked-by: Simon Glass <sjg@chromium.org>

>
> diff --git a/tools/buildman/README b/tools/buildman/README
> index 8c5f861..514bebc 100644
> --- a/tools/buildman/README
> +++ b/tools/buildman/README
> @@ -211,6 +211,15 @@ arm: arm-none-eabi-
>
>  and buildman will find arm-none-eabi-gcc in /usr/bin if you have it installed.
>
> +[toolchain-wrapper]
> +wrapper: ccache

I think it is good to have this in a separate section, as you have
done. If we put it in the '[toolchain]' section, the name 'wrapper'
would be special, and mean something, whereas the other names would
not.

> +
> +This tells buildman to use a compiler wrapper in front of CROSS_COMPILE. In
> +this example, ccache. It doesn't affect the toolchain scan. The wrapper is
> +added when CROSS_COMPILE environtal variable is set. The name in this
> +section is ignored. If more than one line is provided, only the last one
> +is taken.
> +
>  3. Make sure you have the require Python pre-requisites
>
>  Buildman uses multiprocessing, Queue, shutil, StringIO, ConfigParser and
> diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py
> index 41e4e4c..01cdb03 100644
> --- a/tools/buildman/toolchain.py
> +++ b/tools/buildman/toolchain.py
> @@ -127,6 +127,15 @@ class Toolchain:
>                  return PRIORITY_CALC + prio
>          return PRIORITY_CALC + prio
>
> +    def GetWrapper(self, show_warning=True):
> +        """Get toolchain wrapper from the setting file.
> +        """
> +       value = ''
> +       for name, value in bsettings.GetItems('toolchain-wrapper'):
> +            if not value:
> +                print "Warning: Wrapper not found"
> +        return value

Can you make it add the ' ' here?

> +
>      def MakeEnvironment(self, full_path):
>          """Returns an environment for using the toolchain.
>
> @@ -138,10 +147,14 @@ class Toolchain:
>                  PATH
>          """
>          env = dict(os.environ)
> +        wrapper = self.GetWrapper()
> +        if wrapper:
> +            wrapper = wrapper + ' '

Instead of here

> +
>          if full_path:
> -            env['CROSS_COMPILE'] = os.path.join(self.path, self.cross)
> +            env['CROSS_COMPILE'] = wrapper + os.path.join(self.path, self.cross)
>          else:
> -            env['CROSS_COMPILE'] = self.cross
> +            env['CROSS_COMPILE'] = wrapper + self.cross
>              env['PATH'] = self.path + ':' + env['PATH']
>
>          return env
> --
> 2.7.4
>
Regards,
Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [[RFC Patch] 1/2] tools: buildmand: Remove duplicated code
  2016-09-29 21:12 [U-Boot] [[RFC Patch] 1/2] tools: buildmand: Remove duplicated code York Sun
  2016-09-29 21:12 ` [U-Boot] [[RFC Patch] 2/2] tools: buildman: Add compiler wrapper York Sun
@ 2016-10-03 21:49 ` Simon Glass
  1 sibling, 0 replies; 4+ messages in thread
From: Simon Glass @ 2016-10-03 21:49 UTC (permalink / raw)
  To: u-boot

On 29 September 2016 at 15:12, York Sun <york.sun@nxp.com> wrote:
> Signed-off-by: York Sun <york.sun@nxp.com>
> CC: Simon Glass <sjg@chromium.org>
> ---
> The duplicated code seems to exist since the beginning of buildman.
>
>  tools/buildman/builderthread.py | 4 ----
>  1 file changed, 4 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-03 21:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-29 21:12 [U-Boot] [[RFC Patch] 1/2] tools: buildmand: Remove duplicated code York Sun
2016-09-29 21:12 ` [U-Boot] [[RFC Patch] 2/2] tools: buildman: Add compiler wrapper York Sun
2016-10-03 21:49   ` Simon Glass
2016-10-03 21:49 ` [U-Boot] [[RFC Patch] 1/2] tools: buildmand: Remove duplicated code Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.