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:
@@ -39,6 +39,7 @@
|
|||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import pickle
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import textwrap
|
import textwrap
|
||||||
@@ -46,6 +47,7 @@ import textwrap
|
|||||||
from gem5_scons.util import get_termcap
|
from gem5_scons.util import get_termcap
|
||||||
from gem5_scons.configure import Configure
|
from gem5_scons.configure import Configure
|
||||||
from gem5_scons.defaults import EnvDefaults
|
from gem5_scons.defaults import EnvDefaults
|
||||||
|
import SCons.Node.Python
|
||||||
import SCons.Script
|
import SCons.Script
|
||||||
|
|
||||||
termcap = get_termcap()
|
termcap = get_termcap()
|
||||||
@@ -260,5 +262,11 @@ else:
|
|||||||
env['SHCCCOMSTR'] = Transform("SHCC")
|
env['SHCCCOMSTR'] = Transform("SHCC")
|
||||||
env['SHCXXCOMSTR'] = Transform("SHCXX")
|
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',
|
__all__ = ['Configure', 'EnvDefaults', 'Transform', 'warning', 'error',
|
||||||
'MakeAction', 'MakeActionTool']
|
'MakeAction', 'MakeActionTool', 'ToValue', 'FromValue']
|
||||||
|
|||||||
Reference in New Issue
Block a user