Gabe Black has uploaded this change for review. ( 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
---
M site_scons/gem5_scons/util.py
M src/SConscript
2 files changed, 15 insertions(+), 14 deletions(-)



diff --git a/site_scons/gem5_scons/util.py b/site_scons/gem5_scons/util.py
index b62cc01..517e584 100644
--- a/site_scons/gem5_scons/util.py
+++ b/site_scons/gem5_scons/util.py
@@ -38,6 +38,7 @@
 # (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 itertools
 import re
 import sys
@@ -109,3 +110,16 @@
         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])
+        code(''.join('%d,' % d for d in x))
+    code.dedent()
+    code('};')
diff --git a/src/SConscript b/src/SConscript
index ae8bdbe..e7c5067 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -37,7 +37,6 @@
 # (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 importlib
@@ -53,6 +52,7 @@

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

 Export(SourceFilter.factories)

@@ -68,19 +68,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])
-        code(''.join('%d,' % d for d in x))
-    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: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
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