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 --- 184 unchanged lines hidden (view full) --- 193Export('Source') 194Export('PySource') 195Export('SimObject') 196Export('SwigSource') 197Export('UnitTest') 198 199######################################################################## 200# |
201# Debug Flags |
202# |
203debug_flags = {} 204def DebugFlag(name, desc=None): 205 if name in debug_flags: |
206 raise AttributeError, "Flag %s already specified" % name |
207 debug_flags[name] = (name, (), desc) 208TraceFlag = DebugFlag |
209 210def CompoundFlag(name, flags, desc=None): |
211 if name in debug_flags: |
212 raise AttributeError, "Flag %s already specified" % name 213 214 compound = tuple(flags) |
215 debug_flags[name] = (name, compound, desc) |
216 |
217Export('DebugFlag') |
218Export('TraceFlag') 219Export('CompoundFlag') 220 221######################################################################## 222# 223# Set some compiler variables 224# 225 --- 393 unchanged lines hidden (view full) --- 619 env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode, 620 MakeAction('$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} ' 621 '-o ${TARGETS[0]} $SOURCES', Transform("SWIG"))) 622 init_file = 'python/swig/init_%s.cc' % swig.module 623 env.Command(init_file, Value(swig.module), 624 MakeAction(makeEmbeddedSwigInit, Transform("EMBED SW"))) 625 Source(init_file) 626 |
627# 628# Handle debug flags 629# 630def makeDebugFlagCC(target, source, env): 631 assert(len(target) == 1 and len(source) == 1) |
632 |
633 val = eval(source[0].get_contents()) 634 name, compound, desc = val 635 compound = list(sorted(compound)) |
636 |
637 code = code_formatter() 638 |
639 # file header 640 code(''' 641/* 642 * DO NOT EDIT THIS FILE! Automatically generated 643 */ 644 |
645#include "base/debug.hh" |
646''') 647 |
648 for flag in compound: 649 code('#include "debug/$flag.hh"') |
650 code() |
651 code('namespace Debug {') 652 code() |
653 |
654 if not compound: 655 code('SimpleFlag $name("$name", "$desc");') 656 else: 657 code('CompoundFlag $name("$name", "$desc",') |
658 code.indent() |
659 last = len(compound) - 1 660 for i,flag in enumerate(compound): 661 if i != last: 662 code('$flag,') 663 else: 664 code('$flag);') |
665 code.dedent() |
666 |
667 code() 668 code('} // namespace Debug') |
669 670 code.write(str(target[0])) 671 |
672def makeDebugFlagHH(target, source, env): 673 assert(len(target) == 1 and len(source) == 1) |
674 |
675 val = eval(source[0].get_contents()) 676 name, compound, desc = val 677 |
678 code = code_formatter() 679 680 # file header boilerplate 681 code('''\ 682/* 683 * DO NOT EDIT THIS FILE! 684 * |
685 * Automatically generated by SCons |
686 */ 687 |
688#ifndef __DEBUG_${name}_HH__ 689#define __DEBUG_${name}_HH__ |
690 |
691namespace Debug { 692''') |
693 |
694 if compound: 695 code('class CompoundFlag;') 696 code('class SimpleFlag;') |
697 |
698 if compound: 699 code('extern CompoundFlag $name;') 700 for flag in compound: 701 code('extern SimpleFlag $flag;') 702 else: 703 code('extern SimpleFlag $name;') |
704 |
705 code(''' |
706} |
707 |
708#endif // __DEBUG_${name}_HH__ |
709''') 710 711 code.write(str(target[0])) 712 |
713for name,flag in sorted(debug_flags.iteritems()): 714 n, compound, desc = flag 715 assert n == name |
716 |
717 env.Command('debug/%s.hh' % name, Value(flag), 718 MakeAction(makeDebugFlagHH, Transform("TRACING", 0))) 719 env.Command('debug/%s.cc' % name, Value(flag), 720 MakeAction(makeDebugFlagCC, Transform("TRACING", 0))) 721 Source('debug/%s.cc' % name) |
722 723# Embed python files. All .py files that have been indicated by a 724# PySource() call in a SConscript need to be embedded into the M5 725# library. To do that, we compile the file to byte code, marshal the 726# byte code, compress it, and then generate a c++ file that 727# inserts the result into an array. 728def embedPyFile(target, source, env): 729 def c_str(string): --- 190 unchanged lines hidden --- |