style: Check/Fix whitespace on SCons files
--HG-- extra : convert_revision : 46e6b2dd8e1984cbab0ea24c94760794734c0f95
This commit is contained in:
parent
cda354b070
commit
c27e23f2e8
5 changed files with 61 additions and 47 deletions
46
SConstruct
46
SConstruct
|
@ -86,7 +86,7 @@ except:
|
||||||
print "Error checking current SCons version."
|
print "Error checking current SCons version."
|
||||||
print "SCons", ".".join(map(str,min_scons_version)), "or greater required."
|
print "SCons", ".".join(map(str,min_scons_version)), "or greater required."
|
||||||
Exit(2)
|
Exit(2)
|
||||||
|
|
||||||
|
|
||||||
# The absolute path to the current directory (where this file lives).
|
# The absolute path to the current directory (where this file lives).
|
||||||
ROOT = Dir('.').abspath
|
ROOT = Dir('.').abspath
|
||||||
|
@ -211,7 +211,7 @@ env = Environment(ENV = os.environ, # inherit user's environment vars
|
||||||
ROOT = ROOT,
|
ROOT = ROOT,
|
||||||
SRCDIR = SRCDIR)
|
SRCDIR = SRCDIR)
|
||||||
|
|
||||||
#Parse CC/CXX early so that we use the correct compiler for
|
#Parse CC/CXX early so that we use the correct compiler for
|
||||||
# to test for dependencies/versions/libraries/includes
|
# to test for dependencies/versions/libraries/includes
|
||||||
if ARGUMENTS.get('CC', None):
|
if ARGUMENTS.get('CC', None):
|
||||||
env['CC'] = ARGUMENTS.get('CC')
|
env['CC'] = ARGUMENTS.get('CC')
|
||||||
|
@ -240,14 +240,14 @@ env.Append(ENV = { 'M5_PLY' : Dir('ext/ply') })
|
||||||
env['GCC'] = False
|
env['GCC'] = False
|
||||||
env['SUNCC'] = False
|
env['SUNCC'] = False
|
||||||
env['ICC'] = False
|
env['ICC'] = False
|
||||||
env['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True,
|
env['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||||
close_fds=True).communicate()[0].find('GCC') >= 0
|
close_fds=True).communicate()[0].find('GCC') >= 0
|
||||||
env['SUNCC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True,
|
env['SUNCC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||||
close_fds=True).communicate()[0].find('Sun C++') >= 0
|
close_fds=True).communicate()[0].find('Sun C++') >= 0
|
||||||
env['ICC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True,
|
env['ICC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||||
close_fds=True).communicate()[0].find('Intel') >= 0
|
close_fds=True).communicate()[0].find('Intel') >= 0
|
||||||
if env['GCC'] + env['SUNCC'] + env['ICC'] > 1:
|
if env['GCC'] + env['SUNCC'] + env['ICC'] > 1:
|
||||||
print 'Error: How can we have two at the same time?'
|
print 'Error: How can we have two at the same time?'
|
||||||
|
@ -309,7 +309,7 @@ for scanner in env['SCANNERS']:
|
||||||
skeys = scanner.skeys
|
skeys = scanner.skeys
|
||||||
if skeys == '.i':
|
if skeys == '.i':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(skeys, (list, tuple)) and '.i' in skeys:
|
if isinstance(skeys, (list, tuple)) and '.i' in skeys:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -528,7 +528,7 @@ def config_emitter(target, source, env):
|
||||||
val = int(val)
|
val = int(val)
|
||||||
elif isinstance(val, str):
|
elif isinstance(val, str):
|
||||||
val = '"' + val + '"'
|
val = '"' + val + '"'
|
||||||
|
|
||||||
# Sources are option name & value (packaged in SCons Value nodes)
|
# Sources are option name & value (packaged in SCons Value nodes)
|
||||||
return ([target], [Value(option), Value(val)])
|
return ([target], [Value(option), Value(val)])
|
||||||
|
|
||||||
|
@ -585,22 +585,22 @@ def make_switching_dir(dirname, switch_headers, env):
|
||||||
# header to generate. 'source' is a dummy variable, since we get the
|
# header to generate. 'source' is a dummy variable, since we get the
|
||||||
# list of ISAs from env['ALL_ISA_LIST'].
|
# list of ISAs from env['ALL_ISA_LIST'].
|
||||||
def gen_switch_hdr(target, source, env):
|
def gen_switch_hdr(target, source, env):
|
||||||
fname = str(target[0])
|
fname = str(target[0])
|
||||||
basename = os.path.basename(fname)
|
basename = os.path.basename(fname)
|
||||||
f = open(fname, 'w')
|
f = open(fname, 'w')
|
||||||
f.write('#include "arch/isa_specific.hh"\n')
|
f.write('#include "arch/isa_specific.hh"\n')
|
||||||
cond = '#if'
|
cond = '#if'
|
||||||
for isa in all_isa_list:
|
for isa in all_isa_list:
|
||||||
f.write('%s THE_ISA == %s_ISA\n#include "%s/%s/%s"\n'
|
f.write('%s THE_ISA == %s_ISA\n#include "%s/%s/%s"\n'
|
||||||
% (cond, isa.upper(), dirname, isa, basename))
|
% (cond, isa.upper(), dirname, isa, basename))
|
||||||
cond = '#elif'
|
cond = '#elif'
|
||||||
f.write('#else\n#error "THE_ISA not set"\n#endif\n')
|
f.write('#else\n#error "THE_ISA not set"\n#endif\n')
|
||||||
f.close()
|
f.close()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
# String to print when generating header
|
# String to print when generating header
|
||||||
def gen_switch_hdr_string(target, source, env):
|
def gen_switch_hdr_string(target, source, env):
|
||||||
return "Generating switch header " + str(target[0])
|
return "Generating switch header " + str(target[0])
|
||||||
|
|
||||||
# Build SCons Action object. 'varlist' specifies env vars that this
|
# Build SCons Action object. 'varlist' specifies env vars that this
|
||||||
# action depends on; when env['ALL_ISA_LIST'] changes these actions
|
# action depends on; when env['ALL_ISA_LIST'] changes these actions
|
||||||
|
|
|
@ -35,7 +35,7 @@ Import('env')
|
||||||
elf_files = []
|
elf_files = []
|
||||||
def ElfFile(filename):
|
def ElfFile(filename):
|
||||||
elf_files.append(File(filename))
|
elf_files.append(File(filename))
|
||||||
|
|
||||||
ElfFile('elf_begin.c')
|
ElfFile('elf_begin.c')
|
||||||
ElfFile('elf_cntl.c')
|
ElfFile('elf_cntl.c')
|
||||||
ElfFile('elf_data.c')
|
ElfFile('elf_data.c')
|
||||||
|
|
|
@ -43,23 +43,23 @@ Import('*')
|
||||||
|
|
||||||
# List of headers to generate
|
# List of headers to generate
|
||||||
isa_switch_hdrs = Split('''
|
isa_switch_hdrs = Split('''
|
||||||
arguments.hh
|
arguments.hh
|
||||||
faults.hh
|
faults.hh
|
||||||
interrupts.hh
|
interrupts.hh
|
||||||
isa_traits.hh
|
isa_traits.hh
|
||||||
kernel_stats.hh
|
kernel_stats.hh
|
||||||
locked_mem.hh
|
locked_mem.hh
|
||||||
mmaped_ipr.hh
|
mmaped_ipr.hh
|
||||||
process.hh
|
process.hh
|
||||||
predecoder.hh
|
predecoder.hh
|
||||||
regfile.hh
|
regfile.hh
|
||||||
remote_gdb.hh
|
remote_gdb.hh
|
||||||
stacktrace.hh
|
stacktrace.hh
|
||||||
syscallreturn.hh
|
syscallreturn.hh
|
||||||
tlb.hh
|
tlb.hh
|
||||||
types.hh
|
types.hh
|
||||||
utility.hh
|
utility.hh
|
||||||
vtophys.hh
|
vtophys.hh
|
||||||
''')
|
''')
|
||||||
|
|
||||||
# Set up this directory to support switching headers
|
# Set up this directory to support switching headers
|
||||||
|
|
|
@ -173,7 +173,7 @@ def test_builder(env, ref_dir):
|
||||||
'-o', cmd_stdout, '-e', cmd_stderr, base_cmd]
|
'-o', cmd_stdout, '-e', cmd_stderr, base_cmd]
|
||||||
else:
|
else:
|
||||||
cmd = [base_cmd, '>', cmd_stdout, '2>', cmd_stderr]
|
cmd = [base_cmd, '>', cmd_stdout, '2>', cmd_stderr]
|
||||||
|
|
||||||
env.Command([tgt('stdout'), tgt('stderr'), new_stats],
|
env.Command([tgt('stdout'), tgt('stderr'), new_stats],
|
||||||
[env.M5Binary, 'run.py'], ' '.join(cmd))
|
[env.M5Binary, 'run.py'], ' '.join(cmd))
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ if env['FULL_SYSTEM']:
|
||||||
'tsunami-simple-timing',
|
'tsunami-simple-timing',
|
||||||
'tsunami-simple-atomic-dual',
|
'tsunami-simple-atomic-dual',
|
||||||
'tsunami-simple-timing-dual',
|
'tsunami-simple-timing-dual',
|
||||||
'twosys-tsunami-simple-atomic']
|
'twosys-tsunami-simple-atomic']
|
||||||
if env['TARGET_ISA'] == 'sparc':
|
if env['TARGET_ISA'] == 'sparc':
|
||||||
configs += ['t1000-simple-atomic',
|
configs += ['t1000-simple-atomic',
|
||||||
't1000-simple-timing']
|
't1000-simple-timing']
|
||||||
|
|
|
@ -51,14 +51,28 @@ lang_types = { 'c' : "C",
|
||||||
's' : "asm",
|
's' : "asm",
|
||||||
'S' : "asm",
|
'S' : "asm",
|
||||||
'isa' : "isa" }
|
'isa' : "isa" }
|
||||||
whitespace_types = ('C', 'C++', 'swig', 'python', 'asm', 'isa')
|
|
||||||
format_types = ( 'C', 'C++' )
|
|
||||||
|
|
||||||
def file_type(filename):
|
def file_type(filename):
|
||||||
extension = filename.split('.')
|
extension = filename.split('.')
|
||||||
extension = len(extension) > 1 and extension[-1]
|
extension = len(extension) > 1 and extension[-1]
|
||||||
return lang_types.get(extension, None)
|
return lang_types.get(extension, None)
|
||||||
|
|
||||||
|
whitespace_types = ('C', 'C++', 'swig', 'python', 'asm', 'isa')
|
||||||
|
def whitespace_file(filename):
|
||||||
|
if file_type(filename) in whitespace_types:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if filename.startswith("SCons"):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
format_types = ( 'C', 'C++' )
|
||||||
|
def format_file(filename):
|
||||||
|
if file_type(filename) in format_types:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def checkwhite_line(line):
|
def checkwhite_line(line):
|
||||||
match = lead.search(line)
|
match = lead.search(line)
|
||||||
if match and match.group(1).find('\t') != -1:
|
if match and match.group(1).find('\t') != -1:
|
||||||
|
@ -71,7 +85,7 @@ def checkwhite_line(line):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def checkwhite(filename):
|
def checkwhite(filename):
|
||||||
if file_type(filename) not in whitespace_types:
|
if not whitespace_file(filename)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -101,7 +115,7 @@ def fixwhite_line(line, tabsize):
|
||||||
return line.rstrip() + '\n'
|
return line.rstrip() + '\n'
|
||||||
|
|
||||||
def fixwhite(filename, tabsize, fixonly=None):
|
def fixwhite(filename, tabsize, fixonly=None):
|
||||||
if file_type(filename) not in whitespace_types:
|
if not whitespace_file(filename)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -159,7 +173,7 @@ class ValidationStats(object):
|
||||||
self.trailwhite or self.badcontrol or self.cret
|
self.trailwhite or self.badcontrol or self.cret
|
||||||
|
|
||||||
def validate(filename, stats, verbose, exit_code):
|
def validate(filename, stats, verbose, exit_code):
|
||||||
if file_type(filename) not in format_types:
|
if not format_file(filename):
|
||||||
return
|
return
|
||||||
|
|
||||||
def msg(lineno, line, message):
|
def msg(lineno, line, message):
|
||||||
|
|
Loading…
Reference in a new issue