| |
119 |
#--- functons for checking guts ---
|
| |
120 |
|
| |
121 |
def _check_guts_eq(attr, old, new, last_build):
|
| |
122 |
"""
|
| |
123 |
rebuild is required if values differ
|
| |
124 |
"""
|
| |
125 |
if old != new:
|
| |
126 |
print "building because %s changed" % attr
|
| |
127 |
return True
|
| |
128 |
return False
|
| |
129 |
|
| |
130 |
def _check_guts_toc_mtime(attr, old, toc, last_build, pyc=0):
|
| |
131 |
"""
|
| |
132 |
rebuild is required if mtimes of files listed in old toc are newer
|
| |
133 |
than ast_build
|
| |
134 |
|
| |
135 |
if pyc=1, check for .py files, too
|
| |
136 |
"""
|
| |
137 |
for (nm, fnm, typ) in old:
|
| |
138 |
if mtime(fnm) > last_build:
|
| |
139 |
print "building because %s changed" % fnm
|
| |
140 |
return True
|
| |
141 |
elif pyc and mtime(fnm[:-1]) > last_build:
|
| |
142 |
print "building because %s changed" % fnm[:-1]
|
| |
143 |
return True
|
| |
144 |
return False
|
| |
145 |
|
| |
146 |
def _check_guts_toc(attr, old, toc, last_build, pyc=0):
|
| |
147 |
"""
|
| |
148 |
rebuild is required if either toc content changed if mtimes of
|
| |
149 |
files listed in old toc are newer than ast_build
|
| |
150 |
|
| |
151 |
if pyc=1, check for .py files, too
|
| |
152 |
"""
|
| |
153 |
return _check_guts_eq (attr, old, toc, last_build) \
|
| |
154 |
or _check_guts_toc_mtime(attr, old, toc, last_build, pyc=pyc)
|
| |
155 |
|
| |
156 |
#--
|
| |
157 |
|
| |
171 |
GUTS = []
|
| |
172 |
|
| |
173 |
def check_guts(self, last_build):
|
| |
174 |
pass
|
| |
175 |
|
| |
176 |
def get_guts(self, last_build, missing ='missing or bad'):
|
| |
177 |
"""
|
| |
178 |
returns None if guts have changed
|
| |
179 |
"""
|
| |
180 |
try:
|
| |
181 |
data = _load_data(self.out)
|
| |
182 |
except:
|
| |
183 |
print "building because", os.path.basename(self.out), missing
|
| |
184 |
return None
|
| |
185 |
|
| |
186 |
if len(data) != len(self.GUTS):
|
| |
187 |
print "building because %s is bad" % outnm
|
| |
188 |
return None
|
| |
189 |
for i in range(len(self.GUTS)):
|
| |
190 |
attr, func = self.GUTS[i]
|
| |
191 |
if func is None:
|
| |
192 |
# no check for this value
|
| |
193 |
continue
|
| |
194 |
if func(attr, data[i], getattr(self, attr), last_build):
|
| |
195 |
return None
|
| |
196 |
return data
|
| |
197 |
|
| |
198 |
|
| |
217 |
|
| |
218 |
GUTS = (('inputs', _check_guts_eq),
|
| |
219 |
('pathex', _check_guts_eq),
|
| |
220 |
('hookspath', _check_guts_eq),
|
| |
221 |
('excludes', _check_guts_eq),
|
| |
222 |
('scripts', _check_guts_toc_mtime),
|
| |
223 |
('pure', lambda *args: apply(_check_guts_toc_mtime,
|
| |
224 |
args, {'pyc': 1 } )),
|
| |
225 |
('binaries', _check_guts_toc_mtime),
|
| |
226 |
('zipfiles', _check_guts_toc_mtime),
|
| |
227 |
)
|
| |
228 |
|
| 158 |
|
try:
|
| 159 |
|
inputs, pathex, hookspath, excludes, scripts, pure, binaries, zipfiles = _load_data(self.out)
|
| 160 |
|
except:
|
| 161 |
|
print "building because %s disappeared" % outnm
|
| 162 |
|
return True
|
| 163 |
|
if inputs != self.inputs:
|
| 164 |
|
print "building %s because inputs changed" % outnm
|
| 165 |
|
return True
|
| 166 |
|
if pathex != self.pathex:
|
| 167 |
|
print "building %s because pathex changed" % outnm
|
| 168 |
|
return True
|
| 169 |
|
if hookspath != self.hookspath:
|
| 170 |
|
print "building %s because hookspath changed" % outnm
|
| 171 |
|
return True
|
| 172 |
|
if excludes != self.excludes:
|
| 173 |
|
print "building %s because excludes changed" % outnm
|
| |
238 |
|
| |
239 |
data = Target.get_guts(self, last_build)
|
| |
240 |
if not data:
|
| 175 |
|
for (nm, fnm, typ) in scripts:
|
| 176 |
|
if mtime(fnm) > last_build:
|
| 177 |
|
print "building because %s changed" % fnm
|
| 178 |
|
return True
|
| 179 |
|
for (nm, fnm, typ) in pure:
|
| 180 |
|
if mtime(fnm) > last_build:
|
| 181 |
|
print "building because %s changed" % fnm
|
| 182 |
|
return True
|
| 183 |
|
elif mtime(fnm[:-1]) > last_build:
|
| 184 |
|
print "building because %s changed" % fnm[:-1]
|
| 185 |
|
return True
|
| 186 |
|
for (nm, fnm, typ) in binaries + zipfiles:
|
| 187 |
|
if mtime(fnm) > last_build:
|
| 188 |
|
print "building because %s changed" % fnm
|
| 189 |
|
return True
|
| |
242 |
scripts, pure, binaries, zipfiles = data[-4:]
|
| 331 |
|
return 1
|
| 332 |
|
try:
|
| 333 |
|
name, level, toc = _load_data(self.out)
|
| 334 |
|
except:
|
| 335 |
|
print "rebuilding %s because missing" % outnm
|
| 336 |
|
return 1
|
| 337 |
|
if name != self.name:
|
| 338 |
|
print "rebuilding %s because name changed" % outnm
|
| 339 |
|
return 1
|
| 340 |
|
if level != self.level:
|
| 341 |
|
print "rebuilding %s because level changed" % outnm
|
| 342 |
|
return 1
|
| 343 |
|
if toc != self.toc:
|
| 344 |
|
print "rebuilding %s because toc changed" % outnm
|
| 345 |
|
return 1
|
| 346 |
|
for (nm, fnm, typ) in toc:
|
| 347 |
|
if mtime(fnm) > last_build:
|
| 348 |
|
print "rebuilding %s because %s changed" % (outnm, fnm)
|
| 349 |
|
return 1
|
| 350 |
|
if fnm[-1] in ('c', 'o'):
|
| 351 |
|
if mtime(fnm[:-1]) > last_build:
|
| 352 |
|
print "rebuilding %s because %s changed" % (outnm, fnm[:-1])
|
| 353 |
|
return 1
|
| 354 |
|
return 0
|
| |
392 |
return True
|
| |
393 |
|
| |
394 |
data = Target.get_guts(self, last_build)
|
| |
395 |
if not data:
|
| |
396 |
return True
|
| |
397 |
return False
|
| |
398 |
|
| |
503 |
|
| |
504 |
GUTS = (('name', _check_guts_eq),
|
| |
505 |
('cdict', _check_guts_eq),
|
| |
506 |
('toc', _check_guts_toc_mtime),
|
| |
507 |
('exclude_binaries', _check_guts_eq),
|
| |
508 |
('strip_binaries', _check_guts_eq),
|
| |
509 |
('upx_binaries', _check_guts_eq),
|
| |
510 |
)
|
| |
511 |
|
| 464 |
|
try:
|
| 465 |
|
name, cdict, toc, exclude_binaries, strip_binaries, upx_binaries = _load_data(self.out)
|
| 466 |
|
except:
|
| 467 |
|
print "rebuilding %s because %s is missing" % (outnm, outnm)
|
| 468 |
|
return 1
|
| 469 |
|
if name != self.name:
|
| 470 |
|
print "rebuilding %s because name changed" % outnm
|
| 471 |
|
return 1
|
| 472 |
|
if cdict != self.cdict:
|
| 473 |
|
print "rebuilding %s because cdict changed" % outnm
|
| 474 |
|
return 1
|
| 475 |
|
if toc != self.toc:
|
| 476 |
|
print "rebuilding %s because toc changed" % outnm
|
| 477 |
|
return 1
|
| 478 |
|
if exclude_binaries != self.exclude_binaries:
|
| 479 |
|
print "rebuilding %s because exclude_binaries changed" % outnm
|
| 480 |
|
return 1
|
| 481 |
|
if strip_binaries != self.strip_binaries:
|
| 482 |
|
print "rebuilding %s because strip_binaries changed" % outnm
|
| 483 |
|
return 1
|
| 484 |
|
if upx_binaries != self.upx_binaries:
|
| 485 |
|
print "rebuilding %s because upx_binaries changed" % outnm
|
| 486 |
|
return 1
|
| 487 |
|
for (nm, fnm, typ) in toc:
|
| 488 |
|
if mtime(fnm) > last_build:
|
| 489 |
|
print "rebuilding %s because %s changed" % (outnm, fnm)
|
| 490 |
|
return 1
|
| 491 |
|
return 0
|
| |
517 |
|
| |
518 |
data = Target.get_guts(self, last_build)
|
| |
519 |
if not data:
|
| |
520 |
return True
|
| |
521 |
# todo: toc equal
|
| |
522 |
return False
|
| |
523 |
|
| |
524 |
|
| |
604 |
|
| |
605 |
GUTS = (('name', _check_guts_eq),
|
| |
606 |
('console', _check_guts_eq),
|
| |
607 |
('debug', _check_guts_eq),
|
| |
608 |
('icon', _check_guts_eq),
|
| |
609 |
('versrsrc', _check_guts_eq),
|
| |
610 |
('strip', _check_guts_eq),
|
| |
611 |
('upx', _check_guts_eq),
|
| |
612 |
('mtm', None,), # checked bellow
|
| |
613 |
)
|
| |
614 |
|
| 580 |
|
try:
|
| 581 |
|
name, console, debug, icon, versrsrc, strip, upx, mtm = _load_data(self.out)
|
| 582 |
|
except:
|
| 583 |
|
print "rebuilding %s because %s missing or bad" % (outnm, outnm)
|
| 584 |
|
return 1
|
| 585 |
|
if name != self.name:
|
| 586 |
|
print "rebuilding %s because name changed" % outnm
|
| 587 |
|
return 1
|
| 588 |
|
if console != self.console:
|
| 589 |
|
print "rebuilding %s because console option changed" % outnm
|
| 590 |
|
return 1
|
| 591 |
|
if debug != self.debug:
|
| 592 |
|
print "rebuilding %s because debug option changed" % outnm
|
| 593 |
|
return 1
|
| 594 |
|
if config['hasRsrcUpdate']:
|
| 595 |
|
if icon != self.icon:
|
| 596 |
|
print "rebuilding %s because icon option changed" % outnm
|
| 597 |
|
return 1
|
| 598 |
|
if versrsrc != self.versrsrc:
|
| 599 |
|
print "rebuilding %s because versrsrc option changed" % outnm
|
| 600 |
|
return 1
|
| 601 |
|
else:
|
| 602 |
|
if icon or versrsrc:
|
| 603 |
|
print "ignoring icon and version resources = platform not capable"
|
| 604 |
|
if strip != self.strip:
|
| 605 |
|
print "rebuilding %s because strip option changed" % outnm
|
| 606 |
|
return 1
|
| 607 |
|
if upx != self.upx:
|
| 608 |
|
print "rebuilding %s because upx option changed" % outnm
|
| 609 |
|
return 1
|
| |
624 |
|
| |
625 |
data = Target.get_guts(self, last_build)
|
| |
626 |
if not data:
|
| |
627 |
return True
|
| |
628 |
|
| |
629 |
icon, versrsrc = data[3:5]
|
| |
630 |
if (icon or versrsrc) and not config['hasRsrcUpdate']:
|
| |
631 |
# todo: really ignore :-)
|
| |
632 |
print "ignoring icon and version resources = platform not capable"
|
| |
633 |
|
| |
634 |
mtm = data[-1]
|
| 719 |
|
outnm = os.path.basename(self.out)
|
| 720 |
|
try:
|
| 721 |
|
name, strip_binaries, upx_binaries, toc = _load_data(self.out)
|
| 722 |
|
except:
|
| 723 |
|
print "building %s because %s missing" % (outnm, outnm)
|
| 724 |
|
return 1
|
| 725 |
|
if name != self.name:
|
| 726 |
|
print "building %s because name changed" % outnm
|
| 727 |
|
return 1
|
| 728 |
|
if strip_binaries != self.strip_binaries:
|
| 729 |
|
print "building %s because strip_binaries option changed" % outnm
|
| 730 |
|
return 1
|
| 731 |
|
if upx_binaries != self.upx_binaries:
|
| 732 |
|
print "building %s because upx_binaries option changed" % outnm
|
| 733 |
|
return 1
|
| 734 |
|
if toc != self.toc:
|
| 735 |
|
print "building %s because toc changed" % outnm
|
| 736 |
|
return 1
|
| |
754 |
data = Target.get_guts(self, last_build)
|
| |
755 |
if not data:
|
| |
756 |
return True
|
| |
757 |
toc = data[-1]
|
| 851 |
|
outnm = os.path.basename(self.out)
|
| 852 |
|
try:
|
| 853 |
|
root, prefix, excludes, toc = _load_data(self.out)
|
| 854 |
|
except:
|
| 855 |
|
print "building %s because %s is missing / bad" % (outnm, outnm)
|
| 856 |
|
return 1
|
| 857 |
|
if root != self.root:
|
| 858 |
|
print "building %s because root changed" % outnm
|
| 859 |
|
return 1
|
| 860 |
|
if prefix != self.prefix:
|
| 861 |
|
print "building %s because prefix changed" % outnm
|
| 862 |
|
return 1
|
| 863 |
|
if excludes != self.excludes:
|
| 864 |
|
print "building %s because excludes changed" % outnm
|
| 865 |
|
return 1
|
| 866 |
|
stack = [root]
|
| |
880 |
data = Target.get_guts(self, last_build)
|
| |
881 |
if not data:
|
| |
882 |
return True
|
| |
883 |
stack = [ data[0] ] # root
|
| |
884 |
toc = data[3] # toc
|