scons: Add a pair of functions for working with Value nodes.

These nodes are really for working with text, and they do strange and
broken things otherwise. This change adds a pair of convenience
functions which uses pickle to serialize an object for the Value to
hold, and to unpack the Value later.

Change-Id: Id48822ce3de283b003d4cc7ef6b563a70e321ca6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48371
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
This commit is contained in:
Gabe Black
2021-07-19 04:35:41 -07:00
parent 98b50f3f2b
commit 2a4f01b87f

View File

@@ -39,6 +39,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
import pickle
import sys
import tempfile
import textwrap
@@ -46,6 +47,7 @@ import textwrap
from gem5_scons.util import get_termcap
from gem5_scons.configure import Configure
from gem5_scons.defaults import EnvDefaults
import SCons.Node.Python
import SCons.Script
termcap = get_termcap()
@@ -260,5 +262,11 @@ else:
env['SHCCCOMSTR'] = Transform("SHCC")
env['SHCXXCOMSTR'] = Transform("SHCXX")
def ToValue(obj):
return SCons.Node.Python.Value(pickle.dumps(obj))
def FromValue(node):
return pickle.loads(node.read())
__all__ = ['Configure', 'EnvDefaults', 'Transform', 'warning', 'error',
'MakeAction', 'MakeActionTool']
'MakeAction', 'MakeActionTool', 'ToValue', 'FromValue']