SConscript (7675:2221ec64132f) | SConscript (7677:c6e283904437) |
---|---|
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 --- 456 unchanged lines hidden (view full) --- 465 466def createSwigParam(target, source, env): 467 assert len(target) == 1 and len(source) == 1 468 469 name = str(source[0].get_contents()) 470 param = all_params[name] 471 472 code = code_formatter() | 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 --- 456 unchanged lines hidden (view full) --- 465 466def createSwigParam(target, source, env): 467 assert len(target) == 1 and len(source) == 1 468 469 name = str(source[0].get_contents()) 470 param = all_params[name] 471 472 code = code_formatter() |
473 code('%module(package="m5.internal.swig") ${name}_$0', param.file_ext) | 473 code('%module(package="m5.internal") $0_${name}', param.file_ext) |
474 param.swig_decl(code) 475 code.write(target[0].abspath) 476 477def createEnumStrings(target, source, env): 478 assert len(target) == 1 and len(source) == 1 479 480 name = str(source[0].get_contents()) 481 obj = all_enums[name] --- 15 unchanged lines hidden (view full) --- 497def createEnumSwig(target, source, env): 498 assert len(target) == 1 and len(source) == 1 499 500 name = str(source[0].get_contents()) 501 obj = all_enums[name] 502 503 code = code_formatter() 504 code('''\ | 474 param.swig_decl(code) 475 code.write(target[0].abspath) 476 477def createEnumStrings(target, source, env): 478 assert len(target) == 1 and len(source) == 1 479 480 name = str(source[0].get_contents()) 481 obj = all_enums[name] --- 15 unchanged lines hidden (view full) --- 497def createEnumSwig(target, source, env): 498 assert len(target) == 1 and len(source) == 1 499 500 name = str(source[0].get_contents()) 501 obj = all_enums[name] 502 503 code = code_formatter() 504 code('''\ |
505%module(package="m5.internal.enums") $name | 505%module(package="m5.internal") enum_$name |
506 507%{ 508#include "enums/$name.hh" 509%} 510 511%include "enums/$name.hh" 512''') 513 code.write(target[0].abspath) --- 7 unchanged lines hidden (view full) --- 521 hh_file = File('params/%s.hh' % name) 522 params_hh_files.append(hh_file) 523 env.Command(hh_file, Value(name), createSimObjectParam) 524 env.Depends(hh_file, depends + extra_deps) 525 526# Generate any parameter header files needed 527params_i_files = [] 528for name,param in all_params.iteritems(): | 506 507%{ 508#include "enums/$name.hh" 509%} 510 511%include "enums/$name.hh" 512''') 513 code.write(target[0].abspath) --- 7 unchanged lines hidden (view full) --- 521 hh_file = File('params/%s.hh' % name) 522 params_hh_files.append(hh_file) 523 env.Command(hh_file, Value(name), createSimObjectParam) 524 env.Depends(hh_file, depends + extra_deps) 525 526# Generate any parameter header files needed 527params_i_files = [] 528for name,param in all_params.iteritems(): |
529 i_file = File('params/%s_%s.i' % (name, param.file_ext)) | 529 i_file = File('python/m5/internal/%s_%s.i' % (param.file_ext, name)) |
530 params_i_files.append(i_file) 531 env.Command(i_file, Value(name), createSwigParam) 532 env.Depends(i_file, depends) | 530 params_i_files.append(i_file) 531 env.Command(i_file, Value(name), createSwigParam) 532 env.Depends(i_file, depends) |
533 SwigSource('m5.internal.swig', i_file) | 533 SwigSource('m5.internal', i_file) |
534 535# Generate all enum header files 536for name,enum in sorted(all_enums.iteritems()): 537 py_source = PySource.modules[enum.__module__] 538 extra_deps = [ py_source.tnode ] 539 540 cc_file = File('enums/%s.cc' % name) 541 env.Command(cc_file, Value(name), createEnumStrings) 542 env.Depends(cc_file, depends + extra_deps) 543 Source(cc_file) 544 545 hh_file = File('enums/%s.hh' % name) 546 env.Command(hh_file, Value(name), createEnumParam) 547 env.Depends(hh_file, depends + extra_deps) 548 | 534 535# Generate all enum header files 536for name,enum in sorted(all_enums.iteritems()): 537 py_source = PySource.modules[enum.__module__] 538 extra_deps = [ py_source.tnode ] 539 540 cc_file = File('enums/%s.cc' % name) 541 env.Command(cc_file, Value(name), createEnumStrings) 542 env.Depends(cc_file, depends + extra_deps) 543 Source(cc_file) 544 545 hh_file = File('enums/%s.hh' % name) 546 env.Command(hh_file, Value(name), createEnumParam) 547 env.Depends(hh_file, depends + extra_deps) 548 |
549 i_file = File('enums/%s.i' % name) | 549 i_file = File('python/m5/internal/enum_%s.i' % name) |
550 env.Command(i_file, Value(name), createEnumSwig) 551 env.Depends(i_file, depends + extra_deps) | 550 env.Command(i_file, Value(name), createEnumSwig) 551 env.Depends(i_file, depends + extra_deps) |
552 SwigSource('m5.internal.enums', i_file) | 552 SwigSource('m5.internal', i_file) |
553 554def buildParam(target, source, env): 555 name = source[0].get_contents() 556 obj = sim_objects[name] 557 class_path = obj.cxx_class.split('::') 558 classname = class_path[-1] 559 namespaces = class_path[:-1] 560 params = obj._params.local.values() 561 562 code = code_formatter() 563 | 553 554def buildParam(target, source, env): 555 name = source[0].get_contents() 556 obj = sim_objects[name] 557 class_path = obj.cxx_class.split('::') 558 classname = class_path[-1] 559 namespaces = class_path[:-1] 560 params = obj._params.local.values() 561 562 code = code_formatter() 563 |
564 code('%module(package="m5.internal.params") $name') | 564 code('%module(package="m5.internal") param_$name') |
565 code() 566 code('%{') 567 code('#include "params/$obj.hh"') 568 for param in params: 569 param.cxx_predecls(code) 570 code('%}') 571 code() 572 573 for param in params: 574 param.swig_predecls(code) 575 576 code() 577 if obj._base: | 565 code() 566 code('%{') 567 code('#include "params/$obj.hh"') 568 for param in params: 569 param.cxx_predecls(code) 570 code('%}') 571 code() 572 573 for param in params: 574 param.swig_predecls(code) 575 576 code() 577 if obj._base: |
578 code('%import "params/${{obj._base}}.i"') | 578 code('%import "python/m5/internal/param_${{obj._base}}.i"') |
579 code() 580 obj.swig_objdecls(code) 581 code() 582 583 code('%include "params/$obj.hh"') 584 585 code.write(target[0].abspath) 586 587for name in sim_objects.iterkeys(): | 579 code() 580 obj.swig_objdecls(code) 581 code() 582 583 code('%include "params/$obj.hh"') 584 585 code.write(target[0].abspath) 586 587for name in sim_objects.iterkeys(): |
588 params_file = File('params/%s.i' % name) | 588 params_file = File('python/m5/internal/param_%s.i' % name) |
589 env.Command(params_file, Value(name), buildParam) 590 env.Depends(params_file, depends) | 589 env.Command(params_file, Value(name), buildParam) 590 env.Depends(params_file, depends) |
591 SwigSource('m5.internal.params', params_file) | 591 SwigSource('m5.internal', params_file) |
592 593# Generate the main swig init file 594def makeEmbeddedSwigInit(target, source, env): 595 code = code_formatter() 596 module = source[0].get_contents() 597 code('''\ 598#include "sim/init.hh" 599 --- 441 unchanged lines hidden --- | 592 593# Generate the main swig init file 594def makeEmbeddedSwigInit(target, source, env): 595 code = code_formatter() 596 module = source[0].get_contents() 597 code('''\ 598#include "sim/init.hh" 599 --- 441 unchanged lines hidden --- |