How to use mk - 10 common examples

To help you get started, we’ve selected a few mk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vslavik / bakefile / src / finalize.py View on Github external
if outputVarsOnly:
        interestingVars = mk.vars['FORMAT_OUTPUT_VARIABLES'].strip()
        if interestingVars != '':
            interestingVars = interestingVars.split()
            optimizeVars = len(interestingVars) > 0
        else:
            optimizeVars = 0
    else:
        optimizeVars = 0

    for v in mk.make_vars:
        if '$' in mk.make_vars[v]:
            list.append((mk.make_vars,v,None))
    
    for c in mk.cond_vars.values():
        for v in c.values:
            if '$' in v.value:
                list.append((None,v,c.target))

    if optimizeVars:
        for v in interestingVars:
            if v in mk.vars and '$' in mk.vars[v]:
                list.append((mk.vars,v,None))
    else:
        for v in mk.vars:
            if type(mk.vars[v]) is StringType:
                if '$' in mk.vars[v]:
                    list.append((mk.vars,v,None))
   
    if optimizeVars:
        for t in mk.targets.values():
github vslavik / bakefile / src / utils.py View on Github external
if expr in mk.options and mk.options[expr].values != None:
            opt = mk.options[expr]
            for v in opt.values:
                if '$' in v.value:
                    ret += getPossibleValues(v)
                else:
                    ret.append(v)
            return ' '.join(ret)

        # don't know what else to try, return as-is
        return expr

    def callbackTxt(nothing, expr):
        return expr

    return mk.__doEvalExpr(expr, callbackVar, callbackTxt,
                           None, 1, None, None).split()
github glest / glest-source / mk / windows / symbolstore.py View on Github external
def Finish(self, stop_pool=True):
        """Wait for the expected number of jobs to be submitted, and then
        wait for the pool to finish processing them. By default, will close
        and clear the pool, but for testcases that need multiple runs, pass
        stop_pool = False."""
        with Dumper.jobs_condition:
            while len(self.jobs_record) != 0:
                Dumper.jobs_condition.wait()
        if stop_pool:
            Dumper.pool.close()
            Dumper.pool.join()
github glest / glest-source / mk / windows / symbolstore.py View on Github external
    @classmethod
    def GlobalInit(cls, module=multiprocessing):
        """Initialize the class globals for the multiprocessing setup; must
        be called before any Dumper instances are created and used. Test cases
        may pass in a different module to supply Manager and Pool objects,
        usually multiprocessing.dummy."""
        num_cpus = module.cpu_count()
        if num_cpus is None:
            # assume a dual core machine if we can't find out for some reason
            # probably better on single core anyway due to I/O constraints
            num_cpus = 2

        # have to create any locks etc before the pool
        cls.manager = module.Manager()
        cls.jobs_condition = Dumper.manager.Condition()
        cls.lock = Dumper.manager.RLock()
        cls.pool = module.Pool(num_cpus, WorkerInitializer, (cls, cls.lock))
github glest / glest-source / mk / windows / symbolstore.py View on Github external
copy_debug=options.copy_debug,
                                       archs=options.archs,
                                       srcdirs=options.srcdir,
                                       vcsinfo=options.vcsinfo,
                                       srcsrv=options.srcsrv,
                                       exclude=options.exclude,
                                       repo_manifest=options.repo_manifest)
    for arg in args[2:]:
        dumper.Process(arg)
    dumper.Finish()

# run main if run directly
if __name__ == "__main__":
    # set up the multiprocessing infrastructure before we start;
    # note that this needs to be in the __main__ guard, or else Windows will choke
    Dumper.GlobalInit()

    main()
github glest / glest-source / mk / windows / symbolstore.py View on Github external
if subprocess.call([self.objcopy, '--only-keep-debug', file, file_dbg]) == 0 and \
           subprocess.call([self.objcopy, '--add-gnu-debuglink=%s' % file_dbg, file]) == 0:
            rel_path = os.path.join(debug_file,
                                    guid,
                                    debug_file + ".dbg")
            full_path = os.path.normpath(os.path.join(self.symbol_path,
                                                      rel_path))
            shutil.move(file_dbg, full_path)
            # gzip the shipped debug files
            os.system("gzip %s" % full_path)
            self.output(sys.stdout, rel_path + ".gz")
        else:
            if os.path.isfile(file_dbg):
                os.unlink(file_dbg)

class Dumper_Solaris(Dumper):
    def RunFileCommand(self, file):
        """Utility function, returns the output of file(1)"""
        try:
            output = os.popen("file " + file).read()
            return output.split('\t')[1];
        except:
            return ""

    def ShouldProcess(self, file):
        """This function will allow processing of files that are
        executable, or end with the .so extension, and additionally
        file(1) reports as being ELF files.  It expects to find the file
        command in PATH."""
        if not Dumper.ShouldProcess(self, file):
            return False
        if file.endswith(".so") or os.access(file, os.X_OK):
github vslavik / bakefile / src / finalize.py View on Github external
mk.__trackUsage = 1
    mk.__resetUsageTracker(reset_coverage=1)

    list = []

    if outputVarsOnly:
        interestingVars = mk.vars['FORMAT_OUTPUT_VARIABLES'].strip()
        if interestingVars != '':
            interestingVars = interestingVars.split()
            optimizeVars = len(interestingVars) > 0
        else:
            optimizeVars = 0
    else:
        optimizeVars = 0

    for v in mk.make_vars:
        if '$' in mk.make_vars[v]:
            list.append((mk.make_vars,v,None))
    
    for c in mk.cond_vars.values():
        for v in c.values:
            if '$' in v.value:
                list.append((None,v,c.target))

    if optimizeVars:
        for v in interestingVars:
            if v in mk.vars and '$' in mk.vars[v]:
                list.append((mk.vars,v,None))
    else:
        for v in mk.vars:
            if type(mk.vars[v]) is StringType:
                if '$' in mk.vars[v]:
github bkoropoff / makekit / mk / pylib / mk / core.py View on Github external
def parse_options(self):
        if 'OPTIONS' in self.variables:
            self.options = {}

            mode = 'normal'
            for line in self['OPTIONS'].split('\n'):
                if mode == 'doc':
                    if len(line) and line[0] in string.whitespace:
                        docs += line.split()
                    else:
                        self.options[name] = Script.Option(name, arg, docs)
                        mode = 'normal'
                if mode == 'normal':
                    if not len(line):
                        continue
                    parts = line.split()
                    name = parts[0]
                    arg = parts[1]
                    docs = parts[2:]
                    if arg == '-':
                        arg = None
                    mode = 'doc'
        else:
            self.options = None
github bkoropoff / makekit / mk / pylib / mk / core.py View on Github external
if 'MODULES' in self.variables:
            for name in self.variables['MODULES'].split(" "):
                module = modules[name]
                for item in module.closure_order:
                    if item not in self.module_set:
                        self.module_set.add(item)
                        self.module_order.append(item)

    def resolve_phases(self):
        self.phase_closure = set()
        
        for module in self.module_set:
            self.phase_closure.update(module.phase_closure)

class Project(Script):
    def manifest_prefix(self):
        return "MK_"

class Settings:
    mk_dir = os.path.abspath(os.environ['MK_HOME'])
    root_dir = os.path.abspath(os.getcwd())
    constants = Script("constants", os.path.join(mk_dir, 'shlib', 'constants.sh'))
    module_dirname = constants['MK_MODULE_DIRNAME']
    component_dirname = constants['MK_COMPONENT_DIRNAME']
    configure_filename = constants['MK_CONFIGURE_FILENAME']
    action_filename = constants['MK_ACTION_FILENAME']
    makefile_filename = constants['MK_MAKEFILE_FILENAME']
    manifest_filename = constants['MK_MANIFEST_FILENAME']
    project_filename = constants['MK_PROJECT_FILENAME']

def manifest_name(name):
github bkoropoff / makekit / mk / pylib / mk / core.py View on Github external
self.phase_closure.update(module['PHASES'].split(" "))

    def resolve_components(self, components):
        self.component_order = []

        for component in order_depends(components):
            if self in component.module_set:
                self.component_order.append(component)

        self.variables['COMPONENTS'] = " ".join([x.name for x in self.component_order])

    def phase_is_always(self, phase, timing):
        name = manifest_name(timing + "_" + phase + "_ALWAYS")
        return name in self.variables

class Component(Script):
    """Represents a component"""
    def __init__(self, name, filename):
        Script.__init__(self, name, filename)
        self.module_set = None
        self.module_order = None

    def manifest_prefix(self):
        return "MK_COMPONENT_"

    def emit_manifest(self, out):
        Script.emit_manifest(self, out)

        prefix = "%s%s" % (self.manifest_prefix(), manifest_name(self.name))

        closure = " ".join([x.name for x in self.closure_order])
        out.write("%s_CLOSURE='%s'\n" % (prefix, closure))