diff options
author | Amar Takhar <amar@rtems.org> | 2015-06-02 10:26:25 -0400 |
---|---|---|
committer | Amar Takhar <amar@rtems.org> | 2015-06-02 10:26:25 -0400 |
commit | bbcba228e817435c2eb6db425a36011ec5ffc1b8 (patch) | |
tree | 0495a6ffa406021c9ccdfa35907cef945a764a39 | |
parent | 072a2149a32512d1efcd3a376a8e5849bdb98576 (diff) | |
parent | dac540299ca8cb243a8ed83d04713c161d9fdd2c (diff) |
Merge branch 'waf' of ssh://dispatch.rtems.org:/data/git/amar/waf into waf
-rw-r--r-- | rtems_waf/builder.py | 13 | ||||
-rw-r--r-- | wscript | 82 |
2 files changed, 54 insertions, 41 deletions
diff --git a/rtems_waf/builder.py b/rtems_waf/builder.py index 0b9b68ed19..e1e944bf5c 100644 --- a/rtems_waf/builder.py +++ b/rtems_waf/builder.py @@ -16,12 +16,17 @@ class rtems_base(object): def _get_id(self, name): name_id = "auto_%s" % name - if name_id not in self.ctx.counter: - self.ctx.counter[name_id] = 0 + try: + counter = self.ctx.counter + except AttributeError: + counter = self.ctx.counter = {} + + if name_id not in counter: + counter[name_id] = 0 return "%s_0" % name_id else: - self.ctx.counter[name_id] += 1 - return "%s_%d" % (name_id, self.ctx.counter[name_id]) + counter[name_id] += 1 + return "%s_%d" % (name_id, counter[name_id]) def _obj_add(self, name, source, **kwarg): @@ -14,7 +14,7 @@ config["rtems_tool_version"] = "4.11" from sys import argv from waflib import Task, Scripting, Configure, Utils from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext, StepContext, ListContext -from waflib.Context import Context +from waflib import Context, Errors from waflib.Tools import c_preproc from waflib.Logs import pprint from rtems_waf.builder import libcpu, libbsp @@ -40,7 +40,7 @@ class Dist(Scripting.Dist): pprint.__doc__ = None # Make sure waf doesn't see this as a command. Configure.autoconfig = 'clobber' # Apply the original configure command-line arguments -Context.repeat_hack = False +Context.Context.repeat_hack = False top = '.' out = 'build' @@ -53,33 +53,24 @@ if exists("%s/build/c4che/host_cache.py" % top): cset.load("build/c4che/host_cache.py") config["variants"] = cset.BSP - # Init commands manually to iterate over the variants. def init_handler(ctx): - if ctx.cmd == "init_handler" or ctx.cmd == "build": - context = BuildContext - elif ctx.cmd == "install": - context = InstallContext - elif ctx.cmd == "clean": - context = CleanContext - elif ctx.cmd == "uninstall": - ctx.fatal("This command is not available.") - elif ctx.cmd == "list": - context = ListContext - elif ctx.cmd == "step": - context = StepContext - else: - ctx.fatal("init_handler(): Internal error.") + cmd = ctx.cmd + if cmd == 'init_handler': + cmd = 'build' - # By default we want to itterate over each variant. - for v in ["host"] + config["variants"]: - cls = type(context)(v, (context,), {'cmd': ctx.cmd, 'variant': v, 'counter': {}, 'cpu': None}) - bld = cls() - if hasattr(ctx, 'targets'): - bld.targets = ctx.targets - pprint("YELLOW", "--- %sing %s ---" % (ctx.cmd, v)) - bld.execute() + def make_context(name): + for x in Context.classes: + if x.cmd == name and x.fun != 'init_handler': + return x() + ctx.fatal('No class for %r' % cmd) + # By default we want to iterate over each variant. + for v in ["host"] + config["variants"]: + obj = make_context(cmd) + obj.variant = v + pprint("YELLOW", "--- %sing %s ---" % (cmd, v)) + obj.execute() # Add target-specific commands. variant_cmd = ( @@ -97,13 +88,30 @@ for variant in ["host"] + config["variants"]: host = 0 else: v = variant.split("/")[1] + # the reason for creating these subclasses is just for __doc__ below... for cmd, cls in variant_cmd: class tmp(cls): __doc__ = "%s %s BSP" % (cmd, v) cmd = "%s_%s" % (cmd, v) variant = variant - counter = {} - cpu = None + +def get_targets(self): + # targets in host and bsp variants differ, do not raise an exception + to_post = [] + min_grp = 0 + for name in self.targets.split(','): + try: + tg = self.get_tgen_by_name(name) + except Errors.WafError: + continue + m = self.get_group_idx(tg) + if m > min_grp: + min_grp = m + to_post = [tg] + elif m == min_grp: + to_post.append(tg) + return (min_grp, to_post) +BuildContext.get_targets = get_targets # These will stay local functions to avoid importing the subcommands # upon every invocation which will happen during regular development. @@ -143,13 +151,13 @@ commands = ( ) for command, func, descr in commands: - class tmp(Context): + class tmp(Context.Context): if descr: __doc__ = descr cmd = command fun = func if command in 'install uninstall build clean list step docs bsp info': - execute = Scripting.autoconfigure(Context.execute) + execute = Scripting.autoconfigure(Context.Context.execute) def buildlog(ctx): @@ -192,17 +200,17 @@ def build(ctx): # Dump build log in JSON. if ctx.cmd == "build" \ and ctx.env.BUILD_JSON \ - and not Context.repeat_hack: + and not ctx.repeat_hack: from rtems_waf.debug import logger_json_create, exec_command_json, exec_command_json_extra - Context.repeat_hack = True + ctx.repeat_hack = True # Make sure any previous handlers are closed so logs are written. - if hasattr(Context, "logger_json"): - Context.logger_json.handlers[0].close() + if hasattr(ctx, "logger_json"): + ctx.logger_json.handlers[0].close() - Context.logger_json = logger_json_create(ctx) - Context.exec_command = exec_command_json + ctx.logger_json = logger_json_create(ctx) + ctx.exec_command = exec_command_json # Send extra information from the parent task. cls_task = Task.classes["Task"] @@ -214,13 +222,13 @@ def build(ctx): # Host is only meant for building host utilities. - if ctx.variant == "host" and ctx.targets is "": + if ctx.variant == "host": ctx.recurse("tools/build") ctx.recurse("c") # Reset things back so a new log is created for the BSP. if ctx.cmd == "build" and ctx.env.BUILD_JSON: - Context.repeat_hack = False + ctx.repeat_hack = False return # Everything will break if you remove these lines below. |