Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/48377 )

Change subject: scons: Move the bytesToCppArray helper to gem5_scons.util.
......................................................................

scons: Move the bytesToCppArray helper to gem5_scons.util.

Change-Id: Ib8789dd33ebbfb8e10446de5d1079654a2200d2d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48377
Reviewed-by: Hoa Nguyen <[email protected]>
Reviewed-by: Bobby R. Bruce <[email protected]>
Tested-by: kokoro <[email protected]>
Maintainer: Bobby R. Bruce <[email protected]>
---
M site_scons/gem5_scons/util.py
M src/SConscript
2 files changed, 17 insertions(+), 16 deletions(-)

Approvals:
  Hoa Nguyen: Looks good to me, approved
  Bobby R. Bruce: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/site_scons/gem5_scons/util.py b/site_scons/gem5_scons/util.py
index b62cc01..6049fed 100644
--- a/site_scons/gem5_scons/util.py
+++ b/site_scons/gem5_scons/util.py
@@ -38,6 +38,8 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+import array
+import functools
 import itertools
 import re
 import sys
@@ -109,3 +111,17 @@
         if n1 > n2: return  1

     return 0
+
+def bytesToCppArray(code, symbol, data):
+    '''
+ Output an array of bytes to a code formatter as a c++ array declaration.
+    '''
+    code('const std::uint8_t ${symbol}[] = {')
+    code.indent()
+    step = 16
+    for i in range(0, len(data), step):
+        x = array.array('B', data[i:i+step])
+        strs = map(lambda i: f'{i},', x)
+        code(functools.reduce(lambda x, y: x + y, strs))
+    code.dedent()
+    code('};')
diff --git a/src/SConscript b/src/SConscript
index c819ad7..28404aa 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -37,10 +37,8 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-import array
 import bisect
 import distutils.spawn
-import functools
 import importlib
 import importlib.abc
 import importlib.machinery
@@ -55,6 +53,7 @@

 from gem5_scons import Transform, warning, error, ToValue, FromValue
 from gem5_scons.sources import *
+from gem5_scons.util import bytesToCppArray

 Export(SourceFilter.factories)

@@ -70,20 +69,6 @@

 from m5.util import code_formatter

-def bytesToCppArray(code, symbol, data):
-    '''
- Output an array of bytes to a code formatter as a c++ array declaration.
-    '''
-    code('const std::uint8_t ${symbol}[] = {')
-    code.indent()
-    step = 16
-    for i in range(0, len(data), step):
-        x = array.array('B', data[i:i + step])
-        strs = map(lambda i: f'{i},', x)
-        code(functools.reduce(lambda x, y: x + y, strs))
-    code.dedent()
-    code('};')
-
 def build_blob(target, source, env):
     '''
     Embed an arbitrary blob into the gem5 executable,

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/48377
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ib8789dd33ebbfb8e10446de5d1079654a2200d2d
Gerrit-Change-Number: 48377
Gerrit-PatchSet: 12
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Hoa Nguyen <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to