SConscript (10454:dc49b13b6f79) SConscript (10455:30b40ca619ba)
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

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

738 Exit(1)
739
740#
741# Handle debug flags
742#
743def makeDebugFlagCC(target, source, env):
744 assert(len(target) == 1 and len(source) == 1)
745
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

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

738 Exit(1)
739
740#
741# Handle debug flags
742#
743def makeDebugFlagCC(target, source, env):
744 assert(len(target) == 1 and len(source) == 1)
745
746 val = eval(source[0].get_contents())
747 name, compound, desc = val
748 compound = list(sorted(compound))
749
750 code = code_formatter()
751
746 code = code_formatter()
747
748 # delay definition of CompoundFlags until after all the definition
749 # of all constituent SimpleFlags
750 comp_code = code_formatter()
751
752 # file header
753 code('''
754/*
752 # file header
753 code('''
754/*
755 * DO NOT EDIT THIS FILE! Automatically generated
755 * DO NOT EDIT THIS FILE! Automatically generated by SCons.
756 */
757
758#include "base/debug.hh"
756 */
757
758#include "base/debug.hh"
759
760namespace Debug {
761
759''')
760
762''')
763
761 for flag in compound:
762 code('#include "debug/$flag.hh"')
763 code()
764 code('namespace Debug {')
765 code()
764 for name, flag in sorted(source[0].read().iteritems()):
765 n, compound, desc = flag
766 assert n == name
766
767
767 if not compound:
768 code('SimpleFlag $name("$name", "$desc");')
769 else:
770 code('CompoundFlag $name("$name", "$desc",')
771 code.indent()
772 last = len(compound) - 1
773 for i,flag in enumerate(compound):
774 if i != last:
775 code('$flag,')
776 else:
777 code('$flag);')
778 code.dedent()
768 if not compound:
769 code('SimpleFlag $name("$name", "$desc");')
770 else:
771 comp_code('CompoundFlag $name("$name", "$desc",')
772 comp_code.indent()
773 last = len(compound) - 1
774 for i,flag in enumerate(compound):
775 if i != last:
776 comp_code('$flag,')
777 else:
778 comp_code('$flag);')
779 comp_code.dedent()
779
780
781 code.append(comp_code)
780 code()
781 code('} // namespace Debug')
782
783 code.write(str(target[0]))
784
785def makeDebugFlagHH(target, source, env):
786 assert(len(target) == 1 and len(source) == 1)
787
788 val = eval(source[0].get_contents())
789 name, compound, desc = val
790
791 code = code_formatter()
792
793 # file header boilerplate
794 code('''\
795/*
782 code()
783 code('} // namespace Debug')
784
785 code.write(str(target[0]))
786
787def makeDebugFlagHH(target, source, env):
788 assert(len(target) == 1 and len(source) == 1)
789
790 val = eval(source[0].get_contents())
791 name, compound, desc = val
792
793 code = code_formatter()
794
795 # file header boilerplate
796 code('''\
797/*
796 * DO NOT EDIT THIS FILE!
797 *
798 * Automatically generated by SCons
798 * DO NOT EDIT THIS FILE! Automatically generated by SCons.
799 */
800
801#ifndef __DEBUG_${name}_HH__
802#define __DEBUG_${name}_HH__
803
804namespace Debug {
805''')
806

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

823
824 code.write(str(target[0]))
825
826for name,flag in sorted(debug_flags.iteritems()):
827 n, compound, desc = flag
828 assert n == name
829
830 hh_file = 'debug/%s.hh' % name
799 */
800
801#ifndef __DEBUG_${name}_HH__
802#define __DEBUG_${name}_HH__
803
804namespace Debug {
805''')
806

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

823
824 code.write(str(target[0]))
825
826for name,flag in sorted(debug_flags.iteritems()):
827 n, compound, desc = flag
828 assert n == name
829
830 hh_file = 'debug/%s.hh' % name
831 cc_file = 'debug/%s.cc' % name
832 env.Command(hh_file, Value(flag),
833 MakeAction(makeDebugFlagHH, Transform("TRACING", 0)))
831 env.Command(hh_file, Value(flag),
832 MakeAction(makeDebugFlagHH, Transform("TRACING", 0)))
834 env.Command(cc_file, Value(flag),
835 MakeAction(makeDebugFlagCC, Transform("TRACING", 0)))
836 env.Depends(SWIG, [hh_file, cc_file])
837 Source('debug/%s.cc' % name)
833 env.Depends(SWIG, hh_file)
838
834
835env.Command('debug/flags.cc', Value(debug_flags),
836 MakeAction(makeDebugFlagCC, Transform("TRACING", 0)))
837env.Depends(SWIG, 'debug/flags.cc')
838Source('debug/flags.cc')
839
839# Embed python files. All .py files that have been indicated by a
840# PySource() call in a SConscript need to be embedded into the M5
841# library. To do that, we compile the file to byte code, marshal the
842# byte code, compress it, and then generate a c++ file that
843# inserts the result into an array.
844def embedPyFile(target, source, env):
845 def c_str(string):
846 if string is None:

--- 337 unchanged lines hidden ---
840# Embed python files. All .py files that have been indicated by a
841# PySource() call in a SConscript need to be embedded into the M5
842# library. To do that, we compile the file to byte code, marshal the
843# byte code, compress it, and then generate a c++ file that
844# inserts the result into an array.
845def embedPyFile(target, source, env):
846 def c_str(string):
847 if string is None:

--- 337 unchanged lines hidden ---