def action(self): for arg in self._args: if (isinstance(arg, syntax_tag.TagSources)): self._sources.extend(arg.v()) self._depends = self._ctx.depends() for source in self._sources: source.set_target(self) source.set_depends(self._depends) source.pre_action() for source in self._sources: source.action() self._sources_infiles = bfunction.unique( map(lambda x: os.path.normpath(x.in_file()), self._sources)) self._sources_outfiles = bfunction.unique( map(lambda x: os.path.normpath(x.out_file()), self._sources)) self._depends = filter(lambda x: x.obj() != os.path.normpath(''), self._depends) for depend in self._depends: self._depends_libs.append( os.path.join(depend.base_path(self._ctx), depend.obj())) self._depends_libs.sort(lambda x, y: cmp(x, y)) self._depends_libs_s = self._line_delim.join(self._depends_libs)
def set_depends_include_paths(self): self._depends_incpaths = [] for depend in self._depends: self._depends_incpaths.extend( map( lambda x: os.path.normpath( os.path.join(depend.base_path(self), x)), depend.include_paths())) self._depends_incpaths = bfunction.unique(self._depends_incpaths) self._depends_incpaths.sort(lambda x, y: cmp(x, y))
def clean(self): r0 = ('.PHONY', 'clean', []) commands = [] for target in self._ctx.targets(): for x in target.clean_files(): commands.append('rm -rf %s' % (x)) commands.extend(target.make_clean_lines()) sources = bfunction.unique(self._ctx.sources(), lambda x: x.out_file()) for source in sources: for x in source.clean_files(): commands.append('rm -rf %s' % (x)) r1 = ('clean', '', commands) return (r0, r1)
def collect(self, ctx): self._ctx = ctx self.mfname = 'Makefile' make_lines = [] make_lines.extend(self.all()) make_lines.extend(self.clean()) make_lines.extend(self.dist()) make_lines.extend(self.dist_clean()) make_lines.extend(self.love()) for target in self._ctx.targets(): if (target.phony_mode()): r = ('.PHONY', target.target(), []) make_lines.append(r) make_lines.extend(target.make_lines()) for source in self._ctx.sources(): make_lines.extend(source.make_lines()) make_lines = bfunction.unique(make_lines, lambda x: (x[0], x[1])) # Convert make_lines to Makefile format lines = [] self._ctx.print_var(lines) for x in make_lines: (t, dep, cmds) = x lines.append('%s:%s' % (t, dep)) if (not cmds): continue lines.append( "\t@echo \"[%s][Target:'%s']\"" % (bfunction.green_it("BUILDMAKE:BUILD"), bfunction.green_it(t))) for cmd in cmds: lines.append('\t%s' % (cmd)) lines.append('') # Operation for 32/64bit platform self._lines.append( '####################%dBit Mode####################\n' % (ctx.bit())) self._lines.append('ifeq ($(shell uname -m), %s)\n' % ctx.cpu()) self._lines.extend(map(lambda x: '%s\n' % x, lines)) self._lines.append('endif #ifeq ($(shell uname -m), %s)\n\n\n' % (ctx.cpu()))
def _detect_local_lib(self, path): if (path in self._local_lib): return self._local_lib[path] cwd = os.getcwd() os.chdir(path) exts = ('.a', ) # 1. find in current path libs = bfunction.find_files_exts('.', False, exts) # 2. find in ./output if (os.path.exists('./output')): libs += bfunction.find_files_exts('./output', True, exts) # 3. find in ./lib if (os.path.exists('./lib')): libs += bfunction.find_files_exts('./lib', True, exts) # 4. unique libs = bfunction.unique(libs, lambda x: os.path.basename(x)) os.chdir(cwd) self._local_lib[path] = libs return libs