Example #1
0
    def BuildObject(self, env, obj):
        self._GetOpenedFiles(obj.path_, obj)
        # convert to SCons dendency graph
        target = Path.GetAbsRelativePath(obj.name_)
        source = self._GetSourcePath(obj.sources_)
        cpp_path = GetCppInclude(obj)
        lib_sources, libs, libpath, link_flags = self._GetFlags(obj, env)
        cc_flags = env['CCFLAGS']
        if 'cflags' in obj.option_:
            cc_flags += ' '
            cc_flags += ' '.join(obj.option_['cflags'])

        if obj.has_thrift_dep:
            cc_flags += '-Wno-return-type -DHAVE_NETINET_IN_H'

        CXX_value = env['CXX']
        if (not self._use_distcc == 'on'):
            if (self._use_ccache == 'on'):
                CXX_value = Flags.CCACHE_BIN
            else:
                CXX_value = 'g++'

        if obj.build_type_ in ['cc_binary']:
            print Util.BuildMessage(target)
            binary = env.Program(target=target,
                                 source=source + lib_sources,
                                 LIBS=libs,
                                 LIBPATH=libpath,
                                 CPPPATH=cpp_path,
                                 LINKFLAGS=link_flags,
                                 CCFLAGS=cc_flags,
                                 CXX=CXX_value)
        Util.Log(target)
        Util.Log(source + lib_sources)
        Util.Log(libs)
        Util.Log(libpath)
        Util.Log(cpp_path)
        Util.Log(link_flags)
        Util.Log(cc_flags)
        Util.Log(CXX_value)
        if obj.build_type_ in ['cc_library']:
            print Util.BuildMessage(
                os.path.dirname(target) + "/lib" + os.path.basename(target) +
                ".a")
            result = env.StaticLibrary(target=target,
                                       source=source,
                                       CPPPATH=cpp_path,
                                       CCFLAGS=cc_flags,
                                       CXX=CXX_value)
Example #2
0
 def _StyleCheck(self):
     for f in self._source_files:
         cpplint.ProcessFile(f, cpplint._cpplint_state.verbose_level, False)
     if cpplint._cpplint_state.error_count > 0:
         print Util.BuildMessage(
             'There are %d style warnings in the soruce files!' %
             cpplint._cpplint_state.error_count, 'WARNING')
     pass
Example #3
0
 def _ConfigForDistcc(self, env):
     if self._use_distcc == 'on':
         distcc_hosts = [
             x.strip() for x in open(Flags.DISTCC_HOSTS).read().split('\n')
         ]
         distcc_hosts.sort()
         while len(distcc_hosts[0]) == 0:
             del distcc_hosts[0]
             if len(distcc_hosts) == 0:
                 break
             pass
         pass
         # check if the hostname is in the list
         hostname = '%s' % Util.GetIp('eth0')
         for i in range(len(distcc_hosts)):
             if distcc_hosts[i] == hostname:
                 distcc_hosts = distcc_hosts[i + 1:] + distcc_hosts[0:i]
                 break
             if distcc_hosts[i] > hostname:
                 distcc_hosts = distcc_hosts[i:] + distcc_hosts[0:i]
                 break
         env['ENV']['DISTCC_HOSTS'] = ' '.join(distcc_hosts)
         if len(distcc_hosts) == 0:
             print Util.BuildMessage("compiling only at localhost:%s" %
                                     hostname)
         else:
             print Util.BuildMessage("distcc host:" +
                                     ' '.join(distcc_hosts))
         if len(self._distcc_log) > 0:
             if os.path.exists(self._distcc_log):
                 os.remove(self._distcc_log)
             env['ENV']['DISTCC_LOG'] = self._distcc_log
         distcc_dir = os.path.join(Flags.SNAKE_OUT, '.distcc')
         if not os.path.exists(distcc_dir):
             os.mkdir(distcc_dir)
         env['ENV']['DISTCC_DIR'] = distcc_dir
         env['CXX'] = Flags.DISTCC_BIN
Example #4
0
    def BuildObject(self, env, obj):
        source = Path.GetAbsPath(obj.sources_[0])
        target = Path.GetAbsRelativePath(obj.name_)
        target_dir = os.path.dirname(target)

        if not os.path.isdir(target_dir):
            os.makedirs(target_dir)

        basename = Path.GetBaseName(obj.name_)
        options = []
        if obj.option_['paths']:
            options.append(self._GetImportPaths(obj.option_['paths']))
        if basename == input_target:
            for item_i in options:
                for item_j in item_i.strip().split(':'):
                    sys.path.append(item_j)

            pylint_output = WritableObject()
            lint.Run(['-r', 'n', source],
                     reporter=TextReporter(pylint_output),
                     exit=False)
            for line in pylint_output.read():
                if len(line.strip()) != 0:
                    if line.startswith("C:") or line.startswith("R:"):
                        pass
                    elif line.startswith("W:"):
                        if line.find('bad-indentation'): continue
                        print Util.BuildMessage('[%s] %s' % (basename, line),
                                                'INFO')
                    elif line.startswith('E:') or line.startswith('F:'):
                        print Util.BuildMessage('[%s] %s' % (basename, line),
                                                'WARNING')
            env.PythonBuilder(target,
                              source,
                              PY_SOURCE=source,
                              OPTIONS=' '.join(options))