コード例 #1
0
    def __init__(self, debug=False, make_dir=None):
        """Generates the default make files.
    Args:
      make_dir: string: The directory in which make files are created.
      cleanup: bool: Cleanup at the end.
    """
        if not make_dir:
            make_dir = os.path.join(FileUtils.GetBinDir(), '__build_files__')

        self.__make_dir = make_dir
        self.__debug = debug

        # Create the dir if not already present.
        if not os.path.exists(make_dir):
            os.makedirs(make_dir)

        (makefile_fd,
         self.__makefile_name) = tempfile.mkstemp(prefix='makefile_',
                                                  suffix='.main.mak',
                                                  dir=make_dir)

        # Detect supported compilers
        self.__gcc_supported = self._CompilerSupported('gcc')
        self.__clang_supported = self._CompilerSupported('clang')

        # Generate dummy files.
        self.ResetMakeFiles()
コード例 #2
0
    def WorkHorse(cls, rules):
        """Runs the workhorse for the command.

    Args:
      rules: list: List of rules to be handled.

    Return:
      (list, list): Returns a tuple of list in the form
          (successful_rules, failed_rules) specifying rules that succeeded and
          ones that failed.
    """
        # Create the user friendly link to bin dir if it doesn't already exist.
        FileUtils.CreateLink(FileUtils.GetEDir(), FileUtils.GetBinDir())
        # Create the link to the web test directory if it exists
        if os.path.exists(FileUtils.GetWebTestHtmlLink()):
            FileUtils.CreateLink(FileUtils.GetWebTestHtmlLink(),
                                 FileUtils.GetWebTestHtmlDir())

        gen_makefile = GenMakefile(Flags.ARGS.debug)
        gen_makefile.GenMainMakeFile()
        (success_genmake,
         failed_genmake) = gen_makefile.GenAutoMakeFileFromRules(
             rules, Flags.ARGS.allowed_rule_types)

        (success_make,
         failed_make) = cls._MakeRules(success_genmake,
                                       gen_makefile.GetMakeFileName())

        return (success_make, failed_genmake + failed_make)
コード例 #3
0
 def create_working_dir(cls, name):
     """Delete old temporary files AND create the working directory
 Args:
   name (string) : the package name
 Returns:
   the working directory to use
 """
     workingdir = os.path.join(FileUtils.GetBinDir(), 'package',
                               '%s' % name)
     # clean up the old package if necessary
     if os.path.isdir(workingdir):
         shutil.rmtree(workingdir)
     os.makedirs(workingdir)
     return workingdir
コード例 #4
0
 def __init__(self, rule_name):
   """initializes the state
   Args:
     rule_name (string) - the rule name
   Raises:
     UnsupportedRuleError: raises exception if the rule type is not yet
       supported. add to the RULE_TYPES lists
   """
   # Create the user friendly link to bin dir if it doesn't already exist.
   FileUtils.CreateLink(FileUtils.GetEDir(), FileUtils.GetBinDir())
   rule_name = Utils.RuleNormalizedName(rule_name)
   Rules.LoadRule(rule_name)
   self._rule = Rules.GetRule(rule_name)
   if not self._rule['_type'] in Packager.RULE_PACKAGER:
     err = 'Rule type %s not supported' % self._rule._type
     TermColor.Error(err)
     raise UnsupportedRuleError(err)
   self._packager = Packager.RULE_PACKAGER[self._rule['_type']]
コード例 #5
0
 def make_package(cls, rule):
   """@override"""
   name = rule['name']
   if not 'rule' in rule or not rule['rule']:
     err = 'no rule field for %s' % name
     TermColor.Error(err)
     raise Error(err)
   if not 'ctrl' in rule or not rule['ctrl']:
     err = 'no yaml ctrl field for %s' % name
     TermColor.Error(err)
     raise Error(err)
   subprocess.check_call('flash build %s' % rule['rule'], shell=True)
   # clean up the old package and create the working directory
   workingdir = PkgUtils.create_working_dir(name)
   # collect the files
   files = {}
   # the binary path
   files[os.path.join(FileUtils.GetBinDir(), rule['rule'])] = \
     os.path.basename(rule['rule'])
   # the loop script
   files[os.path.join(FileUtils.GetSrcRoot(),
                      Flags.ARGS.loop_script_path)] = 'loop'
   # the control script
   files[os.path.join(FileUtils.GetSrcRoot(),
                      Flags.ARGS.pkg_bin_ctrl_path)] = 'control'
   # the yaml file
   files[os.path.join(FileUtils.GetSrcRoot(),
                      rule['ctrl'])] = 'control.yaml'
   # copy the files
   for src, dest in files.items():
     shutil.copy2(src, os.path.join(workingdir, dest))
   # copy the shared files
   CopyShared.copy(workingdir)
   # import the package
   packages = Packages(host=Flags.ARGS.pkg_host,
                       user=Flags.ARGS.pkg_user,
                       root=Flags.ARGS.pkg_repo)
   # import the package
   if Flags.ARGS.pkg_version_prefix:
     return name, packages.f_import(workingdir, name,
                                    Flags.ARGS.pkg_version_prefix)
   else:
     return name, packages.f_import(workingdir, name)
コード例 #6
0
    def GenMainMakeFile(self):
        """Generates the main make file."""
        f = open(self.GetMakeFileName(), 'w')
        f.write('SRCROOT = %s\n' % FileUtils.GetSrcRoot())
        f.write('BINDIR = %s\n' % FileUtils.GetBinDir())
        f.write('AUTO_MAKEFILE_CC = %s\n' % self.GetAutoMakeFileName('cc'))
        f.write('AUTO_MAKEFILE_JS = %s\n' % self.GetAutoMakeFileName('js'))
        f.write('AUTO_MAKEFILE_NG = %s\n' % self.GetAutoMakeFileName('ng'))
        f.write('AUTO_MAKEFILE_NGE2E = %s\n' %
                self.GetAutoMakeFileName('nge2e'))
        f.write('AUTO_MAKEFILE_PKG = %s\n' % self.GetAutoMakeFileName('pkg'))
        f.write('AUTO_MAKEFILE_PKG_BIN = %s\n' %
                self.GetAutoMakeFileName('pkg_bin'))
        f.write('AUTO_MAKEFILE_PKG_SYS = %s\n' %
                self.GetAutoMakeFileName('pkg_sys'))
        f.write('AUTO_MAKEFILE_PY = %s\n' % self.GetAutoMakeFileName('py'))
        f.write('AUTO_MAKEFILE_SWIG = %s\n' % self.GetAutoMakeFileName('swig'))
        f.write('PROTOBUFDIR = %s\n' % ProtoRules.GetProtoBufBaseDir())
        f.write('PROTOBUFOUTDIR = %s\n' % ProtoRules.GetProtoBufOutDir())
        f.write('SWIGBUFOUTDIR = %s\n' % SwigRules.GetSwigOutDir())
        f.write('\n')

        makefile_template = os.path.join(
            os.path.dirname(
                os.path.abspath(inspect.getfile(inspect.currentframe()))),
            self.GetMakeFileTemplate())

        f.write(
            '###############################################################\n'
        )
        f.write('#Template from: %s \n' % makefile_template)
        f.write(
            '###############################################################\n'
        )
        f.write(open(makefile_template).read())
        f.write(
            '\n###############################################################\n'
        )