Example #1
0
    def _execute_template(self, target):
        target_name = target.getTargetFullName(self._env.getToolkit())
        if target.getType() != "object":
            (filepath, filename) = os.path.split(target_name)
            if filepath and (not os.path.exists(filepath)):
                os.mkdir(filepath)
            (name, ext) = os.path.splitext(filename)
            name = self._env.getPrefix() + target.getPrefix() + name + target.getSuffix() + self._env.getSuffix()
            filename = "".join([name, ext])
            target_name = os.path.join(filepath, filename)

        # clean mode
        if self._env.getCleanMode():
            self._safe_remove(target_name)
            return

        # build mode
        if os.path.isfile(target_name):
            need_update = False
            target_mtime = os.path.getmtime(target_name)
            for source in target.getSources():
                if os.path.getmtime(source) >= target_mtime:
                    need_update = True
                    break
            if not need_update:
                ymessage.message("Target %s is up to date." % target_name)
                return

        cmd_line = self._expand_template(target_name, target)
        ymessage.message(cmd_line)
        if not self._env.execute(cmd_line):
            ymessage.fatal("Failed to execute command!")
Example #2
0
    def _execute_template(self, target):
        target_name = target.getTargetFullName(self._env.getToolkit())
        if target.getType() != 'object':
            (filepath, filename) = os.path.split(target_name)
            if filepath and (not os.path.exists(filepath)):
                os.mkdir(filepath)
            (name, ext) = os.path.splitext(filename)
            name = self._env.getPrefix() + target.getPrefix(
            ) + name + target.getSuffix() + self._env.getSuffix()
            filename = ''.join([name, ext])
            target_name = os.path.join(filepath, filename)

        # clean mode
        if self._env.getCleanMode():
            self._safe_remove(target_name)
            return

        # build mode
        if os.path.isfile(target_name):
            need_update = False
            target_mtime = os.path.getmtime(target_name)
            for source in target.getSources():
                if os.path.getmtime(source) >= target_mtime:
                    need_update = True
                    break
            if not need_update:
                ymessage.message('Target %s is up to date.' % target_name)
                return

        cmd_line = self._expand_template(target_name, target)
        ymessage.message(cmd_line)
        if not self._env.execute(cmd_line):
            ymessage.fatal('Failed to execute command!')
Example #3
0
 def _safe_remove(self, filename):
     if os.path.exists(filename):
         ymessage.message("Delete file: %s" % filename)
         os.unlink(filename)
Example #4
0
 def _safe_remove(self, filename):
     if os.path.exists(filename):
         ymessage.message('Delete file: %s' % filename)
         os.unlink(filename)
Example #5
0
 def message(self, s):
     ymessage.message(s)