SConstruct (12245:ad6fa75d2aba) | SConstruct (12246:9ffa51416f39) |
---|---|
1# -*- mode:python -*- 2 3# Copyright (c) 2013, 2015-2017 ARM Limited 4# All rights reserved. 5# 6# The license below extends only to copyright in the software and shall 7# not be construed as granting a license to any other intellectual 8# property including but not limited to intellectual property relating --- 82 unchanged lines hidden (view full) --- 91from os.path import exists, isdir, isfile 92from os.path import join as joinpath, split as splitpath 93 94# SCons includes 95import SCons 96import SCons.Node 97 98from m5.util import compareVersions, readCommand | 1# -*- mode:python -*- 2 3# Copyright (c) 2013, 2015-2017 ARM Limited 4# All rights reserved. 5# 6# The license below extends only to copyright in the software and shall 7# not be construed as granting a license to any other intellectual 8# property including but not limited to intellectual property relating --- 82 unchanged lines hidden (view full) --- 91from os.path import exists, isdir, isfile 92from os.path import join as joinpath, split as splitpath 93 94# SCons includes 95import SCons 96import SCons.Node 97 98from m5.util import compareVersions, readCommand |
99from m5.util.terminal import get_termcap | |
100 101help_texts = { 102 "options" : "", 103 "global_vars" : "", 104 "local_vars" : "" 105} 106 107Export("help_texts") --- 55 unchanged lines hidden (view full) --- 163 help='Build with Undefined Behavior Sanitizer if available') 164AddLocalOption('--with-asan', dest='with_asan', action='store_true', 165 help='Build with Address Sanitizer if available') 166 167if GetOption('no_lto') and GetOption('force_lto'): 168 print '--no-lto and --force-lto are mutually exclusive' 169 Exit(1) 170 | 99 100help_texts = { 101 "options" : "", 102 "global_vars" : "", 103 "local_vars" : "" 104} 105 106Export("help_texts") --- 55 unchanged lines hidden (view full) --- 162 help='Build with Undefined Behavior Sanitizer if available') 163AddLocalOption('--with-asan', dest='with_asan', action='store_true', 164 help='Build with Address Sanitizer if available') 165 166if GetOption('no_lto') and GetOption('force_lto'): 167 print '--no-lto and --force-lto are mutually exclusive' 168 Exit(1) 169 |
171termcap = get_termcap(GetOption('use_colors')) 172 | |
173######################################################################## 174# 175# Set up the main build environment. 176# 177######################################################################## 178 179main = Environment() 180 | 170######################################################################## 171# 172# Set up the main build environment. 173# 174######################################################################## 175 176main = Environment() 177 |
178from gem5_scons import Transform 179from gem5_scons.util import get_termcap 180termcap = get_termcap() 181 |
|
181main_dict_keys = main.Dictionary().keys() 182 183# Check that we have a C/C++ compiler 184if not ('CC' in main_dict_keys and 'CXX' in main_dict_keys): 185 print "No C++ compiler installed (package g++ on Ubuntu and RedHat)" 186 Exit(1) 187 188################################################### --- 107 unchanged lines hidden (view full) --- 296Export('extras_dir_list') 297 298# the ext directory should be on the #includes path 299main.Append(CPPPATH=[Dir('ext')]) 300 301# Add shared top-level headers 302main.Prepend(CPPPATH=Dir('include')) 303 | 182main_dict_keys = main.Dictionary().keys() 183 184# Check that we have a C/C++ compiler 185if not ('CC' in main_dict_keys and 'CXX' in main_dict_keys): 186 print "No C++ compiler installed (package g++ on Ubuntu and RedHat)" 187 Exit(1) 188 189################################################### --- 107 unchanged lines hidden (view full) --- 297Export('extras_dir_list') 298 299# the ext directory should be on the #includes path 300main.Append(CPPPATH=[Dir('ext')]) 301 302# Add shared top-level headers 303main.Prepend(CPPPATH=Dir('include')) 304 |
304def strip_build_path(path, env): 305 path = str(path) 306 variant_base = env['BUILDROOT'] + os.path.sep 307 if path.startswith(variant_base): 308 path = path[len(variant_base):] 309 elif path.startswith('build/'): 310 path = path[6:] 311 return path 312 313# Generate a string of the form: 314# common/path/prefix/src1, src2 -> tgt1, tgt2 315# to print while building. 316class Transform(object): 317 # all specific color settings should be here and nowhere else 318 tool_color = termcap.Normal 319 pfx_color = termcap.Yellow 320 srcs_color = termcap.Yellow + termcap.Bold 321 arrow_color = termcap.Blue + termcap.Bold 322 tgts_color = termcap.Yellow + termcap.Bold 323 324 def __init__(self, tool, max_sources=99): 325 self.format = self.tool_color + (" [%8s] " % tool) \ 326 + self.pfx_color + "%s" \ 327 + self.srcs_color + "%s" \ 328 + self.arrow_color + " -> " \ 329 + self.tgts_color + "%s" \ 330 + termcap.Normal 331 self.max_sources = max_sources 332 333 def __call__(self, target, source, env, for_signature=None): 334 # truncate source list according to max_sources param 335 source = source[0:self.max_sources] 336 def strip(f): 337 return strip_build_path(str(f), env) 338 if len(source) > 0: 339 srcs = map(strip, source) 340 else: 341 srcs = [''] 342 tgts = map(strip, target) 343 # surprisingly, os.path.commonprefix is a dumb char-by-char string 344 # operation that has nothing to do with paths. 345 com_pfx = os.path.commonprefix(srcs + tgts) 346 com_pfx_len = len(com_pfx) 347 if com_pfx: 348 # do some cleanup and sanity checking on common prefix 349 if com_pfx[-1] == ".": 350 # prefix matches all but file extension: ok 351 # back up one to change 'foo.cc -> o' to 'foo.cc -> .o' 352 com_pfx = com_pfx[0:-1] 353 elif com_pfx[-1] == "/": 354 # common prefix is directory path: OK 355 pass 356 else: 357 src0_len = len(srcs[0]) 358 tgt0_len = len(tgts[0]) 359 if src0_len == com_pfx_len: 360 # source is a substring of target, OK 361 pass 362 elif tgt0_len == com_pfx_len: 363 # target is a substring of source, need to back up to 364 # avoid empty string on RHS of arrow 365 sep_idx = com_pfx.rfind(".") 366 if sep_idx != -1: 367 com_pfx = com_pfx[0:sep_idx] 368 else: 369 com_pfx = '' 370 elif src0_len > com_pfx_len and srcs[0][com_pfx_len] == ".": 371 # still splitting at file extension: ok 372 pass 373 else: 374 # probably a fluke; ignore it 375 com_pfx = '' 376 # recalculate length in case com_pfx was modified 377 com_pfx_len = len(com_pfx) 378 def fmt(files): 379 f = map(lambda s: s[com_pfx_len:], files) 380 return ', '.join(f) 381 return self.format % (com_pfx, fmt(srcs), fmt(tgts)) 382 383Export('Transform') 384 385# enable the regression script to use the termcap 386main['TERMCAP'] = termcap 387 | |
388if GetOption('verbose'): 389 def MakeAction(action, string, *args, **kwargs): 390 return Action(action, *args, **kwargs) 391else: 392 MakeAction = Action 393 main['CCCOMSTR'] = Transform("CC") 394 main['CXXCOMSTR'] = Transform("CXX") 395 main['ASCOMSTR'] = Transform("AS") --- 908 unchanged lines hidden --- | 305if GetOption('verbose'): 306 def MakeAction(action, string, *args, **kwargs): 307 return Action(action, *args, **kwargs) 308else: 309 MakeAction = Action 310 main['CCCOMSTR'] = Transform("CC") 311 main['CXXCOMSTR'] = Transform("CXX") 312 main['ASCOMSTR'] = Transform("AS") --- 908 unchanged lines hidden --- |