SConscript (11500:024291dab733) SConscript (11548:91f58918a76a)
1# -*- mode:python -*-
2
3# Copyright (c) 2004-2005 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright

--- 222 unchanged lines hidden (view full) ---

231
232 def __init__(self, package, source, **guards):
233 '''Specify the python package, the source file, and any guards'''
234 super(SwigSource, self).__init__(source, skip_no_python=True, **guards)
235
236 modname,ext = self.extname
237 assert ext == 'i'
238
1# -*- mode:python -*-
2
3# Copyright (c) 2004-2005 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright

--- 222 unchanged lines hidden (view full) ---

231
232 def __init__(self, package, source, **guards):
233 '''Specify the python package, the source file, and any guards'''
234 super(SwigSource, self).__init__(source, skip_no_python=True, **guards)
235
236 modname,ext = self.extname
237 assert ext == 'i'
238
239 self.package = package
239 self.module = modname
240 cc_file = joinpath(self.dirname, modname + '_wrap.cc')
241 py_file = joinpath(self.dirname, modname + '.py')
242
243 self.cc_source = Source(cc_file, swig=True, parent=self, **guards)
244 self.py_source = PySource(package, py_file, parent=self, **guards)
245
246class ProtoBuf(SourceFile):

--- 564 unchanged lines hidden (view full) ---

811 extra_deps = [ py_source.tnode ]
812 i_file = File('python/m5/internal/param_%s.i' % name)
813 env.Command(i_file, Value(name),
814 MakeAction(createSimObjectSwigWrapper, Transform("SO SWIG")))
815 env.Depends(i_file, depends + extra_deps)
816 SwigSource('m5.internal', i_file)
817
818# Generate the main swig init file
240 self.module = modname
241 cc_file = joinpath(self.dirname, modname + '_wrap.cc')
242 py_file = joinpath(self.dirname, modname + '.py')
243
244 self.cc_source = Source(cc_file, swig=True, parent=self, **guards)
245 self.py_source = PySource(package, py_file, parent=self, **guards)
246
247class ProtoBuf(SourceFile):

--- 564 unchanged lines hidden (view full) ---

812 extra_deps = [ py_source.tnode ]
813 i_file = File('python/m5/internal/param_%s.i' % name)
814 env.Command(i_file, Value(name),
815 MakeAction(createSimObjectSwigWrapper, Transform("SO SWIG")))
816 env.Depends(i_file, depends + extra_deps)
817 SwigSource('m5.internal', i_file)
818
819# Generate the main swig init file
819def makeEmbeddedSwigInit(target, source, env):
820 code = code_formatter()
821 module = source[0].get_contents()
822 code('''\
823#include "sim/init.hh"
820def makeEmbeddedSwigInit(package):
821 def body(target, source, env):
822 assert len(target) == 1 and len(source) == 1
824
823
825extern "C" {
826 void init_${module}();
827}
824 code = code_formatter()
825 module = source[0].get_contents()
826 # Provide the full context so that the swig-generated call to
827 # Py_InitModule ends up placing the embedded module in the
828 # right package.
829 context = str(package) + "._" + str(module)
830 code('''\
831 #include "sim/init.hh"
828
832
829EmbeddedSwig embed_swig_${module}(init_${module});
830''')
831 code.write(str(target[0]))
833 extern "C" {
834 void init_${module}();
835 }
832
836
837 EmbeddedSwig embed_swig_${module}(init_${module}, "${context}");
838 ''')
839 code.write(str(target[0]))
840 return body
841
833# Build all swig modules
834for swig in SwigSource.all:
835 env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode,
836 MakeAction('$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} '
837 '-o ${TARGETS[0]} $SOURCES', Transform("SWIG")))
838 cc_file = str(swig.tnode)
839 init_file = '%s/%s_init.cc' % (dirname(cc_file), basename(cc_file))
840 env.Command(init_file, Value(swig.module),
842# Build all swig modules
843for swig in SwigSource.all:
844 env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode,
845 MakeAction('$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} '
846 '-o ${TARGETS[0]} $SOURCES', Transform("SWIG")))
847 cc_file = str(swig.tnode)
848 init_file = '%s/%s_init.cc' % (dirname(cc_file), basename(cc_file))
849 env.Command(init_file, Value(swig.module),
841 MakeAction(makeEmbeddedSwigInit, Transform("EMBED SW")))
850 MakeAction(makeEmbeddedSwigInit(swig.package),
851 Transform("EMBED SW")))
842 env.Depends(SWIG, init_file)
843 Source(init_file, **swig.guards)
844
845# Build all protocol buffers if we have got protoc and protobuf available
846if env['HAVE_PROTOBUF']:
847 for proto in ProtoBuf.all:
848 # Use both the source and header as the target, and the .proto
849 # file as the source. When executing the protoc compiler, also

--- 478 unchanged lines hidden ---
852 env.Depends(SWIG, init_file)
853 Source(init_file, **swig.guards)
854
855# Build all protocol buffers if we have got protoc and protobuf available
856if env['HAVE_PROTOBUF']:
857 for proto in ProtoBuf.all:
858 # Use both the source and header as the target, and the .proto
859 # file as the source. When executing the protoc compiler, also

--- 478 unchanged lines hidden ---