|
|
| 46 |
from bake.Exceptions import TaskError |
46 |
from bake.Exceptions import TaskError |
| 47 |
from bake.ModuleSource import SystemDependency |
47 |
from bake.ModuleSource import SystemDependency |
| 48 |
from bake.ModuleBuild import NoneModuleBuild |
48 |
from bake.ModuleBuild import NoneModuleBuild |
|
|
49 |
from bake.Module import ModuleDependency |
| 49 |
|
50 |
|
| 50 |
def signal_handler(signal, frame): |
51 |
def signal_handler(signal, frame): |
| 51 |
""" Handles Ctrl+C keyboard interruptions """ |
52 |
""" Handles Ctrl+C keyboard interruptions """ |
|
|
| 89 |
|
90 |
|
| 90 |
parser = OptionParser(usage='usage: %prog fix-config [options]') |
91 |
parser = OptionParser(usage='usage: %prog fix-config [options]') |
| 91 |
self._enable_disable_options(parser) |
92 |
self._enable_disable_options(parser) |
| 92 |
parser.add_option("-c", "--conffile", action="store", type="string", |
93 |
parser.add_option("-f", "--conffile", action="store", type="string", |
| 93 |
dest="bakeconf", default="bakeconf.xml", |
94 |
dest="bakeconf", default="bakeconf.xml", |
| 94 |
help="The Bake meta-data configuration from where to" |
95 |
help="The Bake meta-data configuration from where to" |
| 95 |
" get the updated modules file to use. Default: %default.") |
96 |
" get the updated modules file to use. Default: %default.") |
|
|
| 117 |
|
118 |
|
| 118 |
config = self.check_configuration_file(config, True) |
119 |
config = self.check_configuration_file(config, True) |
| 119 |
|
120 |
|
|
|
121 |
contribconf = [] |
| 122 |
try: |
| 123 |
for cfile in os.listdir("contrib"): |
| 124 |
if cfile.endswith(".xml"): |
| 125 |
contribconf.append("contrib/"+cfile) |
| 126 |
except Exception as e: |
| 127 |
True |
| 128 |
|
| 120 |
# Stores the present configuration |
129 |
# Stores the present configuration |
| 121 |
old_config = Configuration(config) |
130 |
old_config = Configuration(config) |
| 122 |
old_config.read() |
131 |
old_config.read() |
|
|
| 133 |
new_config.read_metadata(options.bakeconf) |
142 |
new_config.read_metadata(options.bakeconf) |
| 134 |
except Exception as e: |
143 |
except Exception as e: |
| 135 |
self._error('Problem reading Configuration file "%s" \n Error: %s' % (options.bakeconf, str(e))) |
144 |
self._error('Problem reading Configuration file "%s" \n Error: %s' % (options.bakeconf, str(e))) |
|
|
145 |
|
| 146 |
for cconf in contribconf: |
| 147 |
try: |
| 148 |
new_config.read_metadata(cconf) |
| 149 |
except Exception as e: |
| 150 |
self._error('Problem reading Configuration file "%s" \n Error: %s' % (cconf, str(e))) |
| 136 |
|
151 |
|
| 137 |
# Checks if the directories where set and if so set the new config file |
152 |
# Checks if the directories where set and if so set the new config file |
| 138 |
# with the new parameters, or let the old ones |
153 |
# with the new parameters, or let the old ones |
|
|
| 209 |
|
224 |
|
| 210 |
def _enable(self, enable, configuration): |
225 |
def _enable(self, enable, configuration): |
| 211 |
""" Handles the --enable option, setting defined modules as enable.""" |
226 |
""" Handles the --enable option, setting defined modules as enable.""" |
| 212 |
|
|
|
| 213 |
for module_name in enable: |
227 |
for module_name in enable: |
| 214 |
module = configuration.lookup(module_name) |
228 |
module = configuration.lookup(module_name) |
| 215 |
if not module: |
229 |
if not module: |
| 216 |
self._error('Module "%s" not found' % module_name) |
230 |
self._error('Module "%s" not found' % module_name) |
|
|
231 |
if module.mtype() == "ns-contrib": |
| 232 |
found=0 |
| 233 |
fmod = None |
| 234 |
for mod in enable: |
| 235 |
if configuration.lookup(mod).mtype() == "ns" and ((mod>=module.minver() and (mod<=module.maxver() or module.maxver() == None)) or (mod == "ns-3-dev" and module.maxver() == None)): |
| 236 |
found+= 1 |
| 237 |
fmod = mod |
| 238 |
if not found==1: |
| 239 |
self._error('Module "%s" has unmet dependency: %s' % (module_name, module.minver())) |
| 240 |
module.get_source().attribute("module_directory").value = fmod+'/contrib/'+module.get_source().attribute("module_directory").value |
| 241 |
module.addDependencies(ModuleDependency(fmod, False)) |
| 217 |
configuration.enable(module) |
242 |
configuration.enable(module) |
| 218 |
|
243 |
|
| 219 |
def _disable(self, disable, configuration): |
244 |
def _disable(self, disable, configuration): |
|
|
| 224 |
if not module: |
249 |
if not module: |
| 225 |
self._error('Module "%s" not found' % module_name) |
250 |
self._error('Module "%s" not found' % module_name) |
| 226 |
configuration.disable(module) |
251 |
configuration.disable(module) |
|
|
252 |
if module.mtype() == "ns": |
| 253 |
enabled_list = configuration.enabled() |
| 254 |
for mod in enabled_list: |
| 255 |
if mod.mtype() == "ns-contrib": |
| 256 |
configuration.disable(mod) |
| 227 |
|
257 |
|
| 228 |
def _variables_process(self, items, configuration, is_append): |
258 |
def _variables_process(self, items, configuration, is_append): |
| 229 |
""" Handles the defined configured variables .""" |
259 |
""" Handles the defined configured variables .""" |
|
|
| 257 |
|
287 |
|
| 258 |
# enables/disables the explicit enable/disable modules passed as argument |
288 |
# enables/disables the explicit enable/disable modules passed as argument |
| 259 |
self._enable(options.enable, configuration) |
289 |
self._enable(options.enable, configuration) |
|
|
290 |
for mod in options.disable: |
| 291 |
if not mod in options.enable: |
| 292 |
self._error('Module "%s" not enabled' % mod) |
| 260 |
self._disable(options.disable, configuration) |
293 |
self._disable(options.disable, configuration) |
| 261 |
|
294 |
|
| 262 |
# if the option -a is used, meaning all the modules should be enabled |
295 |
# if the option -a is used, meaning all the modules should be enabled |
| 263 |
if options.enable_all: |
296 |
if options.enable_all: |
| 264 |
for module in configuration.modules(): |
297 |
for module in configuration.modules(): |
| 265 |
configuration.enable(module) |
298 |
configuration.enable(module) |
|
|
299 |
|
| 266 |
|
300 |
|
| 267 |
# if the option -m is used, meaning the minimum configuration should be used |
301 |
# if the option -m is used, meaning the minimum configuration should be used |
| 268 |
# it disables all the non mandatory dependencies |
302 |
# it disables all the non mandatory dependencies |
|
|
| 382 |
configuration.append(lastConfig) |
416 |
configuration.append(lastConfig) |
| 383 |
self.save_resource_file(configuration, fileName) |
417 |
self.save_resource_file(configuration, fileName) |
| 384 |
|
418 |
|
|
|
419 |
def _list(self, config, args): |
| 420 |
""" Handles the list option for %prog """ |
| 421 |
|
| 422 |
# sets the options the parser should recognize for the configuration |
| 423 |
parser = OptionParser(usage='usage: %prog list [options]') |
| 424 |
parser.add_option("-f", "--conffile", action="store", type="string", |
| 425 |
dest="bakeconf", default="bakeconf.xml", |
| 426 |
help="The Bake meta-data configuration file to use. " |
| 427 |
"Default: %default.") |
| 428 |
parser.add_option("-c", "--contrib", action="store_true", |
| 429 |
dest="contrib", default="False", |
| 430 |
help="Show only contrib modules.") |
| 431 |
(options, args_left) = parser.parse_args(args) |
| 432 |
listconf = Configuration(config) |
| 433 |
contrib_list = [] |
| 434 |
module_list = [] |
| 435 |
|
| 436 |
contribconf = [] |
| 437 |
try: |
| 438 |
for cfile in os.listdir("contrib"): |
| 439 |
if cfile.endswith(".xml"): |
| 440 |
contribconf.append("contrib/"+cfile) |
| 441 |
except Exception as e: |
| 442 |
True |
| 443 |
|
| 444 |
try: |
| 445 |
listconf.read_metadata(options.bakeconf) |
| 446 |
except Exception as e: |
| 447 |
self._error('Problem reading Configuration file "%s" \n Error: %s' % (options.bakeconf, str(e))) |
| 448 |
|
| 449 |
for cconf in contribconf: |
| 450 |
try: |
| 451 |
listconf.read_metadata(cconf) |
| 452 |
except Exception as e: |
| 453 |
self._error('Problem reading Configuration file "%s" \n Error: %s' % (cconf, str(e))) |
| 454 |
|
| 455 |
for mod in listconf.modules(): |
| 456 |
if mod.mtype() == "ns-contrib": |
| 457 |
contrib_list.append(mod.name()) |
| 458 |
elif not options.contrib == True: |
| 459 |
module_list.append(mod.name()) |
| 460 |
|
| 461 |
contrib_list.sort() |
| 462 |
module_list.sort() |
| 463 |
for m in module_list: |
| 464 |
print("module: "+m) |
| 465 |
for c in contrib_list: |
| 466 |
print("contrib: "+c) |
| 385 |
|
467 |
|
| 386 |
def _configure(self, config, args): |
468 |
def _configure(self, config, args): |
| 387 |
""" Handles the configuration option for %prog """ |
469 |
""" Handles the configuration option for %prog """ |
|
|
| 389 |
# sets the options the parser should recognize for the configuration |
471 |
# sets the options the parser should recognize for the configuration |
| 390 |
parser = OptionParser(usage='usage: %prog configure [options]') |
472 |
parser = OptionParser(usage='usage: %prog configure [options]') |
| 391 |
self._enable_disable_options(parser) |
473 |
self._enable_disable_options(parser) |
| 392 |
parser.add_option("-c", "--conffile", action="store", type="string", |
474 |
parser.add_option("-f", "--conffile", action="store", type="string", |
| 393 |
dest="bakeconf", default="bakeconf.xml", |
475 |
dest="bakeconf", default="bakeconf.xml", |
| 394 |
help="The Bake meta-data configuration file to use. " |
476 |
help="The Bake meta-data configuration file to use. " |
| 395 |
"Default: %default.") |
477 |
"Default: %default.") |
|
|
| 432 |
default=0, help='Increase the log verbosity level') |
514 |
default=0, help='Increase the log verbosity level') |
| 433 |
parser.add_option('-q', '--quiet', action='count', dest='quiet', |
515 |
parser.add_option('-q', '--quiet', action='count', dest='quiet', |
| 434 |
default=0, help='Increase the log quietness level') |
516 |
default=0, help='Increase the log quietness level') |
|
|
517 |
parser.add_option("-c", "--clean", action="store_true", |
| 518 |
dest="remove", default=False, |
| 519 |
help="Remove all enabled modules") |
| 435 |
|
520 |
|
| 436 |
# sets the configuration values got from the line command |
521 |
# sets the configuration values got from the line command |
| 437 |
(options, args_left) = parser.parse_args(args) |
522 |
(options, args_left) = parser.parse_args(args) |
| 438 |
|
|
|
| 439 |
if options.bakeconf == "bakeconf.xml": |
523 |
if options.bakeconf == "bakeconf.xml": |
| 440 |
options.bakeconf = self.check_configuration_file(options.bakeconf, False); |
524 |
options.bakeconf = self.check_configuration_file(options.bakeconf, False); |
| 441 |
|
525 |
|
|
|
526 |
contribconf = [] |
| 527 |
try: |
| 528 |
for cfile in os.listdir("contrib"): |
| 529 |
if cfile.endswith(".xml"): |
| 530 |
contribconf.append("contrib/"+cfile) |
| 531 |
except Exception as e: |
| 532 |
True |
| 533 |
|
| 442 |
configuration = Configuration(config) |
534 |
configuration = Configuration(config) |
|
|
535 |
|
| 536 |
if not options.remove: |
| 537 |
try: |
| 538 |
configuration.read() |
| 539 |
for m in configuration.enabled(): |
| 540 |
if m.name() not in options.enable: |
| 541 |
options.enable.append(m.name()) |
| 542 |
except Exception as e: |
| 543 |
True |
| 544 |
|
| 443 |
try: |
545 |
try: |
| 444 |
configuration.read_metadata(options.bakeconf) |
546 |
configuration.read_metadata(options.bakeconf) |
| 445 |
except Exception as e: |
547 |
except Exception as e: |
| 446 |
self._error('Problem reading Configuration file "%s" \n Error: %s' % (options.bakeconf, str(e))) |
548 |
self._error('Problem reading Configuration file "%s" \n Error: %s' % (options.bakeconf, str(e))) |
|
|
549 |
|
| 550 |
for cconf in contribconf: |
| 551 |
try: |
| 552 |
configuration.read_metadata(cconf) |
| 553 |
except Exception as e: |
| 554 |
self._error('Problem reading Configuration file "%s" \n Error: %s' % (cconf, str(e))) |
| 447 |
|
555 |
|
| 448 |
configuration.set_sourcedir(options.sourcedir) |
556 |
configuration.set_sourcedir(options.sourcedir) |
| 449 |
configuration.set_objdir(options.objdir) |
557 |
configuration.set_objdir(options.objdir) |
|
|
| 490 |
self._error('--predefined: "%s" not found.' % p) |
598 |
self._error('--predefined: "%s" not found.' % p) |
| 491 |
|
599 |
|
| 492 |
# Registers the modules are that enabled/disabled |
600 |
# Registers the modules are that enabled/disabled |
| 493 |
# handles the -a, -m, --disable, --enable tags |
601 |
# handles the -a, -m, --disable, --enable tags |
| 494 |
self._parse_enable_disable(options, configuration) |
602 |
self._parse_enable_disable(options, configuration) |
| 495 |
|
603 |
|
| 496 |
# handles the set command line option, to overwrite the specific |
604 |
# handles the set command line option, to overwrite the specific |
| 497 |
# module setting with the new specified value |
605 |
# module setting with the new specified value |
| 498 |
for variable in options.set: |
606 |
for variable in options.set: |
|
|
| 509 |
module.get_build().attribute(name).value = current_value + ' ' + value |
617 |
module.get_build().attribute(name).value = current_value + ' ' + value |
| 510 |
configuration.write() |
618 |
configuration.write() |
| 511 |
|
619 |
|
| 512 |
if not configuration._enabled and not options.append : |
620 |
if not configuration._enabled and not options.append and not options.remove: |
| 513 |
env = self._get_dummy_env(options) |
621 |
env = self._get_dummy_env(options) |
| 514 |
env._logger.commands.write(' > No module enabled: Bake configuration requires at least one module to be enabled' |
622 |
env._logger.commands.write(' > No module enabled: Bake configuration requires at least one module to be enabled' |
| 515 |
' (enable, predefined), or appended.\n' |
623 |
' (enable, predefined), or appended.\n' |
|
|
| 1116 |
if not state: |
1224 |
if not state: |
| 1117 |
return |
1225 |
return |
| 1118 |
for mod in state: |
1226 |
for mod in state: |
| 1119 |
print('module: %s (%s)' % (mod.name(), label)) |
1227 |
if mod.mtype(): |
|
|
1228 |
print('module %s: %s (%s)' % (mod.mtype(), mod.name(), label)) |
| 1229 |
else: |
| 1230 |
print('module: %s (%s)' % (mod.name(), label)) |
| 1120 |
dependencies = mod.dependencies() |
1231 |
dependencies = mod.dependencies() |
| 1121 |
|
1232 |
|
| 1122 |
# Stores the system dependencies |
1233 |
# Stores the system dependencies |
|
|
| 1127 |
if not mod.name() in depen: |
1238 |
if not mod.name() in depen: |
| 1128 |
depen[mod.name()] = dict() |
1239 |
depen[mod.name()] = dict() |
| 1129 |
|
1240 |
|
| 1130 |
if dependencies: |
1241 |
if dependencies and not options.brief == True: |
| 1131 |
print(' depends on:') |
1242 |
print(' depends on:') |
| 1132 |
for dependsOn in mod.dependencies(): |
1243 |
for dependsOn in mod.dependencies(): |
| 1133 |
print(' %s (optional:%s)' % |
1244 |
print(' %s (optional:%s)' % |
| 1134 |
(dependsOn.name(), dependsOn.is_optional())) |
1245 |
(dependsOn.name(), dependsOn.is_optional())) |
| 1135 |
depen[mod.name()][dependsOn.name()]= dependsOn.is_optional() |
1246 |
depen[mod.name()][dependsOn.name()]= dependsOn.is_optional() |
| 1136 |
else: |
1247 |
elif not options.brief == True: |
| 1137 |
print(' No dependencies!') |
1248 |
print(' No dependencies!') |
| 1138 |
|
1249 |
|
| 1139 |
|
1250 |
|
|
|
| 1306 |
parser.add_option('--showSystemDep', action='store_true', dest='showSystemDep', |
1417 |
parser.add_option('--showSystemDep', action='store_true', dest='showSystemDep', |
| 1307 |
default=True, |
1418 |
default=True, |
| 1308 |
help='Shows the system dependency of the enabled/disabled modules') |
1419 |
help='Shows the system dependency of the enabled/disabled modules') |
|
|
1420 |
parser.add_option('-b', '--brief', action='store_true', dest='brief', |
| 1421 |
default=False, |
| 1422 |
help='Show only the module name') |
| 1423 |
parser.add_option('-c', '--configured', action='store_true', dest='configured', |
| 1424 |
default=False, |
| 1425 |
help='Show only the configured module') |
| 1309 |
(options, args_left) = parser.parse_args(args) |
1426 |
(options, args_left) = parser.parse_args(args) |
| 1310 |
# adds a default value so that show will show something even if there is |
1427 |
# adds a default value so that show will show something even if there is |
| 1311 |
# no option |
1428 |
# no option |
|
|
| 1313 |
options.enabled = True |
1430 |
options.enabled = True |
| 1314 |
options.showSystemDep = True |
1431 |
options.showSystemDep = True |
| 1315 |
else: |
1432 |
else: |
| 1316 |
if not options.disabled and not options.enabled: |
1433 |
if not options.disabled and not options.enabled and not options.configured: |
| 1317 |
options.enabled=True |
1434 |
options.enabled=True |
| 1318 |
|
1435 |
|
| 1319 |
config= self.check_configuration_file(config, True); |
1436 |
config= self.check_configuration_file(config, True); |
|
|
| 1327 |
" Call bake with -f [full path configuration file name].\n") |
1444 |
" Call bake with -f [full path configuration file name].\n") |
| 1328 |
return |
1445 |
return |
| 1329 |
# configuration = Configuration(config) |
1446 |
# configuration = Configuration(config) |
| 1330 |
# configuration.read_metadata(config) |
1447 |
# configuration.read_metadata(config) |
| 1331 |
|
|
|
| 1332 |
if options.all: |
1448 |
if options.all: |
| 1333 |
options.enabled = True |
1449 |
options.enabled = True |
| 1334 |
options.disabled = True |
1450 |
options.disabled = True |
|
|
| 1356 |
if options.enabled: |
1472 |
if options.enabled: |
| 1357 |
self.show_module(enabled, options, config, 'enabled') |
1473 |
self.show_module(enabled, options, config, 'enabled') |
| 1358 |
|
1474 |
|
|
|
1475 |
if options.configured: |
| 1476 |
self.show_module(configuration.configured(), options, config, 'configured') |
| 1477 |
|
| 1359 |
if options.disabled: |
1478 |
if options.disabled: |
| 1360 |
self.show_module(disabled, options, config, 'disabled') |
1479 |
self.show_module(disabled, options, config, 'disabled') |
| 1361 |
|
1480 |
|
|
|
| 1484 |
['show', self._show], |
1603 |
['show', self._show], |
| 1485 |
['show-builtin', self._show_builtin], |
1604 |
['show-builtin', self._show_builtin], |
| 1486 |
['check', self._check], |
1605 |
['check', self._check], |
|
|
1606 |
['list', self._list], |
| 1487 |
] |
1607 |
] |
| 1488 |
recognizedCommand = False |
1608 |
recognizedCommand = False |
| 1489 |
|
1609 |
|