SConscript (5601:1acb7016d0e4) SConscript (5604:7c58fc1ec5dc)
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

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

56 _list = _list[:]
57 else:
58 _list = list(_list)
59 _list.sort()
60 return _list
61
62class PySourceFile(object):
63 invalid_sym_char = re.compile('[^A-z0-9_]')
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

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

56 _list = _list[:]
57 else:
58 _list = list(_list)
59 _list.sort()
60 return _list
61
62class PySourceFile(object):
63 invalid_sym_char = re.compile('[^A-z0-9_]')
64 def __init__(self, package, source):
65 filename = str(source)
64 def __init__(self, package, tnode):
65 snode = tnode.srcnode()
66 filename = str(tnode)
66 pyname = basename(filename)
67 assert pyname.endswith('.py')
68 name = pyname[:-3]
69 if package:
70 path = package.split('.')
71 else:
72 path = []
67 pyname = basename(filename)
68 assert pyname.endswith('.py')
69 name = pyname[:-3]
70 if package:
71 path = package.split('.')
72 else:
73 path = []
73 modpath = path
74
75 modpath = path[:]
74 if name != '__init__':
75 modpath += [name]
76 modpath = '.'.join(modpath)
77
78 arcpath = path + [ pyname ]
79 arcname = joinpath(*arcpath)
80
76 if name != '__init__':
77 modpath += [name]
78 modpath = '.'.join(modpath)
79
80 arcpath = path + [ pyname ]
81 arcname = joinpath(*arcpath)
82
81 self.tnode = source
82 self.snode = source.srcnode()
83 debugname = snode.abspath
84 if not exists(debugname):
85 debugname = tnode.abspath
86
87 self.tnode = tnode
88 self.snode = snode
83 self.pyname = pyname
84 self.package = package
85 self.modpath = modpath
86 self.arcname = arcname
89 self.pyname = pyname
90 self.package = package
91 self.modpath = modpath
92 self.arcname = arcname
87 self.filename = filename
93 self.debugname = debugname
88 self.compiled = File(filename + 'c')
89 self.assembly = File(filename + '.s')
90 self.symname = "PyEMB_" + self.invalid_sym_char.sub('_', modpath)
91
92
93########################################################################
94# Code for adding source files of various types
95#

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

844 '''Action function to compile a .py into a code object, marshal
845 it, compress it, and stick it into an asm file so the code appears
846 as just bytes with a label in the data section'''
847
848 src = file(str(source[0]), 'r').read()
849 dst = file(str(target[0]), 'w')
850
851 pysource = py_sources_tnodes[source[0]]
94 self.compiled = File(filename + 'c')
95 self.assembly = File(filename + '.s')
96 self.symname = "PyEMB_" + self.invalid_sym_char.sub('_', modpath)
97
98
99########################################################################
100# Code for adding source files of various types
101#

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

850 '''Action function to compile a .py into a code object, marshal
851 it, compress it, and stick it into an asm file so the code appears
852 as just bytes with a label in the data section'''
853
854 src = file(str(source[0]), 'r').read()
855 dst = file(str(target[0]), 'w')
856
857 pysource = py_sources_tnodes[source[0]]
852 compiled = compile(src, pysource.snode.path, 'exec')
858 compiled = compile(src, pysource.debugname, 'exec')
853 marshalled = marshal.dumps(compiled)
854 compressed = zlib.compress(marshalled)
855 data = compressed
856
857 # Some C/C++ compilers prepend an underscore to global symbol
858 # names, so if they're going to do that, we need to prepend that
859 # leading underscore to globals in the assembly file.
860 if env['LEADING_UNDERSCORE']:

--- 193 unchanged lines hidden ---
859 marshalled = marshal.dumps(compiled)
860 compressed = zlib.compress(marshalled)
861 data = compressed
862
863 # Some C/C++ compilers prepend an underscore to global symbol
864 # names, so if they're going to do that, we need to prepend that
865 # leading underscore to globals in the assembly file.
866 if env['LEADING_UNDERSCORE']:

--- 193 unchanged lines hidden ---