From 0337db3388db335ea23f02f3aa00bca9d483ef1c Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Tue, 30 May 2006 13:11:34 -0400 Subject: Link in Python interpreter. Use embedded zip archive to carry Python code instead of homegrown embedded string/file mechanism. Do argument parsing in Python instead of C++. SConstruct: Add Python interpreter include path & library. Define two new simple builders which copy & concatenate files, respectively, for use by the Python embedded zipfile code. src/SConscript: Encapsulate environment creation in a function. Add code to append Python zip archive to final executable. Eliminate references to obsolete files. src/python/SConscript: Rewrite to generate embedded zip archive of Python code (replacing old "embedded string" mechanism). src/python/m5/__init__.py: Move main arg-parsing loop here (out of C++ main()). src/python/m5/config.py: Minor fix (version incompatibility?). src/sim/main.cc: Invoke embedded Python interpreter to parse args and generate config.ini, replacing C++ arg parsing code. --HG-- extra : convert_revision : 72d21236b2bee139ff39ba4cf031a4a1f8560029 --- SConstruct | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'SConstruct') diff --git a/SConstruct b/SConstruct index cbbcb07a6..2e4f48180 100644 --- a/SConstruct +++ b/SConstruct @@ -169,7 +169,13 @@ if sys.platform == 'cygwin': env.Append(CCFLAGS=Split("-Wno-uninitialized")) env.Append(CPPPATH=[Dir('ext/dnet')]) -# Default libraries +# Environment args for linking in Python interpreter. +# Should really have an option for setting the version instead of +# having 2.4 hardwired in here... +env.Append(CPPPATH='/usr/include/python2.4') +env.Append(LIBS='python2.4') + +# Other default libraries env.Append(LIBS=['z']) # Platform-specific configuration. Note again that we assume that all @@ -310,6 +316,32 @@ config_builder = Builder(emitter = config_emitter, action = config_action) env.Append(BUILDERS = { 'ConfigFile' : config_builder }) +################################################### +# +# Define a SCons builder for copying files. This is used by the +# Python zipfile code in src/python/SConscript, but is placed up here +# since it's potentially more generally applicable. +# +################################################### + +copy_builder = Builder(action = Copy("$TARGET", "$SOURCE")) + +env.Append(BUILDERS = { 'CopyFile' : copy_builder }) + +################################################### +# +# Define a simple SCons builder to concatenate files. +# +# Used to append the Python zip archive to the executable. +# +################################################### + +concat_builder = Builder(action = Action(['cat $SOURCES > $TARGET', + 'chmod +x $TARGET'])) + +env.Append(BUILDERS = { 'Concat' : concat_builder }) + + # base help text help_text = ''' Usage: scons [scons options] [build options] [target(s)] -- cgit v1.2.3