Deleted Added
sdiff udiff text old ( 5863:f73e06bc8765 ) new ( 5871:8007803be77a )
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
9# notice, this list of conditions and the following disclaimer;
10# redistributions in binary form must reproduce the above copyright

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

101import sys
102
103from os import mkdir, environ
104from os.path import abspath, basename, dirname, expanduser, normpath
105from os.path import exists, isdir, isfile
106from os.path import join as joinpath, split as splitpath
107
108import SCons
109
110def read_command(cmd):
111 """run the command cmd, read the results and return them
112 this is sorta like `cmd` in shell"""
113 from subprocess import Popen, PIPE, STDOUT
114 subp = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, close_fds=True)
115 return subp.communicate()[0]
116
117# helper function: compare arrays or strings of version numbers.
118# E.g., compare_version((1,3,25), (1,4,1)')
119# returns -1, 0, 1 if v1 is <, ==, > v2
120def compare_versions(v1, v2):
121 def make_version_list(v):
122 if isinstance(v, (list,tuple)):

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

132 for n1,n2 in zip(v1, v2):
133 if n1 < n2: return -1
134 if n1 > n2: return 1
135 # all corresponding values are equal... see if one has extra values
136 if len(v1) < len(v2): return -1
137 if len(v1) > len(v2): return 1
138 return 0
139
140# The absolute path to the current directory (where this file lives).
141ROOT = Dir('.').abspath
142
143# Path to the M5 source tree.
144SRCDIR = joinpath(ROOT, 'src')
145
146# tell python where to find m5 python code
147sys.path.append(joinpath(ROOT, 'src/python'))
148
149###################################################
150# Mercurial Stuff.
151# 1) Grab repository revision if we know it.
152# 2) Ensure that the style hook is in place.
153###################################################
154
155hg_info = "Unknown"
156try:
157 if not exists(ROOT) or not isdir(ROOT) or \
158 not exists(joinpath(ROOT, ".hg")):
159 raise ValueError(".hg directory not found")
160 hg_info = read_command("cd %s; hg id -n -i -t -b" % ROOT).strip()
161except ImportError, e:
162 print "Mercurial not found"
163except ValueError, e:
164 print e
165except Exception, e:
166 print "Other mercurial exception: %s" % e
167
168def check_style_hook(ui):
169 ui.readconfig(joinpath(ROOT, '.hg', 'hgrc'))
170 style_hook = ui.config('hooks', 'pretxncommit.style', None)
171
172 if not style_hook:
173 print """\
174You're missing the M5 style hook.
175Please install the hook so we can ensure that all code fits a common style.
176
177All you'd need to do is add the following lines to your repository .hg/hgrc
178or your personal .hgrc
179----------------
180
181[extensions]
182style = %s/util/style.py
183
184[hooks]
185pretxncommit.style = python:style.check_whitespace
186""" % (ROOT)
187 sys.exit(1)
188
189if ARGUMENTS.get('IGNORE_STYLE') != 'True' and isdir(joinpath(ROOT, '.hg')):
190 try:
191 from mercurial import ui
192 check_style_hook(ui.ui())
193 except ImportError:
194 pass
195
196
197###################################################
198#
199# Figure out which configurations to set up based on the path(s) of
200# the target(s).
201#
202###################################################
203
204# Find default configuration & binary.

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

252 variant_path = joinpath('/',*path_dirs[:build_top+2])
253 if variant_path not in variant_paths:
254 variant_paths.append(variant_path)
255
256# Make sure build_root exists (might not if this is the first build there)
257if not isdir(build_root):
258 mkdir(build_root)
259
260###################################################
261#
262# Set up the default build environment. This environment is copied
263# and modified according to each selected configuration.
264#
265###################################################
266
267env = Environment(ENV = environ, # inherit user's environment vars
268 ROOT = ROOT,
269 SRCDIR = SRCDIR,
270 HG_INFO = hg_info)
271
272Export('env')
273
274env.SConsignFile(joinpath(build_root, "sconsign"))
275
276# Default duplicate option is to use hard links, but this messes up
277# when you use emacs to edit a file in the target dir, as emacs moves
278# file to file~ then copies to file, breaking the link. Symbolic
279# (soft) links work better.

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

324# Update env with values from ARGUMENTS & file global_sticky_vars_file
325global_sticky_vars.Update(env)
326
327# Save sticky variable settings back to current variables file
328global_sticky_vars.Save(global_sticky_vars_file, env)
329
330# Parse EXTRAS variable to build list of all directories where we're
331# look for sources etc. This list is exported as base_dir_list.
332base_dir = joinpath(ROOT, 'src')
333if env['EXTRAS']:
334 extras_dir_list = env['EXTRAS'].split(':')
335else:
336 extras_dir_list = []
337
338Export('base_dir')
339Export('extras_dir_list')
340
341# M5_PLY is used by isa_parser.py to find the PLY package.
342env.Append(ENV = { 'M5_PLY' : str(Dir('ext/ply')) })
343env['GCC'] = read_command(env['CXX'] + ' --version').find('g++') >= 0
344env['SUNCC'] = read_command(env['CXX'] + ' -V').find('Sun C++') >= 0
345env['ICC'] = read_command(env['CXX'] + ' -V').find('Intel') >= 0
346if env['GCC'] + env['SUNCC'] + env['ICC'] > 1:
347 print 'Error: How can we have two at the same time?'
348 Exit(1)
349
350# Set up default C++ compiler flags
351if env['GCC']:
352 env.Append(CCFLAGS='-pipe')
353 env.Append(CCFLAGS='-fno-strict-aliasing')
354 env.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef'))
355 env.Append(CXXFLAGS='-Wno-deprecated')
356elif env['ICC']:
357 pass #Fix me... add warning flags once we clean up icc warnings
358elif env['SUNCC']:
359 env.Append(CCFLAGS='-Qoption ccfe')
360 env.Append(CCFLAGS='-features=gcc')
361 env.Append(CCFLAGS='-features=extensions')
362 env.Append(CCFLAGS='-library=stlport4')
363 env.Append(CCFLAGS='-xar')
364# env.Append(CCFLAGS='-instances=semiexplicit')
365else:
366 print 'Error: Don\'t know what compiler options to use for your compiler.'
367 print ' Please fix SConstruct and src/SConscript and try again.'
368 Exit(1)
369
370# Do this after we save setting back, or else we'll tack on an
371# extra 'qdo' every time we run scons.
372if env['BATCH']:

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

383
384# Check for SWIG
385if not env.has_key('SWIG'):
386 print 'Error: SWIG utility not found.'
387 print ' Please install (see http://www.swig.org) and retry.'
388 Exit(1)
389
390# Check for appropriate SWIG version
391swig_version = read_command('swig -version').split()
392# First 3 words should be "SWIG Version x.y.z"
393if len(swig_version) < 3 or \
394 swig_version[0] != 'SWIG' or swig_version[1] != 'Version':
395 print 'Error determining SWIG version.'
396 Exit(1)
397
398min_swig_version = '1.3.28'
399if compare_versions(swig_version[2], min_swig_version) < 0:

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

592#
593env = conf.Finish()
594
595######################################################################
596#
597# Collect all non-global variables
598#
599
600# Define the universe of supported ISAs
601all_isa_list = [ ]
602Export('all_isa_list')
603
604# Define the universe of supported CPU models
605all_cpu_list = [ ]
606default_cpus = [ ]
607Export('all_cpu_list', 'default_cpus')

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

703 return ([target], [Value(variable), Value(val)])
704
705config_builder = Builder(emitter = config_emitter, action = config_action)
706
707env.Append(BUILDERS = { 'ConfigFile' : config_builder })
708
709# libelf build is shared across all configs in the build root.
710env.SConscript('ext/libelf/SConscript',
711 variant_dir = joinpath(build_root, 'libelf'),
712 exports = 'env')
713
714# gzstream build is shared across all configs in the build root.
715env.SConscript('ext/gzstream/SConscript',
716 variant_dir = joinpath(build_root, 'gzstream'),
717 exports = 'env')
718
719###################################################
720#
721# This function is used to set up a directory with switching headers
722#
723###################################################
724
725env['ALL_ISA_LIST'] = all_isa_list

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

854
855 # Set up the regression tests for each build.
856 for e in envList:
857 SConscript('tests/SConscript',
858 variant_dir = joinpath(variant_path, 'tests', e.Label),
859 exports = { 'env' : e }, duplicate = False)
860
861Help(help_text)
862
863
864###################################################
865#
866# Let SCons do its thing. At this point SCons will use the defined
867# build environments to build the requested targets.
868#
869###################################################
870