Deleted Added
sdiff udiff text old ( 5863:f73e06bc8765 ) new ( 5871:8007803be77a )
full compact
1# -*- mode:python -*-
2
3# Copyright (c) 2009 The Hewlett-Packard Development Company
4# Copyright (c) 2004-2005 The Regents of The University of Michigan
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are
9# met: redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer;
11# redistributions in binary form must reproduce the above copyright

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

102import sys
103
104from os import mkdir, environ
105from os.path import abspath, basename, dirname, expanduser, normpath
106from os.path import exists, isdir, isfile
107from os.path import join as joinpath, split as splitpath
108
109import SCons
110import SCons.Node
111
112def read_command(cmd, **kwargs):
113 """run the command cmd, read the results and return them
114 this is sorta like `cmd` in shell"""
115 from subprocess import Popen, PIPE, STDOUT
116
117 no_exception = 'exception' in kwargs
118 exception = kwargs.pop('exception', None)
119
120 kwargs.setdefault('shell', False)
121 kwargs.setdefault('stdout', PIPE)
122 kwargs.setdefault('stderr', STDOUT)
123 kwargs.setdefault('close_fds', True)
124 try:
125 subp = Popen(cmd, **kwargs)
126 except Exception, e:
127 if no_exception:
128 return exception
129 raise
130
131 return subp.communicate()[0]
132
133# helper function: compare arrays or strings of version numbers.
134# E.g., compare_version((1,3,25), (1,4,1)')
135# returns -1, 0, 1 if v1 is <, ==, > v2
136def compare_versions(v1, v2):
137 def make_version_list(v):
138 if isinstance(v, (list,tuple)):

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

148 for n1,n2 in zip(v1, v2):
149 if n1 < n2: return -1
150 if n1 > n2: return 1
151 # all corresponding values are equal... see if one has extra values
152 if len(v1) < len(v2): return -1
153 if len(v1) > len(v2): return 1
154 return 0
155
156########################################################################
157#
158# Set up the base build environment.
159#
160########################################################################
161use_vars = set([ 'AS', 'AR', 'CC', 'CXX', 'HOME', 'PATH', 'RANLIB' ])
162
163use_env = {}
164for key,val in os.environ.iteritems():
165 if key in use_vars or key.startswith("M5"):
166 use_env[key] = val
167
168env = Environment(ENV=use_env)
169env.root = Dir(".") # The current directory (where this file lives).
170env.srcdir = Dir("src") # The source directory
171
172########################################################################
173#
174# Mercurial Stuff.
175#
176# If the M5 directory is a mercurial repository, we should do some
177# extra things.
178#
179########################################################################
180
181hgdir = env.root.Dir(".hg")
182
183mercurial_style_message = """
184You're missing the M5 style hook.
185Please install the hook so we can ensure that all code fits a common style.
186
187All you'd need to do is add the following lines to your repository .hg/hgrc
188or your personal .hgrc
189----------------
190
191[extensions]
192style = %s/util/style.py
193
194[hooks]
195pretxncommit.style = python:style.check_whitespace
196""" % (env.root)
197
198mercurial_bin_not_found = """
199Mercurial binary cannot be found, unfortunately this means that we
200cannot easily determine the version of M5 that you are running and
201this makes error messages more difficult to collect. Please consider
202installing mercurial if you choose to post an error message
203"""
204
205mercurial_lib_not_found = """
206Mercurial libraries cannot be found, ignoring style hook
207If you are actually a M5 developer, please fix this and
208run the style hook. It is important.
209"""
210
211if hgdir.exists():
212 # 1) Grab repository revision if we know it.
213 cmd = "hg id -n -i -t -b"
214 try:
215 hg_info = read_command(cmd, cwd=env.root.abspath).strip()
216 except OSError:
217 hg_info = "Unknown"
218 print mercurial_bin_not_found
219
220 env['HG_INFO'] = hg_info
221
222 # 2) Ensure that the style hook is in place.
223 try:
224 ui = None
225 if ARGUMENTS.get('IGNORE_STYLE') != 'True':
226 from mercurial import ui
227 ui = ui.ui()
228 except ImportError:
229 print mercurial_lib_not_found
230
231 if ui is not None:
232 ui.readconfig(hgdir.File('hgrc').abspath)
233 style_hook = ui.config('hooks', 'pretxncommit.style', None)
234
235 if not style_hook:
236 print mercurial_style_message
237 sys.exit(1)
238else:
239 print ".hg directory not found"
240
241###################################################
242#
243# Figure out which configurations to set up based on the path(s) of
244# the target(s).
245#
246###################################################
247
248# Find default configuration & binary.

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

296 variant_path = joinpath('/',*path_dirs[:build_top+2])
297 if variant_path not in variant_paths:
298 variant_paths.append(variant_path)
299
300# Make sure build_root exists (might not if this is the first build there)
301if not isdir(build_root):
302 mkdir(build_root)
303
304Export('env')
305
306env.SConsignFile(joinpath(build_root, "sconsign"))
307
308# Default duplicate option is to use hard links, but this messes up
309# when you use emacs to edit a file in the target dir, as emacs moves
310# file to file~ then copies to file, breaking the link. Symbolic
311# (soft) links work better.

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

356# Update env with values from ARGUMENTS & file global_sticky_vars_file
357global_sticky_vars.Update(env)
358
359# Save sticky variable settings back to current variables file
360global_sticky_vars.Save(global_sticky_vars_file, env)
361
362# Parse EXTRAS variable to build list of all directories where we're
363# look for sources etc. This list is exported as base_dir_list.
364base_dir = env.srcdir.abspath
365if env['EXTRAS']:
366 extras_dir_list = env['EXTRAS'].split(':')
367else:
368 extras_dir_list = []
369
370Export('base_dir')
371Export('extras_dir_list')
372
373# M5_PLY is used by isa_parser.py to find the PLY package.
374env.Append(ENV = { 'M5_PLY' : str(Dir('ext/ply')) })
375
376CXX_version = read_command([env['CXX'],'--version'], exception=False)
377CXX_V = read_command([env['CXX'],'-V'], exception=False)
378
379env['GCC'] = CXX_version and CXX_version.find('g++') >= 0
380env['SUNCC'] = CXX_V and CXX_V.find('Sun C++') >= 0
381env['ICC'] = CXX_V and CXX_V.find('Intel') >= 0
382if env['GCC'] + env['SUNCC'] + env['ICC'] > 1:
383 print 'Error: How can we have two at the same time?'
384 Exit(1)
385
386# Set up default C++ compiler flags
387if env['GCC']:
388 env.Append(CCFLAGS='-pipe')
389 env.Append(CCFLAGS='-fno-strict-aliasing')
390 env.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef'))
391 env.Append(CXXFLAGS='-Wno-deprecated')
392elif env['ICC']:
393 pass #Fix me... add warning flags once we clean up icc warnings
394elif env['SUNCC']:
395 env.Append(CCFLAGS='-Qoption ccfe')
396 env.Append(CCFLAGS='-features=gcc')
397 env.Append(CCFLAGS='-features=extensions')
398 env.Append(CCFLAGS='-library=stlport4')
399 env.Append(CCFLAGS='-xar')
400 #env.Append(CCFLAGS='-instances=semiexplicit')
401else:
402 print 'Error: Don\'t know what compiler options to use for your compiler.'
403 print ' Please fix SConstruct and src/SConscript and try again.'
404 Exit(1)
405
406# Do this after we save setting back, or else we'll tack on an
407# extra 'qdo' every time we run scons.
408if env['BATCH']:

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

419
420# Check for SWIG
421if not env.has_key('SWIG'):
422 print 'Error: SWIG utility not found.'
423 print ' Please install (see http://www.swig.org) and retry.'
424 Exit(1)
425
426# Check for appropriate SWIG version
427swig_version = read_command(('swig', '-version'), exception='').split()
428# First 3 words should be "SWIG Version x.y.z"
429if len(swig_version) < 3 or \
430 swig_version[0] != 'SWIG' or swig_version[1] != 'Version':
431 print 'Error determining SWIG version.'
432 Exit(1)
433
434min_swig_version = '1.3.28'
435if compare_versions(swig_version[2], min_swig_version) < 0:

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

628#
629env = conf.Finish()
630
631######################################################################
632#
633# Collect all non-global variables
634#
635
636Export('env')
637
638# Define the universe of supported ISAs
639all_isa_list = [ ]
640Export('all_isa_list')
641
642# Define the universe of supported CPU models
643all_cpu_list = [ ]
644default_cpus = [ ]
645Export('all_cpu_list', 'default_cpus')

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

741 return ([target], [Value(variable), Value(val)])
742
743config_builder = Builder(emitter = config_emitter, action = config_action)
744
745env.Append(BUILDERS = { 'ConfigFile' : config_builder })
746
747# libelf build is shared across all configs in the build root.
748env.SConscript('ext/libelf/SConscript',
749 variant_dir = joinpath(build_root, 'libelf'))
750
751# gzstream build is shared across all configs in the build root.
752env.SConscript('ext/gzstream/SConscript',
753 variant_dir = joinpath(build_root, 'gzstream'))
754
755###################################################
756#
757# This function is used to set up a directory with switching headers
758#
759###################################################
760
761env['ALL_ISA_LIST'] = all_isa_list

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

890
891 # Set up the regression tests for each build.
892 for e in envList:
893 SConscript('tests/SConscript',
894 variant_dir = joinpath(variant_path, 'tests', e.Label),
895 exports = { 'env' : e }, duplicate = False)
896
897Help(help_text)