Deleted Added
sdiff udiff text old ( 5601:1acb7016d0e4 ) new ( 5604:7c58fc1ec5dc )
full compact
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)
66 pyname = basename(filename)
67 assert pyname.endswith('.py')
68 name = pyname[:-3]
69 if package:
70 path = package.split('.')
71 else:
72 path = []
73 modpath = path
74 if name != '__init__':
75 modpath += [name]
76 modpath = '.'.join(modpath)
77
78 arcpath = path + [ pyname ]
79 arcname = joinpath(*arcpath)
80
81 self.tnode = source
82 self.snode = source.srcnode()
83 self.pyname = pyname
84 self.package = package
85 self.modpath = modpath
86 self.arcname = arcname
87 self.filename = filename
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]]
852 compiled = compile(src, pysource.snode.path, '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 ---